Dynamics 365 FO - How to get TaxCode code from SalesLine X++
Nghia Song - Microsoft Dynamics 365 Technical Consultant
Nghia Song
Tel - WhatsApp: +84967324794
Email: songnghia.uit@gmail.com
public static TaxCode taxCodeFromSalesLine(SalesLine _salesLine) { TaxGroup taxGroup; TaxItemGroup taxItemGroup; TaxGroupData taxGroupData; TaxOnItem taxOnItem; Set taxCodeCombination = new Set(Types::String); container cachedResult; TaxCode taxCode; taxGroup = _salesLine.TaxGroup; taxItemGroup = _salesLine.TaxItemGroup; // Pull the intersection information from cache cachedResult = TaxCache::getValue( TaxCacheScope::IntersectionData, [curext(), taxGroup, taxItemGroup]); if (cachedResult != conNull()) { taxCode = any2str(conPeek(conPeek(cachedResult, 1), 2)); } else { // Data not yet cached, look it up while select TaxGroup, TaxCode, ExemptTax, IntracomVAT from taxGroupData where taxGroupData.TaxGroup == taxGroup join TaxItemGroup, TaxCode // ,ExemptTax_BR // from taxOnItem where taxOnItem.TaxItemGroup == taxItemGroup && taxOnItem.TaxCode == taxGroupData.TaxCode { taxCode = taxGroupData.TaxCode; } } return taxCode; }
No comments:
Post a Comment