Steps to create new cheque layout in D365 FO


Step1. Extend the Standard BaseEnum as ChequeFormType with proper naming convention say (ChequeFormType.SAGlobalExtension)





Step(2) - Duplicate the standard menu item Cheque_US as SAGCheque_TEPL_SCB and set the property of the menu item as given in the screenshot.







Step(3) - Now duplicate the report Cheque_US as SAGCheque_TEPL_SCB and call this report in the controller class extension.



Step(4). Following classes need to be modified to support the new Cheque layout in Extension.

(1)add extension class for existing BankChequePrint class and add below logic.

 [ExtensionOf(classStr(BankChequePrint))]

final class SAGBankChequePrint_Extension

{

    protected str determineReportMenuOutput(ChequeFormType _chequeFormType)

    {

        str menuOutput = next determineReportMenuOutput(_chequeFormType);



              switch (_chequeFormType)

        {

            case ChequeFormType::SAGStyle :

                menuOutput = menuitemoutputstr(SAGCheque_TEPL_SCB);

                break;

        }

        return menuOutput;

    }



}



(2) add extension class for existing BankPrintTestCheque class and add below logic.

[ExtensionOf(classStr(BankPrintTestCheque))]

final class SAGBankPrintTestCheque_Extension

{

    protected boolean canRunChequePrintForExtendedFormType(TmpChequePrintout _tmpChequePrintout)

    {

        boolean ret = next canRunChequePrintForExtendedFormType(_tmpChequePrintout);

        switch (_tmpChequePrintout.ChequeFormType)

        {

            case ChequeFormType::SAGStyle :

                ret = true;

                break;

        }

        return ret;

    }



    protected void runChequePrintForExtendedChequeFormType(TmpChequePrintout _tmpChequePrintout)

    {

        next runChequePrintForExtendedChequeFormType(_tmpChequePrintout);

        switch (_tmpChequePrintout.ChequeFormType)

        {

            case ChequeFormType::SAGStyle :

                Args args = this.getChequePrintArgs(_tmpChequePrintout);

                new MenuFunction(menuitemOutputStr(SAGCheque_TEPL_SCB), MenuItemType::Output).run(args);

                break;

        }

    }

}



 (3)CustVendChequeSlipTextCalculator\ getChequeDocLengthDelegate

Add the delegateHandler for the delegateMethod as below.



class SAGCheckDocLengthEventHandler

{

    /// <summary>

    /// Subscribed to Delegate to be called in the default case within the getChequeDocLength method for executing cheque form types.

    /// </summary>

    /// <param name = "_chequeFormType">The cheque form type used for execution.</param>

    /// <param name = "_result">The <c>EventHandlerResult</c> instance to be assigned to prior to exiting the method once the work is completed.</param>

    [SubscribesTo(classStr(CustVendChequeSlipTextCalculator), delegateStr(CustVendChequeSlipTextCalculator, getChequeDocLengthDelegate))]

    public static void CustVendChequeSlipTextCalculator_getChequeDocLengthDelegate(ChequeFormType _chequeFormType, EventHandlerResult _result)

    {

        const real ChequeSizeDefault = 88.89;

        switch (_chequeFormType)

        {

            case ChequeFormType::SAGStyle:

                _result.result(ChequeSizeDefault);

        }

    }



}

(4)ChequeController\ initChequeReportFromChequeFormTypeDelegate

Add the delegateHandler for the delegateMethod as below.

class SAGCheckFormTypeDelegateEventHandler

{

    /// <summary>

    /// Delegate handler to be called in the default case within the init method for executing cheque form types.

    /// </summary>

    /// <param name = "_chequeFormType">The cheque form type used for execution.</param>

    /// <param name = "_bankChequeLayout">Instance of <c>BankChequeLayout</c> table buffer.</param>

    /// <param name = "_result"><c>EventHandlerResult</c> instance to be assigned to prior to exiting the method once the work is completed.</param>

    [SubscribesTo(classStr(ChequeController), delegateStr(ChequeController, initChequeReportFromChequeFormTypeDelegate))]

    public static void ChequeController_initChequeReportFromChequeFormTypeDelegate(ChequeFormType _chequeFormType, BankChequeLayout _bankChequeLayout, EventHandlerResult _result)

    {

        switch (_chequeFormType)

        {

            case ChequeFormType::SAGStyle:

                _result.result(ssrsReportStr(SAGCheque_TEPL_SCB,Report));

                break;

        }



    }



}

(5) add extension class for existing ChequeController class and add below logic.

[ExtensionOf(classStr(ChequeController))]

final class SAGChequeController_Extension

{

    protected str determineReportMenuOutput(ChequeFormType _chequeFormType, BankChequeLayout _bankChequeLayout)

    {

        chequeReport = next determineReportMenuOutput(_chequeFormType,_bankChequeLayout);

        switch (_chequeFormType)

        {

            case ChequeFormType::SAGStyle:

                chequeReport = ssrsReportStr(SAGCheque_TEPL_SCB,Report);

                break;

        }



        return chequeReport;

    }



}



(6) add extension class for existing ChequeCopy class and add below logic.

[ExtensionOf(classStr(ChequeCopy))]

final class SAGChequeCopy_Extension

{

    [Wrappable(true)]

    protected final MenuFunction getMenuFunction(TmpChequePrintout _tmpChequePrintout)

    {

        MenuFunction menuFunction = next getMenuFunction(_tmpChequePrintout);

        switch (_tmpChequePrintout.ChequeFormType)

        {

            case ChequeFormType::SAGStyle:

                menuFunction = new MenuFunction(menuitemoutputstr(SAGCheque_TEPL_SCB), MenuItemType::Output);

                break;

        }

        return menuFunction;

    }



}



(7) CustVendChequeSlipTextCalculator\getChequeDocLengthDelegate

Add the delegateHandler for the delegateMethod as below.

class SAGChequeDelegateEventHandler

{

   

    /// <summary>

    /// Delegate handler to be called in the default case within the getChequeDocLength method for executing cheque form types.

    /// </summary>

    /// <param name = "_chequeFormType">The cheque form type used for execution.</param>

    /// <param name = "_result">The <c>EventHandlerResult</c> instance to be assigned to prior to exiting the method once the work is completed.</param>

    [SubscribesTo(classStr(CustVendChequeSlipTextCalculator), delegateStr(CustVendChequeSlipTextCalculator, getChequeDocLengthDelegate))]

    public static void CustVendChequeSlipTextCalculator_getChequeDocLengthDelegate(ChequeFormType _chequeFormType, EventHandlerResult _result)

    {

        const real ChequeSizeDefault = 88.89;

        ChequeLength chequeLength;

        switch (_chequeFormType)

        {

            case ChequeFormType::SAGStyle:

                chequeLength = ChequeSizeDefault;

                _result.result(chequeLength);

        }

    }



}



(8)add extension for the ChequeDP\populateChequeTmp() method to format the chequeDate column.

[ExtensionOf(classStr(ChequeDP))]

final class SAGChequeDP_Extension

{

    protected void populateChequeTmp()

    {

        next populateChequeTmp();

        int i,j;

        str tempString;

         if (chequeReportType == ChequeFormType::SAGStyle)

        {

            chequeTmp.Datestr = date2str(tmpChequePrintout.transDate,123,DateDay::Digits2, DateSeparator::None, DateMonth::Digits2, DateSeparator::None, DateYear::Digits4);

            j = strLen(chequeTmp.Datestr);



            for(i = 1; i <= j; i++)

            {

                tempString = tempString + subStr(chequeTmp.Datestr, i, 1);



                if(i != strLen(chequeTmp.Datestr))

                {

                    tempString = tempString + "    ";

                }

            }



            chequeTmp.Datestr = tempString;

        }

      

    }



    protected void populateTmpChequePrintout()

    {

        next populateTmpChequePrintout();

        if(chequeReportType == ChequeFormType::SAGStyle)

        {

          tmpChequePrintout.Numerals2Letter = tmpChequePrintout.AmountCur != 0 ? numeralsToTxt_IN(tmpChequePrintout.AmountCur) : '';

        }

    }



}



(9) add extension class for existing CustVendCheque class and add below logic.

[ExtensionOf(classStr(CustVendCheque))]

final class SAGCustVendCheque_Extension

{

    protected boolean shouldUpdateSlipTextForChequePrinting(ChequeFormType _chequeType)

    {

        boolean ret = next shouldUpdateSlipTextForChequePrinting(_chequeType);

        return (ret || _chequeType == ChequeFormType::SAGStyle);

    }



}

(10) add extension class for existing CustVendChequeSlipTextCalculator class and add below logic.

[ExtensionOf(classStr(CustVendChequeSlipTextCalculator))]

final class SAGCustVendChequeSlipTextCalculator_Extension

{

    public Counter getMinimumSlipLines(ChequeFormType _chequeFormType)

    {

        Counter minSlipLines = next getMinimumSlipLines(_chequeFormType);

        switch (_chequeFormType)

        {

            case ChequeFormType::SAGStyle:

                minSlipLines = 8;

         }

        return minSlipLines;

    }



}

Step(5) - Navigate to the Cash and Bank Management>BankAccounts>Setup>Layout>Check

We can find the new cheque format in the ChequeForm Group in the General tab. Please find the attached screenshot given below.




Comments

Popular posts from this blog

Identifying the Database Synchronization Issue in D 365 FO

SSRS Reports using the QueryInsertRecordSet in D 365 FO