// Get individual dimensions from ledger dimensions
if (accEntry.LedgerDimension)
{
LedgerDimensionPreviewTmp ledgerDimensionPreviewTmpLocal;
// Build the preview data.
ledgerDimensionPreviewTmpLocal = LedgerDimensionPreviewTmp::buildLedgerDimensionPreviewTmp(accEntry.ledgerDimension);
select firstonly ledgerDimensionPreviewTmpLocal
where ledgerDimensionPreviewTmpLocal.Name == "Funds";
fundValue = ledgerDimensionPreviewTmpLocal.Value;
select firstonly ledgerDimensionPreviewTmpLocal
where ledgerDimensionPreviewTmpLocal.Name == "MainAccount";
MainAccValue = ledgerDimensionPreviewTmpLocal.Value;
select firstonly ledgerFund
where ledgerFund.FundNumber == fundValue;
agencyCode = this.wrapUpSpaces(ledgerFund.CMCFundAgencyCode,3) ;
select firstonly mainAcc
where mainAcc.MainAccountId == MainAccValue;
}
//Get display values from leger dimensions
ledgerDimStr = LedgerDimensionFacade::getDisplayValueForLedgerDimension(distribution.LedgerDimension);
// Another way to retrieve dimensios from ledger dimension ( individual segments ) display values
DimensionStorage dimStorage = DimensionStorage::findById(accDis.ledgerDimension);
DimensionStorageSegment segment;
int i;
Description1000 descSeg;
for (i = 1; i <= dimStorage.segmentCount(); i++)
{
segment = dimStorage.getSegment(i);
descSeg += DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DisplayValue+"-";
}
int len = strlen(descSeg);
if(subStr(descSeg,len,1) == "-")
{
descSeg = strDel(descSeg,len,1);
}
purchTmp.CMCMainAccountNum = descSeg;//dimAttrView.DisplayValue;
// Get main account buffer from Ledger dimension
MainAccount accLoc;
accLoc = LedgerDimensionFacade::getMainAccountFromLedgerDimension(accEntry.LedgerDimension)
// Get all default dimension with dimRecId
public str getFundValue(RecId _defaultDimension)
{
DimensionAttributeValueSetStorage dimStorage;
Counter i;
str returnValue;
dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "FUNDS")
{
returnValue = dimStorage.getDisplayValueByIndex(i);
return returnValue;
}
}
return returnValue;
}
//defult dim to ledger dimension
public static DimensionDynamicAccount defaultDimension2ledgerDimension(LedgerJournalAC _ledgerJournalAC,DimensionDefault _defaultDimension )
{
container conDimName;
container conDimValue;
int loop = 1;
DimensionValue dimValue;
Name dimName;
DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider();
LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();
List ListValueContract = new List(Types::Class);
DimensionAttributeValueContract ValueContract;
dimensionAttributeValueCombination dimensionAttributeValueCombination;
DimensionStorage dimStorage;
conDimName = CMCPayrollGJFileImportService::getDimensionNameTID();
while(loop <= conLen(conDimName))
{
dimName = conPeek(conDimName,loop);
dimValue = CMCPayrollGJFileImportService::getDimensionValueTEC(_defaultDimension,dimName);
if(dimValue)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName(dimName);
ValueContract.parmValue(dimValue);
ListValueContract.addEnd(ValueContract);
}
loop++;
}
LedgerAccountContract.parmMainAccount(_ledgerJournalAC);
LedgerAccountContract.parmValues(ListValueContract);
dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
return dimensionAttributeValueCombination.RecId;
}
public static container getDimensionNameTID()
{
DimensionAttribute dimAttr;
DimensionAttributeSetItem dimAttrSetItem;
DimensionEnumeration dimensionSetId;
DimensionAttributeValue dimAttributeValue;
container DimensionName;
dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();
while select dimAttr order by Name
where dimAttr.Type != DimensionAttributeType::MainAccount
join RecId from dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
dimensionName += dimAttr.Name;
}
return DimensionName;
}
public static str 255 getDimensionValueTEC(RecId defaultDimension, Name dimName)
{
DimensionAttributeValueSetStorage dimStorage;
Counter i;
DimensionAttribute dimAttributeCostCenter;
DimensionAttributeValue dimAttributeValue;
dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);
return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
}
Active all financial dimensions
DimensionAttributeSetItem dimAttrItemSet;
DimensionAttribute dimAttrList;
DimensionAttribute dimAttr;
DimensionattributeSetItem dimAttrSetItem;
DimensionEnumeration dimensionSetId;
int dimAttrCount;
dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();
select count(RecId) from dimAttr
where dimAttr.Type != DimensionAttributeType::MainAccount
join RecId from dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
dimAttrSetItem.DimensionAttributeSet == dimensionSetId;
while select * from dimAttr
order by Name
where dimAttr.Type != DimensionAttributeType::MainAccount
join RecId from dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
finLi.addEnd(dimAttr.Name);
fcbc = FinDimGroup.addControl(FormControlType::CheckBox,dimAttr.Name);
fcbc.label(dimAttr.Name);
}
// Creating ledger dimension from account
ledgerjournalTrans.LedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber( calcTmp.VendAccount,LedgerJournalACType::Vend);
ledgerjournalTrans.OffsetLedgerDimension = LedgerDimensionFacade::serviceCreateLedgerDimension(calcTmp.OffsetLedgerDimension,defaultDim);
Comments
Post a Comment