September 30, 2023

X++ code to get GST amount in D365 FO

 public Amount getGSTAmount(str type) 

TaxDocumentRowTransaction           taxDocumentRowTransaction; 
TaxDocumentComponentTransaction     taxDocumentComponentTransaction; 
TaxComponentTable_IN                taxcomponent; 
TaxDocumentComponentTransaction_In  taxDocumentComponentTransactionIn; 

select sum(TaxAmount) from taxDocumentComponentTransaction 
exists join taxDocumentRowTransaction 
where taxDocumentRowTransaction.RecId == taxDocumentComponentTransaction.TaxDocumentRowTransactionRecId 
     && taxDocumentRowTransaction.Voucher == this.Voucher  //Voucher number
             && taxDocumentRowTransaction.InvoiceId == this.CustomerInvoiceNo //Invoice number
     && taxDocumentRowTransaction.TransactionDate == this.CustomerInvoiceDate //Invoice date
exists join taxDocumentComponentTransactionIn 
where taxDocumentComponentTransactionIn.TaxDocumentComponnetTransactionRecId == taxDocumentComponentTransaction.RecId 
exists join taxcomponent where taxcomponent.RecId == taxDocumentComponentTransactionIn.TaxComponent 
&& taxcomponent.TaxType == TaxType_IN::GST 
&& taxcomponent.Component == type; 
return TaxDocumentComponentTransaction.TaxAmount; 

No comments:

Post a Comment