Bläddra i källkod

Anpassungen für 2024 - leider noch nicht dynamisch

Reisacher C7 1 år sedan
förälder
incheckning
1603e255b8
3 ändrade filer med 10 tillägg och 8 borttagningar
  1. 1 1
      webservice/actuals.bat
  2. 6 5
      webservice/csv_accounts.py
  3. 3 2
      webservice/planner_load.py

+ 1 - 1
webservice/actuals.bat

@@ -1,4 +1,4 @@
 @echo off
 cd /d %~dp0
-call python.bat csv_accounts.py actuals 202210
+call python.bat csv_accounts.py actuals 202310
 pause

+ 6 - 5
webservice/csv_accounts.py

@@ -57,12 +57,12 @@ def actuals(period):
 def planning_prev(year):
     base_dir = Path.cwd().parent
     print(base_dir)
-    df1 = pd.read_csv(base_dir / 'data/Planner_2022_V1_Plan.csv',
+    df1 = pd.read_csv(base_dir / f'data/Planner_{year}_V1_Plan.csv',
                       sep=';', decimal=',', encoding='latin-1', dtype={'Betrieb Nr': str, 'Bereich': str, 'Zeile': str})
     df1['Wert'] = df1['Gesamt']
     df1 = df1[['Jahr', 'Betrieb Nr', 'Vstufe 1', 'Bereich', 'Zeile', 'Konto', 'Version', 'Wert']]
 
-    df2 = pd.read_csv(base_dir / 'data/Planner_2022_V1_Stk.csv',
+    df2 = pd.read_csv(base_dir / f'data/Planner_{year}_V1_Stk.csv',
                       sep=';', decimal=',', encoding='latin-1', dtype={'Betrieb Nr': str, 'Bereich': str, 'Zeile': str})
     df2['Menge'] = df2['Gesamt']
     df2['Vstufe 1'] = 'Umsatzerlöse'
@@ -88,7 +88,8 @@ def planning_prev(year):
             res[item['id']] = {}
         res[item['id']][item['Betrieb Nr']] = [item['Wert'], item['Menge']]
     data = {'values': res}
-    json.dump(data, open(base_dir / 'export/planning_2023.json', 'w'), indent=2)
+    next_year = str(int(year) + 1)
+    json.dump(data, open(base_dir / f'export/planning_{next_year}.json', 'w'), indent=2)
 
 
 def planning_new(filename):
@@ -106,7 +107,7 @@ def planning_new(filename):
 
 
 if __name__ == '__main__':
-    actuals('202210')
-    planning_prev('2022')
+    actuals('202310')
+    planning_prev('2023')
     # plac.call(actuals)
     # planning_new('2022_V2_20220407150009.json')

+ 3 - 2
webservice/planner_load.py

@@ -94,7 +94,7 @@ class PlannerLoad:
         return self.structure
 
     def get_values2(self, s):
-        if 'values2' not in s or len(s['values2'].keys()) == 0:
+        if 'values2' not in s or s['values2'] is None or len(s['values2'].keys()) == 0:
             s['values2'] = dict([(str(d), [0] * 30) for d in self.config['department']])
         else:
             for d in s['values2'].keys():
@@ -169,7 +169,8 @@ class PlannerLoad:
                     s['values2'][d][i] = v
                 s['values2'][d][0] = sum(m_values[d])
                 s['values2'][d][14] = sum(m_values[d])
-                s['options'][d]['seasonal'] = False
+                if 'options' in s:
+                    s['options'][d]['seasonal'] = False
         return True
 
     def convert_values2(self, s):