Procházet zdrojové kódy

added filters, future filter by time

marton levente před 7 měsíci
rodič
revize
e61c50ed95
2 změnil soubory, kde provedl 27 přidání a 3 odebrání
  1. 8 3
      anafapi/anafoauth.py
  2. 19 0
      anafapi/en16931/tests/test_inv_from_xml.py

+ 8 - 3
anafapi/anafoauth.py

@@ -101,7 +101,8 @@ class Anafoauth(object):
 class Efactoauth(Anafoauth):
 
     OAUTH = 'https://api.anaf.ro/TestOauth/jaxrs/hello?name="works with python"'
-    MESSAGES = 'https://api.anaf.ro/{}/FCTEL/rest/listaMesajeFactura?zile={}&cif={}'
+    MESSAGES = 'https://api.anaf.ro/{}/FCTEL/rest/listaMesajeFactura?zile={}&cif={}&filtru={}'
+    LISTBYTIME = 'https://api.anaf.ro/{}/FCTEL/rest/listaMesajePaginatieFactura?startTime={}&endTime={}&cif={}&pagina={}'
     VERIFY = 'https://api.anaf.ro/{}/FCTEL/rest/stareMesaj?id_incarcare={}'
     ADD = 'https://api.anaf.ro/{}/FCTEL/rest/upload?standard={}&cif={}'
     DOWNLOAD = 'https://api.anaf.ro/{}/FCTEL/rest/descarcare?id={}'
@@ -174,8 +175,12 @@ class Efactoauth(Anafoauth):
                             # app_icon=app_icon,
                             timeout=3)
 
-    def get_all_messages(self, vat_id, days=60, env='test', root_path='efact', extract=False) -> dict:
-        url = self.MESSAGES.format(env, days, vat_id)
+    def get_all_messages(self, vat_id, days=60, env='test', filter_=None, root_path='efact', extract=False) -> dict:
+        if filter_:
+            url = self.MESSAGES.format(env, days, vat_id, filter_)
+        else:
+            self.MESSAGES = 'https://api.anaf.ro/{}/FCTEL/rest/listaMesajeFactura?zile={}&cif={}'
+            url = self.MESSAGES.format(env, days, vat_id)
         resp = self.oauth.get(url=url)
         # print(resp.text)
         try:

+ 19 - 0
anafapi/en16931/tests/test_inv_from_xml.py

@@ -0,0 +1,19 @@
+'''Created 2 Feb 2024 Levi'''
+
+import unittest
+
+from anafapi.en16931.entity import Entity
+from anafapi.en16931.invoice import Invoice
+from anafapi.en16931.invoice_line import InvoiceLine
+from anafapi.en16931.tax import Tax
+
+class InvTest(unittest.TestCase):
+
+    def test_from_xml(self):
+        inv = Invoice.from_xml('C:/Users/Levi/git/anafapi/tests/17259191/27100508/FACTURA PRIMITA/02_2024/02/4159454005.xml')
+        # inv = Invoice.from_xml('C:/Users/Levi/git/anafapi/tests/17259191/49110383/FACTURA PRIMITA/02_2024/01/4155009906_booked.xml')
+
+
+if __name__ == "__main__":
+    # unittest.main()
+    InvTest().test_from_xml()