Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

vendor payment journal grouping on method of payment

Posted on by 155

Hello,

I see CustVendPaymProposalTransferToJournal run method starts the process of transferring the invoices from vendor payment proposal to journal on click of create payments , however can anyone tell how grouping of invoices are done based on method of payment, for example if method of payment has period set as Total for all invoices then only one payment line is created per vendor. I want to take out a invoice from respective groups and create new payment line for it based on a condition.

*This post is locked for comments

  • Shripriya Profile Picture
    Shripriya 155 on at
    RE: vendor payment journal grouping on method of payment

    thanks for all your responses Sukrut!!

  • Shripriya Profile Picture
    Shripriya 155 on at
    RE: vendor payment journal grouping on method of payment

    Hi sukrut, when you refer "you can get previous invoices" i.e. I need to create any map or table to hold them so that I can access them in my addCustVendTransOpen method? Because I see that all previous invoices are getting inserted in SpecTransInsertTmp towards end of addCustVendTransOpen  method but this will give null records if I create new instance of this temp table in CustVendPaymProposal. Is there any other way I can get previous invoices in addCustVendTransOpen method? or even if I get new hash key for each invoice with total period, in second call to addCustVendTransOpen how do I get previous invoice?

  • Shripriya Profile Picture
    Shripriya 155 on at
    RE: vendor payment journal grouping on method of payment

    Hi Sukrut,

    I had initially checked this but this.invoice in generateHashKey is empty in step1 and also the code in step 2 does not get executed if my payment method for given line is anything other than Invoice, in my case if payment method is Invoice then standard works fine as there is one payment proposal line per invoice with new hashkey for each invoice, however, if payment method has period set to Total,Week or date then hashkey is giving same value. As hashkey value is coming same in case of method of payment other than invoice hence

    if (paymentProposalLineMap.exists(hashKey) ) condition is true in addCustVendTransOpen and new paymProposalLine is not build . The proposal line is assigned same recid as the lookup(hashkey) on satisfying if condition. so in my case of Invoice1,Invoice2,Invoice3 with same method of payment period set as Total, I get same hash key and 1 proposal line. I need to change this behavior to exclude invoice3 from same proposal line by checking if "strlen(invoice1.InvoiceId + Invoice2.InvoiceId) < requiredLimit ".Please let me know if I am missing anything here. I checked the key values in debug mode.

  • Shripriya Profile Picture
    Shripriya 155 on at
    RE: vendor payment journal grouping on method of payment

    Hi sukrut,

    For example Invoice1 , Invoice 2 and Invoice 3 have same dates and say all have payment method period as Total or Date wise . So as per standard this will create only one payment proposal line(paymProposalLine 1), as there will be 3 calls to addCustVendTransOpen and in second and third call we will have same hashkey through below line

    int hashKey = paymProposalLine.generateHashKey();

    so as per standard if condition which is below comes as true for 2nd and 3rd invoice

    if (paymentProposalLineMap.exists(hashKey) )

    and creation of new paymProposalLine is skipped for invoice2 and invoice3 .

    Now all 3 _custVendTransOpen along with same paymProposal recid get inserted in SpecTransInsertTmp towards end of every call to addCustVendTransOpen.

    Now I want to remove 3rd invoice from this proposal line depending on if strLen(Invoice1.InvoiceId+Invoice2.InvoiceId) > requiredLength before it gets added to paymProposalLine 1 and instead create a new paymentProposalLine 2 for Invoice3 which can be done if I let the else part of below if condition in addCustVendTransOpen to execute

     if (paymentProposalLineMap.exists(hashKey) )

    However I do not have a way to query Invoice1, Invoice2(I am referring these as old invoices that are already part of paymProposalLine 1) during 3rd call to addCustVendTransOpen. In generateKey method also I do not see invoice id for payment method type Total and even if I had invoice Id , say I have InvoiceId for Invoice 3 still I will not have Invoice1 and Invoice2 context here to get the summation of invoiceIds for both , without which I cannot have logic to exclude invoice 3 from paymProposalLine 1.

    Please let me know if should add more details to example.

  • Shripriya Profile Picture
    Shripriya 155 on at
    RE: vendor payment journal grouping on method of payment

    Hi Sukrut,

    I have added the example with steps. Please check.

    1) Inside addCustVendTransOpen method of CustVendPaymProposal , I need to skip

    using existing payment proposal line and go to else part to create new proposal line so I have modified if condition by adding "&& !invalidPaymModeGroup" as below. However to know if it is an invalid group for current _custVendTransOpen which is part of method parameter, I also need data of previous invoices that are part of given proposal line(as in step 2). invalidPaymModeGroup Boolean is set as per step 2.

    if (paymentProposalLineMap.exists(hashKey) && !invalidPaymModeGroup)

               {

                   paymProposalLine.RecId = paymentProposalLineMap.lookup(hashKey);

                   if (canUseCustVendPaymProposalLineSetBasedInsert)

                   {

                       paymProposalLine.TmpRecId = paymProposalLine.RecId;

                   }

               }

    2)          The addCustVendTransOpen method keeps inserting invoices of given payment proposal line inside SpecTransInsertTmp towards end of method using below line.

    this.insertSpecTrans(custVendTrans, _custVendTransOpen, paymProposalLine, _paymAmountInvoiceCur, cashDiscToTake);  

    So, towards beginning of addCustVendTransOpen method I needed to find all the invoices that were inserted in SpecTransInsertTmp with same payment proposal recid as SpecRecId and custVendTransOpen as refRecId . From that I can get custVendTrans to get invoice Ids. however, I cannot query temp table here and  also I cannot get previous invoices in generateKey or buildPaymProposalLine method as invoiceId is directly assigned on proposal line only if method of payment has period set to Invoice. I need to do something like below to query previous invoices for current proposal line but unable to get previous invoices for it in addCustVendTransOpen method. If I get invoices then I can set my Boolean invalidPaymModeGroup before the if condition in Step 1 .

              int hashKey = paymProposalLine.generateHashKey();

               CustVendPaymProposalLine localCustVendPaymProposalLine;

               boolean                                 invalidPaymModeGroup  = false;

               CustVendTransOpen             localCustVendTransOpen;

               CustVendTrans                      localCustVendTrans;

               RecId                                     paymProposalLookupRecId;

               SpecTransInsertTmp             localSpecTrans;

               CustVendTransOpenData     localCustVendTransOpenData;

               paymProposalLookupRecId = paymentProposalLineMap.exists(hashKey) ?

                                         paymentProposalLineMap.lookup(hashKey) : 0;

                   while select localCustVendTransOpen

                           join localSpecTrans

                          where localCustVendTransOpen.RecId         == localSpecTrans.RefRecId

                             && localCustVendTransOpen.TableId       == localSpecTrans.RefTableId

                             && localCustVendTransOpen.DataAreaId == localSpecTrans.RefCompany

                             && localSpecTrans.SpecCompany             == localCustVendPaymProposalLine.DataAreaId

                             && localSpecTrans.SpecTableId                 == localCustVendPaymProposalLine.TableId

                             && localSpecTrans.SpecRecId                    == paymProposalLookupRecId            

               {

                   custVendTransOpenData = CustVendTransOpenData::construct(localCustVendTransOpen);

                   localCustVendTrans    = custVendTransOpenData.custVendTrans();

                   if (localCustVendTrans.Invoice)

                   maxInvoiceChar = localCustVendTrans.Invoice+'_';

               }

               maxInvoiceChar = maxInvoiceChar + custVendTrans.Invoice;

               if (maxInvoiceChar != null && strLen(maxInvoiceChar) < requiredLimit)

               {

                   invalidPaymModeGroup = true;

               }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans