Get Ledger journal transactions payment marked invoices for posted and non posted
// Code from customer payment journal report --CustPaymentJournalDP
private LedgerJournalTable ledgerJournalTable;
private LedgerJournalTable tmpLedgerJournalTable;
private LedgerJournalTrans ledgerJournalTrans;
private LedgerJournalTrans tmpLedgerJournalTrans;
private CustTrans tmpCustTrans;
private CustTrans custTrans;
private CustTransOpen custTransOpen;
private CustSettlement custSettlement;
private SpecTrans specTrans;
private LedgerJournalId lastJournalNum;
private AccountNum lastAccountNum;
private Amount sumPaymSettleAmountCur;
private CustPaymentJournalTmp custPaymentJournalTmp;
private RecId ledgerJournalTransRecId;
private Query query;
while (qr.next())
{
tmpLedgerJournalTable = qr.get(tmpLedgerJournalTable.TableId);
this.insertDataFromLedgerJournalTable();
tmpLedgerJournalTrans = qr.get(tmpLedgerJournalTrans.TableId);
this.insertDataFromLedgerJournalTrans();
if (tmpLedgerJournalTable.Posted)
{
LedgerJournalTrans ledgerJournalTransPayment;
if (tmpLedgerJournalTrans.isCompanyIntercompany())
{
ledgerJournalTransPayment = LedgerJournalTrans::findIntercompanyPayment(tmpLedgerJournalTrans);
}
else
{
ledgerJournalTransPayment = tmpLedgerJournalTrans;
}
changecompany(ledgerJournalTransPayment.Company)
{
CustTrans orgCustTrans;
DimensionAttributeValueCombination dimAttrValueCombo;
while select orgCustTrans
order by orgCustTrans.RecId
where orgCustTrans.Voucher == ledgerJournalTransPayment.Voucher
&& orgCustTrans.TransDate == ledgerJournalTransPayment.TransDate
&& orgCustTrans.TransType == LedgerTransType::Payment
join RecId from dimAttrValueCombo
where dimAttrValueCombo.RecId == ledgerJournalTransPayment.LedgerDimension
&& dimAttrValueCombo.DisplayValue == orgCustTrans.AccountNum
{
// Added check if the CustTrans.RecId exists in the set because of
// scenarios where multiple customer transaction exist with the same voucher number.
if (custTransRecIdMap.in(orgCustTrans.RecId))
{
// Already inserted this customer transactions settle, continue
// to see if there are additional customer transaction with same voucher.
continue;
}
else
{
custTransRecIdMap.add(orgCustTrans.RecId);
while select crosscompany custSettlement order by TransDate
where custSettlement.OffsetRecid == orgCustTrans.RecId
&& custSettlement.OffsetAccountNum == orgCustTrans.AccountNum
&& custSettlement.OffsetCompany == orgCustTrans.company()
{
tmpCustTrans = CustTrans::findByCompany(custSettlement.company(), custSettlement.TransRecId);
this.insertDataFromCustTrans();
custPaymentJournalTmp.insert();
detailsinserted = true;
}
break;
}
}
}
}
else // Else, if unposted, get data from SpecTrans.
{
while select crosscompany specTrans
where specTrans.SpecRecId == tmpLedgerJournalTrans.RecId
&& specTrans.SpecTableId == tmpLedgerJournalTrans.TableId
&& specTrans.SpecCompany == tmpLedgerJournalTrans.company()
{
changecompany(tmpLedgerJournalTrans.Company)
{
custTransOpen = specTrans.custTransOpen();
custTrans = specTrans.custTrans();
}
this.insertDataFromSpecTrans();
custPaymentJournalTmp.insert();
detailsinserted = true;
}
}
Comments
Post a Comment