static void GeneralJournalinsert(Args _args)
{
Dialog dialog;
DialogField dfFileName;
boolean first = true;
Io io;
#file
LedgerJournalType JournalType;
str voucher,journalnum,journaldate,offsetaccounttype,offsetaccount,paymentreference,department,costcenter,offsetcostcenter,offsetdepartment,journalname,methodofpayment,currency,name,companyaccount,accounttype,account,Description ;
int debit,credit;
TransDate transdate;
DimensionDynamicAccount ledger;
str filenameopen;
int64 ledgerOffset;
FilenameOpen filename = "j:\\sample.csv";//To assign file name
Container readcon;
AxLedgerJournalTable journalTable;
AxLedgerJournalTrans journalTrans;
container acctPattern;
container offSetAcctPattern;
LedgerJournalTable ledgerJournalTable;
ledgerJournalCheckPost ledgerJournalCheckPost;
journalTable = new AxLedgerJournalTable();// header table class
iO = new CommaTextIo(filename,#IO_Read);
if (! iO || iO.status() != IO_Status::Ok)
{
throw error("@SYS19358");
}
while (iO.status() == IO_Status::Ok)
{
readCon = iO.read();// To read file
if (readCon)
{
if (first) //To skip header
{
first = false;
}
else
{
journalname = conPeek(readCon,1);
journaldate = conPeek(readCon,2);
transdate = str2Date(journaldate,123);
voucher = conPeek(readCon,3);
accounttype = conPeek(readCon,4);
account = conPeek(readCon,5);
Description = conPeek(readCon,6);
Debit = conPeek(readCon,7);
credit = conPeek(readCon,8);
offsetaccounttype = conPeek(readCon,9);
offsetaccount = conPeek(readCon,10);
department = conPeek(readCon,11);
costcenter = conPeek(readCon,12);
offsetcostcenter = conPeek(readCon,13);
offsetdepartment = conPeek(readCon,14);
journalTable.parmJournalName(journalname);
journalTable.save();
journalTrans = new AxLedgerJournalTrans(); //// line table class
journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(transdate);
journalTrans.parmAmountCurDebit(Debit);
journalTrans.parmAmountCurCredit(credit);
journalTrans.parmAccountType(LedgerJournalACType::Ledger);
acctPattern = [account,account, 2, "department",department,"costcenter", costcenter];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
offSetAcctPattern = [offsetaccount,offsetaccount, 2, "Department",offsetdepartment, "CostCenter",offsetcostcenter];
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern));
journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
journalTrans.save();
//ledgerJournalCheckPost = //ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
//ledgerJournalCheckPost.run();
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}
}
}
}
{
Dialog dialog;
DialogField dfFileName;
boolean first = true;
Io io;
#file
LedgerJournalType JournalType;
str voucher,journalnum,journaldate,offsetaccounttype,offsetaccount,paymentreference,department,costcenter,offsetcostcenter,offsetdepartment,journalname,methodofpayment,currency,name,companyaccount,accounttype,account,Description ;
int debit,credit;
TransDate transdate;
DimensionDynamicAccount ledger;
str filenameopen;
int64 ledgerOffset;
FilenameOpen filename = "j:\\sample.csv";//To assign file name
Container readcon;
AxLedgerJournalTable journalTable;
AxLedgerJournalTrans journalTrans;
container acctPattern;
container offSetAcctPattern;
LedgerJournalTable ledgerJournalTable;
ledgerJournalCheckPost ledgerJournalCheckPost;
journalTable = new AxLedgerJournalTable();// header table class
iO = new CommaTextIo(filename,#IO_Read);
if (! iO || iO.status() != IO_Status::Ok)
{
throw error("@SYS19358");
}
while (iO.status() == IO_Status::Ok)
{
readCon = iO.read();// To read file
if (readCon)
{
if (first) //To skip header
{
first = false;
}
else
{
journalname = conPeek(readCon,1);
journaldate = conPeek(readCon,2);
transdate = str2Date(journaldate,123);
voucher = conPeek(readCon,3);
accounttype = conPeek(readCon,4);
account = conPeek(readCon,5);
Description = conPeek(readCon,6);
Debit = conPeek(readCon,7);
credit = conPeek(readCon,8);
offsetaccounttype = conPeek(readCon,9);
offsetaccount = conPeek(readCon,10);
department = conPeek(readCon,11);
costcenter = conPeek(readCon,12);
offsetcostcenter = conPeek(readCon,13);
offsetdepartment = conPeek(readCon,14);
journalTable.parmJournalName(journalname);
journalTable.save();
journalTrans = new AxLedgerJournalTrans(); //// line table class
journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(transdate);
journalTrans.parmAmountCurDebit(Debit);
journalTrans.parmAmountCurCredit(credit);
journalTrans.parmAccountType(LedgerJournalACType::Ledger);
acctPattern = [account,account, 2, "department",department,"costcenter", costcenter];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
offSetAcctPattern = [offsetaccount,offsetaccount, 2, "Department",offsetdepartment, "CostCenter",offsetcostcenter];
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern));
journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
journalTrans.save();
//ledgerJournalCheckPost = //ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
//ledgerJournalCheckPost.run();
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}
}
}
}
No comments:
Post a Comment