Account Payable
Module;
filename
= dialogFilename.value();
transdate =
dialogFromDate.value();
journalNameId =
dialogledger.Value();
impBal =
dialogimpBal.value();
journalName =
dialogJournalName.value();
journalTxt =
dialogJournalTxt.value();
AP à invoice Journal Import:
LedgerJournalName
ledgerJournalName;
AxLedgerJournalTrans
trans = new AxLedgerJournalTrans();
AxLedgerJournalTable
header = new
AxLedgerJournalTable();
str 60
invoiceNumber,vendorAccount,txt,dimensn,offdimensn,offsetAccount,ApprovedBy;
DirPartyTable
dirPartyTable;
HcmWorker hcmWorker;
container dimm,offdim;
Amount
amountCurDebit,amountCurCredit;
first = true;
csvFile =
new CommaTextIo(filename, 'r');
csvFile.inFieldDelimiter(',');
readCon =
csvFile.read();
try
{
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
if (first)
{
header.parmJournalName(journalNameId);
select ledgerJournalName where ledgerJournalName.JournalName ==
journalNameId;
header.parmJournalType(ledgerJournalName.JournalType);
header.save();
first = false;
}
if (readCon )//dont insert first record of file : header
{
Transactiondate =
transdate;
invoiceNumber = conPeek(readCon,1);
vendorAccount = conPeek(readCon,2);
txt = conPeek(readCon,3);
currencycode = conPeek(readCon,4);
amountCurDebit = conPeek(readCon,5);
amountCurCredit = conPeek(readCon,6);
offsetAccount = conPeek(readCon,7);
ApprovedBy = conPeek(readCon,8);
trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
dimensn = strFmt("%1,%1",vendorAccount);//strFmt("%1-%2-%3,%1,2,department,%2,costcenter,%3",ledgerAccount,department,costcenter);
dimm = str2con(dimensn);
trans.parmAccountType(LedgerJournalACTypE::Vend);
trans.parmLedgerDimension(DimensionStorage::getDynamicAccount(vendorAccount,
LedgerJournalACType::vend)); //AxdDimensionUtil::getLedgerAccountId(dimm));
trans.parmTxt(txt);
select hcmworker where
hcmWorker.PersonnelNumber == ApprovedBy;
trans.parmApprover(hcmworker.RecId);
trans.parmApproved(NoYes::Yes);
trans.parmDocumentDate(TransDate);
trans.parmTransDate(TransDate);
trans.parmInvoice(invoiceNumber);
trans.parmAmountCurDebit(AmountCurDebit);
trans.parmAmountCurCredit(AmountCurCredit) ;
trans.parmCompany(curext());
trans.parmCurrencyCode(currencycode);
trans.parmExchRate(1);
offdimensn = strFmt("%1,%1",offsetAccount);
offdim
=str2con(offdimensn);
trans.parmOffsetLedgerDimension(
DimensionStorage::getDynamicAccount(offsetAccount, LedgerJournalACType::Bank));
trans.parmOffsetAccountType(LedgerJournalACTypE::Bank);
trans.parmVoucher(NumberSeq::newGetVoucherFromId((LedgerJournalName::find(JournalNameId).NumberSequenceTable)).voucher());
Trans.currentRecord().insert();
inserted++;
trans.save();
}
}
}
ttsCommit;
icount--;//Remove header recount from total record count
}
catch(Exception::Error)
{
info(strFmt("%1
%2",Exception::Error,icount));
}
args = new Args();
args.record(LedgerJournalTable::find(header.ledgerJournalTable().JournalNum
));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
APà Payment Journal Import:
LedgerJournalName ledgerJournalName;
AxLedgerJournalTrans trans = new
AxLedgerJournalTrans();
AxLedgerJournalTable header = new AxLedgerJournalTable();
str
invoiceNumber,vendorAccount,txt,dimensn,offdimensn,offsetAccount;
container dimm,offdim;
Amount
amountCurDebit,amountCurCredit;
MainAccount mainAccount;
VendTable vendTable;
first = true;
csvFile =
new CommaTextIo(filename, 'r');
csvFile.inFieldDelimiter(',');
readCon =
csvFile.read();
try
{
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
icount++;
readCon = csvFile.read();
if(readCon)
{
if (first)
{
header.parmJournalName(journalNameId);
select ledgerJournalName where ledgerJournalName.JournalName ==
journalNameId;
header.parmJournalType(ledgerJournalName.JournalType);
header.save();
first = false;
}
if (readCon && icount
)//dont insert first record of file : header
{
Transactiondate =
transdate;
invoiceNumber = conPeek(readCon,1);
vendorAccount = conPeek(readCon,2);
txt = conPeek(readCon,3);
currencycode = conPeek(readCon,4);
amountCurDebit = conPeek(readCon,5);
amountCurCredit = conPeek(readCon,6);
offsetAccount = conPeek(readCon,7);
trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
dimensn = strFmt("%1,%1",vendorAccount);//strFmt("%1-%2-%3,%1,2,department,%2,costcenter,%3",ledgerAccount,department,costcenter);
dimm =
str2con(dimensn);
trans.parmAccountType(LedgerJournalACTypE::Vend);
trans.parmLedgerDimension(DimensionStorage::getDynamicAccount(vendorAccount,
LedgerJournalACType::vend)); //AxdDimensionUtil::getLedgerAccountId(dimm));
trans.parmInvoice(invoiceNumber);
trans.parmTxt(txt);
trans.parmDocumentDate(TransDate);
trans.parmTransDate(TransDate);
trans.parmAmountCurDebit(AmountCurDebit);
trans.parmAmountCurCredit(AmountCurCredit) ;
trans.parmCompany(curext());
trans.parmCurrencyCode(currencycode);
trans.parmExchRate(1);
offdimensn = strFmt("%1,%1",offsetAccount);
offdim
=str2con(offdimensn);
mainAccount =
mainAccount::findByMainAccountId(offsetAccount);
if(!mainAccount)
{
trans.parmOffsetLedgerDimension(
DimensionStorage::getDynamicAccount(offsetAccount, LedgerJournalACType::Bank));
trans.parmOffsetAccountType(LedgerJournalACTypE::Bank);
}
else
{
trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offdim));
trans.parmOffsetAccountType(LedgerJournalACTypE::Ledger);
}
trans.parmVoucher(NumberSeq::newGetVoucherFromId((LedgerJournalName::find(JournalNameId).NumberSequenceTable)).voucher());
Trans.currentRecord().insert();
inserted++;
trans.save();
}
}
}
ttsCommit;
icount--;//Remove header recount from total
record count
}
catch(Exception::Error)
{
info(strFmt("%1
%2",Exception::Error,icount));
}
args = new Args();
args.record(LedgerJournalTable::find(header.ledgerJournalTable().JournalNum
));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
Import Completed
No comments:
Post a Comment