Robert Bedner před 3 roky
rodič
revize
646a25bae4

+ 8 - 6
gcstruct/gcstruct.py

@@ -356,7 +356,9 @@ class GCStruct():
         for t_from, t_to in self.translate.items():
             if t_from in ['Marke_HBV', 'Standort_HBV']:
                 continue
-            if t_from != 'Konto_Nr':
+            if t_from == 'Konto_Nr':
+                df_source[t_to] = df_source[t_from]
+            else:
                 df_source[t_to] = t_to + '_' + df_source[t_from]
             for e in cols:
                 df_source = df_source.merge(df_translate, how='left', left_on=[t_to, e], right_on=['Konto_Nr', 'key'],
@@ -364,12 +366,12 @@ class GCStruct():
                 df_source[e] = np.where(df_source['value_' + t_to + '_' + e].notna(), df_source['value_' + t_to + '_' + e], df_source[e])
                 if df_source.shape[0] > rows:
                     print(t_to + '_' + e + ': ' + str(df_source.shape[0]))
+        # df_source.to_csv(f"{self.config['path2']}/SKR51_Variablen2.csv", sep=';', encoding='latin-1', index=False)
         # df_source[t_to + '_Nr'] = np.where(df_source[t_to + '_Nr'].isna(), df_source[t_from], df_source[t_to + '_Nr'])
         for e in cols:
             df_source[e] = np.where(df_source[e].str.startswith('{'), df_source[e].str.extract(r'\/(.*)}', expand=False) +
                                     ' falsch', df_source[e])    # df_source[e].str.extract(r'/(.*)}') +
             df_source[e] = np.where(df_source[e] == '[KTR]', df_source['Kostenträger_Ebene'], df_source[e])
-
         # df_all[df_all['Ebene1'] == ]
         # print(df_source.head())
         df_source['Konto_neu'] = df_source['Marke'] + '-' + df_source['Standort'] + '-' + df_source['Konto_Nr'] + '-' + \
@@ -454,9 +456,9 @@ class GCStruct():
         df_amount['Ebene1'] = 'verkaufte Stückzahlen'
         df_main = pd.concat([df_main, df_amount])
 
-        from_label = cols
-        to_label = get_default_cols(9)
-        df_main = df_main.rename(columns=dict(zip(from_label, to_label)))
+        # from_label = cols
+        to_label = cols   # get_default_cols(9)
+        # df_main = df_main.rename(columns=dict(zip(from_label, to_label)))
         df_main[to_label].to_csv(f"{self.config['path2']}/SKR51_Struktur.csv", sep=';', encoding='latin-1', index_label='Sortierung')
 
 
@@ -472,7 +474,7 @@ def luchtenberg():
             base_dir = base_dir.parent.parent
             import_dir = base_dir.joinpath('System/OPTIMA/Export')
     elif not base_dir.joinpath('GCStruct_Aufbereitung').exists():
-        base_dir = Path('/media/fileserver1/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/')
+        base_dir = Path('//192.168.2.21/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/')
         import_dir = base_dir
 
     struct = GCStruct(str(base_dir.joinpath('GCStruct_Aufbereitung')))

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 241 - 241
mazda/Workshop_Order_Report.csv


+ 2 - 1
mazda/mazda-upload.py

@@ -52,7 +52,8 @@ def convert_csv(csv_file, json_file, year, month):
 
     date_cols = ['invoiceDate', 'orderDate', 'orderCompletionDate', 'vehicleIntakeDate', 'nextMotDueDate']
     df = pd.read_csv(csv_file, encoding='latin-1', decimal=',', sep=';', parse_dates=date_cols)
-    df = df.fillna(0)[(df['invoiceDate'] >= date_min) & (df['invoiceDate'] <= date_max)].sort_values(by='invoiceDate')
+    df = df.fillna(0)[(df['invoiceDate'] >= date_min) & (df['invoiceDate'] <= date_max)]
+    df = df.sort_values(by=['invoiceDate', 'invoiceNumber', 'orderNumber', 'lineNumber'])
     df['vin'] = np.where(df['vin'] == 0, '0' * 17, df['vin'])
     # print(df[['currency','documentType','invoiceCategory','invoiceDate','invoiceNumber']].drop_duplicates().info())
     invoices_filter = ['currency', 'documentType', 'invoiceCategory', 'invoiceDate', 'invoiceNumber']

+ 1 - 2
mazda/mazda-webservice.py

@@ -2,14 +2,13 @@ from requests_oauthlib import OAuth2Session
 from flask import Flask, request, redirect, session, url_for
 from flask.json import jsonify
 import os
+import mazda_upload
 
 
 os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
 app = Flask(__name__)
 
 
-# This information is obtained upon registration of a new GitHub OAuth
-# application here: https://github.com/settings/applications/new
 client_id = "<your client key>"
 client_secret = "<your client secret>"
 authorization_base_url = 'https://github.com/login/oauth/authorize'

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 947 - 1019
mazda/mazda_export.json


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1074 - 1128
mazda/post_error.log


+ 24 - 5
sandbox/starmoney.py

@@ -2,19 +2,38 @@ import pandas as pd
 import numpy as np
 from pathlib import Path
 
-export_dir = 'C:\\Users\\GAPS\\Dropbox\\Jugendchor 2000\\Kasse\\2020\\Export'
+
+export_dir = '/home/robert/Dropbox/Jugendchor 2000/Kasse/2020/Export'
+kst = {'3115532': '0', '3123981': '1', '3124005': '2', '3123999': '3', '3124039': '4', '3123973': '5', '3124013': '6'}
+from_label = ['Buchungstag', 'Internet', 'Verwendungszweckzeile 1', 'Kommentar', 'KST',
+              'Verwendungszweckzeile 3', 'Verwendungszweckzeile 4', 'Verwendungszweckzeile 5',
+              'row_num', 'Einnahmen', 'Ausgaben']
+to_label = ['Datum', 'frei', 'Vorgang', 'Konto', 'KST', 'Nr.', 'Einnahmen_Kasse', 'Ausgaben_Kasse', 'Nr.', 'Einnahmen', 'Ausgaben']
 
 
 def import_csv(filename):
     kto = filename.name.split('_')[0]
-    print(kto)
-    df = pd.read_csv(filename, sep=';', decimal=',', encoding='utf-8', index_col=['IBAN', 'Laufende Nummer'], )
+    print(kto + ': ' + kst[kto])
+    df: pd.DataFrame = pd.read_csv(filename, sep=';', decimal=',', encoding='utf-8', index_col=['IBAN', 'Laufende Nummer']).reset_index()
     df['Einnahmen'] = np.where(df['Betrag'] > 0, df['Betrag'], 0)
-    df['Ausgaben'] = np.where(df['Betrag'] < 0, df['Betrag'], 0)
+    df['Ausgaben'] = np.where(df['Betrag'] < 0, 0 - df['Betrag'], 0)
+    df['KST'] = kst[kto]
+    first_saldo = df.loc[0]['Saldo']
+    last_saldo = df.loc[len(df)-1]['Saldo']
+    df = df[df['Betrag'] != 0]
+    df['row_num'] = np.arange(1, len(df) + 1)
+    df = df[from_label]
+    print(df.shape)
+    df = pd.DataFrame([['01.01.2020', '', 'Anfangsbestand - SLS ' + kto, 'AB', kst[kto], '', '', '', 0, first_saldo, 0]], columns=from_label).append(df).append(
+        pd.DataFrame([['31.12.2020', '', 'Endbestand - SLS ' + kto, 'EB', kst[kto], '', '', '', len(df) + 1, last_saldo, 0]], columns=from_label))
     print(df.shape)
     return df
 
 
 df = [import_csv(f) for f in Path(export_dir).glob('*.csv')]
-df_union = pd.concat(df)
+df_union: pd.DataFrame = pd.concat(df)
 print(df_union.shape)
+
+
+df_union = df_union.rename(columns=dict(zip(from_label, to_label)))
+df_union.to_csv(export_dir + '/export.csv.txt', sep=';', decimal=',', encoding='latin-1', index=False)

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů