In my case, I am going to create Payment journal and vouchers based on multiple Free text invoices. Same process can also be followed for multiple Sales orders.
Create a button on Free text invoice / All sales order form and and set 'MultiSelect' property to YES.
Then, On clicked method of the button, write the code as below
That's it!!
Create a button on Free text invoice / All sales order form and and set 'MultiSelect' property to YES.
Then, On clicked method of the button, write the code as below
void clicked() { CustInvoiceTable custInvoiceTable_loc; SysOperationProgress progressBar = new SysOperationProgress(); Counter progressCount,progressTotal; Ledgerjournalname ledgerjournalname; LedgerjournalTable LedgerjournalTable; LedgerjournalTrans LedgerjournalTrans; CustTable custtable_loc; NumberSeq numberSeq; CustParameters custParametersExt; #avifiles super(); for (custInvoiceTable_loc = getFirstSelection(CustInvoiceTable_ds);custInvoiceTable_loc;custInvoiceTable_loc = CustInvoiceTable_ds.getNext()) {//this is just for total count if (custInvoiceTable_loc.Posted == NoYes::Yes) { progressTotal++; } } progressBar.setCaption(strfmt("Creating payment lines")); progressBar.setAnimation(#aviUpdate); progressBar.setTotal(progressTotal); progressCount = 1; select ledgerjournalname where ledgerjournalname.JournalName == custParametersExt.CustPaymJournalName; ttsBegin; LedgerjournalTable.JournalName = ledgerjournalname.JournalName; LedgerjournalTable.initFromLedgerJournalName(); LedgerjournalTable.JournalNum = JournalTableData::newTable(LedgerjournalTable).nextJournalId(); LedgerjournalTable.insert(); for (custInvoiceTable_loc = getFirstSelection(CustInvoiceTable_ds);custInvoiceTable_loc;custInvoiceTable_loc = CustInvoiceTable_ds.getNext()) { progressBar.setText(strfmt("Creating payment for invoice %1,total payment created",custInvoiceTable_loc.InvoiceId,progressCount)); progressBar.setCount(progressCount); if (custInvoiceTable_loc.Posted == NoYes::Yes) { custtable_loc = CustTable::find(custInvoiceTable_loc.InvoiceAccount); numberSeq = NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable)); LedgerjournalTrans.Voucher = numberSeq.voucher(); LedgerjournalTrans.JournalNum = LedgerjournalTable.JournalNum; LedgerjournalTrans.AccountType = LedgerJournalACType::Cust; LedgerjournalTrans.Company = curext(); LedgerjournalTrans.parmAccount(custtable_loc.AccountNum,LedgerjournalTrans.AccountType); LedgerjournalTrans.initFromCustTable(custtable_loc); LedgerjournalTrans.TransDate = systemDateGet(); LedgerjournalTrans.Invoice = custInvoiceTable_loc.InvoiceId; //Marked Invoice can also be selected if required for settlement LedgerjournalTrans.ExchRate = Currency::exchRate(LedgerjournalTrans.CurrencyCode); LedgerjournalTrans.Txt = strFmt('Payment for Invoice %1',LedgerjournalTrans.Invoice); LedgerjournalTrans.OffsetAccountType = LedgerJournalACType::Bank;//Select as required; LedgerJournalTrans.parmOffsetAccount(custParametersExt.BankAccountID,LedgerjournalTrans.OffsetAccountType); LedgerjournalTrans.DefaultDimension = custtable_loc.DefaultDimension; LedgerjournalTrans.OffsetDefaultDimension = custtable_loc.DefaultDimension; LedgerjournalTrans.TransactionType = LedgerTransType::Payment; LedgerjournalTrans.InstallmentNum = installmentNum; LedgerjournalTrans.PaymMode = custPaymMode; LedgerjournalTrans.AmountCurCredit = custInvoiceTable_loc.InvoiceAmount() LedgerjournalTrans.insert(); } progressCount++; } ttscommit; CustInvoiceTable_ds.reread(); }
That's it!!
Good articles, Have you heard of LFDS (Le_Meridian Funding Service, Email: lfdsloans@outlook.com --WhatsApp Contact:+1-9893943740--lfdsloans@lemeridianfds.com) is as USA/UK funding service they grant me loan of $95,000.00 to launch my business and I have been paying them annually for two years now and I still have 2 years left although I enjoy working with them because they are genuine Loan lender who can give you any kind of loan.
ReplyDeleteNice Article Thanks for sharing this post
ReplyDeleteSupply Chain Management Online Training Course
Dynamics 365 Supply Chain Management Training
D365 Supply Chain Management Functional(T&L)
Dynamics 365 Trade and Logistics Functional Training
Dynamics 365 Supply Chain in Hyderabad
MS Dynamics Trade Logistics Training Hyderabad
Dynamics AX Trade and Logistics Online Training
Microsoft Dynamics Course in Hyderabad
MS Dynamics trade and logistics training
Supply Chain Management Course Online