Dear All,
If you have any concerns on the new front end duplication validation rules (208 for Clearance and 409 for Reporting), please share them on the main thread below or here.
Please note that the new validation rules for front end duplication check (208 and 409 response codes) will be deployed to Production Environment by July 20. These validations were already deployed on Simulation Environment a month ago, please test different business scenarios on Simulation and if you have any concerns please revert asap.
We have added the necessary changes in our system for the test and production environments. Until now we have not seen any any alerts on 409 and 208 in our systems in the test environment, so hopefully everything should be good for the production release.
Strangely, today one of my clients reported 409, which is B2C duplicate. To verify, we checked our database and found no duplicate, as we have a primary key, so a duplicate is not even possible in our table. So, how ZATCA marking/responding few invoices as duplicates?
select INVOICE_NUMBER, INVOICE_STATUS, INVOICE_HASH from JS_ZATCA_INVOICE_HEADER where INVOICE_HASH = ‘mAOAXmHjhEXywDkOsE/f/MaFlsnhp4OiMlUp4k2pUVY=’;
or
select INVOICE_NUMBER, INVOICE_STATUS, INVOICE_HASH from JS_ZATCA_INVOICE_HEADER where INVOICE_NUMBER = ‘EMD-D-014257-25’;
INVOICE_NUMBER
INVOICE_STATUS
INVOICE_HASH
EMD-D-014257-25
SIMPLIFIED: REPORTED409
mAOAXmHjhEXywDkOsE/f/MaFlsnhp4OiMlUp4k2pUVY=
When an invoice is sent to ZATCA we update its status, hence no chance of duplicate reporting while if you see above it is not duplicate even but it returned 409.
Totally 90 among 132 are reported in Reported:409 remaining in Reported as usual
So please suggest what kind of duplication is this which is not in our side but on ZATCA side it is duplicate.
@Abhishek no you should not change any value on the XML otherwise it will be treated as a different invoice by ZATCA as the hash will change. 409 message says that the hash is already reported successfully, this implies invoice is already received by ZATCA. Please share some sample hash values for investigation (just the hash values)
Team was able to find the each of your invoices reported successfully with 200 response codes. Therefore, 409 was correctly returned for subsequent submissions. Please consider below suggestions:
1 Check for any duplication in the invoice hash: Please adjust your query to check for duplicates based on the invoice hash instead of the invoice ID. Example query:
select count(INVOICE_HASH ) , count(distinct INVOICE_HASH) from JS_ZATCA_INVOICE_HEADER ;
if the count is different that means there are duplicated invoice hash in SP DB.
2 Review the submission mechanism to ensure that the original request is not being overwritten if it is submitted multiple times to the Reporting/Clearance APIs.
Thanks for your response, and there is no duplication on our side.
select INVOICE_HASH, count() from JS_ZATCA_INVOICE_HEADER where INVOICE_STATUS like ‘SIMPLIFIED%’ group by INVOICE_HASH having count() > 1
No data found
So let me request your team to check the following,
If the first attempt returned no response from your server, then for us it is not reported as there is no response received, even a 200 or any error. So for us, status is still unchanged, but your server received it.
Now in our system, since it is still not reported due to no response from your side, it will send again, and this time it will get 409 saying duplicate.
now I need to know if the first attempt returned no response at all, so then what to do?
IF r_status = 'REPORTED' AND apex_web_service.g_status_code IN ( 200, 202)
r_status := apex_json.get_varchar2(p_path => 'reportingStatus');
IF r_status = 'REPORTED' AND apex_web_service.g_status_code IN ( 200, 202)THEN
v_clearedinvoice := apex_json.get_varchar2(p_path => 'reportingStatus');
UPDATE js_zatca_invoice_header
SET
invoice_status = 'SIMPLIFIED: ' || r_status,
api_response = l_clob
WHERE
id = p_invoice_id;
ELSif apex_web_service.g_status_code IN ( 409) THEN
UPDATE js_zatca_invoice_header
SET
invoice_status = 'SIMPLIFIED: REPORTED409',
api_response = l_clob
WHERE
id = p_invoice_id;
Else
UPDATE js_zatca_invoice_header
SET
invoice_status = 'REPORTING: ' || nvl(r_status, 'ERROR'),
api_response = l_clob
WHERE
id = p_invoice_id;
END IF;
Indeed, I expect you to get this result from the queries because you don’t guarantee a failure condition when the Zataca is 50x.
The scenario that happens is as follows:
Your system sends the invoice for sharing, for some reason you receive a 50X Response, while Zataka continues to process the transaction and saves the hash in cash.
You try again to send the same invoice for the purpose of sharing, logically you will receive a 409 response.
Try to keep records of the 50X transmissions so that the invoice hash is part of those records.