//Dimension Validation by Account Structure
//Create New Class
class GlobalDimensionValidation
{
}
//Dimension Validation check by ledger
Public Static Boolean DimensionValidationLedger( MainAccountNum _AccountNum,
Name _BU,
Name _CC,
Name _Dept
)
{
boolean validDimCombination = true;
;
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(_AccountNum,_BU,_CC,_Dept));
return validDimCombination;
}
//Dimension Vlaidation check by Non Ledger Account
Public Static Boolean DimensionValidationNonLedger(Name _AccountNum,
LedgerJournalACType _accountType,
Name _BU,
Name _CC,
Name _Dept,
AssetTransType _transType = AssetTransType::Acquisition
)
{
boolean validDimCombination = true;
;
switch(_accountType)
{
case LedgerJournalACType::Cust :
if(GlobalDimensionValidation::CustLedgerInforCode(_AccountNum) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::CustLedgerInforCode(_AccountNum),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for Customer Account");
}
break;
case LedgerJournalACType::Vend :
if(GlobalDimensionValidation::VendLedgerInfoCode(_AccountNum) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::VendLedgerInfoCode(_AccountNum),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for Vendor Account");
}
break;
case LedgerJournalACType::FixedAssets :
if(GlobalDimensionValidation::FALedgerInfoCode(_AccountNum,_transType) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::FALedgerInfoCode(_AccountNum,_transType),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for FA Account");
}
break;
//case LedgerJournalACType::Project :
//break;
case LedgerJournalACType::Bank :
if(GlobalDimensionValidation::BankLedgerInforCode(_AccountNum) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::BankLedgerInforCode(_AccountNum),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for Bank Account");
}
break;
default :
info(strFmt("Account Type %1 is not valid ",_accountType));
break;
}
return validDimCombination;
}
//Diemnsion Check by combiantion (Method after creation of lines)
Public Static Boolean DimensionCombinationCheck(RecId _dimensionCombinationId)
{
boolean validCombination = true;
;
if(DimensionValidation::validateByTree(_dimensionCombinationId,today(),true)
!= DimensionValidationStatus::Valid)
{
validCombination = false;
//DimensionValidation::validateByTree(jourTrans.LedgerDimension,today(),true);
}
return validCombination;
}
//Default Dimension Create
Protected Static DimensionDefault DefaultDimensionCreate(Description _BU,Description _CC,Description _Department)
{
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault result;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue; //DimensionAttributeValueCombination
container conAttr = ["BusinessUnit","CostCenter","Department"]; //101,106,1
container conValue;
str dimValue;
conValue = [_BU,_CC,_Department];
dimValue = "";
i = 0;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
//control will not go down
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
dimensionAttributeValue =
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
valueSetStorage.addItem(dimensionAttributeValue);
}
}
result = valueSetStorage.save();
return result;
}
//Ledger Dimension Create
Protected static LedgerDimensionAccount LedgerDimensionCreate(MainAccountNum _AccountId,Description _BU,Description _CC,Description _Department)
{
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionDefault dimensionDefault;
LedgerDimensionAccount ledgerDimensionAccount;
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
// BusinessUnit
dimensionAttribute = DimensionAttribute::findByName('BusinessUnit');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_BU, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// CostCenter
dimensionAttribute = DimensionAttribute::findByName('CostCenter');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_CC, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// Department
dimensionAttribute = DimensionAttribute::findByName('Department');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_Department, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
dimensionDefault = dimensionAttributeValueSetStorage.save();
// Merging Main Account and default dimension Combination values and return RecId which can be used as ledgerDimension
ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(
DimensionStorage::getDefaultAccountForMainAccountNum(_AccountId),dimensionDefault);
return ledgerDimensionAccount;
}
//Offset Ledger Dimension create
Protected static DimensionDynamicAccount OffsetLedgerDimensionCreate(MainAccountNum _AccountId,Description _BU,Description _CC,Description _Department)
{
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionDefault dimensionDefault;
LedgerDimensionAccount ledgerDimensionAccount;
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
// BusinessUnit
dimensionAttribute = DimensionAttribute::findByName('BusinessUnit');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_BU, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// CostCenter
dimensionAttribute = DimensionAttribute::findByName('CostCenter');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_CC, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// Department
dimensionAttribute = DimensionAttribute::findByName('Department');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_Department, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
dimensionDefault = dimensionAttributeValueSetStorage.save();
//Merging Main Account and default dimension Combination values and return RecId which can be used as ledgerDimension
ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(
DimensionStorage::getDefaultAccountForMainAccountNum(_AccountId),dimensionDefault);
return ledgerDimensionAccount;
}
//Finding Posting Profile Account cust /Bank/Vend
//CUstomer
Protected Static Description255 CustLedgerInforCode(Name _AccountNum,RecId _TransRecId = 0)
{
Description255 CustLedInfo;
CustParameters parms;
LedgerJournalTrans trans;
CustLedgerAccounts ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
;
parms = CustParameters::findByCompany(curext());
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
if(_TransRecId ==0)
{
select firstonly SummaryLedgerDimension from ledgerscustAccounts
where ledgerscustAccounts.PostingProfile == parms.PostingProfile
&& ledgerscustAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgerscustAccounts1
where ledgerscustAccounts1.PostingProfile == parms.PostingProfile
&& ledgerscustAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgerscustAccounts1.Num == CustTable::find(_AccountNum).CustGroup;
select firstonly SummaryLedgerDimension from ledgerscustAccounts2
where ledgerscustAccounts2.PostingProfile == parms.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);
}
}
else
{
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;
}
//Vend
Protected Static Description255 VendLedgerInfoCode(Name _AccountNum,RecId _TransRecId = 0)
{
Description255 VendLedInfo;
VendParameters parms;
LedgerJournalTrans trans;
VendLedgerAccounts ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
;
parms = VendParameters::find();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
if(_TransRecId == 0)
{
select firstonly SummaryLedgerDimension from ledgersAccounts
where ledgersAccounts.PostingProfile == parms.PostingProfile
&& ledgersAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgersAccounts1
where ledgersAccounts1.PostingProfile == parms.PostingProfile
&& ledgersAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAccounts1.Num == VendTable::find(_AccountNum).VendGroup;
select firstonly SummaryLedgerDimension from ledgersAccounts2
where ledgersAccounts2.PostingProfile == parms.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);
}
}
else
{
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;
}
//Bank
Protected Static Description255 BankLedgerInforCode(Name _AccountNum)
{
Description255 BankLedInfo;
;
BankLedInfo = DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find(_AccountNum).LedgerDimension);
return BankLedInfo;
}
//FA -- (Note : For FA Required Posting Profile Account Manadatory)
Protected Static Description255 FALedgerInfoCode(Name _AccountNum,AssetTransType _transType)
{
Description255 FALedInfo;
AssetTable assetTable;
AssetLedgerAccounts ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
AssetTransType AssetTransType;
;
assetTable.clear();
assetTable = AssetTable::find(_AccountNum);
select firstonly LedgerDimension from ledgersAssetAccounts
where ledgersAssetAccounts.PostingProfile == assetTable.book().PostingProfile
&& ledgersAssetAccounts.BookId == assetTable.book().BookId
&& ledgersAssetAccounts.AccountCode == TableGroupAll::All
&& ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(_transType));
select firstonly LedgerDimension from ledgersAssetAccounts1
where ledgersAssetAccounts1.PostingProfile == assetTable.book().PostingProfile
&& ledgersAssetAccounts1.BookId == assetTable.book().BookId
&& ledgersAssetAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAssetAccounts1.TransType == str2enum(AssetTransType,enum2str(_transType))
&& ledgersAssetAccounts1.AccountRelation == AssetTable::find(_AccountNum).AssetGroup;
select firstonly LedgerDimension from ledgersAssetAccounts2
where ledgersAssetAccounts2.PostingProfile == assetTable.book().PostingProfile
&& ledgersAssetAccounts2.BookId == assetTable.book().BookId
&& ledgersAssetAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAssetAccounts2.TransType == str2enum(AssetTransType,enum2str(_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;
}
//Create New Class
class GlobalDimensionValidation
{
}
//Dimension Validation check by ledger
Public Static Boolean DimensionValidationLedger( MainAccountNum _AccountNum,
Name _BU,
Name _CC,
Name _Dept
)
{
boolean validDimCombination = true;
;
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(_AccountNum,_BU,_CC,_Dept));
return validDimCombination;
}
//Dimension Vlaidation check by Non Ledger Account
Public Static Boolean DimensionValidationNonLedger(Name _AccountNum,
LedgerJournalACType _accountType,
Name _BU,
Name _CC,
Name _Dept,
AssetTransType _transType = AssetTransType::Acquisition
)
{
boolean validDimCombination = true;
;
switch(_accountType)
{
case LedgerJournalACType::Cust :
if(GlobalDimensionValidation::CustLedgerInforCode(_AccountNum) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::CustLedgerInforCode(_AccountNum),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for Customer Account");
}
break;
case LedgerJournalACType::Vend :
if(GlobalDimensionValidation::VendLedgerInfoCode(_AccountNum) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::VendLedgerInfoCode(_AccountNum),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for Vendor Account");
}
break;
case LedgerJournalACType::FixedAssets :
if(GlobalDimensionValidation::FALedgerInfoCode(_AccountNum,_transType) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::FALedgerInfoCode(_AccountNum,_transType),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for FA Account");
}
break;
//case LedgerJournalACType::Project :
//break;
case LedgerJournalACType::Bank :
if(GlobalDimensionValidation::BankLedgerInforCode(_AccountNum) != "")
{
validDimCombination = GlobalDimensionValidation::DimensionCombinationCheck(
GlobalDimensionValidation::LedgerDimensionCreate(
GlobalDimensionValidation::BankLedgerInforCode(_AccountNum),
_BU,
_CC,
_Dept)
);
}
else
{
throw warning("Map Ledger Posting Profile for Bank Account");
}
break;
default :
info(strFmt("Account Type %1 is not valid ",_accountType));
break;
}
return validDimCombination;
}
//Diemnsion Check by combiantion (Method after creation of lines)
Public Static Boolean DimensionCombinationCheck(RecId _dimensionCombinationId)
{
boolean validCombination = true;
;
if(DimensionValidation::validateByTree(_dimensionCombinationId,today(),true)
!= DimensionValidationStatus::Valid)
{
validCombination = false;
//DimensionValidation::validateByTree(jourTrans.LedgerDimension,today(),true);
}
return validCombination;
}
//Default Dimension Create
Protected Static DimensionDefault DefaultDimensionCreate(Description _BU,Description _CC,Description _Department)
{
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault result;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue; //DimensionAttributeValueCombination
container conAttr = ["BusinessUnit","CostCenter","Department"]; //101,106,1
container conValue;
str dimValue;
conValue = [_BU,_CC,_Department];
dimValue = "";
i = 0;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
//control will not go down
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
dimensionAttributeValue =
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
valueSetStorage.addItem(dimensionAttributeValue);
}
}
result = valueSetStorage.save();
return result;
}
//Ledger Dimension Create
Protected static LedgerDimensionAccount LedgerDimensionCreate(MainAccountNum _AccountId,Description _BU,Description _CC,Description _Department)
{
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionDefault dimensionDefault;
LedgerDimensionAccount ledgerDimensionAccount;
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
// BusinessUnit
dimensionAttribute = DimensionAttribute::findByName('BusinessUnit');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_BU, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// CostCenter
dimensionAttribute = DimensionAttribute::findByName('CostCenter');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_CC, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// Department
dimensionAttribute = DimensionAttribute::findByName('Department');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_Department, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
dimensionDefault = dimensionAttributeValueSetStorage.save();
// Merging Main Account and default dimension Combination values and return RecId which can be used as ledgerDimension
ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(
DimensionStorage::getDefaultAccountForMainAccountNum(_AccountId),dimensionDefault);
return ledgerDimensionAccount;
}
//Offset Ledger Dimension create
Protected static DimensionDynamicAccount OffsetLedgerDimensionCreate(MainAccountNum _AccountId,Description _BU,Description _CC,Description _Department)
{
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionDefault dimensionDefault;
LedgerDimensionAccount ledgerDimensionAccount;
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
// BusinessUnit
dimensionAttribute = DimensionAttribute::findByName('BusinessUnit');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_BU, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// CostCenter
dimensionAttribute = DimensionAttribute::findByName('CostCenter');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_CC, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
// Department
dimensionAttribute = DimensionAttribute::findByName('Department');
if(dimensionAttribute)
{
dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,_Department, false, true);
dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
}
dimensionDefault = dimensionAttributeValueSetStorage.save();
//Merging Main Account and default dimension Combination values and return RecId which can be used as ledgerDimension
ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(
DimensionStorage::getDefaultAccountForMainAccountNum(_AccountId),dimensionDefault);
return ledgerDimensionAccount;
}
//Finding Posting Profile Account cust /Bank/Vend
//CUstomer
Protected Static Description255 CustLedgerInforCode(Name _AccountNum,RecId _TransRecId = 0)
{
Description255 CustLedInfo;
CustParameters parms;
LedgerJournalTrans trans;
CustLedgerAccounts ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
;
parms = CustParameters::findByCompany(curext());
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
if(_TransRecId ==0)
{
select firstonly SummaryLedgerDimension from ledgerscustAccounts
where ledgerscustAccounts.PostingProfile == parms.PostingProfile
&& ledgerscustAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgerscustAccounts1
where ledgerscustAccounts1.PostingProfile == parms.PostingProfile
&& ledgerscustAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgerscustAccounts1.Num == CustTable::find(_AccountNum).CustGroup;
select firstonly SummaryLedgerDimension from ledgerscustAccounts2
where ledgerscustAccounts2.PostingProfile == parms.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);
}
}
else
{
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;
}
//Vend
Protected Static Description255 VendLedgerInfoCode(Name _AccountNum,RecId _TransRecId = 0)
{
Description255 VendLedInfo;
VendParameters parms;
LedgerJournalTrans trans;
VendLedgerAccounts ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
;
parms = VendParameters::find();
trans = LedgerJournalTrans::findRecId(_TransRecId,false);
if(_TransRecId == 0)
{
select firstonly SummaryLedgerDimension from ledgersAccounts
where ledgersAccounts.PostingProfile == parms.PostingProfile
&& ledgersAccounts.AccountCode == TableGroupAll::All;
select firstonly SummaryLedgerDimension from ledgersAccounts1
where ledgersAccounts1.PostingProfile == parms.PostingProfile
&& ledgersAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAccounts1.Num == VendTable::find(_AccountNum).VendGroup;
select firstonly SummaryLedgerDimension from ledgersAccounts2
where ledgersAccounts2.PostingProfile == parms.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);
}
}
else
{
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;
}
//Bank
Protected Static Description255 BankLedgerInforCode(Name _AccountNum)
{
Description255 BankLedInfo;
;
BankLedInfo = DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find(_AccountNum).LedgerDimension);
return BankLedInfo;
}
//FA -- (Note : For FA Required Posting Profile Account Manadatory)
Protected Static Description255 FALedgerInfoCode(Name _AccountNum,AssetTransType _transType)
{
Description255 FALedInfo;
AssetTable assetTable;
AssetLedgerAccounts ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
AssetTransType AssetTransType;
;
assetTable.clear();
assetTable = AssetTable::find(_AccountNum);
select firstonly LedgerDimension from ledgersAssetAccounts
where ledgersAssetAccounts.PostingProfile == assetTable.book().PostingProfile
&& ledgersAssetAccounts.BookId == assetTable.book().BookId
&& ledgersAssetAccounts.AccountCode == TableGroupAll::All
&& ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(_transType));
select firstonly LedgerDimension from ledgersAssetAccounts1
where ledgersAssetAccounts1.PostingProfile == assetTable.book().PostingProfile
&& ledgersAssetAccounts1.BookId == assetTable.book().BookId
&& ledgersAssetAccounts1.AccountCode == TableGroupAll::GroupId
&& ledgersAssetAccounts1.TransType == str2enum(AssetTransType,enum2str(_transType))
&& ledgersAssetAccounts1.AccountRelation == AssetTable::find(_AccountNum).AssetGroup;
select firstonly LedgerDimension from ledgersAssetAccounts2
where ledgersAssetAccounts2.PostingProfile == assetTable.book().PostingProfile
&& ledgersAssetAccounts2.BookId == assetTable.book().BookId
&& ledgersAssetAccounts2.AccountCode == TableGroupAll::Table
&& ledgersAssetAccounts2.TransType == str2enum(AssetTransType,enum2str(_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;
}