Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Setting VAT Biz posting group per sales invoice via API

Posted on by 14
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.
 
 
  • Suggested answer
    CU09081641-3 Profile Picture
    CU09081641-3 14 on at
    Setting VAT Biz posting group per sales invoice via API
    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.
  • Ramiz Profile Picture
    Ramiz 281 on at
    Setting VAT Biz posting group per sales invoice via API
    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
    YUN ZHU Profile Picture
    YUN ZHU 71,656 Super User 2024 Season 2 on at
    Setting VAT Biz posting group per sales invoice via API
    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
  • CU09081641-3 Profile Picture
    CU09081641-3 14 on at
    Setting VAT Biz posting group per sales invoice via API
    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..
     
     

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,297 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans