From 870bd14a63e709b0bd8c971177309d15ff3d14d8 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Thu, 13 Feb 2025 00:52:18 +0100 Subject: [PATCH] feat: parse billing period (#100) * feat: parse billing period * docs: parse billing period (cherry picked from commit aeb3f0657efaf3c67d5268339849168660f5d9dd) --- README.md | 3 +++ .../e_invoice_import/e_invoice_import.json | 27 ++++++++++++++++++- .../e_invoice_import/e_invoice_import.py | 11 +++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 885d07f..d847bb2 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,9 @@ The following fields are currently extracted from the eInvoice: - Payee Account Name - Payee BIC - Payee IBAN +- Billing Period + - Start Date + - End Date diff --git a/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.json b/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.json index 33ea9e5..b24dc04 100644 --- a/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.json +++ b/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.json @@ -52,6 +52,10 @@ "taxes", "due_date", "payment_terms", + "billing_period_section", + "billing_period_start", + "column_break_etpy", + "billing_period_end", "payment_means_section", "payee_account_name", "payee_iban", @@ -359,6 +363,27 @@ "fieldtype": "Data", "label": "BIC", "read_only": 1 + }, + { + "fieldname": "billing_period_section", + "fieldtype": "Section Break", + "label": "Billing Period" + }, + { + "fieldname": "billing_period_start", + "fieldtype": "Date", + "label": "Billing Period Start", + "read_only": 1 + }, + { + "fieldname": "column_break_etpy", + "fieldtype": "Column Break" + }, + { + "fieldname": "billing_period_end", + "fieldtype": "Date", + "label": "Billing Period End", + "read_only": 1 } ], "index_web_pages_for_search": 1, @@ -369,7 +394,7 @@ "link_fieldname": "e_invoice_import" } ], - "modified": "2025-02-12 23:47:22.751802", + "modified": "2025-02-13 00:31:19.390900", "modified_by": "Administrator", "module": "European e-Invoice", "name": "E Invoice Import", diff --git a/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py b/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py index fc67f73..8ebe6ac 100644 --- a/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py +++ b/eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py @@ -22,7 +22,7 @@ from drafthorse.models.accounting import ApplicableTradeTax from drafthorse.models.party import PostalTradeAddress, TradeParty from drafthorse.models.payment import PaymentTerms - from drafthorse.models.trade import PaymentMeans + from drafthorse.models.trade import BillingSpecifiedPeriod, PaymentMeans from drafthorse.models.tradelines import LineItem from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import PurchaseInvoice @@ -45,6 +45,8 @@ class EInvoiceImport(Document): ) amended_from: DF.Link | None + billing_period_end: DF.Date | None + billing_period_start: DF.Date | None buyer_address_line_1: DF.Data | None buyer_address_line_2: DF.Data | None buyer_city: DF.Data | None @@ -174,6 +176,7 @@ def read_values_from_einvoice(self) -> None: self.parse_payment_term(term) self.parse_bank_details(doc.trade.settlement.payment_means) + self.parse_billing_period(doc.trade.settlement.period) def _validate_schematron(self, xml_bytes): self.validation_errors = "" @@ -283,6 +286,10 @@ def parse_bank_details(self, payment_means: "PaymentMeans"): self.payee_account_name = payment_means.payee_account.account_name._text or None self.payee_bic = payment_means.payee_institution.bic._text or None + def parse_billing_period(self, period: "BillingSpecifiedPeriod"): + self.billing_period_start = period.start._value + self.billing_period_end = period.end._value + def guess_supplier(self): if self.supplier: return @@ -425,6 +432,8 @@ def process_payment_term(source, target, source_parent): "id": "bill_no", "issue_date": "bill_date", "currency": "currency", + "billing_period_start": "from_date", + "billing_period_end": "to_date", }, # "field_no_map": ["items"], },