Skip to main content

Notifications

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

Setting VAT Biz posting group per sales invoice via API

(1) ShareShare
ReportReport
Posted on by 53
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 53 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 344 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 74,036 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 53 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans