class ledgerSettlementService extends SysOperationServiceBase
{
public void processOperation()
{
GeneralJournalAccountEntry GeneralJournalAccountEntry,GeneralJournalAccountEntryLoc;
GeneralJournalEntry GeneralJournalEntry,GeneralJournalEntryLocal;
LedgerTransSettlement ledgerTransSettlement,ledgerTransSettlementloc,ledgerTransSettlementdata;
LedgerEntryJournal LedgerEntryJournal,LedgerEntryJournalLocal;
real balance;
// Getting dimension from parameters
RefRecId mainAccountRecId = MainAccount::findByMainAccountId(LedgerDimensionFacade::getMainAccountIdFromLedgerDimension(Parameters.WindcaveLedgerDimension)).RecId;
while SELECT PaymentReference from GeneralJournalAccountEntry
group by GeneralJournalAccountEntry.PaymentReference
where GeneralJournalAccountEntry.MainAccount == mainAccountRecId
JOIN GeneralJournalEntry
where GeneralJournalAccountEntry.GeneralJournalEntry == GeneralJournalEntry.RecId
&& GeneralJournalEntry.Ledger == CompanyInfo::find().RecId
&& GeneralJournalEntry.PostingLayer == CurrentOperationsTax::Current
OUTER join LedgerEntryJournal
where generalJournalEntry.LedgerEntryJournal == LedgerEntryJournal.RecId
NOTEXISTS join LedgerTransSettlement
WHERE GeneralJournalAccountEntry.RecId == LedgerTransSettlement.TransRecId
{
// balance = 0;
if(!this.balance(GeneralJournalAccountEntry,mainAccountRecId))
{
ledgerTransSettlementloc.SettleId = NumberSeq::newGetNum(CompanyInfo::numRefParmId()).num();
while SELECT * FROM GeneralJournalAccountEntryLoc
where GeneralJournalAccountEntryLoc.MainAccount == mainAccountRecId
&& GeneralJournalAccountEntryLoc.PaymentReference == GeneralJournalAccountEntry.PaymentReference
JOIN GeneralJournalEntryLocal
where GeneralJournalAccountEntryLoc.GeneralJournalEntry == GeneralJournalEntryLocal.RecId &&
GeneralJournalEntryLocal.Ledger == CompanyInfo::find().RecId
&& GeneralJournalEntryLocal.PostingLayer == 0
OUTER join LedgerEntryJournalLocal
where GeneralJournalEntryLocal.LedgerEntryJournal == LedgerEntryJournalLocal.RecId
NOTEXISTS join ledgerTransSettlementdata
WHERE GeneralJournalAccountEntryLoc.RecId == ledgerTransSettlementdata.TransRecId
//while select GeneralJournalEntryLoc
// where GeneralJournalEntryLoc.PaymentReference == GeneralJournalAccountEntry.PaymentReference
// && GeneralJournalEntryLoc.LedgerDimension == T07_TenderParameters::Find().WindcaveLedgerDimension
{
ledgerTransSettlementloc.TransRecId = GeneralJournalAccountEntryLoc.RecId;
ledgerTransSettlementloc.insert();
}
}
}
}
public real balance(GeneralJournalAccountEntry _generalJournalEntry,RefRecId mainAccount)
{
GeneralJournalAccountEntry GeneralJournalAccountEntry,GeneralJournalEntryLoc;
GeneralJournalEntry GeneralJournalEntry;
LedgerTransSettlement ledgerTransSettlement,ledgerTransSettlementloc;
RecordInsertList settlementCollection;
LedgerEntryJournal LedgerEntryJournal;
real balance = 0;
while SELECT GeneralJournalAccountEntry
where GeneralJournalAccountEntry.MainAccount == mainAccount
&& GeneralJournalAccountEntry.PaymentReference == _generalJournalEntry.PaymentReference
JOIN GeneralJournalEntry
where GeneralJournalAccountEntry.GeneralJournalEntry == GeneralJournalEntry.RecId
&& GeneralJournalEntry.Ledger == CompanyInfo::find().RecId
&& GeneralJournalEntry.PostingLayer == CurrentOperationsTax::Current
OUTER join LedgerEntryJournal
where generalJournalEntry.LedgerEntryJournal == LedgerEntryJournal.RecId
NOTEXISTS join LedgerTransSettlement
WHERE GeneralJournalAccountEntry.RecId == LedgerTransSettlement.TransRecId
//while select GeneralJournalEntryLocal
// where GeneralJournalEntryLocal.PaymentReference == GeneralJournalEntry.PaymentReference
// && GeneralJournalEntryLocal.LedgerDimension == T07_TenderParameters::Find().WindcaveLedgerDimension
{
balance += GeneralJournalAccountEntry.AccountingCurrencyAmount;
}
return balance;
}
}
No comments:
Post a Comment