Skip to content

Facing an issue on sumbitting a sales invoice to Zatca. (Zatca phase-2>Send Invoice to ZATCA) #92

@Psharma00714

Description

@Psharma00714

While sending an invoice to Zatca (send invoice to Zatca phase 2) this is the error:

App Versions


{

"drive": "0.0.1",

"erpnext": "15.38.2",

"frappe": "15.44.1",

"grandhyper": "0.0.1",

"hrms": "15.28.3",

"ksa": "0.0.1",

"next_attachment": "0.0.1",

"nextstock": "0.0.1",

"payments": "0.0.1",

"print_designer": "1.0.0",

"zatca_erpgulf": "2.0.1"

}

Route


Form/Sales Invoice/SIN/25/GHHJ/000019-1

Traceback


Traceback (most recent call last):

File "apps/frappe/frappe/[app.py](http://app.py/)", line 114, in application

response = frappe.api.handle(request)

File "apps/frappe/frappe/api/__init__.py", line 49, in handle

data = endpoint(**arguments)

File "apps/frappe/frappe/api/[v1.py](http://v1.py/)", line 36, in handle_rpc_call

return frappe.handler.handle()

File "apps/frappe/frappe/[handler.py](http://handler.py/)", line 49, in handle

data = execute_cmd(cmd)

File "apps/frappe/frappe/[handler.py](http://handler.py/)", line 85, in execute_cmd

return [frappe.call](http://frappe.call/)(method, **frappe.form_dict)

File "apps/frappe/frappe/__init__.py", line 1775, in call

return fn(*args, **newargs)

File "apps/frappe/frappe/utils/typing_[validations.py](http://validations.py/)", line 31, in wrapper

return func(*args, **kwargs)

File "apps/frappe/frappe/desk/form/[save.py](http://save.py/)", line 37, in savedocs

doc.submit()

File "apps/frappe/frappe/utils/typing_[validations.py](http://validations.py/)", line 31, in wrapper

return func(*args, **kwargs)

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1048, in submit

return self._submit()

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1031, in _submit

return [self.save](http://self.save/)()

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 337, in save

return self._save(*args, **kwargs)

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 390, in _save

[self.run](http://self.run/)_post_save_methods()

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1131, in run_post_save_methods

[self.run](http://self.run/)_method("on_submit")

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 962, in run_method

out = Document.hook(fn)(self, args, *kwargs)

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1322, in composer

return composed(self, method, args, *kwargs)

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1306, in runner

add_to_return_value(self, f(self, method, args, *kwargs))

File "apps/frappe/frappe/utils/typing_[validations.py](http://validations.py/)", line 31, in wrapper

return func(*args, **kwargs)

File "apps/zatca_erpgulf/zatca_erpgulf/zatca_erpgulf/sign_[invoice.py](http://invoice.py/)", line 1345, in zatca_background_on_submit

zatca_call(

File "apps/frappe/frappe/utils/typing_[validations.py](http://validations.py/)", line 31, in wrapper

return func(*args, **kwargs)

File "apps/zatca_erpgulf/zatca_erpgulf/zatca_erpgulf/sign_[invoice.py](http://invoice.py/)", line 785, in zatca_call

clearance_api(

File "apps/zatca_erpgulf/zatca_erpgulf/zatca_erpgulf/sign_[invoice.py](http://invoice.py/)", line 488, in clearance_api

response = [requests.post](http://requests.post/)(

File "env/lib/python3.10/site-packages/requests/[api.py](http://api.py/)", line 115, in post

return request("post", url, data=data, json=json, **kwargs)

File "env/lib/python3.10/site-packages/requests/[api.py](http://api.py/)", line 59, in request

return session.request(method=method, url=url, **kwargs)

File "env/lib/python3.10/site-packages/requests/[sessions.py](http://sessions.py/)", line 589, in request

resp = self.send(prep, **send_kwargs)

File "env/lib/python3.10/site-packages/requests/[sessions.py](http://sessions.py/)", line 703, in send

r = adapter.send(request, **kwargs)

File "env/lib/python3.10/site-packages/requests/[adapters.py](http://adapters.py/)", line 667, in send

resp = conn.urlopen(

File "env/lib/python3.10/site-packages/urllib3/[connectionpool.py](http://connectionpool.py/)", line 715, in urlopen

httplib_response = self._make_request(

File "env/lib/python3.10/site-packages/urllib3/[connectionpool.py](http://connectionpool.py/)", line 404, in makerequest

self._validate_conn(conn)

File "env/lib/python3.10/site-packages/urllib3/[connectionpool.py](http://connectionpool.py/)", line 1060, in validateconn

conn.connect()

File "env/lib/python3.10/site-packages/urllib3/[connection.py](http://connection.py/)", line 406, in connect

context.verify_mode = resolve_cert_reqs(self.cert_reqs)

File "/usr/lib/python3.10/[ssl.py](http://ssl.py/)", line 738, in verify_mode

super(SSLContext, SSLContext).verify_mode.__set__(self, value)

File "/usr/lib/python3.10/[ssl.py](http://ssl.py/)", line 738, in verify_mode

super(SSLContext, SSLContext).verify_mode.__set__(self, value)

File "/usr/lib/python3.10/[ssl.py](http://ssl.py/)", line 738, in verify_mode

super(SSLContext, SSLContext).verify_mode.__set__(self, value)

[Previous line repeated 471 more times]

RecursionError: maximum recursion depth exceeded while calling a Python object

Request Data


{

"type": "POST",

"args": {

"doc": "{\"name\":\"SIN/25/GHHJ/000019-1\",\"owner\":\"[zainulabdeen@grandhyper.com](mailto:zainulabdeen@grandhyper.com)\",\"creation\":\"2025-03-25 11:28:45.835143\",\"modified\":\"2025-03-25 11:41:27.818470\",\"modified_by\":\"[sjain@dexciss.com](mailto:sjain@dexciss.com)\",\"docstatus\":0,\"idx\":0,\"ksa_einv_qr\":\"/files/QRCode-bf9f7.png\",\"title\":\"ARZAN ADVANCED COMMUNICATIONS COMPANY\",\"naming_series\":\"SIN/.YY./.abbr./.######\",\"custom_zatca_third_party_invoice\":0,\"custom_zatca_nominal_invoice\":0,\"custom_zatca_export_invoice\":0,\"custom_summary_invoice\":0,\"custom_self_billed_invoice\":0,\"created_by\":\"ZAINUL KADER\",\"customer\":\"ARZ001\",\"custom_b2c\":0,\"customer_name\":\"ARZAN ADVANCED COMMUNICATIONS COMPANY\",\"custom_uuid\":\"Not Submitted\",\"company\":\"GRAND HYPER HARAJ\",\"abbr\":\"GHHJ\",\"company_tax_id\":\"311369601400003\",\"posting_date\":\"2025-01-31\",\"posting_time\":\"11:16:17.889211\",\"set_posting_time\":1,\"due_date\":\"2025-01-31\",\"custom_zatca_status\":\"503 Service Unavailable\",\"custom_zatca_tax_category\":\"Standard\",\"custom_exemption_reason_code\":\"Standard 15%\",\"custom_zatca_discount_reason_code\":\"95\",\"custom_zatca_discount_reason\":\"Discount\",\"custom_submit_line_item_discount_to_zatca\":0,\"is_pos\":0,\"posa_is_printed\":0,\"is_consolidated\":0,\"is_return\":0,\"update_outstanding_for_self\":1,\"update_billed_amount_in_sales_order\":0,\"update_billed_amount_in_delivery_note\":1,\"is_debit_note\":0,\"amended_from\":\"SIN/25/GHHJ/000019\",\"vertical\":\"Retail\",\"country\":\"Saudi Arabia\",\"cost_center\":\"Main - GHHJ\",\"pattern\":\"KSA - 2\",\"brand\":\"GRAND\",\"segment\":\"Hypermarket\",\"currency\":\"SAR\",\"conversion_rate\":1,\"selling_price_list\":\"SAUDI PRICE LIST\",\"price_list_currency\":\"SAR\",\"plc_conversion_rate\":1,\"ignore_pricing_rule\":0,\"update_stock\":0,\"total_qty\":1,\"total_net_weight\":0,\"base_total\":2500,\"base_net_total\":2500,\"total\":2500,\"net_total\":2500,\"tax_category\":\"Sales Taxable\",\"base_total_taxes_and_charges\":375,\"total_taxes_and_charges\":375,\"base_grand_total\":2875,\"base_rounding_adjustment\":0,\"base_rounded_total\":0,\"base_in_words\":\"\",\"grand_total\":2875,\"rounding_adjustment\":0,\"use_company_roundoff_cost_center\":0,\"rounded_total\":0,\"in_words\":\"\",\"total_advance\":0,\"outstanding_amount\":2875,\"disable_rounded_total\":1,\"apply_discount_on\":\"Grand Total\",\"base_discount_amount\":0,\"is_cash_or_non_trade_discount\":0,\"additional_discount_percentage\":0,\"discount_amount\":0,\"other_charges_calculation\":\"<div class=\\\"tax-break-up\\\" style=\\\"overflow-x: auto;\\\">\\n\\t<table class=\\\"table table-bordered table-hover\\\">\\n\\t\\t<thead>\\n\\t\\t\\t<tr>\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-left\\\">Item</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-right\\\">Taxable Amount</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-right\\\">Output VAT</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t</tr>\\n\\t\\t</thead>\\n\\t\\t<tbody>\\n\\t\\t\\t\\n\\t\\t\\t\\t<tr>\\n\\t\\t\\t\\t\\t<td>SPACE RENTAL</td>\\n\\t\\t\\t\\t\\t<td class=\\\"text-right\\\">\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t2,500.00\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t</td>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t<td class=\\\"text-right\\\">\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t(15.0%)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t375.00\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t</td>\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t</tr>\\n\\t\\t\\t\\n\\t\\t</tbody>\\n\\t</table>\\n</div>\",\"total_billing_hours\":0,\"total_billing_amount\":0,\"base_paid_amount\":0,\"paid_amount\":0,\"base_change_amount\":0,\"change_amount\":0,\"allocate_advances_automatically\":0,\"only_include_allocated_payments\":0,\"write_off_amount\":0,\"base_write_off_amount\":0,\"write_off_outstanding_amount_automatically\":0,\"redeem_loyalty_points\":0,\"loyalty_points\":0,\"loyalty_amount\":0,\"customer_address\":\"ARZAN ADVANCED COMMUNICATIONS COMPANY-Billing\",\"address_display\":\"SALAH AL-DIN AL-AYYUBI ROAD<br>AL-MALAZ DISTRICT<br>RIYADH<br>\\n12841<br>Saudi Arabia<br>\\nPhone: +966 55 556 9220<br>\",\"territory\":\"MENA\",\"company_address\":\"GRAND HYPER HARAJ-Billing\",\"company_trn\":\"311369601400003\",\"company_address_display\":\"AL HAMRA PLAZA BATHAH EXTENSION<br>AL HARAJ<br>Riyadh<br>\\nRiyadh<br>12684<br>Saudi Arabia<br>\\n\",\"ignore_default_payment_terms_template\":0,\"po_no\":\"\",\"debit_to\":\"1202001 - Trade Receivables - Sales Ledger Control - GHHJ\",\"party_account_currency\":\"SAR\",\"is_opening\":\"No\",\"against_income_account\":\"3201014 - Space Rentals - GHHJ\",\"amount_eligible_for_commission\":0,\"commission_rate\":0,\"total_commission\":0,\"letter_head\":\"RG\",\"group_same_items\":0,\"vat_emirate\":\"\",\"tourist_tax_return\":0,\"reverse_charge_applicable\":\"N\",\"language\":\"en\",\"status\":\"Draft\",\"customer_group\":\"\",\"custom_zatca_full_response\":\"Error: Error: The request you are sending to Zatca is in incorrect format. Status code: 400{\\\"validationResults\\\":{\\\"infoMessages\\\":[{\\\"type\\\":\\\"INFO\\\",\\\"code\\\":\\\"XSD_ZATCA_VALID\\\",\\\"category\\\":\\\"XSD validation\\\",\\\"message\\\":\\\"Complied with UBL 2.1 standards in line with ZATCA specifications\\\",\\\"status\\\":\\\"PASS\\\"}],\\\"warningMessages\\\":[{\\\"type\\\":\\\"WARNING\\\",\\\"code\\\":\\\"BR-S-05\\\",\\\"category\\\":\\\"EN_16931\\\",\\\"message\\\":\\\"For invoice items (BG-25) in which the VAT category code of invoiced items (BT-151) is “Standard rated” the VAT rate of the invoiced item (BT-152) must be greater than zero.\\\",\\\"status\\\":\\\"WARNING\\\"},{\\\"type\\\":\\\"WARNING\\\",\\\"code\\\":\\\"BR-KSA-81\\\",\\\"category\\\":\\\"KSA\\\",\\\"message\\\":\\\"The other Buyer ID (BT-46) must present in the tax invoice and associated debit notes and credit notes (KSA-2, position 1 and 2 = 01), where the buyer VAT registration number or buyer group VAT registration number (BT-48) is not provided.\\\",\\\"status\\\":\\\"WARNING\\\"},{\\\"type\\\":\\\"WARNING\\\",\\\"code\\\":\\\"BR-KSA-63\\\",\\\"category\\\":\\\"KSA\\\",\\\"message\\\":\\\"If the buyer country code (BT-55) is “SA”, then these fields are mandatory: street name (BT-50), building number (KSA-18), postal code (BT-53), city (BT-52), District (KSA-4), country code (BT-55). For more information please access this link: [https://splonline.com.sa/en/national-address-1/\\\",\\\"status\\\":\\\"WARNING\\\"}],\\\"errorMessages\\\":[{\\\"type\\\":\\\"ERROR\\\",\\\"code\\\":\\\"BR-S-06\\\",\\\"category\\\":\\\"EN_16931\\\",\\\"message\\\":\\\"In](https://splonline.com.sa/en/national-address-1////%22,///%22status///%22:///%22WARNING///%22%7D],///%22errorMessages///%22:[%7B///%22type///%22:///%22ERROR///%22,///%22code///%22:///%22BR-S-06///%22,///%22category///%22:///%22EN_16931///%22,///%22message///%22:///%22In) a Document level allowance (BG-20) where the Document level allowance VAT category code (BT-95) is 'Standard rated' the Document level allowance VAT rate (BT-96) shall be greater than zero.\\\",\\\"status\\\":\\\"ERROR\\\"},{\\\"type\\\":\\\"ERROR\\\",\\\"code\\\":\\\"BR-KSA-84\\\",\\\"category\\\":\\\"KSA\\\",\\\"message\\\":\\\"The Document level allowance VAT rate (BT-96), Document level Charge VAT rate (BT-103), VAT category rate(BT-119), Invoiced item VAT rate (BT-152), Prepayment VAT rate(KSA-34) must be limited to one of the following values (5 or 15) when the relevant Document level allowance VAT category code (BT-95), Document level Charge VAT category code(BT-102), VAT category code(BT-118), Invoiced item VAT category code(BT-151), Prepayment VAT Category Code (KSA-33) is “S“- “Standard rated”. In other words, for Standard Rate VAT Category the rate can either be 15% or 5%.\\\",\\\"status\\\":\\\"ERROR\\\"}],\\\"status\\\":\\\"ERROR\\\"},\\\"clearanceStatus\\\":\\\"NOT_CLEARED\\\",\\\"clearedInvoice\\\":null}\",\"is_internal_customer\":0,\"is_discounted\":0,\"remarks\":\"SPACE RENT RECEIVABLE FROM ARZAN ADVANCED COMMUNICATION COPMANY FOR THE MONTH OF JAN 2025 - MANSOURAH BRANCH\",\"doctype\":\"Sales Invoice\",\"advances\":[],\"payments\":[],\"payment_schedule\":[{\"name\":\"f3udo6b5jc\",\"owner\":\"[zainulabdeen@grandhyper.com](mailto:zainulabdeen@grandhyper.com)\",\"creation\":\"2025-03-25 11:28:45.835143\",\"modified\":\"2025-03-25 11:41:27.818470\",\"modified_by\":\"[sjain@dexciss.com](mailto:sjain@dexciss.com)\",\"docstatus\":0,\"idx\":1,\"due_date\":\"2025-01-31\",\"invoice_portion\":100,\"discount_type\":\"Percentage\",\"discount\":0,\"payment_amount\":2875,\"outstanding\":2875,\"paid_amount\":0,\"discounted_amount\":0,\"base_payment_amount\":2875,\"parent\":\"SIN/25/GHHJ/000019-1\",\"parentfield\":\"payment_schedule\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Payment Schedule\"}],\"packed_items\":[],\"items\":[{\"name\":\"f3ucb1re01\",\"owner\":\"[zainulabdeen@grandhyper.com](mailto:zainulabdeen@grandhyper.com)\",\"creation\":\"2025-03-25 11:28:45.835143\",\"modified\":\"2025-03-25 11:41:27.818470\",\"modified_by\":\"[sjain@dexciss.com](mailto:sjain@dexciss.com)\",\"docstatus\":0,\"idx\":1,\"has_item_scanned\":0,\"item_name\":\"SPACE RENTAL\",\"description\":\"SPACE RENT RECEIVABLE FROM ARZAN ADVANCED COMMUNICATION COPMANY FOR THE MONTH OF JAN 2025 - MANSOURAH BRANCH\",\"tax_rate\":15,\"tax_amount\":375,\"total_amount\":2875,\"is_zero_rated\":0,\"is_exempt\":0,\"is_nil_exempt\":0,\"brand\":\"GRAND\",\"qty\":1,\"stock_uom\":\"Nos\",\"uom\":\"Nos\",\"conversion_factor\":1,\"stock_qty\":1,\"price_list_rate\":0,\"base_price_list_rate\":0,\"margin_type\":\"\",\"margin_rate_or_amount\":0,\"rate_with_margin\":0,\"discount_percentage\":0,\"discount_amount\":0,\"base_rate_with_margin\":0,\"rate\":2500,\"amount\":2500,\"base_rate\":2500,\"base_amount\":2500,\"stock_uom_rate\":2500,\"is_free_item\":0,\"grant_commission\":0,\"net_rate\":2500,\"net_amount\":2500,\"base_net_rate\":2500,\"base_net_amount\":2500,\"delivered_by_supplier\":0,\"income_account\":\"3201014 - Space Rentals - GHHJ\",\"is_fixed_asset\":0,\"enable_deferred_revenue\":0,\"weight_per_unit\":0,\"total_weight\":0,\"use_serial_batch_fields\":0,\"allow_zero_valuation_rate\":0,\"incoming_rate\":0,\"margin_in_per\":0,\"actual_batch_qty\":0,\"actual_qty\":0,\"delivered_qty\":0,\"vertical\":\"Retail\",\"country\":\"Saudi Arabia\",\"cost_center\":\"Main - GHHJ\",\"territory\":\"MENA\",\"pattern\":\"KSA - 2\",\"segment\":\"Hypermarket\",\"page_break\":0,\"parent\":\"SIN/25/GHHJ/000019-1\",\"parentfield\":\"items\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Sales Invoice Item\",\"item_tax_template\":\"KSA VAT 15% - GHHJ\",\"item_tax_rate\":\"{\\\"2308001 - Out Put VAT - GHHJ\\\": 15.0}\"}],\"taxes\":[{\"docstatus\":0,\"doctype\":\"Sales Taxes and Charges\",\"name\":\"fbcf1ff5ov\",\"__unsaved\":1,\"owner\":\"[sjain@dexciss.com](mailto:sjain@dexciss.com)\",\"charge_type\":\"On Net Total\",\"included_in_print_rate\":0,\"included_in_paid_amount\":0,\"cost_center\":\"Main - GHHJ\",\"territory\":\"MENA\",\"account_currency\":\"SAR\",\"dont_recompute_tax\":0,\"parent\":\"SIN/25/GHHJ/000019-1\",\"parentfield\":\"taxes\",\"parenttype\":\"Sales Invoice\",\"idx\":1,\"account_head\":\"2308001 - Out Put VAT - GHHJ\",\"description\":\"Output VAT\",\"vertical\":\"Retail\",\"country\":\"United Arab Emirates\",\"pattern\":\"KSA - 2\",\"brand\":\"GRAND\",\"segment\":\"Hypermarket\",\"rate\":15,\"tax_amount\":375,\"total\":2875,\"tax_amount_after_discount_amount\":375,\"base_tax_amount\":375,\"base_total\":2875,\"base_tax_amount_after_discount_amount\":375,\"item_wise_tax_detail\":\"{\\\"SPACE RENTAL\\\":[15,375]}\",\"creation\":\"2025-03-25 11:28:45.835143\",\"modified\":\"2025-03-25 11:41:27.818470\",\"modified_by\":\"[sjain@dexciss.com](mailto:sjain@dexciss.com)\",\"currency\":\"SAR\"}],\"pricing_rules\":[],\"sales_team\":[],\"timesheets\":[],\"__onload\":{\"make_payment_via_journal_entry\":0},\"taxes_and_charges\":\"KSA VAT 15% - GHHJ\"}",

"action": "Submit"

},

"btn": {

"jQuery370087897629537689271": {

"events": {

"click": [

{

"type": "click",

"origType": "click",

"guid": 3588,

"namespace": ""

}

]

}

}

},

"freeze": true,

"headers": {},

"error_handlers": {},

"url": "/api/method/[frappe.desk.form.save](http://frappe.desk.form.save/).savedocs",

"request_id": null

}

Response Data


{

"exception": "RecursionError: maximum recursion depth exceeded while calling a Python object",

"exc_type": "RecursionError",

"_exc_source": "zatca_erpgulf (app)"

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions