To create JV and Post by using class
To create JV and Post by using class:
[SysEntryPointAttribute]
public void InterPropsaol(WRE_InterestProposalDC _WRE_InterestProposalDC)
{
QueryRun queryrun;
BankAccountTable bankAccountTable;
WRE_LoanDetails wre_LoanDetails;
WRE_LoanDetailsTrans wre_LoanDetailsTrans;
AxLedgerJournalTrans journalTrans; // class
AxLedgerJournalTable journalTable;
DimensionAttributeValueCombination ledgerDimension, ledgerDimension2;
//<Wrexim_Shafee_7/11/2017>
TransDate effectiveDate;
WRE_BankPostingTable bankPostingTable, bankPostingTable2;
MainAccount mainAccount;
LedgerJournalTrans ledgerJournalTrans;
BankAccountID accountId;
Wre_BankInterestPosted wre_BankInterestPosted;
MainAccountNum bankAccountLedgerDimension;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
str dept, subDept, location, units;
RecId bankDim;
//</Wrexim_Shafee_7/11/2017>
real intrestAmout, totalIntrestAmout;
LedgerJournalTable ledgerJournalTable; // table
ledgerJournalCheckPost ledgerJournalCheckPost;// table
container acctPattern, offSetAcctPattern, acctLoanBank;
journalTable = new AxLedgerJournalTable();
journalTrans = new AxLedgerJournalTrans();
queryRun = new queryRun(_WRE_InterestProposalDC.getQuery());
effectiveDate = _WRE_InterestProposalDC.parmDate(); //<Wrexim_Shafee_24/10/2017>
while(queryRun.next())
{
bankAccountTable = queryRun.get(tableNum(bankAccountTable));
//<Wrexim_Shafee_24/10/2017>
dimStorage = DimensionAttributeValueSetStorage::find(bankAccountTable.DefaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Departments")
{
dept = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "SubDepartments")
{
subDept = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Location")
{
location = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "unitsGOFSCO")
{
units = dimStorage.getDisplayValueByIndex(i);
}
}
bankAccountLedgerDimension = MainAccount::find(DimensionAttributeValueCombination::find(bankAccountTable.LedgerDimension).MainAccount).MainAccountId;
select wre_BankInterestPosted
where wre_BankInterestPosted.BankAccount == bankAccountTable.AccountID
&& wre_BankInterestPosted.Date == effectiveDate;
if(wre_BankInterestPosted)
{
throw warning(strFmt("Interest for bank %1 for %2 is already posted",wre_BankInterestPosted.BankAccount,wre_BankInterestPosted.Date));
}
else
{
//</Wrexim_Shafee_24/10/2017>
while select wre_LoanDetailsTrans
join wre_LoanDetails
where wre_LoanDetailsTrans.BankAccountID == wre_LoanDetails.BankAccountID
&& wre_LoanDetails.BankAccountID == bankAccountTable.AccountID
&& wre_LoanDetailsTrans.EffEndDate <= effectiveDate //<Wrexim_Shafee_24/10/2017>
{
accountId = wre_LoanDetailsTrans.BankAccountID;
intrestAmout = wre_LoanDetailsTrans.Amount;
totalIntrestAmout = totalIntrestAmout + intrestAmout;
totalIntrestAmout = decRound(totalIntrestAmout, 2);
}
//
journalTable.parmJournalName("IntJn");
journalTable.save();
journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(systemDateGet());
journalTrans.parmCurrencyCode("KWD");
journalTrans.parmAmountCurDebit(totalIntrestAmout);
journalTrans.parmBankAccountId(wre_LoanDetailsTrans.BankAccountID);
//<Wrexim_Shafee_24/10/2017>
select bankPostingTable
join ledgerDimension
where bankPostingTable.Accounts == ledgerDimension.RecId
&& bankPostingTable.WRE_LedgerTransactionsTye == WRE_LedgerTransactionsTye::InterestExp
join mainAccount
where mainAccount.RecId == ledgerDimension.MainAccount;
info(strFmt("%1",ledgerDimension.RecId));
acctPattern = [ledgerDimension.DisplayValue, mainAccount.MainAccountId, 0];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
journalTrans.parmAccountType(bankPostingTable.LedgerJournalACType);
journalTrans.parmLedgerTransactionsTye(WRE_LedgerTransactionsTye::InterestExp);
select bankPostingTable2
join ledgerDimension2
where bankPostingTable2.Accounts == ledgerDimension2.RecId
&& bankPostingTable2.WRE_LedgerTransactionsTye == WRE_LedgerTransactionsTye::IntExpensePayable
join mainAccount
where mainAccount.RecId == ledgerDimension2.MainAccount;
info(strFmt("%1--%2",ledgerDimension2.RecId,mainAccount.MainAccountId));
offSetAcctPattern = [ledgerDimension2.DisplayValue, mainAccount.MainAccountId, 0];
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern));
//</Wrexim_Shafee_24/10/2017>
journalTrans.save();
ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
ledgerJournalCheckPost.run();
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
//<Wrexim_Shafee_7/11/2017>
//acctLoanBank = [accountId, bankAccountLedgerDimension, 4, "Departments", dept, "SubDepartments", subDept, "Location", location, "unitsGOFSCO", units];
select forUpdate ledgerJournalTrans
where ledgerJournalTrans.JournalNum == journalTable.ledgerJournalTable().JournalNum;
ttsBegin;
//ledgerJournalTrans.Wre_LoanBank = AxdDimensionUtil::getLedgerAccountId(acctLoanBank);
ledgerJournalTrans.LoanBankAccountId = accountId +" - "+ dept +" - "+ subDept +" - "+ location +" - "+ units;
ledgerJournalTrans.update();
ttsCommit;
wre_BankInterestPosted.BankAccount = accountId;
wre_BankInterestPosted.Date = effectiveDate;
wre_BankInterestPosted.InterestPaid = totalIntrestAmout;
wre_BankInterestPosted.JournalNum = journalTable.ledgerJournalTable().JournalNum;
wre_BankInterestPosted.insert();
while select forUpdate wre_LoanDetailsTrans
where wre_LoanDetailsTrans.BankAccountID == accountId
&& wre_LoanDetailsTrans.EffEndDate <= effectiveDate
{
ttsBegin;
wre_LoanDetailsTrans.InterestPaid = wre_LoanDetailsTrans.Amount;
wre_LoanDetailsTrans.update..
[SysEntryPointAttribute]
public void InterPropsaol(WRE_InterestProposalDC _WRE_InterestProposalDC)
{
QueryRun queryrun;
BankAccountTable bankAccountTable;
WRE_LoanDetails wre_LoanDetails;
WRE_LoanDetailsTrans wre_LoanDetailsTrans;
AxLedgerJournalTrans journalTrans; // class
AxLedgerJournalTable journalTable;
DimensionAttributeValueCombination ledgerDimension, ledgerDimension2;
//<Wrexim_Shafee_7/11/2017>
TransDate effectiveDate;
WRE_BankPostingTable bankPostingTable, bankPostingTable2;
MainAccount mainAccount;
LedgerJournalTrans ledgerJournalTrans;
BankAccountID accountId;
Wre_BankInterestPosted wre_BankInterestPosted;
MainAccountNum bankAccountLedgerDimension;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
str dept, subDept, location, units;
RecId bankDim;
//</Wrexim_Shafee_7/11/2017>
real intrestAmout, totalIntrestAmout;
LedgerJournalTable ledgerJournalTable; // table
ledgerJournalCheckPost ledgerJournalCheckPost;// table
container acctPattern, offSetAcctPattern, acctLoanBank;
journalTable = new AxLedgerJournalTable();
journalTrans = new AxLedgerJournalTrans();
queryRun = new queryRun(_WRE_InterestProposalDC.getQuery());
effectiveDate = _WRE_InterestProposalDC.parmDate(); //<Wrexim_Shafee_24/10/2017>
while(queryRun.next())
{
bankAccountTable = queryRun.get(tableNum(bankAccountTable));
//<Wrexim_Shafee_24/10/2017>
dimStorage = DimensionAttributeValueSetStorage::find(bankAccountTable.DefaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Departments")
{
dept = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "SubDepartments")
{
subDept = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Location")
{
location = dimStorage.getDisplayValueByIndex(i);
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "unitsGOFSCO")
{
units = dimStorage.getDisplayValueByIndex(i);
}
}
bankAccountLedgerDimension = MainAccount::find(DimensionAttributeValueCombination::find(bankAccountTable.LedgerDimension).MainAccount).MainAccountId;
select wre_BankInterestPosted
where wre_BankInterestPosted.BankAccount == bankAccountTable.AccountID
&& wre_BankInterestPosted.Date == effectiveDate;
if(wre_BankInterestPosted)
{
throw warning(strFmt("Interest for bank %1 for %2 is already posted",wre_BankInterestPosted.BankAccount,wre_BankInterestPosted.Date));
}
else
{
//</Wrexim_Shafee_24/10/2017>
while select wre_LoanDetailsTrans
join wre_LoanDetails
where wre_LoanDetailsTrans.BankAccountID == wre_LoanDetails.BankAccountID
&& wre_LoanDetails.BankAccountID == bankAccountTable.AccountID
&& wre_LoanDetailsTrans.EffEndDate <= effectiveDate //<Wrexim_Shafee_24/10/2017>
{
accountId = wre_LoanDetailsTrans.BankAccountID;
intrestAmout = wre_LoanDetailsTrans.Amount;
totalIntrestAmout = totalIntrestAmout + intrestAmout;
totalIntrestAmout = decRound(totalIntrestAmout, 2);
}
//
journalTable.parmJournalName("IntJn");
journalTable.save();
journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(systemDateGet());
journalTrans.parmCurrencyCode("KWD");
journalTrans.parmAmountCurDebit(totalIntrestAmout);
journalTrans.parmBankAccountId(wre_LoanDetailsTrans.BankAccountID);
//<Wrexim_Shafee_24/10/2017>
select bankPostingTable
join ledgerDimension
where bankPostingTable.Accounts == ledgerDimension.RecId
&& bankPostingTable.WRE_LedgerTransactionsTye == WRE_LedgerTransactionsTye::InterestExp
join mainAccount
where mainAccount.RecId == ledgerDimension.MainAccount;
info(strFmt("%1",ledgerDimension.RecId));
acctPattern = [ledgerDimension.DisplayValue, mainAccount.MainAccountId, 0];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
journalTrans.parmAccountType(bankPostingTable.LedgerJournalACType);
journalTrans.parmLedgerTransactionsTye(WRE_LedgerTransactionsTye::InterestExp);
select bankPostingTable2
join ledgerDimension2
where bankPostingTable2.Accounts == ledgerDimension2.RecId
&& bankPostingTable2.WRE_LedgerTransactionsTye == WRE_LedgerTransactionsTye::IntExpensePayable
join mainAccount
where mainAccount.RecId == ledgerDimension2.MainAccount;
info(strFmt("%1--%2",ledgerDimension2.RecId,mainAccount.MainAccountId));
offSetAcctPattern = [ledgerDimension2.DisplayValue, mainAccount.MainAccountId, 0];
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern));
//</Wrexim_Shafee_24/10/2017>
journalTrans.save();
ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
ledgerJournalCheckPost.run();
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
//<Wrexim_Shafee_7/11/2017>
//acctLoanBank = [accountId, bankAccountLedgerDimension, 4, "Departments", dept, "SubDepartments", subDept, "Location", location, "unitsGOFSCO", units];
select forUpdate ledgerJournalTrans
where ledgerJournalTrans.JournalNum == journalTable.ledgerJournalTable().JournalNum;
ttsBegin;
//ledgerJournalTrans.Wre_LoanBank = AxdDimensionUtil::getLedgerAccountId(acctLoanBank);
ledgerJournalTrans.LoanBankAccountId = accountId +" - "+ dept +" - "+ subDept +" - "+ location +" - "+ units;
ledgerJournalTrans.update();
ttsCommit;
wre_BankInterestPosted.BankAccount = accountId;
wre_BankInterestPosted.Date = effectiveDate;
wre_BankInterestPosted.InterestPaid = totalIntrestAmout;
wre_BankInterestPosted.JournalNum = journalTable.ledgerJournalTable().JournalNum;
wre_BankInterestPosted.insert();
while select forUpdate wre_LoanDetailsTrans
where wre_LoanDetailsTrans.BankAccountID == accountId
&& wre_LoanDetailsTrans.EffEndDate <= effectiveDate
{
ttsBegin;
wre_LoanDetailsTrans.InterestPaid = wre_LoanDetailsTrans.Amount;
wre_LoanDetailsTrans.update..
Comments
Post a Comment