web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Setting VAT Biz posting group per sales invoice via API

(2) ShareShare
ReportReport
Posted on by 82
We import sales invoices via API.
The issue is some customers are UK based but want us to ship VAT free countries.
As the customers VAT biz posting group is 'DOMESTIC' the imported invoice always includes VAT which is incorrect.
 
On the GUI its a simple case of manually setting the VAT PG to EU or EXPORT to correct this.
 
I have added an extension that exposes the VAT Biz posting group to the sales invoice API so I can set it when importing but it doesn't work.
No errors when I try to set it so the field is registered OK.
 
Am I right in assuming that BC either does not allow this to be set on import and/or overwrites it with its calculated VAT posting group when processing?
 
I suppose I could try setting each items VAT Product group when adding sales invoice lines but this seems a complicated fix. Any suggestions on a work around?
 
Maybe I should try to patch it after the import is complete.?
 
Any suggestions appreciated.
 
 
I have the same question (0)
  • CU09081641-3 Profile Picture
    82 on at
    TBH I am now assuming the VAT biz PG field is set later on by the Base code when processing the sales invoice aggregate table to a sales Invoice, overwriting any value given by API. (I had to add access by:
     
                    field("vatPg"; Rec."VAT Bus. Posting Group")
                    {
                        Caption = 'VAT Bus. Posting Group';
                        trigger OnValidate()
                        begin
                            RegisterFieldSet(Rec.FieldNo("VAT Bus. Posting Group"));
                        end;
                    }
     
    It seems logical to do this. Maybe someone can confirm.?
    For now I will just make sure any invoice with non matching totals is not posted and send an alert for manual intervention as it is quite a rare occurrance..
     
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,763 Super User 2025 Season 2 on at
    I think you can try to solve it through the triggers of the API page. I hope the video below can give you some help.
     
    Thanks.
    ZHU
  • Ramiz Profile Picture
    597 on at
    Hi,

    You mentioned that you have exposed an API and passing the VAT Posting Group so, it should work but I think the order of the fields are quite important in the API. In which order you are validating the fields in API?

    Check the Gen.Business Posting Groups as well if there's a default VAT Bus. Posting Group setup in it. If its setup and the API validates Bus Posting Group after the VAT Posting group, it will change it to whatever has been setup.

  • Suggested answer
    CU09081641-3 Profile Picture
    82 on at
    Thanks for all your help.
    It seems field are validated in the order of the API not the request.
    I moved it to the bottom of the API code and all is good.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans