Customer free text invoices are an essential aspect of financial management in D365FO. In this blog, I have compiled all the code needed to retrieve the value of every single field in the "Totals" form, as shown in the image below.
Note: Pre-requisite to get all the values is customer invoice (CustomerInvoiceTable).
Instantiating
CustFreeInvoiceCalcTotals class:
CustFreeInvoiceCalcTotals
custFreeInvoiceCalcTotals = new CustFreeInvoiceCalcTotals(custInvoiceTable);
Calculating Totals:
custFreeInvoiceCalcTotals.calc();
1- Get a Credit limit from the
custFreeInvoiceCalcTotals class:
CustCreditMaxMST creditMax;
creditMax = custFreeInvoiceCalcTotals.custFreeInvoiceCreditMax();
2- Get a Credit Available from
the custFreeInvoiceCalcTotals class:
CustCreditFreeValueMST freeValue;
freeValue = custFreeInvoiceCalcTotals.custFreeInvoiceFreeValue();
3- Get a Line Discount from the
custFreeInvoiceCalcTotals class:
SalesSumLineDiscAmount lineDisc;
lineDisc = custFreeInvoiceCalcTotals.custFreeInvoiceLineDisc();
4- Get a Subtotal Amount from the
custFreeInvoiceCalcTotals class:
AmountCur sumLines;
sumLines = custFreeInvoiceCalcTotals.custFreeInvoiceInvoiceAmountGTE();
5- Get a Total Discount from the
custFreeInvoiceCalcTotals class:
SalesEndDiscAmount endDisc;
endDisc = custFreeInvoiceCalcTotals.custFreeInvoiceEndDisc();
6- Get a Total Charges from the
custFreeInvoiceCalcTotals class:
MarkupSumSales sumMarkup;
sumMarkup =
custFreeInvoiceCalcTotals.custFreeInvoiceMarkup();
7- Get a Sales Tax from the custFreeInvoiceCalcTotals class:
TaxAmountCur sumTax;
sumTax = custFreeInvoiceCalcTotals.custFreeInvoiceTaxTotal();
8- Get a Round-Off from the custFreeInvoiceCalcTotals class:
RoundOff invoiceRoundOff;
invoiceRoundOff =
abs(custFreeInvoiceCalcTotals.custFreeInvoiceRoundOff());
9- Get an Invoice Amount from the custFreeInvoiceCalcTotals class:
AmountCur invoiceAmount;
invoiceAmount =
custFreeInvoiceCalcTotals.custFreeInvoiceInvoiceAmount();
10- Get a Cash Discount from the custFreeInvoiceCalcTotals class:
CustCashDiscAmount cashDisc;
cashDisc = custFreeInvoiceCalcTotals.custFreeInvoiceCashDisc();
11- Get an Exchange rate from the CustInvoiceTable table1-:
Exchrate exchRate;
exchRate = CustInvoiceTable.displayExchRateForReportingCurrency();
12- Get a Currency from the custFreeInvoiceCalcTotals class:
CustCurrencyCode currency;
currency =
custFreeInvoiceCalcTotals.custFreeInvoiceCurrency();
Result: