Hello everyone!
I need to get all vendor invoiced transactions and all vendor honored transactions related to each transaction.
I can't find any good relation between this type of transactions (invoiced to honored). My aim is get the invoiced date and the settlement date to get how many days have passed.
I attach my code and thank you in advance.
static void JRA_VendSettlements(Args _args) { TmpDueDateCompliance_ES_INL TmpDueDateCompliance_ES_INL; VendSettlement VendSettlement; VendInvoiceJour VendInvoiceJour; VendInvoiceTrans VendInvoiceTrans; VendTrans VendTrans, offsetVendTrans; str text; boolean isFreshDelivery; void findSettlement(VendTrans _vendtrans, vendSettlement _vendSettlement) { VendSettlement vendSettlementNew; if (!_vendtrans || !_vendSettlement) return; select firstonly offsetVendTrans order by recid desc where offsetVendTrans.Voucher == _vendSettlement.OffsetTransVoucher && offsetVendTrans.AccountNum == _vendSettlement.AccountNum && offsetVendTrans.RecId != _vendtrans.RecId; if (offsetVendTrans.PromissoryNoteStatus != CustVendNegInstStatus::Honored) { select firstOnly vendSettlementNew where vendSettlementNew.TransRecId == offsetVendTrans.RecId; /*&& vendSettlementNew.TransDate == offsetVendTrans.TransDate && vendSettlementNew.TransCompany == offsetVendTrans.dataAreaId;*/ findsettlement(offsetVendTrans, vendSettlementNew); } } ttsBegin; while select VendSettlement where VendSettlement.AccountNum == '1002' join VendTrans where VendTrans.RecId == VendSettlement.TransRecId && VendTrans.PromissoryNoteStatus == CustVendNegInstStatus::Invoiced { //VendTrans = VendTrans::find(VendSettlement.TransRecId); offsetVendTrans.clear(); VendInvoiceJour = VendInvoiceJour::findFromVendTrans(VendTrans.Invoice, VendTrans.TransDate, VendTrans.AccountNum); findSettlement(VendTrans, VendSettlement); isFreshDelivery = PurchTable::find(VendInvoiceJour.PurchId).FreshDelivery; TmpDueDateCompliance_ES_INL.clear(); TmpDueDateCompliance_ES_INL.AccountNum = VendSettlement.AccountNum; TmpDueDateCompliance_ES_INL.AmountMST = VendSettlement.SettleAmountMST; TmpDueDateCompliance_ES_INL.LedgerVoucher = VendTrans.Voucher; TmpDueDateCompliance_ES_INL.OffsetTransVoucher = VendSettlement.OffsetTransVoucher; TmpDueDateCompliance_ES_INL.DueDate = VendSettlement.DueDate; TmpDueDateCompliance_ES_INL.InvoiceDate = VendTrans.TransDate; TmpDueDateCompliance_ES_INL.InvoiceId = VendTrans.Invoice; TmpDueDateCompliance_ES_INL.PaymDate = offsetVendTrans.TransDate; TmpDueDateCompliance_ES_INL.SettlementVoucher = offsetVendTrans.Voucher; TmpDueDateCompliance_ES_INL.AmountMSTSettle = offsetVendTrans.AmountMST; TmpDueDateCompliance_ES_INL.Status = offsetVendTrans.PromissoryNoteStatus; TmpDueDateCompliance_ES_INL.DaysReal = TmpDueDateCompliance_ES_INL.PaymDate - TmpDueDateCompliance_ES_INL.InvoiceDate; TmpDueDateCompliance_ES_INL.DaysTheory = isFreshDelivery ? 30 : 60; TmpDueDateCompliance_ES_INL.DaysDifference = TmpDueDateCompliance_ES_INL.DaysReal - TmpDueDateCompliance_ES_INL.DaysTheory; if (TmpDueDateCompliance_ES_INL.Status == CustVendNegInstStatus::Invoiced || TmpDueDateCompliance_ES_INL.Status == CustVendNegInstStatus::Honored) TmpDueDateCompliance_ES_INL.insert(); } ttsCommit; }
*This post is locked for comments
Hello Jesus,
Probably have a look at the VendStatistics form and related methods that already does a similar calculation for a single vendor. I believe that you can take out the one or the other peace from there for your purpose.
Best regards,
Ludwig
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,802 Super User 2024 Season 2
Martin Dráb 229,129 Most Valuable Professional
nmaenpaa 101,154