AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.10.2012, 21:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,538 / 847 (80) +++++++
Регистрация: 28.10.2006
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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
ax-erp: Ax2012 Import Items from CSV file Blog bot DAX Blogs 0 17.10.2012 21:12
ax-erp: Creating SSRS-Reports in Dynamics AX 2012 – What’s no longer possible in AX-reports Blog bot DAX Blogs 0 18.07.2012 12:11
emeadaxsupport: New Content for Microsoft Dynamics AX 2012 : October 2011 Blog bot DAX Blogs 0 27.10.2011 17:11
axinthefield: Dynamics AX Event IDs Blog bot DAX Blogs 0 01.03.2011 22:11
daxdilip: Whats New in Dynamics AX 2012 (A brief extract from the recently held Tech Conf.) Blog bot DAX Blogs 7 31.01.2011 12:35

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 02:10.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.