How to Print Total Discount and Subtotal with final Total per each Delivery Note in AX7 (Dynamics 365 for Operations)
Hi,
How to Print Total Discount and Subtotal with final Total per each Delivery Note
static void ShyamSalesTotalJob(Args _args)
{
// Sales line Unit Price * units delivered per line. Then add the lines together with Discount
DiscAmount totalDisc=0;RealBase subTotal=0;Amount subTotalAmount=0;AmountCur TotalAmount=0;RealBase discPercent=0;
CustPackingSlipTrans custPackingSlipTrans;SalesLine salesLine;
SalesTable salesTable;
salesTable= SalesTable::find(“000746”,false);
CustPackingSlipJour _custPackingSlipJour
while select Qty from custPackingSlipTrans
where _custPackingSlipJour.SalesID == custPackingSlipTrans.SalesID && _custPackingSlipJour.PackingSlipId == custPackingSlipTrans.PackingSlipId
join SalesPrice
from salesLine where salesLine.SalesID == custPackingSlipTrans.SalesID && salesLine.InventTransId == custPackingSlipTrans.InventTransId
{
subTotal=(custPackingSlipTrans.Qty * salesLine.SalesPrice );
subTotalAmount= subTotalAmount + subTotal;
}
info(strfmt("Sub Total Amount %1",subTotalAmount));
discPercent=salesTable.DiscPercent;
if (discPercent>0)
{
totalDisc=(subTotalAmount * (discPercent/100));
}
info(Strfmt("Total discount %1", totalDisc));
if(totalDisc>0)
{
TotalAmount=(subTotalAmount - totalDisc);
info(Strfmt("Total Amount %1", TotalAmount));
}
else
{
info(Strfmt("Total Amount %1", subTotalAmount));
}
}
Comments
Post a Comment