Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Run ER Payment Model f...
Finance forum
Unanswered

Run ER Payment Model for multiple customer payment journals

Posted on by 6,390
Hello,
some time ago we have developed a solution where when generating payment from customer payment journal with ER, we are saving the file directly to Azure storage.
But this is done manually with standard steps:
Open customer payment journal >> Functions >> Generate Payment.
 
We want to automate it, so we can Generate multiple customer payments with batch processing.
 
To test some solutions I have create controller and service classes.
In the service class I have the following code:
"jourNum" and "journNum2" are just Journal numbers for testing purposes on 2 different journals.
What is happening here is that "custVendSumForPaym.runOperation();" executes the logic (as by standard) to Generate the payment and if the ER format is setup, it sends it to ER for processing.
The problem we have here is that even though below while select loop goes through the both journal, at the end ER only picks up the first journal number for processing and therefore we only see 1 journal with "Sent" status and file in destination.
 
So, jourNum is selected and executed, goes through all the standard methods that is run by "custVendSumForPaym.runOperation();".
Then it comes back to while select and selects the journNum2 and goes through all the tandard methods that is run by "custVendSumForPaym.runOperation();".
When I debug (in batch) it kinda feels that process is over, but after about 1 minute, breakpoint is hit in some ER classes, where we see, that it is processing the file for jourNum only and then the process ends. jourNum2 isn't taken into account.
 
So, I guess, first question would be, if you maybe have better suggestion how to achieve to run "Generate payment" in batch for multiple journals (I could not find standard batch job for it), which would also use ER as it is setup.
Second questions would be, if you have any suggestions what to change in the code below, because it is kinda the only modification in this process. (There is a custom class to send files to Azure, but it processes the Stream that it will get)
while select journalTable
    where   journalTable.Posted     == NoYes::No    &&
            journalTable.JournalNum == jourNum || journalTable.JournalNum == jourNum2
    join    journalTrans
    where   journalTrans.JournalNum     == journalTable.JournalNum &&
            (journalTrans.PaymentStatus == CustVendPaymStatus::None ||
            journalTrans.PaymentStatus  == CustVendPaymStatus::Rejected)
{
    custVendSumForPaym = CustVendSumForPaym::newLedgerJournalTrans(journalTrans);
    custVendSumForPaym.parmPaymMode(journalTrans.PaymMode);
    custVendSumForPaym.parmBankAccountID(CustPaymModeTable::find(journalTrans.PaymMode).bankAccountTable().AccountID);
    custVendSumForPaym.runOperation();
}
 
  • Suggested answer
    Dan Emreus Profile Picture
    Dan Emreus 1,150 on at
    Run ER Payment Model for multiple customer payment journals
    Hi,
     
    I built something similar to this a couple of years ago but it is also a crosscompany job that by company loops through open payment journals and than finally using the standard class CustVendPaymErExport with the parameters needed to generate the payments. I found how it is used in standard and just copied it for my needs. Hope this helps.
     
    Good luck!
     
    /Dan
     

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,556 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,625 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans