0% found this document useful (0 votes)
97 views9 pages

New Text Document

This code is updating ledger journal transactions and related records by setting their default dimension values based on the offset dimension value of the ledger journal transaction. It is retrieving dimension attribute values from the offset dimension, using them to set the default dimension of various records, and updating those records. The code appears to be standardizing dimensions for bank account transactions by defaulting dimensions to values related to specific bank accounts.

Uploaded by

PANKAJ KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views9 pages

New Text Document

This code is updating ledger journal transactions and related records by setting their default dimension values based on the offset dimension value of the ledger journal transaction. It is retrieving dimension attribute values from the offset dimension, using them to set the default dimension of various records, and updating those records. The code appears to be standardizing dimensions for bank account transactions by defaulting dimensions to values related to specific bank accounts.

Uploaded by

PANKAJ KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

static void ymsliOldVoucherBusinessunit_26_02_19(Args _args)

{
LedgerJournalTrans ledgerJournalTrans;
bankAccountTrans bankAccountTrans ;
VendTrans VendTrans;
CustTrans CustTrans;
bankAccountTable bankAccoffountTable;

DimensionAttributeValueSetStorage davssDefault, davssOffset;


RecId defaultDimension;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
GeneralJournalAccountEntry generalJournalAccountEntry;
GeneralJournalEntry GeneralJournalEntry;
SubledgerJournalAccountEntry subledgerJournalAccountEntry;
str bankAccoff;
str bankAccMain;

Voucher voucher;
DimensionStorage dimensionStorageMain;
DimensionAttribute deparmentDimensionAttributeMain;
DimensionAttributeValue newDepartmentValueMain;

DimensionStorage dimensionStorageOffset;
DimensionAttribute deparmentDimensionAttributeOffset;
DimensionAttributeValue newDepartmentValueOffset;

MainAccount mainAccount;
DimensionHierarchy hierarchy;
DimensionAttributeValueSetStorage storage = new
DimensionAttributeValueSetStorage();

DimensionDefault dimDef;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
DimensionAttributeValueSetStorage davss;

DimensionAttributeLevelValueView valueView;
DimensionAttribute attribute;
;

ttsBegin;

While select forUpdate ledgerJournalTrans


where
(ledgerJournalTrans.AccountType == LedgerJournalACType::Bank
|| ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Bank)
&& (ledgerJournalTrans.TransDate >= str2Date("01/10/2017",123)
&& ledgerJournalTrans.TransDate <= str2Date("1/11/2017",123))
&& (ledgerJournalTrans.Voucher == "NZ-PAY-01000000001")
//|| (ledgerJournalTrans.Voucher == "GL-17-10-0577")
// && (ledgerJournalTrans.Voucher != "GL-17-10-0575")
//&& (ledgerJournalTrans.Voucher!="AP-17-08-0870")
//&& (ledgerJournalTrans.Voucher!="GL-17-10-0575")
//&& (ledgerJournalTrans.Voucher!="AP-17-11-0036")
//&& (ledgerJournalTrans.Voucher!="AP-17-11-0037")
//&& (ledgerJournalTrans.Voucher!="AP-17-11-0038")
//&& (ledgerJournalTrans.Voucher!="AP-17-11-0277")
//&& (ledgerJournalTrans.Voucher!="AP-17-11-0278")
//&& (ledgerJournalTrans.Voucher!="GL-18-02-0041")
//&& (ledgerJournalTrans.Voucher!="GL-18-02-0042")
//&& (ledgerJournalTrans.Voucher!="AP-18-02-0349")
//&& (ledgerJournalTrans.Voucher!="AP-18-02-0351")
//&& (ledgerJournalTrans.Voucher!="AP-18-02-0360")
//&& (ledgerJournalTrans.Voucher!="AP-18-03-0101")
//&& (ledgerJournalTrans.Voucher!="AP-18-03-0178")

outer join bankAccountTrans


where bankAccountTrans.Voucher == ledgerJournalTrans.Voucher
outer join VendTrans
where VendTrans.Voucher == ledgerJournalTrans.Voucher
outer join CustTrans
where CustTrans.Voucher == ledgerJournalTrans.Voucher

{
bankAccoff =
DimensionAttributeValueCombination::find(ledgerJournalTrans.OffsetLedgerDimension).
DisplayValue;
bankAccMain =
DimensionAttributeValueCombination::find(ledgerJournalTrans.LedgerDimension).Displa
yValue;
voucher = bankAccountTrans.Voucher;
voucher = VendTrans.Voucher;
voucher = CustTrans.Voucher;

if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Bank)
{

ledgerJournalTrans.OffsetDefaultDimension =
bankAccountTable::find(bankAccoff).DefaultDimension;
ledgerJournalTrans.DefaultDimension =
bankAccountTable::find(bankAccoff).DefaultDimension;
ledgerJournalTrans.update();
//
if(VendTrans)
{
VendTrans.selectForUpdate(true);
VendTrans.DefaultDimension = ledgerJournalTrans.DefaultDimension;
VendTrans.update();
}
if(bankAccountTrans)
{
bankAccountTrans.selectForUpdate(true);
bankAccountTrans.DefaultDimension =
ledgerJournalTrans.DefaultDimension;
bankAccountTrans.update();
}
if(CustTrans)
{
CustTrans.selectForUpdate(true);
CustTrans.DefaultDimension = ledgerJournalTrans.DefaultDimension;
CustTrans.update();
}
while select GeneralJournalEntry
where GeneralJournalEntry.SubledgerVoucher ==
ledgerJournalTrans.Voucher
join generalJournalAccountEntry
where generalJournalAccountEntry.GeneralJournalEntry ==
GeneralJournalEntry.recid
outer join subledgerJournalAccountEntry
where subledgerJournalAccountEntry.GeneralJournalAccountEntry ==
generalJournalAccountEntry.RecId
{
mainAccount =
MainAccount::findByMainAccountId(MainAccount::findByLedgerDimension(generalJournalA
ccountEntry.LedgerDimension).MainAccountId);
hierarchy = DimensionHierarchy::findByTypeAndName(
DimensionHierarchyType::AccountStructure, 'YMSLI');

attribute = DimensionAttribute::findByName('Department');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Department'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('BusinessUnit');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('BusinessUnit'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('CostCenter');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('CostCenter'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Location');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Location'),
valueView.DisplayValue));
attribute = DimensionAttribute::findByName('Region');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Region'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Project');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Project'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Worker');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
ledgerJournalTrans.OffsetLedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Worker'),
valueView.DisplayValue));
generalJournalAccountEntry.LedgerDimension =
DimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(
mainAccount.RecId, hierarchy.RecId, storage.save());
generalJournalAccountEntry.LedgerAccount =
DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension
).DisplayValue;
generalJournalAccountEntry.selectForUpdate(true);
generalJournalAccountEntry.update();

//storage.addItemDisplayValue(DimensionAttributeValueCombination::find(generalJourn
alAccountEntry.LedgerDimension).DisplayValue);

if(bankAccoff == "B101")
{

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('BusinessUnit'),
"00000061"));
}
/* else
{

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('BusinessUnit'),
"00000002"));
}*/
attribute = DimensionAttribute::findByName('Department');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Department'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('BusinessUnit');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('BusinessUnit'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('CostCenter');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('CostCenter'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Location');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Location'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Region');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Region'),
valueView.DisplayValue));
attribute = DimensionAttribute::findByName('Project');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Project'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Worker');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Worker'),
valueView.DisplayValue));
generalJournalAccountEntry.LedgerDimension =
DimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(
mainAccount.RecId, hierarchy.RecId, storage.save());
generalJournalAccountEntry.LedgerAccount =
DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension
).DisplayValue;
generalJournalAccountEntry.selectForUpdate(true);
generalJournalAccountEntry.update();
}
info(strFmt("%1",ledgerJournalTrans.voucher));

}
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Bank)
{

ledgerJournalTrans.DefaultDimension =
bankAccountTable::find(bankAccMain).DefaultDimension;
ledgerJournalTrans.offsetDefaultDimension =
bankAccountTable::find(bankAccMain).DefaultDimension;
ledgerJournalTrans.update();

while select GeneralJournalEntry


where GeneralJournalEntry.SubledgerVoucher ==
ledgerJournalTrans.Voucher
join generalJournalAccountEntry
where generalJournalAccountEntry.GeneralJournalEntry ==
GeneralJournalEntry.recid
outer join subledgerJournalAccountEntry
where subledgerJournalAccountEntry.GeneralJournalAccountEntry ==
generalJournalAccountEntry.RecId
{
mainAccount =
MainAccount::findByMainAccountId(MainAccount::findByLedgerDimension(generalJournalA
ccountEntry.LedgerDimension).MainAccountId);
hierarchy = DimensionHierarchy::findByTypeAndName(
DimensionHierarchyType::AccountStructure, 'YMSLI');
if(bankAccMain == "B101")
{

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('BusinessUnit'),
"00000061"));
}
/*else
{

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('BusinessUnit'),
"00000002"));
}*/
attribute = DimensionAttribute::findByName('Department');

select DisplayValue from valueView


where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Department'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('CostCenter');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('CostCenter'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Location');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Location'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Region');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Region'),
valueView.DisplayValue));
attribute = DimensionAttribute::findByName('Project');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Project'),
valueView.DisplayValue));

attribute = DimensionAttribute::findByName('Worker');
select DisplayValue from valueView
where valueView.ValueCombinationRecId ==
generalJournalAccountEntry.LedgerDimension
&& valueView.DimensionAttribute == attribute.RecId;
if(valueView)

storage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(
DimensionAttribute::findByName('Worker'),
valueView.DisplayValue));

generalJournalAccountEntry.LedgerDimension =
DimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(
mainAccount.RecId, hierarchy.RecId, storage.save());
generalJournalAccountEntry.LedgerAccount =
DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension
).DisplayValue;
generalJournalAccountEntry.selectForUpdate(true);
generalJournalAccountEntry.update();
}
if(VendTrans)
{
VendTrans.selectForUpdate(true);
VendTrans.DefaultDimension = ledgerJournalTrans.DefaultDimension;
VendTrans.update();
}
if(bankAccountTrans)
{
bankAccountTrans.selectForUpdate(true);
bankAccountTrans.DefaultDimension =
ledgerJournalTrans.DefaultDimension;
bankAccountTrans.update();
}
if(CustTrans)
{
CustTrans.selectForUpdate(true);
CustTrans.DefaultDimension = ledgerJournalTrans.DefaultDimension;
CustTrans.update();
}
info(strFmt("%1",ledgerJournalTrans.voucher));
}

}
ttsCommit;

You might also like