Skip to content

fix(vat audit report): fallback to item name when item code is missing#54049

Draft
ravibharathi656 wants to merge 2 commits intofrappe:version-15-hotfixfrom
aerele:v15-vat-audit-report-item-name-fallback
Draft

fix(vat audit report): fallback to item name when item code is missing#54049
ravibharathi656 wants to merge 2 commits intofrappe:version-15-hotfixfrom
aerele:v15-vat-audit-report-item-name-fallback

Conversation

@ravibharathi656
Copy link
Copy Markdown
Member

Issue:
VAT Audit Report throws an error when an invoice item has no item code and only the item name is present.

Ref: #64257

follow-up: #54030

VAT Audit Report:

image

Traceback:

Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 120, in application
response = frappe.api.handle(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/api/init.py", line 52, in handle
data = endpoint(**arguments)
^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
return frappe.handler.handle()
^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/handler.py", line 53, in handle
data = execute_cmd(cmd)
^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
return frappe.call(method, **frappe.form_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/init.py", line 1764, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/init.py", line 901, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/desk/query_report.py", line 229, in run
result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/init.py", line 901, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/desk/query_report.py", line 85, in generate_report_result
res = get_report_result(report, filters) or []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/desk/query_report.py", line 66, in get_report_result
res = report.execute_script_report(filters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/core/doctype/report/report.py", line 179, in execute_script_report
res = self.execute_module(filters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/core/doctype/report/report.py", line 195, in execute_module
return frappe.get_attr(method_name)(frappe._dict(filters))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/erpnext/erpnext/regional/report/vat_audit_report/vat_audit_report.py", line 13, in execute
return VATAuditReport(filters).run()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/erpnext/erpnext/regional/report/vat_audit_report/vat_audit_report.py", line 41, in run
self.get_items_based_on_tax_rate(doctype)
File "apps/erpnext/erpnext/regional/report/vat_audit_report/vat_audit_report.py", line 129, in get_items_based_on_tax_rate
is_zero_rated = self.invoice_items.get(parent).get(item_code).get("is_zero_rated")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

no-backport

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-tests This PR needs automated unit-tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant