Tuesday, June 20, 2023

Posting Pending Vendor Invoice In d365 fo X++

 As per the standard when a pending vendor invoice is created and posted, it will not populate the data to description field in the vendtrans table, my requirement is to populate the data to the description field in vendtrans table.

[ExtensionOf(classStr(PurchFormLetter_Invoice))]

internal final class DAX_PurchInvoiceJournal_Extension

{

   protected void afterOperationEnd()

   {

       FormletterOutputContract         purchFormLetterOutputContract;

       ParmId                           parmId,parmID2;

       Purchparmline                    purchParmLineTable;

       PurchParmTable                   purchParmTable;

       purchline                        purchlineTable;

       Amount                           purchPreviousPrice,purchCurrentPrice;

       InventTableModule                inventTableModuleTable;

       VendInvoiceJour                  vendInvoiceJournal;

       Amount                           costPrice,profitPercentage,salesPrice,salesCost,salesOverHead;

       VendTrans                         updateVendTrans;

       str                                journalLines;

       VendInvoiceTrans                  vendInvoiceTrans;

       VendInvoiceInfoTable             vendInvoiceInfoTable;

 

       next  afterOperationEnd();

 

       purchFormLetterOutputContract = this.getOutputContract();

 

       vendInvoiceJournal = purchFormLetterOutputContract.parmJournal() as VendInvoiceJour;

 

       if (purchFormLetterOutputContract.parmNumberOfOrdersPosted() > 0)

       {

           select vendInvoiceInfoTable where vendInvoiceInfoTable.ParmId==vendInvoiceJournal.ParmId

                      && vendInvoiceInfoTable.PurchId==vendInvoiceJournal.PurchId;

 

           select forupdate updateVendTrans where updateVendTrans.Voucher==vendInvoiceJournal.LedgerVoucher

                       && updateVendTrans.TransDate == vendInvoiceJournal.InvoiceDate

                       && updateVendTrans.AccountNum == vendInvoiceJournal.InvoiceAccount;

        if (updateVendTrans.RecId)

           {

               ttsbegin;

               updateVendTrans.Txt=vendInvoiceInfoTable.Description;

               updateVendTrans.doUpdate();

               ttscommit;

           }

       }

   }

 

}

--------------------------------









No comments:

Post a Comment

How to Control Edit Access for Sales Tax Fields in PR Lines Through Configuration in D365 Finance & Operations

 To provide a configuration-driven approach for controlling edit access to the Item Sales Tax Group and Sales Tax Group fields on Purchase...