lavaloon-eg / ksa_compliance

KSA Compliance App for KSA E-invoice
https://www.lavaloon.com/
GNU Affero General Public License v3.0
37 stars 31 forks source link

Error When press button Perform Compliance Check in ZATCA Business Settings DocType #75

Closed osman-yasser closed 3 months ago

osman-yasser commented 3 months ago

When I press Button Perform Compliance Check that was in ZATCA Business Settings DocType, I encounter the error in the image below:

image

image


When I investigate what make this error, I found a peace of code on the action on button click in js:

image

The code make a frappe.prompt and build its fields based on some condition, simplified and standard. Since, I chosen Type of Business Transactions to be Standard Tax Invoices, the simplified field never shown:

image

image


So, the value object will never have simplified_customer_id and will be undefined, consequently, the parameter simplified_customer_id in python whitelist method will never passed and this error appear

image


mhaggag commented 3 months ago

Thanks for the report and the excellent investigation and write-up.

There's a fix for this currently on the dev branch, as part of 0.21.1, among other fixes but they're still under test. I'll keep you posted when it's approved and merged.

In the mean time, if you're trying on a development or test clone of your instance, you can switch to the dev branch to see if you run into other issues.

Also, as a workaround to this issue, you can choose "Let the system decide" and create a customer with a fake VAT to use for the standard tax invoice compliance check.

osman-yasser commented 3 months ago

That is right choose Let the system decide (both) and the error solved :)

But there is an error appear when the invoice was in sign process

Invoice Result: Invoice sent to ZATCA. Integration status: Rejected
{
    "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": [],
        "errorMessages": [
            {
                "type": "ERROR",
                "code": "GENERAL",
                "category": "BUSINESS_RULES",
                "message": "Unable to execute Business Rules validation ->",
                "status": "ERROR"
            },
            {
                "type": "ERROR",
                "code": "certificate-permissions",
                "category": "CERTIFICATE_ERRORS",
                "message": "Production CSID does not cover Simplified documents",
                "status": "ERROR"
            }
        ],
        "status": "ERROR"
    },
    "reportingStatus": "NOT_REPORTED",
    "clearanceStatus": null,
    "qrSellertStatus": null,
    "qrBuyertStatus": null
}
Credit Note Result: Invoice sent to ZATCA. Integration status: Rejected
{
    "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": [],
        "errorMessages": [
            {
                "type": "ERROR",
                "code": "GENERAL",
                "category": "BUSINESS_RULES",
                "message": "Unable to execute Business Rules validation ->",
                "status": "ERROR"
            },
            {
                "type": "ERROR",
                "code": "certificate-permissions",
                "category": "CERTIFICATE_ERRORS",
                "message": "Production CSID does not cover Simplified documents",
                "status": "ERROR"
            }
        ],
        "status": "ERROR"
    },
    "reportingStatus": "NOT_REPORTED",
    "clearanceStatus": null,
    "qrSellertStatus": null,
    "qrBuyertStatus": null
}
Debit Note Result: Invoice sent to ZATCA. Integration status: Rejected
{
    "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": [],
        "errorMessages": [
            {
                "type": "ERROR",
                "code": "GENERAL",
                "category": "BUSINESS_RULES",
                "message": "Unable to execute Business Rules validation ->",
                "status": "ERROR"
            },
            {
                "type": "ERROR",
                "code": "certificate-permissions",
                "category": "CERTIFICATE_ERRORS",
                "message": "Production CSID does not cover Simplified documents",
                "status": "ERROR"
            }
        ],
        "status": "ERROR"
    },
    "reportingStatus": "NOT_REPORTED",
    "clearanceStatus": null,
    "qrSellertStatus": null,
    "qrBuyertStatus": null
}
error
Comments

How can fix this error, I press Perform Compliance Check, fulfilled the dialog and submit

mhaggag commented 3 months ago

I haven't seen these errors before, but "Production CSID does not cover Simplified documents" could possibly mean the compliance CSID was generated from a CSR that only targeted standard tax invoices. The CSR includes a field defining what type of invoices will be generated, whether standard, simplified, or both. I'm assuming these errors are the results of using the CSR previously generated when the setting was "Standard".

Since we've changed it to "Let the system decide", please try generating a new CSR (through the "Onboard" button) and then perform the compliance checks again.

mhaggag commented 3 months ago

0.21.1 was merged into master, which includes a fix to the initial report.

osman-yasser commented 3 months ago

Thanks :)