wes4m / zatca-xml-js

An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.
MIT License
68 stars 58 forks source link

Rounding Amount and Calculation Error ! #31

Closed asim009 closed 1 year ago

asim009 commented 1 year ago

@wes4m @HaimenToshi @adriantoro26 There is an error from zatca when I tried to execute below calculation "message": "The line VAT amount (KSA-11) must be Invoice line net amount (BT-131) x (Line VAT rate (BT-152)/100).", 3000.07=20000.50*15/100;> 3000.075 (calculator value) I assume Zatca calculation is rounding up the value to 3000.075 to 3000.08. I tried to round up the thing with in this package but entire calculation is getting messed up. Suggest me what we can do

Test case Json for line


"line_items": [
       {
           "id": "1",
           "name": "NPR75L-KL5VAYSN",
           "quantity": 1,
           "Sales_unit": "UN",
           "tax_exclusive_price": 20000.5,
           "net_price": 20000.5,
           "line_amount_without_tax": 20000.5,
           "line_amount_withtax": 23000.575,
           "advance%": 0,
           "advance_amount": 0,
           "advance_vat": 0,
           "advance_amount_after_tax": 0,
           "model_year": "",
           "tax_level1": "SR15",
           "VAT_percent": 0.15,
           "other_taxes": [],
           "discounts": [
               {
                   "amount": 0,
                   "reason": 0
               },
               {
                   "amount": 0,
                   "reason": 0
               }
           ]
       }
   ]
wes4m commented 1 year ago

@asim009 I tried this. Passes for me

const line_item: ZATCASimplifiedInvoiceLineItem = {
    id: "1",
    name: "TEST NAME",
    quantity: 1,
    tax_exclusive_price: 20000.5,
    VAT_percent: 0.15,
    other_taxes: [
    ],
    discounts: [
    ]
};

Also, Yes don't pass the lib anything with more than 2 decimal places (0.00). It will be fixed to 2 anyway.