Generate dimension

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)