Hi everyone,
I am doing a customization to generate the total of all related invoices to each LedgerJournalTrans row on the Grid for Accounts Receivable’s payment Journal as attached pic shows:
RIght now, I found the way to find the related specTrans for a certain LedgerJournalTrans row Before the Journal is posted in the following way(both single invoice for the single LedgerJournalTrans or multiple invoices for the single LedgerJournalTrans cases work well) :
while select crossCompany specTrans
where specTrans.SpecCompany == _ledgerJournalTrans.company() &&
specTrans.SpecTableId == _ledgerJournalTrans.TableId &&
specTrans.SpecRecId == _ledgerJournalTrans.RecId
{
custTransOpenLocal = specTrans.custTransOpen();
invoicesTotalAmount += custTransOpenLocal.AmountCur; //accumulates invoice(s)’ total
}
However, when the LedgerJournalTrans is posted, the SpecTrans is wiped out, so if the ledgerJournalTrans has only 1 invoice then I can do the following:
total for the invoice = invoiceAmount from the invoice of (_ledgerJournalTrans.invoice)
BUT, what if there are multiple invoices related to the single LedgerJournalTrans row, there is an asterisk here, how to organize the select statement? I know I am close, but I need another condition, the picture is like:
I have problem when there are multiple invoices included in the LedgerJournalTrans record, as the ledgerJournalTrans.invoice is an “*” now. How should I change? I am considering CustTrans / CustSettlement like
While select custTransLocal
where custTransLocal.TransType == LedgerTransType::Payment
join custSettlementLocal
where custSettlementLocal.TransRecId == custTransLocal.RecId
join custTransLocal_Offset
where custSettlementLocal.OffsetRecId == custTransLocal_Offset.RecId
join _ledgerJournalTrans
where _ledgerJournalTrans.Voucher == custTransLocal.Voucher
&& _ledgerJournalTrans.invoice , in this case, it’s an “*”, I cannot use it here, so should I use another way?
Any advice is greatly appreciated!