mikrowerk-edi-invoicing 0.1.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -178,7 +178,7 @@ class XRechnung:
178
178
  def map_tradeline_to_dict(cls, x_trade_line: XRechnungTradeLine) -> dict:
179
179
  _dict = asdict(x_trade_line)
180
180
  _dict.update(
181
- {'trade_tax': asdict(x_trade_line.trade_tax),
181
+ {'trade_tax': asdict(x_trade_line.trade_tax) if x_trade_line.trade_tax is not None else None,
182
182
  'price_unit': float(x_trade_line.price_unit),
183
183
  'quantity_billed': float(x_trade_line.quantity_billed),
184
184
  'total_amount_net': float(x_trade_line.total_amount_net),
@@ -0,0 +1,4 @@
1
+ from ..util.file_helper import get_checked_file_path
2
+ from ..model.x_rechnung import XRechnung
3
+ from ..x_mapper.cross_industry_invoice_mapper import parse_and_map_x_rechnung
4
+ __all__ = ["get_checked_file_path", "XRechnung", "parse_and_map_x_rechnung"]
@@ -4,9 +4,9 @@ from parameterized import parameterized
4
4
 
5
5
  from facturx import get_facturx_xml_from_pdf
6
6
 
7
- from ..util.file_helper import get_checked_file_path
8
- from ..model.x_rechnung import XRechnung
9
- from ..x_mapper.cross_industry_invoice_mapper import parse_and_map_x_rechnung
7
+ from . import get_checked_file_path
8
+ from . import parse_and_map_x_rechnung
9
+ from . import XRechnung
10
10
 
11
11
 
12
12
  class XRechnungEinfachTestCase(unittest.TestCase):
@@ -8,8 +8,8 @@ import xml.sax as sax
8
8
  from decimal import Decimal
9
9
 
10
10
  from ..model.x_rechnung import (XRechnung, XRechnungTradeParty, XRechnungTradeAddress, XRechnungTradeContact,
11
- XRechnungPaymentMeans, XRechnungBankAccount, XRechnungCurrency, XRechnungTradeLine,
12
- XRechnungAppliedTradeTax)
11
+ XRechnungPaymentMeans, XRechnungBankAccount, XRechnungCurrency, XRechnungTradeLine,
12
+ XRechnungAppliedTradeTax)
13
13
  from .xml_abstract_x_rechnung_parser import XMLAbstractXRechnungParser
14
14
 
15
15
 
@@ -58,6 +58,10 @@ class UblSaxHandler(sax.ContentHandler):
58
58
  self.current_payment_means.payee_account = XRechnungBankAccount()
59
59
  case "InvoiceLine":
60
60
  self.current_trade_line = XRechnungTradeLine()
61
+ self.current_trade_tax = None
62
+ case "AllowanceCharge":
63
+ self.current_trade_line = XRechnungTradeLine()
64
+ self.current_trade_tax = None
61
65
  case "TaxSubtotal":
62
66
  self.current_trade_tax = XRechnungAppliedTradeTax()
63
67
  case "ClassifiedTaxCategory":
@@ -65,6 +69,9 @@ class UblSaxHandler(sax.ContentHandler):
65
69
 
66
70
  _path = '/'.join([tag for tag, _attrs in self.stack])
67
71
 
72
+ if _path.endswith('/AllowanceCharge/TaxCategory'):
73
+ self.current_trade_tax = XRechnungAppliedTradeTax()
74
+
68
75
  print(f">>>>>>>>>>>>>>> start: {_ns} {_tag_name} >>>>>>>>>>>>>>>>")
69
76
  print(_path)
70
77
  for k, v in attrs.items():
@@ -83,10 +90,14 @@ class UblSaxHandler(sax.ContentHandler):
83
90
  self.handle_payment_means(_path, _tag_name, _content, attrs)
84
91
  if "/InvoiceLine" in _path:
85
92
  self.handle_invoice_line(_path, _tag_name, _content, attrs)
93
+ if "/AllowanceCharge" in _path:
94
+ self.handle_allowance_charge(_path, _tag_name, _content, attrs)
86
95
  if "/ClassifiedTaxCategory" in _path:
87
96
  self.handle_trade_tax(_path, _tag_name, _content, attrs)
88
97
  if "/TaxTotal/TaxSubtotal" in _path:
89
98
  self.handle_trade_tax(_path, _tag_name, _content, attrs)
99
+ if "/AllowanceCharge/TaxCategory" in _path:
100
+ self.handle_trade_tax(_path, _tag_name, _content, attrs)
90
101
 
91
102
  # collect results when closing a main tag
92
103
  match _tag_name:
@@ -102,6 +113,13 @@ class UblSaxHandler(sax.ContentHandler):
102
113
 
103
114
  if _path.endswith("Invoice/TaxTotal/TaxSubtotal"):
104
115
  self.applicable_trade_taxes.append(self.current_trade_tax)
116
+ elif _path.endswith('Invoice/AllowanceCharge'):
117
+ self.current_trade_line.trade_tax = self.current_trade_tax
118
+ self.current_trade_line.line_id = "99999"
119
+ self.current_trade_line.seller_assigned_id = "AllowanceCharge"
120
+ self.current_trade_line.total_amount_net = (
121
+ self.current_trade_line.price_unit * self.current_trade_line.quantity_billed)
122
+ self.trade_line_list.append(self.current_trade_line)
105
123
 
106
124
  # invoice top level properties
107
125
  self.handle_invoice(_path, _tag_name, _content, attrs)
@@ -239,6 +257,17 @@ class UblSaxHandler(sax.ContentHandler):
239
257
  elif path.endswith("/InvoiceLine/Price/PriceAmount"):
240
258
  self.current_trade_line.price_unit = float(content)
241
259
 
260
+ def handle_allowance_charge(self, path: str, tag: str, content: str, attr=None):
261
+ if path.endswith("/AllowanceCharge/AllowanceChargeReason"):
262
+ self.current_trade_line.name = content
263
+ elif path.endswith("/AllowanceCharge/Amount"):
264
+ self.current_trade_line.price_unit = float(content)
265
+ elif path.endswith("/AllowanceCharge/ChargeIndicator"):
266
+ if content.lower() == "true":
267
+ self.current_trade_line.quantity_billed = 1.0
268
+ else:
269
+ self.current_trade_line.quantity_billed = -1.0
270
+
242
271
  def handle_trade_tax(self, path: str, tag: str, content: str, attr=None):
243
272
  if path.endswith("/ClassifiedTaxCategory/ID") or path.endswith("/TaxCategory/ID"):
244
273
  self.current_trade_tax.category_code = content
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mikrowerk_edi_invoicing
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Parser for EDI invoices in CII or UBL format
5
5
  Author: Mikrowerk a Gammadata Division
6
6
  Author-email: info@mikrowerk.com
@@ -0,0 +1,19 @@
1
+ edi_invoice_parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ edi_invoice_parser/model/__init__.py,sha256=eM8kFNSQHvV3RbGnrOPECSNcdOZIU_FJYkqOJ9gZ5-0,59
3
+ edi_invoice_parser/model/x_rechnung.py,sha256=55Lr-1ACipHA3ZZ93lb5VsMhW_48DnxsAAk9etwdjqE,9838
4
+ edi_invoice_parser/tests/__init__.py,sha256=yIVXlfwl4AFgit_XRZ6gjCdRPh_xM11sXKYFQCAsljk,248
5
+ edi_invoice_parser/tests/test_iban_handling.py,sha256=suRaB9gxbNc2Dc7spjHmQyPBdXva98HF1js85wQWqPM,662
6
+ edi_invoice_parser/tests/test_parse_x_rechnung.py,sha256=vi37eetsNXdgth1TIhvOJ4U5NA_ZNOFZWi_8gLYtRM4,3512
7
+ edi_invoice_parser/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ edi_invoice_parser/util/file_helper.py,sha256=4gdWbv8L9LSMraLKvGI1Z3NMcuGGy7JB1qFvNaW-yo4,767
9
+ edi_invoice_parser/x_mapper/__init__.py,sha256=Ee222PGj2y9wgsjx53yP9InOwkig31SZd8ra29gkPMc,536
10
+ edi_invoice_parser/x_mapper/cross_industry_invoice_mapper.py,sha256=HmIDFJhJf4iB5efFZoPhs04c2qvwvTn0pfbsrPA9EJk,827
11
+ edi_invoice_parser/x_mapper/drafthorse_elements_helper.py,sha256=gO8VobJnBqKEdRDcVsz4XixCvSCQEYqhcZeb7v51jGE,3756
12
+ edi_invoice_parser/x_mapper/xml_abstract_x_rechnung_parser.py,sha256=puxCSC02zIXpfMY9xNLqY-w0aRv0y5ROHmNtmaV16o4,673
13
+ edi_invoice_parser/x_mapper/xml_cii_dom_parser.py,sha256=q_0osUHGloVkG0ZL782SBMWAGtMaBdEI8xblyGrDlmw,10980
14
+ edi_invoice_parser/x_mapper/xml_ubl_sax_parser.py,sha256=xhJXvSAhM7gz2W-ZheyrS-hE2hfBUjbBqZuu3SoAkMU,15613
15
+ mikrowerk_edi_invoicing-0.2.1.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
16
+ mikrowerk_edi_invoicing-0.2.1.dist-info/METADATA,sha256=M779tRSWxaJa5ctU0Ygpyo7dyvhvG52U5Cn0ElleIjE,1004
17
+ mikrowerk_edi_invoicing-0.2.1.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
18
+ mikrowerk_edi_invoicing-0.2.1.dist-info/top_level.txt,sha256=OyIJDXDBfR9f0EvTDTmEHdXEFHscjRqX1MxeOeT2VKM,19
19
+ mikrowerk_edi_invoicing-0.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.1)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1 @@
1
+ edi_invoice_parser
@@ -1,18 +0,0 @@
1
- model/__init__.py,sha256=eM8kFNSQHvV3RbGnrOPECSNcdOZIU_FJYkqOJ9gZ5-0,59
2
- model/x_rechnung.py,sha256=qklcfdmihPZL9Ny7rqvP_KgvcnEsNGXLJUEO8iafZas,9790
3
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- tests/test_iban_handling.py,sha256=suRaB9gxbNc2Dc7spjHmQyPBdXva98HF1js85wQWqPM,662
5
- tests/test_parse_x_rechnung.py,sha256=ChVUcDp3P1o8IzQmRJJWwkIlrqZel3xYmoE3V1ukytE,3584
6
- util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- util/file_helper.py,sha256=4gdWbv8L9LSMraLKvGI1Z3NMcuGGy7JB1qFvNaW-yo4,767
8
- x_mapper/__init__.py,sha256=Ee222PGj2y9wgsjx53yP9InOwkig31SZd8ra29gkPMc,536
9
- x_mapper/cross_industry_invoice_mapper.py,sha256=HmIDFJhJf4iB5efFZoPhs04c2qvwvTn0pfbsrPA9EJk,827
10
- x_mapper/drafthorse_elements_helper.py,sha256=gO8VobJnBqKEdRDcVsz4XixCvSCQEYqhcZeb7v51jGE,3756
11
- x_mapper/xml_abstract_x_rechnung_parser.py,sha256=puxCSC02zIXpfMY9xNLqY-w0aRv0y5ROHmNtmaV16o4,673
12
- x_mapper/xml_cii_dom_parser.py,sha256=q_0osUHGloVkG0ZL782SBMWAGtMaBdEI8xblyGrDlmw,10980
13
- x_mapper/xml_ubl_sax_parser.py,sha256=VZcZSQo-iHiVA3IUtZu9xAQwWglgk34lD_Y-Hw3Sq5M,14008
14
- mikrowerk_edi_invoicing-0.1.0.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
15
- mikrowerk_edi_invoicing-0.1.0.dist-info/METADATA,sha256=9kizoXNxoAkO0FHNyu10gjLF10aJr6VYsPlQpPQgjBM,1004
16
- mikrowerk_edi_invoicing-0.1.0.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
17
- mikrowerk_edi_invoicing-0.1.0.dist-info/top_level.txt,sha256=pchuH1VFSrOMiUHBeuZxMaHNvC6mgZ59aac8eM_PXgs,26
18
- mikrowerk_edi_invoicing-0.1.0.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- model
2
- tests
3
- util
4
- x_mapper
File without changes
File without changes
File without changes
File without changes
File without changes