From 2af92a9a6db2c0cc0fc0f94b770df28ca9db8f9b Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Fri, 17 Jan 2025 14:20:29 +0100 Subject: [PATCH] read total + payment-data --- document.py | 39 ++++++++++++++++++++++++++++++++++++++ tests/facturx-extended.xml | 11 +++++++++++ 2 files changed, 50 insertions(+) diff --git a/document.py b/document.py index e2c73c8..4cb29ff 100644 --- a/document.py +++ b/document.py @@ -543,6 +543,45 @@ class Incoming(metaclass=PoolMeta): if taxes: self.parsed_data['payment']['taxes'] = taxes + xpath_payterms = xpath_payment + ['ram:SpecifiedTradePaymentTerms'] + xpath_discount = ['ram:ApplicableTradePaymentDiscountTerms'] + pay_terms = self._readxml_read_listdata(xmltree, xpath_payterms, [], [ + ('ram:Description', 'description'), + (['ram:DueDateDateTime', 'udt:DateTimeString'], + 'duedate', date), + ('ram:DirectDebitMandateID', 'mandat_id'), + ('ram:PartialPaymentAmount', 'amount', Decimal), + (xpath_discount + ['ram:BasisDateTime', 'udt:DateTimeString'], + 'discount_date', date), + (xpath_discount + ['ram:BasisPeriodMeasure'], + 'discount_measure', Decimal), + (xpath_discount + ['ram:BasisAmount'], + 'discount_base', Decimal), + (xpath_discount + ['ram:CalculationPercent'], + 'discount_perc', Decimal), + (xpath_discount + ['ram:ActualDiscountAmount'], + 'discount_amount', Decimal) + ]) + if pay_terms: + self.parsed_data['payment']['terms'] = pay_terms + + # total + xpath_total = xpath_payment + [ + 'ram:SpecifiedTradeSettlementHeaderMonetarySummation'] + total = self._readxml_read_listdata(xmltree, xpath_total, [], [ + ('ram:LineTotalAmount', 'amount', Decimal), + ('ram:ChargeTotalAmount', 'charge', Decimal), + ('ram:AllowanceTotalAmount', 'allowance', Decimal), + ('ram:TaxBasisTotalAmount', 'taxbase', Decimal), + ('ram:TaxTotalAmount', 'taxtotal', Decimal), + ('ram:RoundingAmount', 'rounding', Decimal), + ('ram:GrandTotalAmount', 'grand', Decimal), + ('ram:TotalPrepaidAmount', 'prepaid', Decimal), + ('ram:DuePayableAmount', 'duepayable', Decimal), + ]) + if total: + self.parsed_data['total'] = total[0] + def _readxml_getinvoiceline(self, invoice, line_data): """ create invoice line in memory diff --git a/tests/facturx-extended.xml b/tests/facturx-extended.xml index 6b964a8..0f29bf1 100644 --- a/tests/facturx-extended.xml +++ b/tests/facturx-extended.xml @@ -220,10 +220,21 @@ 7.00 + Payment description + mandat id 20240701 3355.50 + + + 20240702 + + 10.0 + 3355.0 + 2.0 + 70.0 + 1350.00