class DTPaymentTrackingBatchServiceLoc extends SysOperationServiceBase { public void processOperation() { CustInvoiceSalesLink custInvoiceSalesLink; SalesTable salesTable; InterCompanyPurchSalesReference interCompanyPurchSalesReference; //TO GET RELATED PURCHASE ORDER FROM INVOICED SALES ID while select * from custInvoiceSalesLink join salesTable where salesTable.SalesId == custInvoiceSalesLink.SalesId { select firstonly purchid from interCompanyPurchSalesReference where interCompanyPurchSalesReference.SalesId == salesTable.SalesId; if(interCompanyPurchSalesReference.PurchId != "") { this.InsertInvoicesDetails(custInvoiceSalesLink,salesTable); } } } public void InsertInvoicesDetails(CustInvoiceSalesLink _custInvoiceSalesLink,SalesTable _salesTable) { CustInvoiceSalesLink custInvoiceSalesLinkloc; SalesTable salestable; DTCustomerDetailsTable dTCustomerDetailsTable; InterCompanyPurchSalesReference InterCompanyPurchSalesReference; Purchtable purchTable,purchTableloc; VendTrans vendTrans; Custtable custtable; DirPartyTable dirPartyTable; HCMWORKER HcmWorker; VendInvoiceJour vendInvoiceJour,vendInvoiceJourloc; DTPaymentTrackingTbl dTPaymentTrackingTbl,dTPaymentTrackingTblUpdate; //InterCompanyPurchId PruchId; container intPruchId; CustInvoiceId invoiceid; InterCompanyCompanyId intercompanyId; AmountCur amountCur; //SalesId salesId; VendInvoiceId vendInvoiceId; VendInvoiceAccount vendInvoiceAccount; TransDate transDate; Voucher voucher; str salesId,salesStatus,value; AmountMST remainingAmountMST; AmountMSTDebCred amountMST; int i, length; //TO GET THE RELATED PURCHID FROM REFRENCE TABLE. while select PurchId from InterCompanyPurchSalesReference where InterCompanyPurchSalesReference.SalesId == _salestable.SalesId && salestable.SalesId == _custInvoiceSalesLink.SalesId { intPruchId += InterCompanyPurchSalesReference.PurchId; } invoiceid = _custInvoiceSalesLink.InvoiceId; //intercompanyId = salestable.InterCompanyCompanyId; salesId = _custInvoiceSalesLink.SalesId; salesStatus = enum2Str(salestable.SalesStatus); dTPaymentTrackingTbl.DTWorkerName = HcmWorker::find(salesTable.WorkerSalesResponsible).name(); dTPaymentTrackingTbl.InvoiceAccount = _custInvoiceSalesLink.InvoiceAccount; dTPaymentTrackingTbl.Name = _custInvoiceSalesLink.custTable_OrderAccount().name(); dTPaymentTrackingTbl.CustomerRef = salestable.CustomerRef; dTPaymentTrackingTbl.SalesId = salesId; dTPaymentTrackingTbl.InvoiceId = invoiceid; //TO GET SALES ORDER DETAILS FROM CUSTOMER DETAILS TABLE select * from dTCustomerDetailsTable where dTCustomerDetailsTable.InvoiceId == invoiceid && dTCustomerDetailsTable.SalesId == salesId && dTCustomerDetailsTable.CustAccount == _custInvoiceSalesLink.InvoiceAccount && dTCustomerDetailsTable.InvoiceDate == _custInvoiceSalesLink.InvoiceDate; dTPaymentTrackingTbl.PackingSlipId = dTCustomerDetailsTable.PackingSlipId; dTPaymentTrackingTbl.InvoiceAmount = dTCustomerDetailsTable.InvoiceAmount; dTPaymentTrackingTbl.AmountNotSettled = dTCustomerDetailsTable.AmountNotSettled; dTPaymentTrackingTbl.DTCustInvoicePaymtType = dTCustomerDetailsTable.DTCustInvoicePaymtType; dTPaymentTrackingTbl.DTInvoiceStatus = salesStatus; // LOOP TO GET THE DATA OF PURCH TABLE length = conLen(intPruchId); for (i = 1; i <= length; i++) { value = conPeek(intPruchId,i); dTPaymentTrackingTbl.InterCompanyPurchId += value; select * from purchTable where purchTable.PurchId == value; dTPaymentTrackingTbl.DTDateTime = purchTable.CreatedDateTime; while select sum(InvoiceAmount) from vendInvoiceJour where vendInvoiceJour.PurchId == value { amountCur += vendInvoiceJour.InvoiceAmount; } dTPaymentTrackingTbl.VendInvoiceAMT = amountCur; select vendInvoiceJourloc where vendInvoiceJourloc.PurchId == value; vendInvoiceId = vendInvoiceJourloc.InvoiceId; vendInvoiceAccount = vendInvoiceJourloc.InvoiceAccount; transDate = vendInvoiceJourloc.InvoiceDate; voucher = vendInvoiceJourloc.LedgerVoucher; while select * from vendtrans where vendtrans.Invoice == vendInvoiceId && vendtrans.AccountNum == vendInvoiceAccount && vendtrans.TransDate == transDate && vendtrans.Voucher == voucher && vendtrans.TransType == 3 { amountMST += vendtrans.AmountMST; remainingAmountMST += vendtrans.remainAmountMST(); } if(vendtrans) { if(amountMST == remainingAmountMST && remainingAmountMST != 0 && amountMST != 0) { dTPaymentTrackingTbl.PurchStatus = DTVendInvoicePaymentType::NotPaid; } else if(amountMST != remainingAmountMST && remainingAmountMST != 0) { dTPaymentTrackingTbl.PurchStatus = DTVendInvoicePaymentType::PartiallyPaid; } else if(amountMST != 0 && remainingAmountMST == 0) { dTPaymentTrackingTbl.PurchStatus = DTVendInvoicePaymentType::FullyPaid; } } } select firstonly dTPaymentTrackingTblUpdate where dTPaymentTrackingTblUpdate.SalesId == dTPaymentTrackingTbl.SalesId && dTPaymentTrackingTblUpdate.InterCompanyPurchId == dTPaymentTrackingTbl.InterCompanyPurchId && dTPaymentTrackingTblUpdate.InvoiceId == dTPaymentTrackingTbl.InvoiceId && dTPaymentTrackingTblUpdate.PackingSlipId == dTPaymentTrackingTbl.PackingSlipId; if(dTPaymentTrackingTblUpdate.RecId != 0) { this.UpdateInvoicesDetails(dTPaymentTrackingTbl); } else { dTPaymentTrackingTbl.insert(); } }
// LOOP TO GET THE DATA OF PURCH TABLE length = conLen(intPruchId); for (i = 1; i <= length; i++) { value = conPeek(intPruchId,i); dTPaymentTrackingTbl.InterCompanyPurchId += value; select * from purchTable where purchTable.PurchId == value; dTPaymentTrackingTbl.DTDateTime = purchTable.CreatedDateTime; while select sum(InvoiceAmount) from vendInvoiceJour where vendInvoiceJour.PurchId == value { amountCur += vendInvoiceJour.InvoiceAmount; } dTPaymentTrackingTbl.VendInvoiceAMT = amountCur; select vendInvoiceJourloc where vendInvoiceJourloc.PurchId == value; vendInvoiceId = vendInvoiceJourloc.InvoiceId; vendInvoiceAccount = vendInvoiceJourloc.InvoiceAccount; transDate = vendInvoiceJourloc.InvoiceDate; voucher = vendInvoiceJourloc.LedgerVoucher; while select * from vendtrans where vendtrans.Invoice == vendInvoiceId && vendtrans.AccountNum == vendInvoiceAccount && vendtrans.TransDate == transDate && vendtrans.Voucher == voucher && vendtrans.TransType == 3 { amountMST += vendtrans.AmountMST; remainingAmountMST += vendtrans.remainAmountMST(); } if(vendtrans) { if(amountMST == remainingAmountMST && remainingAmountMST != 0 && amountMST != 0) { dTPaymentTrackingTbl.PurchStatus = DTVendInvoicePaymentType::NotPaid; } else if(amountMST != remainingAmountMST && remainingAmountMST != 0) { dTPaymentTrackingTbl.PurchStatus = DTVendInvoicePaymentType::PartiallyPaid; } else if(amountMST != 0 && remainingAmountMST == 0) { dTPaymentTrackingTbl.PurchStatus = DTVendInvoicePaymentType::FullyPaid; } } }
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 683 Most Valuable Professional
André Arnaud de Cal... 563 Super User 2025 Season 2
Sohaib Cheema 398 User Group Leader