Günü Sözü

"Hiçbir şey bilmeyen cahildir, ama bilip de susan ahlaksızdır. " Bertolt Brecht.
"İyilik yapabildiğim zaman mutlu olurum; ama en büyük mutluluk yapılan bir haksızlığı düzeltmektir." Tolstoy

4 Aralık 2014 Perşembe

Ax2012 Import Fixed Assets Table, csv,excel den sabit kıymetlere import


public void _createAssetTable(
AssetId _assetId
, AssetGroupId _assetGroupId
, AssetName _assetName
, AssetLocationId _assetLocationId
, Num _num
, AssetType _assetType
, AssetNameAlias _assetNameAlias
, AssetNotes _assetNotes
, AssetMajorTypeId _assetMajorTypeId)
{
AxAssetTable axAssetTable;
;
axAssetTable = new AxAssetTable();
axAssetTable.validateInput(true);

axAssetTable.parmAssetId(_assetId);
axAssetTable.parmAssetGroup(_assetGroupId ?_assetGroupId : assetGroupId);
axAssetTable.parmName(_assetName);
axAssetTable.parmLocation(_assetLocationId);
axAssetTable.parmSerialNum(_num);
axAssetTable.parmAssetType(_assetType);
axAssetTable.parmNameAlias(_assetNameAlias);
axAssetTable.parmNotes(_assetNotes);
axAssetTable.parmMajorType(_assetMajorTypeId);

axAssetTable.save();


}

// creates the Assets book

protected void CreateAssetBook(container _conLine)
{
#Define.AssetId(1)
#Define.BookId(2)
#Define.PostingProfile(9)
#Define.LifeTime(11)
#Define.LifeTimeRest(12)
#Define.DepreciationStartDate(16)
#Define.LastDepreciationDate(18)
#Define.AcquisitionDate(27)

AssetBook assetBook;
AxAssetBook axAssetBook = AxAssetBook::construct();
SysDictClass sysDictClassAxAssetBook = new SysDictClass(classIdGet(AxAssetBook));
;

assetBook = AssetBook::find(this.getLineValue(_conLine, #AssetId), this.getLineValue(_conLine, #BookId), true);

if(assetBook)
{
axAssetBook = AxAssetBook::newAssetBook(assetBook);

// AssetId
axAssetBook.parmAssetId(this.getLineValue(_conLine,#AssetId))

// BookId
axAssetBook.parmBookId(this.getLineValue(_conLine,#BookId));

// PostingProfile
axAssetBook.parmPostingProfile( this.getLineValue(_conLine, #PostingProfile) );

// LifeTime
axAssetBook.parmLifeTimes(str2num(this.getLineValue(_conLine,#LifeTime)));

// LifeTimeRest
axAssetBook.parmLifeTimeRest(str2num(this.getLineValue(_conLine,#LifeTimeRest)));

// DepreciationStartDate
axAssetBook.parmDepreciationStartDate(str2date((this.getLineValue(_conLine,#DepreciationStartDate),123));
// LastDepreciationDate
axAssetBook.parmLastDepreciationDate(str2dat(this.getLineValue(_conLine,#LastDepreciationDate),123));

// AcquisitionDate
axAssetBook.parmAcquisitionDate(str2date(this.getLineValue(_conLine,#AcquisitionDate),123));

axAssetBook.save();
}
else
{
throw error(strFmt(AssetBook::txtNotExist(), this.getLineValue(_conLine, #AssetId),
this.getLineValue(_conLine, #BookId)));
}
}

// gets the value from the container
protected anytype getLineValue(container _conLine,
int _columnNum,
Types _valueType = Types::String,
EnumId _enumId = 0)
{
str strValue;
anytype anyTypeValue;
DictEnum dictEnum;

strValue = conPeek(_conLine,
_columnNum);

switch(_valueType)
{
case Types::String :

anyTypeValue = strValue;
break;

case Types::Integer :

if(strValue)
{
anyTypeValue = str2int(strValue);
}
else
{
anyTypeValue = 0;
}
break;

case Types::Real :

if(strValue)
{
anyTypeValue = str2num(strValue);
}
else
{
anyTypeValue = 0.00;
}
break;

case Types::Enum :

if(!_enumId)
{
throw error(strFmt("@SYS22828", funcName()));
}

dictEnum = new DictEnum(_enumId);

if(!dictEnum)
{
throw error(strFmt("@SYS22828", funcName()));
}

if(strValue)
{
anyTypeValue = dictEnum.name2Value(strValue);
}
else
{
anyTypeValue = 0;
}
break;

case Types::Date :

if(strValue)
{
anyTypeValue = str2date(strValue,123);
}
else
{
anyTypeValue = dateNull();
}
break;

case Types::UtcDateTime :

if(strValue)
{
anyTypeValue = DateTimeUtil::parse(strValue);
}
else
{
anyTypeValue = utcDateTimeNull();
}
break;

default :

throw error(strFmt("@SYS26908", _valueType));
}

return anyTypeValue;
}

Hiç yorum yok:

Yorum Gönder