Skip to content

Commit

Permalink
feat: add VAT exemption reason codes
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Nov 18, 2024
1 parent 1d9de49 commit 7f6aa00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Code List | Mapped DocType | Default Value
[Codes for Units of Measure Used in International Trade](https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:rec20_3:technischerBestandteilGenericode) | UOM | C62
[Codes for Passengers, Types of Cargo, Packages and Packaging Materials](https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:rec21_3:technischerBestandteilGenericode) (optional) | UOM | C62
[Codes for Duty Tax and Fee Categories](https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.5305_3:technischerBestandteilGenericode) | Item Tax Template, Account, Tax Category, Sales Taxes and Charges Template | S
[VAT exemption reason code list](https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:vatex_1:technischerBestandteilGenericode) | Item Tax Template, Account, Tax Category, Sales Taxes and Charges Template | vatex-eu-ae

For example, let's say your standard **Payment Terms Template** is "Bank Transfer, 30 days". You'll need to find the suitable **Common Code** for bank transfers within the **Code List** "UNTDID.4461". In this case, the code is "58". Then you add a row to the _Applies To_ table, select "Payment Terms Template" as the _Link Document Type_ and "Bank Transfer, 30 days" as the _Link Name_. If you now create an Invoice with this **Payment Terms Template**, the eInvoice will contain the code "58" for the payment means, signalling that the payment should done via bank transfer.

Expand Down
17 changes: 17 additions & 0 deletions eu_einvoice/european_e_invoice/custom/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
payment_means_codes = CommonCodeRetriever(["urn:xoev-de:xrechnung:codeliste:untdid.4461_3"], "ZZZ")
duty_tax_fee_category_codes = CommonCodeRetriever(["urn:xoev-de:kosit:codeliste:untdid.5305_3"], "S")
vat_exemption_reason_codes = CommonCodeRetriever(["urn:xoev-de:kosit:codeliste:vatex_1"], "vatex-eu-ae")


@frappe.whitelist()
Expand Down Expand Up @@ -171,6 +172,16 @@ def get_xml(invoice, company, seller_address=None, customer_address=None):
item.item_tax_template, invoice.taxes
)

if li.settlement.trade_tax.rate_applicable_percent._value == 0:
li.settlement.trade_tax.exemption_reason_code = vat_exemption_reason_codes.get(
[
("Item Tax Template", item.item_tax_template),
("Account", item.income_account),
("Tax Category", invoice.tax_category),
("Sales Taxes and Charges Template", invoice.taxes_and_charges),
]
)

li.settlement.monetary_summation.total_amount = item.amount
doc.trade.items.add(li)

Expand Down Expand Up @@ -263,6 +274,12 @@ def get_xml(invoice, company, seller_address=None, customer_address=None):
trade_tax.basis_amount = invoice.net_total
trade_tax.rate_applicable_percent = 0
trade_tax.calculated_amount = 0
trade_tax.exemption_reason_code = vat_exemption_reason_codes.get(
[
("Tax Category", invoice.tax_category),
("Sales Taxes and Charges Template", invoice.taxes_and_charges),
]
)
doc.trade.settlement.trade_tax.add(trade_tax)

for ps in invoice.payment_schedule:
Expand Down

0 comments on commit 7f6aa00

Please sign in to comment.