|
@@ -275,37 +275,91 @@ class WinMentor(object):
|
|
df_conts = pd.DataFrame(df_dicts[2])
|
|
df_conts = pd.DataFrame(df_dicts[2])
|
|
df_oblig = pd.DataFrame(df_dicts[0])
|
|
df_oblig = pd.DataFrame(df_dicts[0])
|
|
df_obligf = pd.DataFrame(df_dicts[3])
|
|
df_obligf = pd.DataFrame(df_dicts[3])
|
|
|
|
+ df_mons = pd.DataFrame(df_dicts[4])
|
|
df_obligf = df_obligf.rename(columns={'TipTranz': 'TipDoc'})
|
|
df_obligf = df_obligf.rename(columns={'TipTranz': 'TipDoc'})
|
|
# join oblig<>part<>cont with left join
|
|
# join oblig<>part<>cont with left join
|
|
df_oblig = pd.merge(df_oblig, df_parts, how='left', left_on='Part', right_on='Cod')
|
|
df_oblig = pd.merge(df_oblig, df_parts, how='left', left_on='Part', right_on='Cod')
|
|
df_oblig.drop(columns=['Part', 'Cod'], inplace=True)
|
|
df_oblig.drop(columns=['Part', 'Cod'], inplace=True)
|
|
df_oblig = pd.merge(df_oblig, df_conts, how='left', left_on='Cont', right_on='Cod')
|
|
df_oblig = pd.merge(df_oblig, df_conts, how='left', left_on='Cont', right_on='Cod')
|
|
df_oblig.drop(columns=['Cont', 'Cod'], inplace=True)
|
|
df_oblig.drop(columns=['Cont', 'Cod'], inplace=True)
|
|
|
|
+ df_oblig = pd.merge(df_oblig, df_mons, how='left', left_on='Moneda', right_on='Cod')
|
|
|
|
+ df_oblig.drop(columns=['Moneda', 'Cod'], inplace=True)
|
|
|
|
+ df_oblig.drop(columns=['TipDoc'], inplace=True)
|
|
# join obligf<>party<>cont
|
|
# join obligf<>party<>cont
|
|
try:
|
|
try:
|
|
df_obligf = pd.merge(df_obligf, df_parts, how='left', left_on='Part', right_on='Cod')
|
|
df_obligf = pd.merge(df_obligf, df_parts, how='left', left_on='Part', right_on='Cod')
|
|
df_obligf.drop(columns=['Part', 'Cod'], inplace=True)
|
|
df_obligf.drop(columns=['Part', 'Cod'], inplace=True)
|
|
df_obligf = pd.merge(df_obligf, df_conts, how='left', left_on='Cont', right_on='Cod')
|
|
df_obligf = pd.merge(df_obligf, df_conts, how='left', left_on='Cont', right_on='Cod')
|
|
df_obligf.drop(columns=['Cont', 'Cod'], inplace=True)
|
|
df_obligf.drop(columns=['Cont', 'Cod'], inplace=True)
|
|
|
|
+ df_obligf = pd.merge(df_obligf, df_mons, how='left', left_on='Moneda', right_on='Cod')
|
|
|
|
+ df_obligf.drop(columns=['Moneda', 'Cod'], inplace=True)
|
|
|
|
+ df_obligf.drop(columns=['TipDoc'], inplace=True)
|
|
df_obligall = pd.concat([df_oblig, df_obligf])
|
|
df_obligall = pd.concat([df_oblig, df_obligf])
|
|
except KeyError as exc_:
|
|
except KeyError as exc_:
|
|
df_obligall = df_oblig
|
|
df_obligall = df_oblig
|
|
options = ['581', '455', '455.01', '167', '666']
|
|
options = ['581', '455', '455.01', '167', '666']
|
|
- df_obligall = df_obligall.loc[(~df_obligall['Simbol'].isin(options)) & (df_obligall['Rest'] != 0)]
|
|
|
|
|
|
+ suppliers = ['401', '404', '409', '409.01', '409.02', '409.04']
|
|
|
|
+ clients = ['411', '411.01', '419', '472']
|
|
|
|
+ df_obligall['TipPartener'] = df_obligall.apply(lambda row: self.part_type(row), axis=1)
|
|
|
|
+ df_obligall['RestRon'] = df_obligall['Rest'] * df_obligall['Curs']
|
|
|
|
+ mask = (~df_obligall['Simbol_x'].isin(options)) & (df_obligall['Rest'] != 0)
|
|
|
|
+ df_obligsp = df_obligall.loc[mask & (df_obligall['Simbol_x'].isin(suppliers))]
|
|
|
|
+ df_obligcl = df_obligall.loc[mask & (df_obligall['Simbol_x'].isin(clients))]
|
|
print(df_obligall.head(10))
|
|
print(df_obligall.head(10))
|
|
- df_obligall.to_excel('obligatii.xlsx')
|
|
|
|
|
|
+ writer = pd.ExcelWriter(
|
|
|
|
+ 'obligatii.xlsx',
|
|
|
|
+ engine='xlsxwriter')
|
|
|
|
+
|
|
|
|
+ df_obligsp.to_excel(writer, sheet_name='Furnizori', index=False)
|
|
|
|
+ df_obligcl.to_excel(writer, sheet_name='Clienti', index=False)
|
|
|
|
+ workbook = writer.book
|
|
|
|
+ num_format = workbook.add_format()
|
|
|
|
+ num_format.set_num_format('#,##0.00')
|
|
|
|
+ sh = workbook.get_worksheet_by_name('Furnizori')
|
|
|
|
+ sh.freeze_panes(1, 0)
|
|
|
|
+ sh.autofilter('A1:N500')
|
|
|
|
+ sh.set_column('E:F', 12, cell_format=num_format)
|
|
|
|
+ sh.set_column('L:L', 12, cell_format=num_format)
|
|
|
|
+ sh.set_column('D:D', 10)
|
|
|
|
+ sh.set_column('G:G', 30)
|
|
|
|
+ sh2 = workbook.get_worksheet_by_name('Clienti')
|
|
|
|
+ sh2.freeze_panes(1, 0)
|
|
|
|
+ sh2.autofilter('A1:N500')
|
|
|
|
+ sh2.set_column('E:F', 12, cell_format=num_format)
|
|
|
|
+ sh2.set_column('L:L', 12, cell_format=num_format)
|
|
|
|
+ sh2.set_column('D:D', 10)
|
|
|
|
+ sh2.set_column('G:G', 30)
|
|
|
|
+ writer._save()
|
|
|
|
+ # writer.close()
|
|
|
|
|
|
|
|
+ def part_type(self, row):
|
|
|
|
+ suppliers = ['401', '403', '404', '408']
|
|
|
|
+ adv_suppliers = ['409', '409.01', '409.02', '409.03', '409.04']
|
|
|
|
+ clients = ['411', '411.01', '418']
|
|
|
|
+ adv_clients = ['419', '419.01', '419.02', '472', '472.01']
|
|
|
|
+ if row.loc['Simbol_x'] in suppliers:
|
|
|
|
+ return 'Furnizor'
|
|
|
|
+ elif row.loc['Simbol_x'] in adv_suppliers:
|
|
|
|
+ return 'avans furnizor'
|
|
|
|
+ elif row.loc['Simbol_x'] in clients:
|
|
|
|
+ return 'Client'
|
|
|
|
+ elif row.loc['Simbol_x'] in adv_clients:
|
|
|
|
+ return 'Avans client'
|
|
|
|
+
|
|
|
|
+
|
|
def get_oblig(self, short_name, db_file='/ObligPI.DB'):
|
|
def get_oblig(self, short_name, db_file='/ObligPI.DB'):
|
|
firm_list = self.filtered_firmlist(None)
|
|
firm_list = self.filtered_firmlist(None)
|
|
- oblig_headers = ['Part', 'TipDoc', 'Cont', 'Doc', 'NrDoc', 'DataDoc', 'Valoare', 'Rest']
|
|
|
|
- obligf_headers = ['Part', 'TipTranz', 'Cont', 'Doc', 'NrDoc', 'DataDoc', 'Valoare', 'Rest']
|
|
|
|
|
|
+ oblig_headers = ['Part', 'TipDoc', 'Cont', 'Doc', 'Moneda', 'Curs', 'NrDoc', 'DataDoc', 'Valoare', 'Rest']
|
|
|
|
+ obligf_headers = ['Part', 'TipTranz', 'Cont', 'Doc', 'Moneda', 'Curs', 'NrDoc', 'DataDoc', 'Valoare', 'Rest']
|
|
nparts_headres = ['Cod', 'Denumire', 'CodFiscal']
|
|
nparts_headres = ['Cod', 'Denumire', 'CodFiscal']
|
|
cont_headers = ['Cod', 'Simbol']
|
|
cont_headers = ['Cod', 'Simbol']
|
|
|
|
+ mon_headers = ['Cod', 'Simbol']
|
|
for firm in firm_list:
|
|
for firm in firm_list:
|
|
if firm[6] == short_name:
|
|
if firm[6] == short_name:
|
|
short_path = self.winment_path + short_name
|
|
short_path = self.winment_path + short_name
|
|
# update files
|
|
# update files
|
|
nparts_db = self.update_copy(short_path + '/NPART.DB')
|
|
nparts_db = self.update_copy(short_path + '/NPART.DB')
|
|
|
|
+ mons_db = self.update_copy(short_path + '/NMONEDE.DB')
|
|
oblig_db = self.update_copy(short_path + '/' + self.get_last_month(short_name) + db_file)
|
|
oblig_db = self.update_copy(short_path + '/' + self.get_last_month(short_name) + db_file)
|
|
obligf_db = self.update_copy(short_path + '/' + self.get_last_month(short_name) + '/ObligF.DB')
|
|
obligf_db = self.update_copy(short_path + '/' + self.get_last_month(short_name) + '/ObligF.DB')
|
|
conts_db = self.update_copy(short_path + '/' + self.get_last_month(short_name) + '/NCONT.DB')
|
|
conts_db = self.update_copy(short_path + '/' + self.get_last_month(short_name) + '/NCONT.DB')
|
|
@@ -313,13 +367,15 @@ class WinMentor(object):
|
|
dbtodf_oblig = Dbtodf(oblig_db, *oblig_headers)
|
|
dbtodf_oblig = Dbtodf(oblig_db, *oblig_headers)
|
|
dbtodf_parts = Dbtodf(nparts_db, *nparts_headres)
|
|
dbtodf_parts = Dbtodf(nparts_db, *nparts_headres)
|
|
dbtodf_conts = Dbtodf(conts_db, *cont_headers)
|
|
dbtodf_conts = Dbtodf(conts_db, *cont_headers)
|
|
- dbtodf_obligf =Dbtodf(obligf_db, *obligf_headers)
|
|
|
|
|
|
+ dbtodf_obligf = Dbtodf(obligf_db, *obligf_headers)
|
|
|
|
+ dbtodf_mons = Dbtodf(mons_db, *mon_headers)
|
|
# actual converting
|
|
# actual converting
|
|
oblig_dict = dbtodf_oblig.convert_oblig()
|
|
oblig_dict = dbtodf_oblig.convert_oblig()
|
|
obligf_dict = dbtodf_obligf.convert_obligf()
|
|
obligf_dict = dbtodf_obligf.convert_obligf()
|
|
parts_dict = dbtodf_parts.convert_parts()
|
|
parts_dict = dbtodf_parts.convert_parts()
|
|
conts_dict = dbtodf_conts.convert_cont()
|
|
conts_dict = dbtodf_conts.convert_cont()
|
|
- return (oblig_dict, parts_dict, conts_dict, obligf_dict)
|
|
|
|
|
|
+ mons_dict = dbtodf_mons.convert_mon()
|
|
|
|
+ return (oblig_dict, parts_dict, conts_dict, obligf_dict, mons_dict)
|
|
|
|
|
|
def corp_list(self, name=None):
|
|
def corp_list(self, name=None):
|
|
'''returns company list from actual shortnames from winmwnt/data folder
|
|
'''returns company list from actual shortnames from winmwnt/data folder
|