static void GLImport(Args _args)
{
LedgerjournalTable LedgerjournalTable;
LedgerjournalTrans LedgerjournalTrans;
numberSeq numberSeq;
container ledgerDimensions, offsetDimensions;
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Filename filename;
Name ledgerdim, offsetledgerdim;
boolean first;
MainAccount main;
filename = "c:\\Test.csv";
first = true;
csvFile = new CommaTextIo(filename, 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
//main = MainAccount::findByMainAccountId(conPeek(readCon,1));
//if (!main)
//{
//info(strFmt("does not exist --- %1", conPeek(readCon,1))) ;
//}
//else{
//info(strFmt("exist --- %1", conPeek(readCon,1))) ;
//}
if (first)
{
LedgerjournalTable.clear();
LedgerjournalTable.JournalName ="OpBal";
LedgerjournalTable.initFromLedgerJournalName();
LedgerjournalTable.name = "Ledger opening balance";
LedgerjournalTable.JournalNum = NumberSeq::newGetNum(LedgerParameters::numRefJournalNum()).num(); //JournalTableData::newTable(LedgerjournalTable).nextJournalId();
LedgerjournalTable.insert();
first = false;
}
LedgerjournalTrans.clear();
LedgerjournalTrans.AmountCurCredit = 0;
LedgerjournalTrans.AmountCurDebit = 0;
ledgerdim = conPeek(readCon,1);
offsetledgerdim = conpeek(readCon,4);
LedgerjournalTrans.Voucher = NumberSeq::newGetVoucherFromId((LedgerJournalName::find("OpBal").NumberSequenceTable)).voucher();
LedgerjournalTrans.JournalNum = LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode = CompanyInfo::standardCurrency();
LedgerjournalTrans.Txt = "Opening Balance";
LedgerjournalTrans.TransDate = mkDate(31,12,2013);
ledgerDimensions = [ledgerdim, ledgerdim, 0];
offsetDimensions = [offsetledgerdim, offsetledgerdim, 0];
LedgerjournalTrans.DocumentDate = mkDate(31,12,2013);
LedgerjournalTrans.AccountType = LedgerJournalACType::Ledger;
LedgerjournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
LedgerjournalTrans.AmountCurCredit = conPeek(readCon,3);
LedgerjournalTrans.AmountCurDebit = conPeek(readCon,2);
LedgerjournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
LedgerjournalTrans.OffsetLedgerDimension = AxdDimensionUtil::getLedgerAccountId(offsetDimensions);
LedgerjournalTrans.insert();
}
}
}
CSV Format :
1) Ledger Dimension
2) Debit Amount
3) Credit Amount
4) Offset Ledger Dimension
{
LedgerjournalTable LedgerjournalTable;
LedgerjournalTrans LedgerjournalTrans;
numberSeq numberSeq;
container ledgerDimensions, offsetDimensions;
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Filename filename;
Name ledgerdim, offsetledgerdim;
boolean first;
MainAccount main;
filename = "c:\\Test.csv";
first = true;
csvFile = new CommaTextIo(filename, 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
//main = MainAccount::findByMainAccountId(conPeek(readCon,1));
//if (!main)
//{
//info(strFmt("does not exist --- %1", conPeek(readCon,1))) ;
//}
//else{
//info(strFmt("exist --- %1", conPeek(readCon,1))) ;
//}
if (first)
{
LedgerjournalTable.clear();
LedgerjournalTable.JournalName ="OpBal";
LedgerjournalTable.initFromLedgerJournalName();
LedgerjournalTable.name = "Ledger opening balance";
LedgerjournalTable.JournalNum = NumberSeq::newGetNum(LedgerParameters::numRefJournalNum()).num(); //JournalTableData::newTable(LedgerjournalTable).nextJournalId();
LedgerjournalTable.insert();
first = false;
}
LedgerjournalTrans.clear();
LedgerjournalTrans.AmountCurCredit = 0;
LedgerjournalTrans.AmountCurDebit = 0;
ledgerdim = conPeek(readCon,1);
offsetledgerdim = conpeek(readCon,4);
LedgerjournalTrans.Voucher = NumberSeq::newGetVoucherFromId((LedgerJournalName::find("OpBal").NumberSequenceTable)).voucher();
LedgerjournalTrans.JournalNum = LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode = CompanyInfo::standardCurrency();
LedgerjournalTrans.Txt = "Opening Balance";
LedgerjournalTrans.TransDate = mkDate(31,12,2013);
ledgerDimensions = [ledgerdim, ledgerdim, 0];
offsetDimensions = [offsetledgerdim, offsetledgerdim, 0];
LedgerjournalTrans.DocumentDate = mkDate(31,12,2013);
LedgerjournalTrans.AccountType = LedgerJournalACType::Ledger;
LedgerjournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
LedgerjournalTrans.AmountCurCredit = conPeek(readCon,3);
LedgerjournalTrans.AmountCurDebit = conPeek(readCon,2);
LedgerjournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
LedgerjournalTrans.OffsetLedgerDimension = AxdDimensionUtil::getLedgerAccountId(offsetDimensions);
LedgerjournalTrans.insert();
}
}
}
CSV Format :
1) Ledger Dimension
2) Debit Amount
3) Credit Amount
4) Offset Ledger Dimension
No comments:
Post a Comment