Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse billing period (backport #100) #101

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

</details>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"],
},
Expand Down