写入通用期刊,财务维度不起作用

时间:2015-01-15 21:36:37

标签: axapta x++ dynamics-ax-2012

我用x ++写了一般期刊。我当前可以在那里发布,但是订单项上的尺寸没有显示出来。代码运行只有701100- - - - - 其余的没有填充在订单项上。我不确定为什么......我已经尝试了几种不同的东西......比如下面。

 ledgerDimensions = ["701100","701100", "MIDWHS", "ACCT", "000001", "AIR", "019-000100"];   
  journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(ledgerDimensions));   
offsetDimensions =  ["701100","701100", "MIDWHS", "ACCT", "000001", "AIR", "019-000100"];   
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDimensions)); 
 journaltrans.save()

也尝试了

 // dimensionAttribute = DimensionAttribute::findByName("Location");
 // dimensionAttributeValue =            //DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, "MINOT");
 // dimStorage = DimensionAttributeValueSetStorage::find(0);
 // dimStorage.addItem(dimensionAttributeValue);
 //   journalTrans.parmOffsetDefaultDimension(dimStorage.save()); 
//journalTrans.save()

两者都只是添加了帐号,没有其他内容..不知道为什么!

1 个答案:

答案 0 :(得分:0)

我将该服务用于普通期刊的导入界面。 在我的代码下面,尝试这种方式,使用此服务创建维度很容易。 我复制了我们系统中的代码并对其进行了评论,如果您需要进一步解释,请问我。

声明:

LedgerGeneralJournal                    ledgerGeneralJournal;
LedgerGeneralJournalService             ledgerGeneralJournalService;
AfStronglyTypedDataContainerList        journalHeaderCollection;
LedgerGeneralJournal_LedgerJournalTable journalHeader;
AfStronglyTypedDataContainerList        journalLineCollection;
AifEntityKeyList                        journalHeaderCollectionKeyList;
int                                     journalLineCounter; // to create more than one line
int                                     entityKeyCount;
int                                     journalHeaderCounter; // to create more than one journal header if needed

如果需要,为您的计数器变量添加parm方法:

public int parmJournalLineCounter(int _journalLineCounter = journalLineCounter)
{
    journalLineCounter = _journalLineCounter;

    return journalLineCounter;
}

public int parmJournalHeaderCounter(int _journalHeaderCounter = journalHeaderCounter)
{
    journalHeaderCounter = _journalHeaderCounter;

    return journalHeaderCounter;
}

初​​始化: 头

ledgerGeneralJournalService = LedgerGeneralJournalService::construct();
ledgerGeneralJournal = new LedgerGeneralJournal();
journalHeaderCollection = ledgerGeneralJournal.createLedgerJournalTable();
this.parmJournalLineCounter(0); // note to add a parm method for your counter variables

this.parmJournalHeaderCounter(_newInstance ? 1 : this.parmJournalHeaderCounter() + 1); // i added a parameter if more headers are needed
    journalHeader = journalHeaderCollection.insertNew(this.parmJournalHeaderCounter());
    journalHeader.parmJournalName(contract.parmJournalNameId()); // init your own journal ID

这是我创建带尺寸线条的方法。 请注意,我只在这里使用CostCenter,如果您需要更多,请使用CostCenter添加它们(我注释了这些行)

protected void writeLine(
    str                     _oldCompany,
    TransDate               _transDate,
    Voucher                 _voucher,
    str                     _mainAccountNum,
    AmountMST               _amount,
    LedgerJournalTransTxt   _transTxt,
    CurrencyCode            _currencyCode,
    str                     _offsetAccountNum,
    str                     costCenter
    )
{
    LedgerGeneralJournal_LedgerJournalTrans journalLine;
    AifMultiTypeAccount                     journalLineLedgerDimensionMain;
    AifDimensionAttributeValue              journalLineDim1Main;
    AfStronglyTypedDataContainerList        journalLineDimensionCollectionMain;
    AifMultiTypeAccount                     journalLineLedgerDimensionOffset;
    str                                     lineMainAccount;
    str                                     lineFullAccount;
    str                                     lineMainDimensionName = 'CostCenter';
    str                                     lineMainDimensionValue;
    str                                     lineOffsetAccount;
    str                                     lineOffsetFullAccount;


    this.parmJournalLineCounter(this.parmJournalLineCounter()+1);
    journalLine = this.parmJournalLineCollection().insertNew(this.parmJournalLineCounter());
    journalLine.parmLineNum(this.parmJournalLineCounter());

    journalLine.parmCompany(CompanyInfo::findByPTROldCompany(_oldCompany).company());
    journalLine.parmOffsetCompany(journalLine.parmCompany());
    journalLine.parmTransDate(_transDate);
    journalLine.parmVoucher(_voucher);
    journalLine.parmAccountType(LedgerJournalACType::Ledger);
    lineMainAccount = _mainAccountNum;

    journalLine.parmAmountCurCredit(_amount > 0 ? 0 : _amount);
    journalLine.parmAmountCurDebit(_amount > 0 ? _amount : 0);
    journalLine.parmTxt(_transTxt);
    journalLine.parmCurrencyCode(_currencyCode);
    journalLine.parmOffsetAccountType(LedgerJournalACType::Ledger);
    lineOffsetAccount = _offsetAccountNum;

    // Create Main Account Dimensions
    journalLineLedgerDimensionMain = journalLine.createLedgerDimension();
    journalLineLedgerDimensionMain.parmAccount(lineMainAccount);
    lineFullAccount = strFmt("%1-%2-", lineMainAccount, costCenter ? lineMainDimensionValue : ''); // if you need more dimensions, add them here first
    journalLineLedgerDimensionMain.parmDisplayValue(lineFullAccount);
// and then add the values here like costcenter:
        if (costCenter)
        {
            lineMainDimensionValue = costCenter;
            journalLineDimensionCollectionMain = journalLineLedgerDimensionMain.createValues();
            journalLineDim1Main = new AifDimensionAttributeValue();
            journalLineDim1Main.parmName(lineMainDimensionName);
            journalLineDim1Main.parmValue(lineMainDimensionValue);
            journalLineDimensionCollectionMain.add(journalLineDim1Main);
            journalLineLedgerDimensionMain.parmValues(journalLineDimensionCollectionMain);
        }
        journalLine.parmLedgerDimension(journalLineLedgerDimensionMain);
        // Create Offset Account Dimensions
// same procedure with offset dimensions if needed
        if (_offsetAccountNum)
        {
            journalLineLedgerDimensionOffset = journalLine.createOffsetLedgerDimension();
            journalLineLedgerDimensionOffset.parmAccount(lineOffsetAccount);
            lineOffsetFullAccount = strFmt("%1--", lineOffsetAccount);
            journalLineLedgerDimensionOffset.parmDisplayValue(lineOffsetFullAccount);
            journalLine.parmOffsetLedgerDimension(journalLineLedgerDimensionOffset);
        }
    }

        // Create Lines
        journalLineCollection = journalHeader.createLedgerJournalTrans();

最后写日记:

public void finalizeLedgerJournal()
{
    int     keyCount;
    List    journalIdList;

    journalHeader.parmLedgerJournalTrans(journalLineCollection);
    ledgerGeneralJournal.parmLedgerJournalTable(journalHeaderCollection);
    journalHeaderCollectionKeyList = LedgerGeneralJournalService.create(ledgerGeneralJournal);

    // if you need the journalId for further processing:
this.parmEntityKeyCount(journalHeaderCollectionKeyList.getEntityKeyCount());

    if (entityKeyCount > 0)
    {
        for (keyCount = 1;keyCount <= entityKeyCount;keyCount++)
        {
            if (!contract.parmJournalIdList())
            {
                contract.parmJournalIdList(new List(Types::String));
            }
            journalIdList = contract.parmJournalIdList();
            journalIdList.addEnd(LedgerJournalTable::findByRecId(journalHeaderCollectionKeyList.getEntityKey(keyCount).parmRecId()).JournalNum);
            contract.parmJournalId(LedgerJournalTable::findByRecId(journalHeaderCollectionKeyList.getEntityKey(keyCount).parmRecId()).JournalNum);
        }
    }
}