|
@@ -69,8 +69,8 @@ class efactTest(unittest.TestCase):
|
|
|
inv_file = os.path.join(root, file)
|
|
|
self.efactoauth.transform_to_pdf(inv_file, no_validation=True)
|
|
|
|
|
|
- def test_get_all_messages(self):
|
|
|
- self.efactoauth.get_all_messages('17259191', days=5, root_path='17259191', env='prod', filter_='T', extract=True)
|
|
|
+ def test_get_all_messages(self, vat_id, days, root_path, env, filter_, extract):
|
|
|
+ self.efactoauth.get_all_messages(vat_id, days=days, env=env, root_path=root_path, filter_=filter_, extract=extract)
|
|
|
|
|
|
def test_pretty_messages(self):
|
|
|
self.efactoauth.pretty_messages('17259191', env='prod')
|
|
@@ -82,7 +82,7 @@ class efactTest(unittest.TestCase):
|
|
|
# self.efactoauth.getxml_from_zip(path='../efact/3016038776.zip', dest_f='')
|
|
|
# latest = self.efactoauth.get_latest_invoice('efact')
|
|
|
inv_files = utils.get_not_booked('17259191')
|
|
|
- # inv_files = ['c:/Users/levi/git/anafapi/tests/17259191/18115143/FACTURA PRIMITA/01_2024/26/4151932773.xml']
|
|
|
+ # inv_files = ['C:/Users/Levi/git/anafapi/tests/17259191/FACTURA PRIMITA/2024_02/06/17317438/4159771982.xml']
|
|
|
for latest in inv_files:
|
|
|
if 'booked' not in latest:
|
|
|
inv = self.efactoauth.parse_inv(invoice=latest)
|
|
@@ -95,7 +95,7 @@ class efactTest(unittest.TestCase):
|
|
|
exp_plan=691,
|
|
|
warehouse_code=23,
|
|
|
generic=True,
|
|
|
- generic_value='2209')
|
|
|
+ generic_value='27')
|
|
|
os.rename(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
|
# os.remove(latest)
|
|
|
|
|
@@ -123,13 +123,15 @@ class efactTest(unittest.TestCase):
|
|
|
if kind == 'seller':
|
|
|
account = 'AccountingCustomerParty'
|
|
|
# print(os.path.basename(dir_path))
|
|
|
- dir_path = os.path.join(dir_path, os.path.basename(dir_path))
|
|
|
+ # dir_path = os.path.join(dir_path, os.path.basename(dir_path))
|
|
|
else:
|
|
|
account = 'AccountingSupplierParty'
|
|
|
# next_subfolder = next(os.walk(dir_path))[1][0]
|
|
|
for root_f, _dirs, files in os.walk(dir_path):
|
|
|
for file in files:
|
|
|
- # print(root_f, files)
|
|
|
+ # print(root_f.split('/'))
|
|
|
+ # print(os.path.basename(dir_path))
|
|
|
+ # print(root_f, file)
|
|
|
if file.endswith('.xml') and file.count('_') < 2 and 'cif error' not in root_f:
|
|
|
# print(os.path.join(root_f, file))
|
|
|
tree = etree.parse(os.path.join(root_f, file))
|
|
@@ -155,27 +157,13 @@ class efactTest(unittest.TestCase):
|
|
|
new_name = '{}_{}_{}_{}.xml'.format(file.replace('.xml', ''), file_id, file_partie, is_date)
|
|
|
current_path = os.path.join(root_f, file)
|
|
|
new_path = os.path.join(root_f, new_name)
|
|
|
- if kind == 'buyer':
|
|
|
- root_f = root_f + '/'
|
|
|
- path_parts = root_f.split('/')
|
|
|
- # print(path_parts)
|
|
|
- try:
|
|
|
- seventh_part = path_parts[7] if len(path_parts) > 6 else None
|
|
|
- except IndexError:
|
|
|
- seventh_part = None
|
|
|
- # print(seventh_part)
|
|
|
- if seventh_part != os.path.basename(dir_path):
|
|
|
- #
|
|
|
- # !This will rename all files
|
|
|
- #
|
|
|
- os.rename(current_path, new_path)
|
|
|
- print(new_name)
|
|
|
- else:
|
|
|
- #
|
|
|
- # !This will rename all files
|
|
|
- #
|
|
|
- os.rename(current_path, new_path)
|
|
|
- print(new_name)
|
|
|
+ #
|
|
|
+ # !This will rename all files
|
|
|
+ #
|
|
|
+ os.rename(current_path, new_path)
|
|
|
+ print(new_name)
|
|
|
+ else:
|
|
|
+ print('Nothing to rename')
|
|
|
|
|
|
def test_parse_inv(self):
|
|
|
inv = self.efactoauth.parse_inv('C:/Users/Levi/git/anafapi/tests/17259191/8262600/FACTURA PRIMITA/01_2024/31/4154212674_booked.xml')
|
|
@@ -188,7 +176,7 @@ class efactTest(unittest.TestCase):
|
|
|
if __name__ == "__main__":
|
|
|
# unittest.main()
|
|
|
# efactTest().test_add_invoice()
|
|
|
- efactTest().test_get_all_messages()
|
|
|
- # efactTest().test_rename_all(os.path.join(os.path.expanduser('~'), 'git/anafapi/tests/17259191/'), kind='seller')
|
|
|
- # efactTest().test_rename_all(os.path.join(os.path.expanduser('~'), 'git/anafapi/tests/17259191/'), kind='buyer')
|
|
|
+ efactTest().test_get_all_messages('17259191', 10, '17259191', 'prod', 'P', True)
|
|
|
+ # efactTest().test_rename_all(os.path.join(os.path.expanduser('~'), 'git/anafapi/tests/17259191/FACTURA TRIMISA'), kind='seller')
|
|
|
+ # efactTest().test_rename_all(os.path.join(os.path.expanduser('~'), 'git/anafapi/tests/17259191/FACTURA PRIMITA'), kind='buyer')
|
|
|
# anoauth.get_token()
|