In this article, we will customize the Vendor Payment Journal form and Bank Cheque Payment report in D365. We will add the custom field in the Vendor Payment Journal form, report and also customize the slip text area of the cheque printing report which is generated dynamically at runtime.
To fulfil the requirement, we will follow some steps which are as under:
Step # 1: We will create an extension of the LedgerJournalTrans table and then add the custom field Memo to it.
Step # 2: We will create an extension of the form LedgerJournalTransVendPaym (Vendor Payment Journal) and drag the Memo field in the lines from the LedgerJournalTrans datasource.
Note: The custom field is successfully added to the form. Now we will add this field to the cheque report.
Step # 3: We will create COC of the determineReportMenuOutput method of ChequeController class to call our custom design of the cheque report.
[ExtensionOf(classStr(ChequeController))]
internal final class HMChequeController_Extension
{
protected str determineReportMenuOutput(ChequeFormType _chequeFormType, BankChequeLayout _bankChequeLayout)
{
chequeReport = next determineReportMenuOutput(_chequeFormType, _bankChequeLayout);
if (chequeReport == 'Cheque_US.Report')
{
chequeReport = ssrsReportStr(HMCheque_US, Report);
}
return chequeReport;
}
}
Step # 4: We will create an extension of the ChequeTmp table and add a Memo field in this too.
Step # 5: We need to create the COC of method populateChequeTmp of class ChequeDP to fill the Memo field in the ChequeTmp table.
[ExtensionOf(classStr(ChequeDP))]
internal final class MDChequeDP_Extension
{
protected void populateChequeTmp()
{
next populateChequeTmp();
chequeTmp.Memo = LedgerJournalTrans::findRecId(tmpChequePrintout.TransactionRecId, false).Memo;
}
}
Note: The Memo field has been successfully added to the form and report. Now we have to customize the slip text area of the report which is created dynamically.
Step # 6: We will create an extension of the BankChequePaymTrans table and then add the custom field Description to it.
Step # 7: We need to create the COC of method InitBankChequePaymentTransFromVendTrans of class CustVendCheque to fill the Description field as this field has to be populated from the ledger transaction of vendor payment.
[ExtensionOf(classStr(CustVendCheque))]
internal final class MDCustVendCheque_Extension
{
protected BankChequePaymTrans initBankChequePaymentTransFromVendTrans(SpecTrans _specTrans, CustVendPaym _custVendPaym, AmountCur _paymAmount)
{
BankChequePaymTrans bankChequePaymTrans;
bankChequePaymTrans = next initBankChequePaymentTransFromVendTrans(_specTrans, _custVendPaym, _paymAmount);
bankChequePaymTrans.Description = _custVendPaym.ledgerJournalTrans().Txt;
return bankChequePaymTrans;
}
}
Step # 8: Now we will create the COC of different methods of CustVendChequeSlipTextCalculator class to customize the slip text area.
[ExtensionOf(classStr(CustVendChequeSlipTextCalculator))]
internal final class MDCustVendChequeSlipTextCalculator_Extension
{
public container determineSlipTextTitleAndEndLinesAdjustmentForChequeRecipientType(BankChequeTable _bankChequeTable, ChequeFormType _chequeFormType)
{
ChequeSlipTxt chequeSlipText;
Counter endLines;
BankAccountTable bankAccountTable = BankAccountTable::find(_bankChequeTable.AccountID, false);
[chequeSlipText, endLines] = next determineSlipTextTitleAndEndLinesAdjustmentForChequeRecipientType(_bankChequeTable, _chequeFormType);
switch (_bankChequeTable.RecipientType)
{
case BankChequeRecipientType::Vend:
chequeSlipText += (bankAccountTable
? strFmt('\n%1 : %2', "@SYS40757", bankAccountTable.Name)
: strFmt('\n%1 : ', "@SYS40757"));
break;
}
return [chequeSlipText, endLines];
}
public container determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders(BankChequeTable _bankChequeTable, ChequeFormType _chequeFormType)
{
ChequeSlipTxt chequeSlipText;
Counter endLines;
[chequeSlipText, endLines] = next determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders(_bankChequeTable, _chequeFormType);
switch (_chequeFormType)
{
case ChequeFormType::USStyle:
chequeSlipText = strFmt(
'\n\n\n%1 %2 %3 %4 %5\n\n',
"@SYS14204", "@SYS80056", "@SYS41042", "@SYS11818", "@SYS1943");
endLines = -2;
break;
}
return [chequeSlipText, endLines];
}
protected container determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans(BankChequePaymTrans bankChequePaymTrans)
{
ChequeSlipTxt chequeSlipText;
Counter endLines;
[chequeSlipText, endLines] = next determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans(bankChequePaymTrans);
FromDate invoiceDate = bankChequePaymTrans.InvoiceDate;
chequeSlipText = strFmt(
'%1 %2 %3 %4 %5\n',
strLFix(bankChequePaymTrans.InvoiceId, 12),
strLFix(date2StrUsr(invoiceDate), 10),
strLFix(bankChequePaymTrans.Description, 36),
strRFix(num2str(-bankChequePaymTrans.InvoiceAmountCur, 0, 2, -1, -1), 12),
strRFix(num2str(-bankChequePaymTrans.PaymentAmountCur, 0, 2, -1, -1), 14));
endLines = -1;
return [chequeSlipText, endLines];
}
protected CustVendChequeSlipTextCalcDeterminSlipTextForTotalReturn determineSlipTextTitleAndEndLinesForSubTotalOrTotal(CustVendChequeSlipTextCalcDeterminSlipTextForTotalParameters _args)
{
CustVendChequeSlipTextCalcDeterminSlipTextForTotalReturn totalReturn = CustVendChequeSlipTextCalcDeterminSlipTextForTotalReturn::construct();
totalReturn = next determineSlipTextTitleAndEndLinesForSubTotalOrTotal(_args);
totalReturn.chequeSlipTxt = strFmt(
'\n%1 %2',
strLFix(_args.chequeSlipTxtLabel, 75),
num2str(_args.TotalAmountCur, 16, 2, -1, -1));
totalReturn.endLines = -1;
return totalReturn;
}
}
Note: The keyword ‘strLFix’and‘strRFix’is used to add the padding from the left and right of the string.
The following description for the above methods are as below:
- determineSlipTextTitleAndEndLinesAdjustmentForChequeRecipientType:In this method, we have concatenated the Bank Account details in the slip text area.
- determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders:In this method, we have customized the header section of the lines of slip text and added the description label.
- determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans:In this method, we have customized the lines of slip textand also added the description field.
- determineSlipTextTitleAndEndLinesForSubTotalOrTotal:In this method, need to move the total amount of Sliptext to a bit of the right side to adjust.
Output