Override standard report with custom report in India GST taxes Invoice report in D365FO:

Override standard report with custom report in India GST taxes Invoice report in D365FO:
We came across the scenario where we have to skip the standard Report and call our customized Report:
·         Standard GST reportName is set in the setReportName() method. And it is a private method, so can’t be overridden in COC.
·         We had handled it by storing Boolean flag in the Global Cache and skip the setReportMethod() execution by returning false in the  [PostHandlerFor(classStr(SysCountryRegionCode), staticMethodStr(SysCountryRegionCode, isLegalEntityInCountryRegion))] method.
·         Custom reportName is set in outputReport() method in the extension class HSOSalesInvoiceController_IN_Extension.

[ExtensionOf(classStr(SalesInvoiceController))]
final class HSOSalesInvoiceController_IN_Extension
{
    protected void outputReport()
    {
        boolean skipReportNameINMethod;
       
        #ISOCountryRegionCodes

        if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIN]))
        {
            FormLetterReport    formLetterReportLoc = formLetterReport;
            PrintMgmtPrintSettingDetail printSettingDetailLoc = formLetterReport.getCurrentPrintSetting();

            CustInvoiceJour custInvoiceJourLoc = this.parmArgs().record();

            if (this.parmArgs().menuItemName() == menuitemOutputStr(HSOBillOfSupply_IN))
            {
                this.parmReportName(ssrsReportStr(HSOBillOfSupplyReport_IN, BillOfSupplyReport));
                isGSTInvoice = false;
            }
            else if(this.parmArgs().menuItemName() == menuitemOutputStr(HSOTaxInvoice_IN))
            {
                if (custInvoiceJourLoc.SalesId != "")
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoiceReport_IN, SalesInvoiceTaxReport));
                    isGSTInvoice = false;
                }
                else
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoiceFTIReport_IN, SalesInvoiceTaxFTIReport));
                    isGSTInvoice = false;
                }
            }
            else if (this.parmArgs().menuItemName() == menuitemOutputStr(HSOSalesCreditNote_IN))
            {
                if (custInvoiceJourLoc.SalesId != "")
                {
                    this.parmReportName(ssrsReportStr(HSOSalesCreditNoteReport_IN, SalesCreditNoteReport));
                    isGSTInvoice = false;
                }
                else
               {
                    this.parmReportName(ssrsReportStr(HSOSalesCreditNoteReport_IN, SalesCreditNoteFTIReport));
                    isGSTInvoice = false;
                }
            }
            else if (this.parmArgs().menuItemName() == menuitemOutputStr(HSOSalesDebitNote_IN))
            {
                this.parmReportName(ssrsReportStr(HSOSalesDebitNoteReport_IN, SalesDebitNoteFTIReport));
                isGSTInvoice = false;
            }
            else if (this.parmArgs().menuItemName() == menuItemOutputStr(SalesInvoice) && this.parmArgs().callerName() == classStr(SalesInvoiceJournalPrint))
            {
                CustInvoiceJour_IN    custInvoiceJour_IN = CustInvoiceJour_IN::findByCustInvoiceJour(custInvoiceJour.RecId);

                if (custInvoiceJour_IN.HSOSalesTaxInvoice_IN == NoYes::Yes)
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoice_IN, SalesTaxInvoice_IN));
                    isGSTInvoice = false;
                }
                else if (custInvoiceJour_IN.HSOFreeofCostInvoice_IN == NoYes::Yes)
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoice_IN, FOCInvoice_IN));
                    isGSTInvoice = false;
                }
                else if (custInvoiceJour_IN.HSOSampleInvoice_IN == NoYes::Yes)
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoice_IN, SampleInvoice_IN));
                    isGSTInvoice = false;
                }
            }
            else
            {
                if (this.parmArgs().menuItemName() == menuItemOutputStr(HSOSalesTaxInvoice_IN))
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoice_IN, SalesTaxInvoice_IN));
                    isGSTInvoice = false;
                }
                else if (this.parmArgs().menuItemName() == menuItemOutputStr(HSOFreeofCostInvoice_IN))
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoice_IN, FOCInvoice_IN));
                    isGSTInvoice = false;
                }
                else if (this.parmArgs().menuItemName() == menuItemOutputStr(HSOSampleInvoice_IN))
                {
                    this.parmReportName(ssrsReportStr(HSOSalesTaxInvoice_IN, SampleInvoice_IN));
                    isGSTInvoice = false;
                }
            }
            printSettingDetailLoc.parmReportFormatName(this.parmReportName());
        }

        skipReportNameINMethod = true;
   
        SysGlobalObjectCache cache = TaxSolutionScopeIntegrationUtil::getCacheObject();
        cache.insert(
                TaxSolutionScopeIntegrationUtil::companyEnableScope,
                ['HSOSalesInvoiceController_IN_Extension'],
                [skipReportNameINMethod]);
       
        next outputReport();
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(classStr(SysCountryRegionCode), staticMethodStr(SysCountryRegionCode, isLegalEntityInCountryRegion))]
    public static void SysCountryRegionCode_Post_isLegalEntityInCountryRegion(XppPrePostArgs args)
    {
        boolean skipReportNameINMethod;
        SysGlobalObjectCache cache = TaxSolutionScopeIntegrationUtil::getCacheObject();

        [skipReportNameINMethod] = cache.find(
                TaxSolutionScopeIntegrationUtil::companyEnableScope,
                ['HSOSalesInvoiceController_IN_Extension']);

        if (skipReportNameINMethod)
        {
            TaxSolutionScopeIntegrationUtil::getCacheObject().remove(TaxSolutionScopeIntegrationUtil::companyEnableScope,
                                                                ['HSOSalesInvoiceController_IN_Extension']);

            args.setReturnValue(false);
        }

    }

}





Thanks
Dynamics 365 Learner


Comments

Popular posts from this blog

Identifying the Database Synchronization Issue in D 365 FO

Steps to create new cheque layout in D365 FO

SSRS Reports using the QueryInsertRecordSet in D 365 FO