17.10.2012, 21:12 | #1 |
Участник
|
ax-erp: AX2012 Import Fixes Assests journals
Источник: http://microsoft-dynamics-ax-erp.blo...-journals.html
============== This class is used to load the fixed asset journal lines , before using this class you can write to read the data from the CSV and call the function called as createJournalLine(parameters) When you run this batch you will get the dialog to select which journal number you want to insert into. publi class krishh_FixedAssetsJournal extends RunBaseBatch { LedgerJournalId journalNum; DialogField dlgJournalNum; LedgerJournalTable ledgerJournalTable; Map voucherMap; #define.CurrentVersion(1) #localmacro.CurrentList journalNum #endmacro } public Object dialog(Dialog _dialog) { ; _dialog = super(_dialog); _dialog.addGroup("Assets"); dlgJournalNum = _dialog.addFieldValue(extendedtypestr(LedgerJournalId), journalNum,"@SYS328705", "General journal that transactions will be imported to."); return _dialog; } private Voucher findCreateVoucher(Voucher _voucher) { Voucher ret; ; if (!voucherMap.exists(_voucher)) { ret = new JournalVoucherNum(JournalTableData::newTable(ledgerJournalTable)).getNew(false); voucherMap.insert(_voucher, ret); } else { ret = voucherMap.lookup(_voucher); } return ret; } public void findJournal() { ; ledgerJournalTable = LedgerJournalTable::find(JournalNum); } public boolean getFromDialog() { ; journalNum = dlgJournalNum.value(); return super(); } public void new() { ; voucherMap = new Map(Types::String, Types::String); } public container pack() { return [#CurrentVersion,#CurrentList, super()]; } public LedgerJournalId parmJournalNum(LedgerJournalId _journalNum = journalNum) { journalNum = _journalNum; return journalNum; } public boolean unpack(container _packedClass) { Version version = RunBase::getVersion(_packedClass); container packedSuper; ; switch (version) { case #CurrentVersion : [version, #CurrentList, packedSuper] = _packedClass; if (packedSuper) super(packedSuper); break; default : return false; } return true; } // this Method is used to Find and if not find create the dimension with the dimension values for Department and project. static RecId findCreateDimension(str _project, str _department) { RecId ret; DimensionAttributeValueSetStorage dimStorage; DimensionAttributeValue dimensionAttributeValue; DimensionAttribute dimensionAttribute; ; if (_project || _department) { dimStorage = new DimensionAttributeValueSetStorage(); if (_project) { dimensionAttribute = AxdDimensionUtil::validateFinancialDimension("project"); dimensionAttributeValue = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, _project); dimStorage.addItem(dimensionAttributeValue); } if (_department) { dimensionAttribute = AxdDimensionUtil::validateFinancialDimension("Department"); dimensionAttributeValue = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, _department); dimStorage.addItem(dimensionAttributeValue); } ret = dimStorage.save(); } return ret; } // This function is used to load into the fixed Asset journal. public void createJournalLine( TransDate _transDate , LedgerJournalACType _ledgerJournalACType , MainAccountNum _mainAccount , LedgerJournalTransTxt _transactionText , AmountCurDebit _debitAmount , AmountCurCredit _creditAmount , CurrencyCode _currencyCode , str _department , str _project , Voucher _voucher) { LedgerJournalTrans ledgerJournalTrans; LedgerJournalTrans_Asset ledgerJournalTransAssets; AssetTable assetTable ; LedgerDimensionDefaultAccount defaultAccount; LedgerJournalEngine ledgerJournalEngine; AssetBook assetBook; ledgerJournalTrans.clear(); assetTable=assetTable::find(_mainAccount); assetBook=AssetBook::find(assetTable.AssetId,AssetParameters::find().BookIdDefault); if(assetTable && assetBook) { ledgerJournalTrans.CurrencyCode = _currencyCode; ledgerJournalTrans.initValue(); if (!ledgerJournalTable) { this.findJournal(); } ledgerJournalTrans.LedgerDimension = DimensionStorage::getDynamicAccount(_mainAccount,_ledgerJournalACType); ledgerJournalTrans.parmAccount(assetBook.AssetId, LedgerJournalACType::FixedAssets); ledgerJournalTrans.TransDate = _transDate; ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum; ledgerJournalTrans.Txt = _transactionText; ledgerJournalTrans.AccountType = _ledgerJournalACType; ledgerJournalTrans.Voucher = this.findCreateVoucher(_voucher); ledgerJournalTrans.PostingProfile =AssetParameters::find().PostingProfile; ledgerJournalTrans.Company = curext(); ledgerJournalTrans.OffsetCompany = curext(); ledgerJournalTrans.OffsetDefaultDimension = 0; ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger; ledgerJournalTrans.AmountCurCredit = _creditAmount; ledgerJournalTrans.AmountCurDebit = _debitAmount; ledgerJournalTrans.DefaultDimension = GNDTDestAxLedgerDailyJournal::findCreateDimension(_project, _department); ledgerJournalTrans.OffsetAccountType = ledgerJournalTable.OffsetAccountType; ledgerJournalTrans.OffsetLedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerJournalTable.OffsetLedgerDimension, ledgerJournalTrans.DefaultDimension); defaultAccount = AssetTable::find(assetTable.AssetId).assetOffsetLedgerDimension(ledgerJournalTrans.PostingProfile, AssetPost::assetTransTypeJournal2AssetTransType(AssetTransTypeJournal::Acquisition), AssetBook.BookId); ledgerJournalTrans.parmOffsetLedgerDimension(ledgerJournalTrans.getOffsetLedgerDimensionForLedgerType(defaultAccount, ledgerJournalTrans.getOffsetCompany())); // Calculate AmountMST ledgerJournalTrans.calcAmountMST(); ledgerJournalTransAssets.BookId = assetBook.BookId; ledgerJournalTransAssets.TransType = AssetTransTypeJournal::Acquisition; ledgerJournalTransAssets.AssetId = ledgerJournalTrans.parmAccount(); ledgerJournalTransAssets.Company = ledgerJournalTrans.Company; ledgerJournalEngine = new LedgerJournalEngine(); ledgerJournalEngine.initDefaultDimension(ledgerJournalTrans, ledgerJournalTransAssets); ledgerJournalTrans.insert(); ledgerJournalTransAssets.RefRecId = ledgerJournalTrans.RecId; ledgerJournalTransAssets.insert(); this.storeItem(); journalNum = ledgerJournalTable.JournalNum; } else { info(strFmt("Asset Id not found %1",_mainAccount)); } } Источник: http://microsoft-dynamics-ax-erp.blo...-journals.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|