Error in an electronic invoice in UBL (Universal Business Language) format that relates to compliance with billing requirements, so here I'm using django block template that function call to create xml files from invoices depending on ubl 2.1 , i got error when I'm trying to check validity of xml invoice ... could any one help
here is the code of the template
{% comment %} {% for discount in %} {% endcomment %}
{% if invoice.allowance_discount %}
<cac:AllowanceCharge>
<cbc:ID>1</cbc:ID>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="{{ invoice.currency.code }}">{{ invoice.allowance_discount|default:"0.0"|floatformat:2 }}</cbc:Amount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">{{ invoice.company.finance_company.account_sale_tax.vat_category_code }}</cbc:ID>
<cbc:Percent>{{ invoice.company.finance_company.account_sale_tax.amount|default:"0.0"|floatformat:2 }}</cbc:Percent>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:AllowanceCharge>
{% endif %}
{% comment %} {% endfor %} {% endcomment %}`
```
here is the error and warning i got
`Errors
category : BR_ERROR
code :BR-CL-18
message : Invoice tax categories MUST be coded using UNCL5305 code list
Warnings
category : BR_KSA_WARNING
code :BR-KSA-80
message : The Pre-Paid amount (BT-113) must be equal to the sum total of the Prepayment VAT category Taxable Amount (KSA-31) and the Prepayment VAT Category Tax Amount (KSA-32).
category : BR_KSA_WARNING
code :BR-KSA-08
message : The seller identification (BT-29) must exist only once with one of the scheme ID (BT-29-1) (CRN, MOM, MLS, SAG, OTH, 700) and must contain only alphanumeric characters. Commercial Registration number with 'CRN' as schemeID. Momrah license with 'MOM' as schemeID. MHRSD license with 'MLS' as schemeID. 700 Number with '700' as schemeID. MISA license with 'SAG' as schemeID . Other OD with 'OTH' as schemeID.In case of multiple commercial registrations, the seller should fill the commercial registration of the branch in respect of which the Tax Invoice is being issued. In case multiple IDs exist then one of the above must be entered following the sequence specified above.
category : BR_WARNING
code :BR-S-01
message : [BR-S-01] An Invoice that contains an Invoice line (BG-25), a Document level allowance (BG-20) or a Document level charge (BG-21) where the VAT category code (BT-151, BT-95 or BT-102) is "Standard rated" shall contain in the VAT breakdown (BG-23) at least one VAT category code (BT-118) equal with "Standard rated".
category : BR_WARNING
code :BR-CO-17
message : VAT category tax amount (BT-117) = VAT category taxable amount (BT-116) x (VAT category rate (BT-119) / 100), rounded to two decimals.
category : BR_KSA_WARNING
code :BR-KSA-73
message : If Pre-Paid amount (BT-113) is provided, then the following data is mandatory to provide as additional invoice line(s) Prepayment ID (KSA-26) ; Sequential invoice number (BT-1) of the prepayment invoice(s) Prepayment Issue Date (KSA-28) ; Issue date (BT-2) of the prepayment invoice(s) Prepayment Issue Time (KSA-29) ; Issue time (KSA-25) of the prepayment invoice(s) Prepayment Document Type Code (KSA-30); Invoice type code (BT-3) must be 386 `
I don’t know, if I have the answer for your question. You should follow the comments and give us more info.
But I searched for other templates, or this this looks like:
<cac:ClassifiedTaxCategory>
<!-- 51 -->
<cbc:ID schemeID="UNCL5305">E</cbc:ID>
<cbc:Percent>0</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
So here is used schemeID="UNCL5305"
instead of schemeID="UN/ECE 5305"
with slash.
You should also ensure your template prevents an empty value
Common valid codes include, e.g.:
Missing or Null Value for Tax Category Code could also lead to an error. If vat_category_code is None or empty, the template might be rendering an invalid XML structure.
Solution: Ensure it has a default value:
<cbc:ID schemeAgencyID="6" schemeID= schemeID="UNCL5305" >
{{ invoice.company.finance_company.account_sale_tax.vat_category_code|default:"S" }}
</cbc:ID>
Replace "S" with the appropriate default value based on your business requirements.
Hope this helps a bit, but all the warnings should be also consider.