Wednesday, August 23, 2023

Code to change the Electronic payment format of vendor payment journal in D365 F&O

 My requirement is to change the exported format(NACHA) of vendor payment journal.

Standard Format (Existing):

AP>Vendor payment journal>lines>generate payements.



Code to modify the existing format :


[ExtensionOf(classStr(VendOutPaym_NACHA))]

internal final class DaxvendOutPaym_NACHA_Extension

{

   public LedgerJournalTrans  ledgerJournalTrans;

   protected container createACH_HeaderRecord()

   {

       LogisticsPostalAddress  logisticsPotalAddress;

       container   headerACH,con;

       str         value = "HD";

       str         value2,dateValue,value3,datevalue2,effectivedateloc,journalnum,amountcurdebit,accountid,vendorid;

                 

       #define.spc(' ')

       str 50      aditonalname            =   strRep(#spc, 50); //to get spaces of length 50

       value3      = "PYCHK";

       dateValue   = date2str( systemDateGet(),

                       321,

                       DateDay::Digits2,

                       DateSeparator::Hyphen,

                       DateMonth::Digits2,

                       DateSeparator::Hyphen,

                       DateYear::Digits4,

                       DateFlags::FormatAll);

       effectivedateloc = date2str( effectiveEntDate,

                       321,

                       DateDay::Digits2,

                       DateSeparator::Hyphen,

                       DateMonth::Digits2,

                       DateSeparator::Hyphen,

                       DateYear::Digits4,

                       DateFlags::FormatAll);

 

       headerACH = next createACH_HeaderRecord();

       CompanyInfo     companyInfo = CompanyInfo::find();

       //while

       select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalId;

       vendorid = LedgerDimensionFacade::getDisplayValueForLedgerDimension(ledgerJournalTrans.LedgerDimension);

       if(ledgerJournalTrans.PaymentStatus == CustVendPaymStatus::None)

       {

           select logisticsPotalAddress

           where logisticsPotalAddress.Location == ledgerJournalTrans.RemittanceLocation;

           //{

           value2 = ledgerJournalTrans.PaymReference;

           if(ledgerJournalTrans.AmountCurCredit)

           {

               value3 = value3 + "C";

           }

           if(ledgerJournalTrans.AmountCurDebit)

           {

               value3 = value3 + "D";

           }

           datevalue2 = date2str( ledgerJournalTrans.TransDate,

                       321,

                       DateDay::Digits2,

                       DateSeparator::Hyphen,

                       DateMonth::Digits2,

                       DateSeparator::Hyphen,

                       DateYear::Digits4,

                       DateFlags::FormatAll);

           amountcurdebit = strRFix(any2Str(ledgerJournalTrans.AmountCurDebit),16,'0');

           // }

           value2 = strRFix(value2,15,'0');

           journalnum = strLFix(ledgerJournalId,30,' ');

           accountid = strLFix(bankAccountTable.AccountID,35,' ');

 

           headerACH = conNull();

           con = conIns(headerACH,1,value + value2 + dateValue + "\n" + value3 + journalnum

                   + datevalue2 + effectivedateloc + effectivedateloc + amountcurdebit + "." + any2Str(ledgerJournalTrans.AmountCurDebit));

           return con;

       }

       else

       {

           return headerACH;

       }   

   }

   protected container createBatchHeaderRecord()

   {

       container   headerBatch;

       headerBatch =  next createBatchHeaderRecord();

       if(ledgerJournalTrans.PaymentStatus == CustVendPaymStatus::None)

       {

           headerBatch = conNull();

           return headerBatch;

       }

       else

       {

           return headerBatch;

       }

   }

   protected container createBatchControlRecord()

   {

       container   headerBatch;

       headerBatch = next createBatchControlRecord();

       if(ledgerJournalTrans.PaymentStatus == CustVendPaymStatus::None)

       {

           headerBatch = conNull();

           return headerBatch;

       }

       else

       {

           return headerBatch;

       }

   }

 

   protected container createACH_ControlRecord()

   {

       container   headerBatch;

       container  contai;

       str  con = "lohith";

       headerBatch = next createACH_ControlRecord();

       if(ledgerJournalTrans.PaymentStatus == CustVendPaymStatus::None)

       {

           headerBatch = conNull();

           return headerBatch;

       }

       else

       {

           return headerBatch;

       }

   }

}

..............................

[ExtensionOf(classstr(VendOutPaymRecord_NACHA_CCD))]

internal final class DaxVendOutpaymRecord_NACHA_CCD_Extension

{

   protected void initRecord()

   {

       next initRecord();

       outputRecord = "";

   }

}


OutPut :








No comments:

Post a Comment