Breaking news from around the world
Get the Bing + MSN extension
Now Available in Community - MBAS 2019 Presentation Videos
Catch the most popular sessions on demand and learn how Dynamics 365, Power BI, Power Apps, Power Automate, and Excel are powering major transformations around the globe. | View Gallery
2019 release wave 2 Discover the latest updates and new features to Dynamics 365 planned through March 2020
Release overview guides and videos Release Plan | View virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Talent TechTalks | Upcoming TechTalks
I have a requirement to override/adjust sales tax for individual pending vendor invoice lines through code.
I am able to adjust the sales tax for the pending vendor invoice header from AP > Invoices > Pending vendor invoices > select/open any invoice > Financials (Action pane) > Sales Tax > Adjustment (tab). Even-though, we can see the sales tax for each vendor invoice line, by selecting a vendor invoice line > Financials (on top of lines grid) > Sales Tax, it doesn't have an option to adjust the Sales Tax amounts.
If you open the sales tax form from the header then you should see a multiple lines for each of the lines that is included in your pending vendor invoice form and that has sales tax associated because of the item sales tax group / sales tax group combination selected.
You can thus make the changes in the header and they apply to your respective lines.
Sometime back I had similar requirement to auto adjust sales tax amount to a specific value based on manual input for Free text invoice. I used following code for my requirement.
For your requirement, you can use PurchTotals class or corresponding class and use this code.
Thank you for your response. I was trying the similar logic as below. This works when I have to update the sales tax at vendor invoice header. However, I when have more than one line in the invoice with sales tax code (eg ABCD), the amount which I pass (eg 100), will get split as 50 on one line and 50 for other line. I am not able to update sales tax for just one invoice line (say line 1) and leave the sales tax of the second line unchanged.
public void overrideVendInvoiceTax(TradeLineRefId tableRefId, Map _salesTaxOverrides, RefRecID _vendInvoiceLineRecID)
VendInvoiceInfoTable vendInvoiceInfoTable = VendInvoiceInfoTable::findTableRefId(tableRefId);
purchTotals = PurchTotals::newParmTable(vendInvoiceInfoTable,PurchUpdate::All, vendInvoiceInfoTable.ParmId,vendInvoiceInfoTable.PurchId, DocumentStatus::Invoice);
select vendInvoiceInfoLine where vendInvoiceInfoLine.RecId == _vendInvoiceLineRecID;
taxRegulation = TaxRegulation::newTaxRegulation(purchTotals.tax(),null, vendInvoiceInfoLine.TableId, vendInvoiceInfoLine.RecId);
tmpTaxRegulation = taxRegulation.tmpTaxRegulation();
while select tmptaxRegulation
tmptaxRegulation.SourceRegulateAmountCur = _salesTaxOverrides.lookup(tmpTaxRegulation.taxCode);
tmptaxRegulation.SourceRecId = vendInvoiceInfoLine.RecId;
tmptaxRegulation.SourceTableId = vendInvoiceInfoLine.TableId;
Thank you for your response.
For my requirement, I would need the sales tax to be be updated on one of the invoice line and leave the sales tax of other line unchanged.
On the vendor invoice sales tax form, when we navigate to Adjustment tab, sales tax amount for all lines gets summed up by sales tax codes. When I change the value there, the new value get split against the lines which are associated. Not just one line which I want to change.
Can you try this?
Replace purchTotals.calc(false, false, true); with following 2 lines
Also inside the if() statement, comment all update code and just call following
Please try this and let me know how this goes.
Appreciate if you kindly elaborate and help to understand what is the business expectation for such requirement as you mentioned in your last post in this thread "I would need the sales tax to be updated on one of the invoice line and leave the sales tax of other line unchanged." ?
If anyhow through coding if you achieve this; based on what criteria you will pick a line (out of many lines) in pending vendor invoice form to adjust the sales tax in that line ?
Best regards,Sourav Dam
Thank you again for the response, I was busy yesterday and tried your suggestion today. For me the results are same as of my previous code as I update on the header. The amount I pass is distributed across multiple lines which have same sales tax code. Example as below.
Line 1 - Item A, Line amount: 1000, Tax code : ABC, Tax amount 180 - Calculated with 18%
Line 2 - Item B, Line amount: 1200, Tax code : ABC, Tax amount 216 - Calculated with 18%
After update (Actual) - I tried the update of Line 2 with tax amount '120.10' identifying the vendor invoice line record using RECID
Line 1 - Item A, Line amount: 1000, Tax code : ABC, Tax amount 54.59 - Calculated by distributing the value I passed
Line 2 - Item B, Line amount: 1200, Tax code : ABC, Tax amount 65.51 - Calculated by distributing the value I passed
As you can see in the above example, the tax amount i passed (120.10) for line 2 has been distributed on both the lines based on the line amount.
This is in-line with the manual update which we do on the header level through UI
My Requirement (Expectation) - When I pass tax amount '120.10' for Line 2 identifying the vendor invoice line record using RECID.
Line 1 - Item A, Line amount: 1000, Tax code : ABC, Tax amount 180 - Tax amount not changed
Line 2 - Item B, Line amount: 1200, Tax code : ABC, Tax amount 120.10 - Tax amount changed with the value I passed.
Thank you for your response. I think my latest response to Sumit will clarify your questions also.
The above changes helped me. I had to add one more extension. Had to do a COC on class 'PurchCalcTax_ParmTransInvoice' method 'allowSingleLineAdjustment' to return true when my conditions are met.
Business Applications communities