Here is an example of a job
// Changed on 22 Jui 2011 at 17:28:00 by ibs
static void Import_Immobilisations(Args _args)
{
LedgerJournalTrans_Asset ledgerJournalTrans_Asset;
container c;
AssetledgerAccounts assetledgerAccounts;
TextIo io;
String50 filename;
AssetTransType assetTransType;
LedgerJournalTrans ledgerJournalTrans, LedgerJournalTrans_Update;
AssetTransTypeJournal assetTransTypeJournal;
AssetId assetId;
AssetBookId assetBookId;
AssetTransType TransType;
String30 stringdate;
ExchRates ExchRates;
LedgerJournalNameId LedgerJournalNameId;
NumberSeq numSeq1, numSeq2;
Voucher Voucher1, Voucher2 ;
LedgerJournalACType LedgerJournalACType;
AssetGroupId AssetGroupId;
TextBuffer amount;
;
delete_from LedgerJournalTrans_Asset where LedgerJournalTrans.createdBy =='ibs';
delete_from LedgerJournalTrans where LedgerJournalTrans.createdBy =='ibs';
amount = new TextBuffer();
fileName = @"C:\\IMMOB\IMMOBILISATIONS_I.csv";
io = SysLicenseCodeReadFile::openFile(fileName,'r');
if (!io)
throw error(strfmt("@SYS18678",fileName));
io.inFieldDelimiter(";");
c = io.read();
numSeq1 = NumberSeq::newGetVoucherFromCode(LedgerJournalName::find('Invest').VoucherSeries, true );
numSeq2 = NumberSeq::newGetVoucherFromCode(LedgerJournalName::find('Invest_I').VoucherSeries, true );
Voucher1 = numSeq1.voucher();
Voucher2 = numSeq2.voucher();
numSeq1.used();
numSeq2.used();
while (io.status() == IO_Status::Ok)
{
c = io.read();
if (io.status() != IO_Status::Ok)
break;
assetBookId = conpeek(c,1);
assetId = conpeek(c,4);
stringdate = conpeek(c,7);
assetTransType = AssetTransType::Acquisition;
AssetGroupId = conpeek(c,2);
if (LedgerJournalTrans::findAssetId(assetId, true).RecId == 0 && assetId != '' )
{
if( conpeek(c,5) == '1' )
{
LedgerJournalNameId = 'Invest';
LedgerJournalTrans.JournalNum = LedgerJournalTable::findByName(LedgerJournalNameId).JournalNum;
LedgerJournalTrans.Voucher = Voucher1;
}
else
{
LedgerJournalNameId = 'Invest_I';
LedgerJournalTrans.JournalNum = LedgerJournalTable::findByName(LedgerJournalNameId).JournalNum;
LedgerJournalTrans.Voucher = Voucher2;
}
ledgerJournalTrans.Company = curext();
LedgerJournalTrans.currencyCode = 'TND';
LedgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
LedgerJournalTrans.AccountNum = assetId;
LedgerJournalTrans.AccountType = LedgerJournalACType::FixedAssets;
LedgerJournalTrans_Asset.BookId = assetBookId;
LedgerJournalTrans.Txt = conpeek(c,6);
amount.setText(conpeek(c,8));
amount.replace(',','.');
LedgerJournalTrans.AmountCurDebit = str2num(amount.getText());
LedgerJournalTrans.TransDate = str2date(stringdate,123);
LedgerJournalTrans.OffsetAccount = AssetLedgerAccounts::findLedgerAccount(assetBookId,"IMMOB",assetTransType).LedgerOffsetAccount;
// LedgerJournalTrans.OffsetAccount = AssetLedgerAccounts::find(assetBookId,"IMMOB",assetTransType,TableGroupAll::GroupId,AssetGroupId).LedgerOffsetAccount;
LedgerJournalTrans.Qty = str2num(conpeek(c,5));
LedgerJournalTrans.PostingProfile = "IMMOB";
LedgerJournalTrans.ExchRate = Currency::exchRate(ledgerJournalTrans.currencyCode);
LedgerJournalTrans.insert();
select recId, Company from LedgerJournalTrans_Update where LedgerJournalTrans_Update.RecId == LedgerJournalTrans.RecId;
if ( LedgerJournalTrans_Asset::find(LedgerJournalTrans_Update.RecId).RefRecId == 0)
{
LedgerJournalTrans_Asset.AssetId = assetId;
LedgerJournalTrans_Asset.BookId = assetBookId;
LedgerJournalTrans_Asset.TransType = AssetTransTypeJournal::Acquisition;
LedgerJournalTrans_Asset.RefRecId = ledgerJournalTrans.RecId;
ledgerJournalTrans_Asset.Company = LedgerJournalTrans_Update.Company;
LedgerJournalTrans_Asset.insert();
}
print 'inserted';
}
}
info("finished");
}
Aucun commentaire:
Enregistrer un commentaire