Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Run ER Payment Model for multiple customer payment journals

(1) ShareShare
ReportReport
Posted on by 6,414
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();
}
 
  • Johnny Profile Picture
    Johnny 6,414 on at
    Run ER Payment Model for multiple customer payment journals
    Hello,
    When we do the process manually "Generate payment" >> OK >> Then comes "Electronic report parameters" dialog.
    I could not find anywhere in code during the debugging, where are those dialog field values initialized. How or where can I find it?
    Since I want to run the whole process in Batch, I off course do not get the "Electronic report parameters" dialog to set the values manually, so I have to do it from code, but I could not find the correct place where to do it.
  • Suggested answer
    Dan Emreus Profile Picture
    Dan Emreus 1,162 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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans