fix: KSA E-Invoice QR Code showing wrong VAT amount
This commit is contained in:
parent
22dfd5a4b1
commit
b37559c535
@ -90,7 +90,7 @@ def create_qr_code(doc, method=None):
|
||||
tlv_array.append(''.join([tag, length, value]))
|
||||
|
||||
# VAT Amount
|
||||
vat_amount = str(doc.total_taxes_and_charges)
|
||||
vat_amount = str(get_vat_amount(doc))
|
||||
|
||||
tag = bytes([5]).hex()
|
||||
length = bytes([len(vat_amount)]).hex()
|
||||
@ -127,6 +127,22 @@ def create_qr_code(doc, method=None):
|
||||
doc.db_set('ksa_einv_qr', _file.file_url)
|
||||
doc.notify_update()
|
||||
|
||||
def get_vat_amount(doc):
|
||||
vat_settings = frappe.db.get_value('KSA VAT Setting', {'company': doc.company})
|
||||
vat_accounts = []
|
||||
vat_amount = 0
|
||||
|
||||
if vat_settings:
|
||||
vat_settings_doc = frappe.get_doc('KSA VAT Setting', vat_settings)
|
||||
|
||||
for row in vat_settings_doc.get('ksa_vat_sales_accounts'):
|
||||
vat_accounts.append(row.account)
|
||||
|
||||
for tax in doc.get('taxes'):
|
||||
if tax.account_head in vat_accounts:
|
||||
vat_amount += tax.tax_amount
|
||||
|
||||
return vat_amount
|
||||
|
||||
def delete_qr_code_file(doc, method=None):
|
||||
region = get_region(doc.company)
|
||||
|
Loading…
Reference in New Issue
Block a user