hmrc / vat-api

Apache License 2.0
67 stars 18 forks source link

Incorrect Open VAT Obligations returned #980

Closed itzbits closed 1 year ago

itzbits commented 1 year ago

Bug report

Describe the bug A client submitted a VAT Return for the period 01-11-2022 to 30-11-2022, but had not submitted a return for the previous period of 01-10-2022 to 31-10-2022. The VAT Return submission for November was accepted and a receipt ID received. The client has received notification from HMRC that a VAT Return has not been submitted for the October period. When attempting to submit the earlier VAT Return for October, the Open Obligations returned by the /organisations/vat/{vrn}/obligations EndPoint shows the November period as an open obligation, but not October, so the return fails as there is no matching open obligation for the VAT Return being submitted.

HMRC are obviously seeing that the October period return has not been made (since is what they are reporting to the customer) and so this period should be returned as an open obligation by the /organisations/vat/{vrn}/obligations endpoint.

To Reproduce The situation appears to have occurred where a VAT Return has not been submitted for a month (01-10-2022 to 31-10-2022 ), and a later VAT Return is then submitted (01-11-2022 to 30-11-2022). Although the VAT Return submission was made with the correct Period Key for the relevant November Open Obligation, on the face of it it looks like the return has been made against the first open obligation found, i.e. for October.

Expected behavior The Open obligations returned by the /organisations/vat/{vrn}/obligations endpoint should be for periods:

01-10-2022 to 31-10-2022 01-12-2022 to 31-12-2022 01-02-2023 to 31-01-2023

Screenshots / Requests / Responses If applicable, add screenshots to help explain your problem.

Additional context There is no way for the client to submit the missed VAT Return as no open obligation is available to submit it against.

charles-f commented 1 year ago

Hi - I'm not HMRC but hopefully this may help debug.

are you sure the November submission was submitted with the correct Periodkey.

Ultimately that is what decides which period is submitted.

I would check how your logic works in getting the periodkey - as if it was getting the Oct one when filing Nov, then obviously your software filed the wrong period. Ie. Are you getting the first open obligation - and taking that PeriodKey? when actually you should define the obligation request dates specifically to the dates of the period - so that only one periodkey can return.

https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/vat-api/1.0 Example json is - you see only the period Key defines what period it is.

{ "periodKey": "A001", "vatDueSales": 105.50, "vatDueAcquisitions": -100.45, "totalVatDue": 5.05, "vatReclaimedCurrPeriod": 105.15, "netVatDue": 100.10, "totalValueSalesExVAT": 300, "totalValuePurchasesExVAT": 300, "totalValueGoodsSuppliedExVAT": 3000, "totalAcquisitionsExVAT": 3000, "finalised": true }

That said not the same thing but, I've seen with my products submissions that HMRC has updated periodkeys and in very rare cases updated period dates of already submitted periods too. Which I find bizarre. The period is already submitted and the dates are changing after being submitted. I can understand still open periods. But then that looks like the data used was a snapshot which since changed when they actually actioned that change.

itzbits commented 1 year ago

@charles-f

Thank you so much for your response Charles. I had forgotten that I had posted this query here...it was a while back.

We have resolved this issue, and I should have posted as such here. Your diagnosis was correct...it was a bug in our software. We were correctly locating the relevant open obligation period based on the VAT Return being submitted (and identifying that a VAT Return was due for the period), but during the actual submission process, the software would get the period key for the earliest open obligation and submit the VAT Return for that period. It only showed up as an issue when a client forgot to submit a return, and subsequently submitted another later return.

Thanks for your response.