最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

从主科目和财务维度创建LedgerDimension / Create LedgerDimension from main account and financial dimensions

网络文摘 William 80浏览 0评论
The following code will (hopefully) keep generating valid LedgerDimension values, even after account structures or advanced rule structures are modified. In the example below, there is an account structure with MainAccount-BusinessUnit-Department segments and an advanced rule with Project segment.
class TestLedgerDim
{        
    public static DimensionDynamicAccount generateLedgerDimension(
        MainAccountNum _mainAccountId,
        str _departmentId,
        str _businessUnit,
        str _projectId)
    {
        DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage 
            = new DimensionAttributeValueSetStorage();
void addDimensionAttributeValue( DimensionAttribute _dimensionAttribute, str _dimValueStr) { DimensionAttributeValue dimensionAttributeValue; if (_dimValueStr != '') { dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError( _dimensionAttribute, _dimValueStr); } if (dimensionAttributeValue.RecId != 0) { dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue); } } DimensionAttribute dimensionAttribute; while select dimensionAttribute where dimensionAttribute.ViewName == tableStr(DimAttributeOMDepartment) || dimensionAttribute.ViewName == tableStr(DimAttributeOMBusinessUnit) || dimensionAttribute.ViewName == tableStr(DimAttributeProjTable) { switch (dimensionAttribute.ViewName) { case tableStr(DimAttributeOMDepartment): addDimensionAttributeValue(dimensionAttribute, _departmentId); break; case tableStr(DimAttributeOMBusinessUnit): addDimensionAttributeValue(dimensionAttribute, _businessUnit); break; case tableStr(DimAttributeProjTable): addDimensionAttributeValue(dimensionAttribute, _projectId); break; } } RecId defaultDimensionRecId = dimensionAttributeValueSetStorage.save(); return LedgerDimensionFacade::serviceCreateLedgerDimension( LedgerDefaultAccountHelper::getDefaultAccountFromMainAccountRecId( MainAccount::findByMainAccountId(_mainAccountId).RecId), defaultDimensionRecId); } /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = "_args">The specified arguments.</param> public static void main(Args _args) { // Prints 110110-001-022-000002 info( DimensionAttributeValueCombination::find( TestLedgerDim::generateLedgerDimension( '110110', '022', '001', '000002')).DisplayValue); } }
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址