mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 10:11:20 +00:00
Merge pull request #30246 from frappe/mergify/bp/version-13-hotfix/pr-30230
fix: KSA E-Invoice QR Code showing wrong VAT amount (backport #30230)
This commit is contained in:
@@ -93,7 +93,7 @@ def create_qr_code(doc, method=None):
|
|||||||
tlv_array.append(''.join([tag, length, value]))
|
tlv_array.append(''.join([tag, length, value]))
|
||||||
|
|
||||||
# VAT Amount
|
# VAT Amount
|
||||||
vat_amount = str(doc.total_taxes_and_charges)
|
vat_amount = str(get_vat_amount(doc))
|
||||||
|
|
||||||
tag = bytes([5]).hex()
|
tag = bytes([5]).hex()
|
||||||
length = bytes([len(vat_amount)]).hex()
|
length = bytes([len(vat_amount)]).hex()
|
||||||
@@ -130,6 +130,22 @@ def create_qr_code(doc, method=None):
|
|||||||
doc.db_set('ksa_einv_qr', _file.file_url)
|
doc.db_set('ksa_einv_qr', _file.file_url)
|
||||||
doc.notify_update()
|
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_cached_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):
|
def delete_qr_code_file(doc, method=None):
|
||||||
region = get_region(doc.company)
|
region = get_region(doc.company)
|
||||||
|
|||||||
@@ -28,9 +28,12 @@ def update_itemised_tax_data(doc):
|
|||||||
elif row.item_code and itemised_tax.get(row.item_code):
|
elif row.item_code and itemised_tax.get(row.item_code):
|
||||||
tax_rate = sum([tax.get('tax_rate', 0) for d, tax in itemised_tax.get(row.item_code).items()])
|
tax_rate = sum([tax.get('tax_rate', 0) for d, tax in itemised_tax.get(row.item_code).items()])
|
||||||
|
|
||||||
row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
|
meta = frappe.get_meta(row.doctype)
|
||||||
row.tax_amount = flt((row.net_amount * tax_rate) / 100, row.precision("net_amount"))
|
|
||||||
row.total_amount = flt((row.net_amount + row.tax_amount), row.precision("total_amount"))
|
if meta.has_field('tax_rate'):
|
||||||
|
row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
|
||||||
|
row.tax_amount = flt((row.net_amount * tax_rate) / 100, row.precision("net_amount"))
|
||||||
|
row.total_amount = flt((row.net_amount + row.tax_amount), row.precision("total_amount"))
|
||||||
|
|
||||||
def get_account_currency(account):
|
def get_account_currency(account):
|
||||||
"""Helper function to get account currency."""
|
"""Helper function to get account currency."""
|
||||||
|
|||||||
Reference in New Issue
Block a user