美文网首页
Generate dimension

Generate dimension

作者: axxxxxxxx | 来源:发表于2018-03-29 09:19 被阅读0次
    static recId generateDim(Name   dimName, DimensionValue dimValue)
    {
        RecId                               dim;
        DimensionAttribute                  dimAttr;
        DimensionFinancialTag               dimtag;
        DimensionAttributeValue             dimAttrValue;
        DimensionAttributeValueSetStorage   dimStorage;
    
        dimAttr         = DimensionAttribute::findByName(dimName);
        dimAttrValue    = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttr, dimValue);
        if(!dimAttrvalue)
        {
            dimTag = DimensionFinancialTag::findByFinancialTagCategoryAndValue(dimAttr.financialTagCategory(), dimValue, true);
            if(!dimTag)
            {
                dimTag.clear();
                dimTag.FinancialTagCategory = dimAttr.financialTagCategory();
                dimTag.Value = dimValue;
                dimTag.Description = dimValue;
                dimTag.insert();
            }
            dimAttrValue    = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttr, dimValue, false, true);
        }
    
        if(dimAttrValue)
        {
            dimStorage = new DimensionAttributeValueSetStorage();
            dimStorage.addItem(dimAttrValue);
            dim = dimStorage.save();
        }
        else
        {
            dim = 0;
        }
        return dim;
    }
    
    static RecId getNewDefaultDimension(RecId _defaultDimension, Name _dimName, str 255 _dimValue)
    {
        DimensionAttributeValueSetStorage   dimStorageLocal;
        DimensionAttribute                  dimensionAttribute;
        DimensionAttributeValue             dimAttributeValue;
        dimStorageLocal = DimensionAttributeValueSetStorage::find(_defaultDimension);
        dimensionAttribute = DimensionAttribute::findByName(_dimName);
        if(_dimValue)
        {
            dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, _dimValue, true, true);
            dimStorageLocal.addItem(dimAttributeValue);
        }
        else
            dimStorageLocal.removeDimensionAttribute(DimensionAttribute::findByName(_dimName).RecId);
        return dimStorageLocal.save();
    }
    
    static recId getOffsetLegderDim(str _mainAccountStr)
    {
        LedgerAccountContract               mainAccountContract;
        List                                dimValueList;
        DimensionAttributeValueContract     dimValueContract;
        RecId                               dimRecId;
        DimensionStorage                    dimStorage;
        #define.MainAccountName("MainAccount")
    
        mainAccountContract = new LedgerAccountContract();
        mainAccountContract.parmMainAccount(_mainAccountStr);
        dimValueList = new List(Types::Class);
        dimValueContract = new DimensionAttributeValueContract();
        dimValueContract.parmName(#MainAccountName);
        dimValueContract.parmValue(_mainAccountStr);
        dimValueList.addEnd(dimValueContract);
        mainAccountContract.parmValues(dimValueList);
        dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(mainAccountContract);
        dimRecId = dimStorage.save();
        return dimRecId;
    }
    

    相关文章

      网友评论

          本文标题:Generate dimension

          本文链接:https://www.haomeiwen.com/subject/vtopcftx.html