|
@@ -66,6 +66,38 @@ class efactTest(unittest.TestCase):
|
|
efactoauth.load_token_file(token_file_path.format('efact_jwt.json'))
|
|
efactoauth.load_token_file(token_file_path.format('efact_jwt.json'))
|
|
efactoauth.load_session()
|
|
efactoauth.load_session()
|
|
|
|
|
|
|
|
+ def test_to_erp(self):
|
|
|
|
+ # 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 = [r'C:\Users\Levi\git\anafapi\tests\17259191\FACTURA PRIMITA\2024_05\23\16702141\4290867417.xml',
|
|
|
|
+ #
|
|
|
|
+ # ]
|
|
|
|
+ for latest in inv_files:
|
|
|
|
+ if 'booked' not in latest:
|
|
|
|
+ inv = self.efactoauth.parse_inv(invoice=latest)
|
|
|
|
+ print(inv.seller_party.name, inv.invoice_id, inv.issue_date.date())
|
|
|
|
+ # for line in inv.lines:
|
|
|
|
+ # print(line.tax)
|
|
|
|
+ self.efactoauth.addinvoice_tonextup(invoice=inv,
|
|
|
|
+ kind='stock',
|
|
|
|
+ template=32,
|
|
|
|
+ exp_plan=363,
|
|
|
|
+ warehouse_code=23,
|
|
|
|
+ generic=True,
|
|
|
|
+ generic_value='2209',
|
|
|
|
+ send=True)
|
|
|
|
+ os.rename(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
|
|
+ # os.remove(latest)
|
|
|
|
+
|
|
|
|
+ def test_validate_invoice(self):
|
|
|
|
+ # print(os.listdir('c:/Users/DECEL/FACT1/MZK/2023.01.03/'))
|
|
|
|
+ for root, _dir, files in os.walk(r'c:\Users\levi\FACT1\MZK\2024_05_22'):
|
|
|
|
+ for file in files:
|
|
|
|
+ # print(file)
|
|
|
|
+ self.efactoauth.validate_invoice(os.path.join(root, file))
|
|
|
|
+ # self.efactoauth.validate_invoice('c:/Users/levi/FACT1/MZK/2024_01_23/MZK241157.xml')
|
|
|
|
+
|
|
def test_add_invoice(self):
|
|
def test_add_invoice(self):
|
|
# self.efactoauth.validate_invoice('C:/Users/DECEL/FACT1/MZK/2023_06/MZK2321602.xml', env='prod')
|
|
# self.efactoauth.validate_invoice('C:/Users/DECEL/FACT1/MZK/2023_06/MZK2321602.xml', env='prod')
|
|
self.efactoauth.add_invoice('17259191', r'C:/Users/DECEL/FACT1/MZK/2023_06/MZK2321602.xml', env='prod')
|
|
self.efactoauth.add_invoice('17259191', r'C:/Users/DECEL/FACT1/MZK/2023_06/MZK2321602.xml', env='prod')
|
|
@@ -96,27 +128,11 @@ class efactTest(unittest.TestCase):
|
|
def test_download_invoice(self):
|
|
def test_download_invoice(self):
|
|
self.efactoauth.download_invoice('3105899770', path=r'C:/Users/DECEL/FACT1/MZK/2023_06', env='prod')
|
|
self.efactoauth.download_invoice('3105899770', path=r'C:/Users/DECEL/FACT1/MZK/2023_06', env='prod')
|
|
|
|
|
|
- def test_getxml_to_erp(self):
|
|
|
|
- # 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 = [r'C:\Users\Levi\git\anafapi\tests\17259191\FACTURA PRIMITA\2024_05\15\25222010\4268226934.xml']
|
|
|
|
- for latest in inv_files:
|
|
|
|
- if 'booked' not in latest:
|
|
|
|
- inv = self.efactoauth.parse_inv(invoice=latest)
|
|
|
|
- print(inv.seller_party.name, inv.invoice_id, inv.issue_date.date())
|
|
|
|
- # for line in inv.lines:
|
|
|
|
- # print(line.tax)
|
|
|
|
- self.efactoauth.addinvoice_tonextup(invoice=inv,
|
|
|
|
- kind='service',
|
|
|
|
- template=32,
|
|
|
|
- exp_plan=370,
|
|
|
|
- warehouse_code=23,
|
|
|
|
- generic=False,
|
|
|
|
- generic_value=None,
|
|
|
|
- send=True)
|
|
|
|
- os.rename(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
|
|
- # os.remove(latest)
|
|
|
|
|
|
+ def test_getxml(self):
|
|
|
|
+ files = [file for file in os.listdir(r'C:\Users\Levi\git\anafapi\tests\17259191\FACTURA PRIMITA\2024_05\24\9845734') if '.zip' in file]
|
|
|
|
+ # print(files)
|
|
|
|
+ for file in files:
|
|
|
|
+ self.efactoauth.getxml_from_zip(path=os.path.join(r'C:\Users\Levi\git\anafapi\tests\17259191\FACTURA PRIMITA\2024_05\24\9845734', file), dest_f=r'C:\Users\Levi\git\anafapi\tests\17259191\FACTURA PRIMITA\2024_05\24\9845734')
|
|
|
|
|
|
def test_partner_code(self):
|
|
def test_partner_code(self):
|
|
with open(r'C:/Users/Levi/git/ciel_rest_api/parts.json') as partner_file:
|
|
with open(r'C:/Users/Levi/git/ciel_rest_api/parts.json') as partner_file:
|
|
@@ -140,14 +156,6 @@ class efactTest(unittest.TestCase):
|
|
print(latest)
|
|
print(latest)
|
|
# os.replace(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
# os.replace(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
|
|
|
|
- def test_validate_invoice(self):
|
|
|
|
- # print(os.listdir('c:/Users/DECEL/FACT1/MZK/2023.01.03/'))
|
|
|
|
- for root, _dir, files in os.walk(r'c:\Users\levi\FACT1\MZK\2024_05_13'):
|
|
|
|
- for file in files:
|
|
|
|
- # print(file)
|
|
|
|
- self.efactoauth.validate_invoice(os.path.join(root, file))
|
|
|
|
- # self.efactoauth.validate_invoice('c:/Users/levi/FACT1/MZK/2024_01_23/MZK241157.xml')
|
|
|
|
-
|
|
|
|
def test_rename_all(self, dir_path, kind: Union[str, 'seller', 'buyer']): # @UndefinedVariable
|
|
def test_rename_all(self, dir_path, kind: Union[str, 'seller', 'buyer']): # @UndefinedVariable
|
|
if kind == 'seller':
|
|
if kind == 'seller':
|
|
account = 'AccountingCustomerParty'
|
|
account = 'AccountingCustomerParty'
|