D365: Modifying check report along with the slip text
Today I came across a requirement to modify the standard check format in D365F&O. The requirement was to modify the design and also change the slip text that displays on the check report. Below are the steps for reference purpose that I followed to achieve the desired solution:
STEPS:
1. Duplicated the Check_US report in my specified Model.
2. Modified the design accordingly.
3. Create the extension of the "ChequeController" class in order to call my newly created report and design, the code is as below:
4. In order to modify the slip text the following class extension was created with the below code for reference:
5. To modify the field/data mapping for the tmpCheckPrintout :
STEPS:
1. Duplicated the Check_US report in my specified Model.
2. Modified the design accordingly.
3. Create the extension of the "ChequeController" class in order to call my newly created report and design, the code is as below:
[ExtensionOf(classStr(ChequeController))]
final class LevChequeController_LevridgeEquity_Extension
{
///
<summary>
///
Determine the report menu item.
///
</summary>
///
<param name = "_chequeFormType">The check form
type.</param>
///
<param name = "_bankChequeLayout">The bank cheque layout table
buffer.</param>
///
<returns>The menu item name</returns>
protected str
determineReportMenuOutput(ChequeFormType _chequeFormType, BankChequeLayout _bankChequeLayout)
{
CustomChequeLayout_BR
customChequeLayout_BR;
chequeReport = next determineReportMenuOutput(_chequeFormType, _bankChequeLayout);
switch (_chequeFormType)
{
case ChequeFormType::USStyle:
chequeReport = ssrsReportStr(LevCheque_US,
Report);
break;
}
return chequeReport;
}
}
[ExtensionOf(classStr(CustVendChequeSlipTextCalculator))]
final class LevCustVendChequeSlipTextCalculator_LevridgeEquity_Extension
{
///
<summary>
///
Determine slip text title and end lines adjustment for column headers.
///
</summary>
///
<param name = "_bankChequeTable">The bank check
table.</param>
///
<param name = "_chequeFormType">The check form
type.</param>
///
<returns>The slip text and the end lines adjustment.</returns>
public container determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders(
BankChequeTable _bankChequeTable,
ChequeFormType _chequeFormType)
{
ChequeSlipTxt chequeSlipText;
Counter endLines;
[chequeSlipText, endLines] = next determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders(_bankChequeTable,
_chequeFormType);
switch (_chequeFormType)
{
case ChequeFormType::USStyle,
ChequeFormType::ESStyle,
ChequeFormType::MXStyle,
ChequeFormType::CAStyle,
ChequeFormType::DEStyle,
ChequeFormType::UKStyle:
chequeSlipText = '';
chequeSlipText += strFmt(
'%1 %2
%3 %4 %5\n\n',
"@LevridgeEquity:LevVendorAccountNumber", "@LevridgeEquity:LevVendorAccountName", "@LevridgeEquity:LevPaymentType", "@LevridgeEquity:LevCheckDate", "@LevridgeEquity:LevCheckNumber");
endLines = -2;
break;
}
return [chequeSlipText,
endLines];
}
///
<summary>
///
Determine slip text and end lines adjustment for
<c>BankChequePaymTrans</c>.
///
</summary>
///
<param name = "bankChequePaymTrans">The bank payment transaction.</param>
///
<returns>The slip text and the end lines adjustment.</returns>
protected container
determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans(BankChequePaymTrans _bankChequePaymTrans)
{
ChequeSlipTxt chequeSlipText;
Counter endLines;
FromDate invoiceDate =
_bankChequePaymTrans.TransDate;
CashDiscAmount cashDiscAmount =
_bankChequePaymTrans.CashDiscAmountCur;
BankChequeTable bankChequeTable;
[chequeSlipText, endLines] = next determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans(_bankChequePaymTrans);
bankChequeTable = bankChequeTable::find(_bankChequePaymTrans.AccountId,
_bankChequePaymTrans.ChequeNum);
switch
(bankChequeTable.RecipientType)
{
case BankChequeRecipientType::Vend:
VendTable vendTable = VendTable::findByCompany(bankChequeTable.RecipientCompany,
bankChequeTable.RecipientAccountNum);
chequeSlipText = '';
chequeSlipText += strFmt(
'%1 %2
%3 %4 %5\n',
strLFix(vendTable.AccountNum, 21),
strLFix(vendTable.name(), 19),
strLFix(vendTable.paymentType(), 12),
strLFix(date2StrUsr(invoiceDate),
10),
strLFix(_bankChequePaymTrans.ChequeNum, 12));
endLines = -1;
break;
}
return [chequeSlipText,
endLines];
}
}
[ExtensionOf(classStr(CustVendCheque))]
final class LevCustVendCheque_LevridgeEquity_Extension
{
///
<summary>
///
Creates the <c>TmpChequePrintout</c> table buffer that contains the
information that is required to
///
create the physical check.
///
</summary>
///
<param name="_custVendPaym">
///
A class that contains the transaction information that is needed for the check.
/// </param>
///
<exception cref="M:Exception::Error">
///
The <c>LedgerJournalACType</c> enumeration value cannot have
checks.
///
</exception>
public void output(CustVendPaym _custVendPaym)
{
LedgerJournalTrans ledgerJournalTrans =
_custVendPaym.ledgerJournalTrans();
LevPatronageInvoiceDetails
patronageInvoiceDetails;
next
output(_custVendPaym);
select firstonly Name,
LogisticsAddressing from patronageInvoiceDetails
where patronageInvoiceDetails.JournalLineRefId ==
ledgerJournalTrans.RecId;
ttsbegin;
tmpChequePrintout.selectforupdate(true);
tmpChequePrintout.RecipientName = patronageInvoiceDetails.Name;
tmpChequePrintout.Address = patronageInvoiceDetails.LogisticsAddressing;
tmpChequePrintout.update();
ttscommit;
}
}
Comments
Post a Comment