// Fetching Journal UnPosted transaction by Ledger from Cust/Vend/Bank/FA/Ledger ax 2012
Table--> ledger Journal Trans
Display Amount AmountAccCur()
{
if(this.Company != curext() && this.CurrencyCode == Ledger::accountingCurrency())
{
return decRound((this.AmountCurDebit + this.AmountCurCredit),3);
}
else
{
return decRound((this.ExchRate * (this.AmountCurDebit + this.AmountCurCredit)/100),3);
}
}
Class-->
Description255 BankLedgerInforCode(Name _AccountNum,RecId _TransRecId)
{
Description255 BankLedInfo;
LedgerJournalTrans trans;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
BankLedInfo = DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find(_AccountNum).LedgerDimension);
return BankLedInfo;
}
Description255 BankLedgerInforCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 BankLedInfo;
LedgerJournalTrans trans;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
BankLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find(_AccountNum).LedgerDimension)).Name;
return BankLedInfo;
}
Description255 CustLedgerInforCode(Name _AccountNum,RecId _TransRecId)
{
Description255 CustLedInfo;
LedgerJournalTrans trans;
CustLedgerAccounts ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgerscustAccounts
where ledgerscustAccounts.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgerscustAccounts1
where ledgerscustAccounts1.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgerscustAccounts1.Num == CustTable::find(_AccountNum).CustGroup;
select firstonly SummaryLedgerDimension from ledgerscustAccounts2
where ledgerscustAccounts2.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts2.AccountCode == TableGroupAll::Table
&& ledgerscustAccounts2.Num == _AccountNum;
if(ledgerscustAccounts)
{
CustLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts.SummaryLedgerDimension);
}
if(ledgerscustAccounts1)
{
CustLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts1.SummaryLedgerDimension);
}
if(ledgerscustAccounts2)
{
CustLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts2.SummaryLedgerDimension);
}
return CustLedInfo;
}
Description255 CustLedgerInforCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 CustLedInfo;
LedgerJournalTrans trans;
CustLedgerAccounts ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgerscustAccounts
where ledgerscustAccounts.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgerscustAccounts1
where ledgerscustAccounts1.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgerscustAccounts1.Num == CustTable::find(_AccountNum).CustGroup;
select firstonly SummaryLedgerDimension from ledgerscustAccounts2
where ledgerscustAccounts2.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts2.AccountCode == TableGroupAll::Table
&& ledgerscustAccounts2.Num == _AccountNum;
if(ledgerscustAccounts)
{
CustLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts.SummaryLedgerDimension)).Name;
}
if(ledgerscustAccounts1)
{
CustLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts1.SummaryLedgerDimension)).Name;
}
if(ledgerscustAccounts2)
{
CustLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts2.SummaryLedgerDimension)).Name;
}
return CustLedInfo;
}
Description255 FALedgerInfoCode(Name _AccountNum,RecId _TransRecId)
{
Description255 FALedInfo;
LedgerJournalTrans trans;
AssetLedgerAccounts ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
LedgerJournalTrans_Asset transAsset;
AssetTransType AssetTransType;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select transAsset
where transAsset.RefRecId == trans.RecId;
select firstonly LedgerDimension from ledgersAssetAccounts
where ledgersAssetAccounts.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts.BookId == transAsset.BookId
&& ledgersAssetAccounts.AccountCode == TableGroupAll::All
&& ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType));
select firstonly LedgerDimension from ledgersAssetAccounts1
where ledgersAssetAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts1.BookId == transAsset.BookId
&& ledgersAssetAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAssetAccounts1.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts1.AccountRelation == AssetTable::find(_AccountNum).AssetGroup;
select firstonly LedgerDimension from ledgersAssetAccounts2
where ledgersAssetAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts2.BookId == transAsset.BookId
&& ledgersAssetAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAssetAccounts2.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts2.AccountRelation == _AccountNum;
if(ledgersAssetAccounts)
{
FALedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts.LedgerDimension);
}
if(ledgersAssetAccounts1)
{
FALedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts1.LedgerDimension);
}
if(ledgersAssetAccounts2)
{
FALedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts2.LedgerDimension);
}
return FALedInfo;
}
Description255 FALedgerInfoCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 FALedInfo;
LedgerJournalTrans trans;
AssetLedgerAccounts ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
LedgerJournalTrans_Asset transAsset;
AssetTransType AssetTransType;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select transAsset
where transAsset.RefRecId == trans.RecId;
select firstonly LedgerDimension from ledgersAssetAccounts
where ledgersAssetAccounts.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts.BookId == transAsset.BookId
&& ledgersAssetAccounts.AccountCode == TableGroupAll::All
&& ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType));
select firstonly LedgerDimension from ledgersAssetAccounts1
where ledgersAssetAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts1.BookId == transAsset.BookId
&& ledgersAssetAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAssetAccounts1.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts1.AccountRelation == AssetTable::find(_AccountNum).AssetGroup;
select firstonly LedgerDimension from ledgersAssetAccounts2
where ledgersAssetAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts2.BookId == transAsset.BookId
&& ledgersAssetAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAssetAccounts2.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts2.AccountRelation == _AccountNum;
if(ledgersAssetAccounts)
{
FALedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts.LedgerDimension)).Name;
}
if(ledgersAssetAccounts1)
{
FALedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts1.LedgerDimension)).Name;
}
if(ledgersAssetAccounts2)
{
FALedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts2.LedgerDimension)).Name;
}
return FALedInfo;
}
Description255 VendLedgerInfoCode(Name _AccountNum,RecId _TransRecId)
{
Description255 VendLedInfo;
LedgerJournalTrans trans;
VendLedgerAccounts ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgersAccounts
where ledgersAccounts.PostingProfile == trans.PostingProfile
&& ledgersAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgersAccounts1
where ledgersAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAccounts1.Num == VendTable::find(_AccountNum).VendGroup;
select firstonly SummaryLedgerDimension from ledgersAccounts2
where ledgersAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAccounts2.Num == _AccountNum;
if(ledgersAccounts)
{
VendLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts.SummaryLedgerDimension);
}
if(ledgersAccounts1)
{
VendLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts1.SummaryLedgerDimension);
}
if(ledgersAccounts2)
{
VendLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts2.SummaryLedgerDimension);
}
return VendLedInfo;
}
Description255 VendLedgerInfoCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 VendLedInfo;
LedgerJournalTrans trans;
VendLedgerAccounts ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgersAccounts
where ledgersAccounts.PostingProfile == trans.PostingProfile
&& ledgersAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgersAccounts1
where ledgersAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAccounts1.Num == VendTable::find(_AccountNum).VendGroup;
select firstonly SummaryLedgerDimension from ledgersAccounts2
where ledgersAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAccounts2.Num == _AccountNum;
if(ledgersAccounts)
{
VendLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts.SummaryLedgerDimension)).Name;
}
if(ledgersAccounts1)
{
VendLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts1.SummaryLedgerDimension)).Name;
}
if(ledgersAccounts2)
{
VendLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts2.SummaryLedgerDimension)).Name;
}
return VendLedInfo;
}
private void insertLedgerJournalTmp(
LedgerJournalTable _ledgerJournalTable,
LedgerJournalTrans _ledgerJournalTrans,
AccountOffsetaccount _accountOffsetAccount = AccountOffsetaccount::Account)
{
StagTmpTable.JournalId = _ledgerJournalTable.JournalNum;
StagTmpTable.TransRecId = _ledgerJournalTrans.RecId;
if(_accountOffsetAccount == AccountOffsetaccount::OffsetAccount
&& _ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
StagTmpTable.AccountType = _ledgerJournalTrans.OffsetAccountType;
StagTmpTable.LedgerDimension = _ledgerJournalTrans.OffsetLedgerDimension;
}
else
{
StagTmpTable.AccountType = _ledgerJournalTrans.AccountType;
StagTmpTable.LedgerDimension = _ledgerJournalTrans.LedgerDimension;
}
StagTmpTable.Company = _ledgerJournalTrans.Company;
StagTmpTable.CurrencyCode = _ledgerJournalTrans.CurrencyCode;
StagTmpTable.Voucher = _ledgerJournalTrans.Voucher;
StagTmpTable.TransDate = _ledgerJournalTrans.TransDate;
StagTmpTable.AmountCurCredit = _ledgerJournalTrans.AmountCurCredit;
StagTmpTable.AmountCurDebit = _ledgerJournalTrans.AmountCurDebit;
StagTmpTable.AccountOffsetaccount = _accountOffsetAccount;
StagTmpTable.TXT = _ledgerJournalTrans.Txt;
StagTmpTable.ExchRate = _ledgerJournalTrans.ExchRate/100;
StagTmpTable.Insert();
}
private LedgerJournalTrans ledgerJournalTransOffset(LedgerJournalTrans _ledgerJournalTrans)
{
AmountCur amountCurLocal;
if (_ledgerJournalTrans.parmOffsetLedgerDimension())
{
if (_ledgerJournalTrans.ledgerJournalTable().LedgerJournalInclTax)
{
if (!(_ledgerJournalTrans.AccountType != LedgerJournalACType::Ledger &&
_ledgerJournalTrans.AccountType != LedgerJournalACType::Project &&
(_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger ||
_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Project)))
{
_ledgerJournalTrans.TaxGroup = '';
_ledgerJournalTrans.TaxItemGroup = '';
_ledgerJournalTrans.TaxCode = '';
}
}
else
{
if ((_ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger ||
_ledgerJournalTrans.AccountType == LedgerJournalACType::Project) &&
(_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger ||
_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Project))
{
_ledgerJournalTrans.TaxGroup = '';
_ledgerJournalTrans.TaxItemGroup = '';
_ledgerJournalTrans.TaxCode = '';
}
}
_ledgerJournalTrans.parmLedgerDimension(_ledgerJournalTrans.parmOffsetLedgerDimension());
_ledgerJournalTrans.parmDefaultDimension(_ledgerJournalTrans.parmOffsetDefaultDimension());
_ledgerJournalTrans.AccountType = _ledgerJournalTrans.OffsetAccountType;
_ledgerJournalTrans.Company = _ledgerJournalTrans.OffsetCompany ? _ledgerJournalTrans.OffsetCompany : _ledgerJournalTrans.Company;
_ledgerJournalTrans.Txt = _ledgerJournalTrans.OffsetTxt ? _ledgerJournalTrans.OffsetTxt : _ledgerJournalTrans.Txt;
amountCurLocal = _ledgerJournalTrans.AmountCurDebit;
_ledgerJournalTrans.AmountCurDebit = _ledgerJournalTrans.AmountCurCredit;
_ledgerJournalTrans.AmountCurCredit = amountCurLocal;
_ledgerJournalTrans.parmOffsetLedgerDimension(0);
}
else
{
_ledgerJournalTrans.parmLedgerDimension(0);
_ledgerJournalTrans.AmountCurDebit = 0;
_ledgerJournalTrans.AmountCurCredit = 0;
}
return _ledgerJournalTrans;
}
private void ProcessReportUnPosted()
{
LedgerJournalTrans Journaltrans;
LedgerJournalTable Journaltable;
FromDate fromdate;
ToDate todate;
MainAccountNum AccountNum;
Fcc_LedgerPostedAndNotPostedContract contract;
;
contract = this.parmDataContract() as Fcc_LedgerPostedAndNotPostedContract;
AccountNum = contract.parmmainaccount();
fromdate = contract.parmFromDate();
todate = contract.parmToDate();
delete_from StagTmpTable;
//Inserting Open Journal Transaction
while select Journaltable
where Journaltable.posted == NoYes::no
join Journaltrans where Journaltrans.JournalNum == Journaltable.JournalNum
&& Journaltrans.TransDate >= fromdate
&& Journaltrans.TransDate <= todate
{
this.insertLedgerJournalTmp(Journaltable, Journaltrans,AccountOffsetaccount::Account);
Journaltrans = this.ledgerJournalTransOffset(Journaltrans);
if (Journaltrans.parmLedgerDimension())
{
this.insertLedgerJournalTmp(Journaltable, Journaltrans,AccountOffsetaccount::OffsetAccount);
}
}
//Updating Account Name for Open Transaction
this.UpdateStagTmpAccountName();
//updating Ledger Account for all Open Transaction
StagTmpTable.clear();
ttsBegin;
while select forUpdate StagTmpTable
where StagTmpTable.AccountType == LedgerJournalACType::Vend
|| StagTmpTable.AccountType == LedgerJournalACType::Cust
|| StagTmpTable.AccountType == LedgerJournalACType::FixedAssets
|| StagTmpTable.AccountType == LedgerJournalACType::Bank
|| StagTmpTable.AccountType == LedgerJournalACType::Ledger
{
if(StagTmpTable.AccountType == LedgerJournalACType::Vend)
{
StagTmpTable.AccountName = this.VendLedgerInfoCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.VendLedgerInfoCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::Cust)
{
StagTmpTable.AccountName = this.CustLedgerInforCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.CustLedgerInforCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::FixedAssets)
{
StagTmpTable.AccountName = this.FALedgerInfoCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.FALedgerInfoCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::Bank)
{
StagTmpTable.AccountName = this.BankLedgerInforCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.BankLedgerInforCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::Ledger)
{
StagTmpTable.AccountNum = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).LedgerDimensionValue("MainAccount",StagTmpTable.AccountOffsetaccount);
StagTmpTable.AccountName = MainAccount::findByMainAccountId(LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).LedgerDimensionValue("MainAccount",StagTmpTable.AccountOffsetaccount)).Name;
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
StagTmpTable.Update();
}
ttsCommit;
}
Table--> ledger Journal Trans
Display Amount AmountAccCur()
{
if(this.Company != curext() && this.CurrencyCode == Ledger::accountingCurrency())
{
return decRound((this.AmountCurDebit + this.AmountCurCredit),3);
}
else
{
return decRound((this.ExchRate * (this.AmountCurDebit + this.AmountCurCredit)/100),3);
}
}
Class-->
Description255 BankLedgerInforCode(Name _AccountNum,RecId _TransRecId)
{
Description255 BankLedInfo;
LedgerJournalTrans trans;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
BankLedInfo = DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find(_AccountNum).LedgerDimension);
return BankLedInfo;
}
Description255 BankLedgerInforCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 BankLedInfo;
LedgerJournalTrans trans;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
BankLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find(_AccountNum).LedgerDimension)).Name;
return BankLedInfo;
}
Description255 CustLedgerInforCode(Name _AccountNum,RecId _TransRecId)
{
Description255 CustLedInfo;
LedgerJournalTrans trans;
CustLedgerAccounts ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgerscustAccounts
where ledgerscustAccounts.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgerscustAccounts1
where ledgerscustAccounts1.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgerscustAccounts1.Num == CustTable::find(_AccountNum).CustGroup;
select firstonly SummaryLedgerDimension from ledgerscustAccounts2
where ledgerscustAccounts2.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts2.AccountCode == TableGroupAll::Table
&& ledgerscustAccounts2.Num == _AccountNum;
if(ledgerscustAccounts)
{
CustLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts.SummaryLedgerDimension);
}
if(ledgerscustAccounts1)
{
CustLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts1.SummaryLedgerDimension);
}
if(ledgerscustAccounts2)
{
CustLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts2.SummaryLedgerDimension);
}
return CustLedInfo;
}
Description255 CustLedgerInforCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 CustLedInfo;
LedgerJournalTrans trans;
CustLedgerAccounts ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgerscustAccounts
where ledgerscustAccounts.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgerscustAccounts1
where ledgerscustAccounts1.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgerscustAccounts1.Num == CustTable::find(_AccountNum).CustGroup;
select firstonly SummaryLedgerDimension from ledgerscustAccounts2
where ledgerscustAccounts2.PostingProfile == trans.PostingProfile
&& ledgerscustAccounts2.AccountCode == TableGroupAll::Table
&& ledgerscustAccounts2.Num == _AccountNum;
if(ledgerscustAccounts)
{
CustLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts.SummaryLedgerDimension)).Name;
}
if(ledgerscustAccounts1)
{
CustLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts1.SummaryLedgerDimension)).Name;
}
if(ledgerscustAccounts2)
{
CustLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgerscustAccounts2.SummaryLedgerDimension)).Name;
}
return CustLedInfo;
}
Description255 FALedgerInfoCode(Name _AccountNum,RecId _TransRecId)
{
Description255 FALedInfo;
LedgerJournalTrans trans;
AssetLedgerAccounts ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
LedgerJournalTrans_Asset transAsset;
AssetTransType AssetTransType;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select transAsset
where transAsset.RefRecId == trans.RecId;
select firstonly LedgerDimension from ledgersAssetAccounts
where ledgersAssetAccounts.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts.BookId == transAsset.BookId
&& ledgersAssetAccounts.AccountCode == TableGroupAll::All
&& ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType));
select firstonly LedgerDimension from ledgersAssetAccounts1
where ledgersAssetAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts1.BookId == transAsset.BookId
&& ledgersAssetAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAssetAccounts1.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts1.AccountRelation == AssetTable::find(_AccountNum).AssetGroup;
select firstonly LedgerDimension from ledgersAssetAccounts2
where ledgersAssetAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts2.BookId == transAsset.BookId
&& ledgersAssetAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAssetAccounts2.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts2.AccountRelation == _AccountNum;
if(ledgersAssetAccounts)
{
FALedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts.LedgerDimension);
}
if(ledgersAssetAccounts1)
{
FALedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts1.LedgerDimension);
}
if(ledgersAssetAccounts2)
{
FALedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts2.LedgerDimension);
}
return FALedInfo;
}
Description255 FALedgerInfoCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 FALedInfo;
LedgerJournalTrans trans;
AssetLedgerAccounts ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
LedgerJournalTrans_Asset transAsset;
AssetTransType AssetTransType;
;
trans.clear();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select transAsset
where transAsset.RefRecId == trans.RecId;
select firstonly LedgerDimension from ledgersAssetAccounts
where ledgersAssetAccounts.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts.BookId == transAsset.BookId
&& ledgersAssetAccounts.AccountCode == TableGroupAll::All
&& ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType));
select firstonly LedgerDimension from ledgersAssetAccounts1
where ledgersAssetAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts1.BookId == transAsset.BookId
&& ledgersAssetAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAssetAccounts1.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts1.AccountRelation == AssetTable::find(_AccountNum).AssetGroup;
select firstonly LedgerDimension from ledgersAssetAccounts2
where ledgersAssetAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAssetAccounts2.BookId == transAsset.BookId
&& ledgersAssetAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAssetAccounts2.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType))
&& ledgersAssetAccounts2.AccountRelation == _AccountNum;
if(ledgersAssetAccounts)
{
FALedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts.LedgerDimension)).Name;
}
if(ledgersAssetAccounts1)
{
FALedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts1.LedgerDimension)).Name;
}
if(ledgersAssetAccounts2)
{
FALedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts2.LedgerDimension)).Name;
}
return FALedInfo;
}
Description255 VendLedgerInfoCode(Name _AccountNum,RecId _TransRecId)
{
Description255 VendLedInfo;
LedgerJournalTrans trans;
VendLedgerAccounts ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgersAccounts
where ledgersAccounts.PostingProfile == trans.PostingProfile
&& ledgersAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgersAccounts1
where ledgersAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAccounts1.Num == VendTable::find(_AccountNum).VendGroup;
select firstonly SummaryLedgerDimension from ledgersAccounts2
where ledgersAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAccounts2.Num == _AccountNum;
if(ledgersAccounts)
{
VendLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts.SummaryLedgerDimension);
}
if(ledgersAccounts1)
{
VendLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts1.SummaryLedgerDimension);
}
if(ledgersAccounts2)
{
VendLedInfo = DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts2.SummaryLedgerDimension);
}
return VendLedInfo;
}
Description255 VendLedgerInfoCodeName(Name _AccountNum,RecId _TransRecId)
{
Description255 VendLedInfo;
LedgerJournalTrans trans;
VendLedgerAccounts ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
;
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
select firstonly SummaryLedgerDimension from ledgersAccounts
where ledgersAccounts.PostingProfile == trans.PostingProfile
&& ledgersAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgersAccounts1
where ledgersAccounts1.PostingProfile == trans.PostingProfile
&& ledgersAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAccounts1.Num == VendTable::find(_AccountNum).VendGroup;
select firstonly SummaryLedgerDimension from ledgersAccounts2
where ledgersAccounts2.PostingProfile == trans.PostingProfile
&& ledgersAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAccounts2.Num == _AccountNum;
if(ledgersAccounts)
{
VendLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts.SummaryLedgerDimension)).Name;
}
if(ledgersAccounts1)
{
VendLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts1.SummaryLedgerDimension)).Name;
}
if(ledgersAccounts2)
{
VendLedInfo = MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts2.SummaryLedgerDimension)).Name;
}
return VendLedInfo;
}
private void insertLedgerJournalTmp(
LedgerJournalTable _ledgerJournalTable,
LedgerJournalTrans _ledgerJournalTrans,
AccountOffsetaccount _accountOffsetAccount = AccountOffsetaccount::Account)
{
StagTmpTable.JournalId = _ledgerJournalTable.JournalNum;
StagTmpTable.TransRecId = _ledgerJournalTrans.RecId;
if(_accountOffsetAccount == AccountOffsetaccount::OffsetAccount
&& _ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
StagTmpTable.AccountType = _ledgerJournalTrans.OffsetAccountType;
StagTmpTable.LedgerDimension = _ledgerJournalTrans.OffsetLedgerDimension;
}
else
{
StagTmpTable.AccountType = _ledgerJournalTrans.AccountType;
StagTmpTable.LedgerDimension = _ledgerJournalTrans.LedgerDimension;
}
StagTmpTable.Company = _ledgerJournalTrans.Company;
StagTmpTable.CurrencyCode = _ledgerJournalTrans.CurrencyCode;
StagTmpTable.Voucher = _ledgerJournalTrans.Voucher;
StagTmpTable.TransDate = _ledgerJournalTrans.TransDate;
StagTmpTable.AmountCurCredit = _ledgerJournalTrans.AmountCurCredit;
StagTmpTable.AmountCurDebit = _ledgerJournalTrans.AmountCurDebit;
StagTmpTable.AccountOffsetaccount = _accountOffsetAccount;
StagTmpTable.TXT = _ledgerJournalTrans.Txt;
StagTmpTable.ExchRate = _ledgerJournalTrans.ExchRate/100;
StagTmpTable.Insert();
}
private LedgerJournalTrans ledgerJournalTransOffset(LedgerJournalTrans _ledgerJournalTrans)
{
AmountCur amountCurLocal;
if (_ledgerJournalTrans.parmOffsetLedgerDimension())
{
if (_ledgerJournalTrans.ledgerJournalTable().LedgerJournalInclTax)
{
if (!(_ledgerJournalTrans.AccountType != LedgerJournalACType::Ledger &&
_ledgerJournalTrans.AccountType != LedgerJournalACType::Project &&
(_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger ||
_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Project)))
{
_ledgerJournalTrans.TaxGroup = '';
_ledgerJournalTrans.TaxItemGroup = '';
_ledgerJournalTrans.TaxCode = '';
}
}
else
{
if ((_ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger ||
_ledgerJournalTrans.AccountType == LedgerJournalACType::Project) &&
(_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger ||
_ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Project))
{
_ledgerJournalTrans.TaxGroup = '';
_ledgerJournalTrans.TaxItemGroup = '';
_ledgerJournalTrans.TaxCode = '';
}
}
_ledgerJournalTrans.parmLedgerDimension(_ledgerJournalTrans.parmOffsetLedgerDimension());
_ledgerJournalTrans.parmDefaultDimension(_ledgerJournalTrans.parmOffsetDefaultDimension());
_ledgerJournalTrans.AccountType = _ledgerJournalTrans.OffsetAccountType;
_ledgerJournalTrans.Company = _ledgerJournalTrans.OffsetCompany ? _ledgerJournalTrans.OffsetCompany : _ledgerJournalTrans.Company;
_ledgerJournalTrans.Txt = _ledgerJournalTrans.OffsetTxt ? _ledgerJournalTrans.OffsetTxt : _ledgerJournalTrans.Txt;
amountCurLocal = _ledgerJournalTrans.AmountCurDebit;
_ledgerJournalTrans.AmountCurDebit = _ledgerJournalTrans.AmountCurCredit;
_ledgerJournalTrans.AmountCurCredit = amountCurLocal;
_ledgerJournalTrans.parmOffsetLedgerDimension(0);
}
else
{
_ledgerJournalTrans.parmLedgerDimension(0);
_ledgerJournalTrans.AmountCurDebit = 0;
_ledgerJournalTrans.AmountCurCredit = 0;
}
return _ledgerJournalTrans;
}
private void ProcessReportUnPosted()
{
LedgerJournalTrans Journaltrans;
LedgerJournalTable Journaltable;
FromDate fromdate;
ToDate todate;
MainAccountNum AccountNum;
Fcc_LedgerPostedAndNotPostedContract contract;
;
contract = this.parmDataContract() as Fcc_LedgerPostedAndNotPostedContract;
AccountNum = contract.parmmainaccount();
fromdate = contract.parmFromDate();
todate = contract.parmToDate();
delete_from StagTmpTable;
//Inserting Open Journal Transaction
while select Journaltable
where Journaltable.posted == NoYes::no
join Journaltrans where Journaltrans.JournalNum == Journaltable.JournalNum
&& Journaltrans.TransDate >= fromdate
&& Journaltrans.TransDate <= todate
{
this.insertLedgerJournalTmp(Journaltable, Journaltrans,AccountOffsetaccount::Account);
Journaltrans = this.ledgerJournalTransOffset(Journaltrans);
if (Journaltrans.parmLedgerDimension())
{
this.insertLedgerJournalTmp(Journaltable, Journaltrans,AccountOffsetaccount::OffsetAccount);
}
}
//Updating Account Name for Open Transaction
this.UpdateStagTmpAccountName();
//updating Ledger Account for all Open Transaction
StagTmpTable.clear();
ttsBegin;
while select forUpdate StagTmpTable
where StagTmpTable.AccountType == LedgerJournalACType::Vend
|| StagTmpTable.AccountType == LedgerJournalACType::Cust
|| StagTmpTable.AccountType == LedgerJournalACType::FixedAssets
|| StagTmpTable.AccountType == LedgerJournalACType::Bank
|| StagTmpTable.AccountType == LedgerJournalACType::Ledger
{
if(StagTmpTable.AccountType == LedgerJournalACType::Vend)
{
StagTmpTable.AccountName = this.VendLedgerInfoCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.VendLedgerInfoCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::Cust)
{
StagTmpTable.AccountName = this.CustLedgerInforCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.CustLedgerInforCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::FixedAssets)
{
StagTmpTable.AccountName = this.FALedgerInfoCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.FALedgerInfoCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::Bank)
{
StagTmpTable.AccountName = this.BankLedgerInforCodeName(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
StagTmpTable.AccountNum = this.BankLedgerInforCode(StagTmpTable.AccountNum,StagTmpTable.TransRecId);
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
if(StagTmpTable.AccountType == LedgerJournalACType::Ledger)
{
StagTmpTable.AccountNum = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).LedgerDimensionValue("MainAccount",StagTmpTable.AccountOffsetaccount);
StagTmpTable.AccountName = MainAccount::findByMainAccountId(LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).LedgerDimensionValue("MainAccount",StagTmpTable.AccountOffsetaccount)).Name;
if(StagTmpTable.AmountCurCredit != 0)
{
StagTmpTable.AmountCurCredit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
if(StagTmpTable.AmountCurDebit != 0)
{
StagTmpTable.AmountCurDebit = LedgerJournalTrans::findRecId(StagTmpTable.TransRecId,false).AmountAccCur();
}
}
StagTmpTable.Update();
}
ttsCommit;
}
No comments:
Post a Comment