Opening Balance CSV
import:
filename = dialogFilename.value();
fromDate = dialogFromDate.value();
journalNameId = dialogledger.Value();
impBal = dialogimpBal.value();
journalName = dialogJournalName.value();
journalTxt = dialogJournalTxt.value();
Customer Opening Balance:
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)
{
icount++;
if (first)
{
LedgerjournalTable.clear();
LedgerjournalTable.JournalName
= JournalNameId;
LedgerjournalTable.initFromLedgerJournalName();
LedgerjournalTable.name
= journalName;
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(JournalNameId).NumberSequenceTable)).voucher();
LedgerjournalTrans.JournalNum =
LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode
=
CompanyInfo::standardCurrency();
LedgerjournalTrans.Txt
= journalTxt;
LedgerjournalTrans.ExchRate =
100;
LedgerjournalTrans.TransDate
= Fromdate;
ledgerDimensions
= [ledgerdim, ledgerdim, 0];
//ledgerDimensions = [ledgerdim, 0];
offsetDimensions
= [offsetledgerdim, offsetledgerdim, 0];
LedgerjournalTrans.DocumentDate
= Fromdate;
LedgerjournalTrans.AccountType = LedgerJournalACType::Cust;
dim =
DimensionStorage::getDynamicAccount(ledgerdim,enum2int(LedgerJournalACType::Cust));
//LedgerjournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
LedgerjournalTrans.LedgerDimension
= dim;
LedgerjournalTrans.AmountCurCredit
= conPeek(readCon,3);
LedgerjournalTrans.AmountCurDebit
= conPeek(readCon,2);
LedgerjournalTrans.OffsetAccountType
= LedgerJournalACType::Ledger;
LedgerjournalTrans.OffsetLedgerDimension =
AxdDimensionUtil::getLedgerAccountId(offsetDimensions);
LedgerjournalTrans.insert();
//currentMainAccountId =
dimAccountController.getValue(DimensionAttribute::getMainAccountDimensionAttribute());
}
}
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(ledgerjournaltable.JournalNum ));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
MainAccount opening Balance:
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)
{
icount++;
if (first)
{
LedgerjournalTable.clear();
LedgerjournalTable.JournalName
= JournalNameId;
LedgerjournalTable.initFromLedgerJournalName();
LedgerjournalTable.name
= journalName;
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(JournalNameId).NumberSequenceTable)).voucher();
LedgerjournalTrans.JournalNum
= LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode
=
CompanyInfo::standardCurrency();
LedgerjournalTrans.Txt
= journalTxt;
LedgerjournalTrans.ExchRate
= 100;
LedgerjournalTrans.TransDate
= Fromdate;
//
ledgerDimensions
= [ledgerdim, ledgerdim, 0];
ledgerDimensions =
[ledgerdim,ledgerdim, 0];
offsetDimensions
= [offsetledgerdim, offsetledgerdim, 0];
LedgerjournalTrans.DocumentDate
= Fromdate;
LedgerjournalTrans.AccountType
= LedgerJournalACType::Ledger;
// dim =
DimensionStorage::getDynamicAccount(ledgerdim,enum2int(LedgerJournalACType::Ledger));
LedgerjournalTrans.LedgerDimension
= AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
// LedgerjournalTrans.LedgerDimension = dim;
LedgerjournalTrans.AmountCurCredit
= conPeek(readCon,3);
LedgerjournalTrans.AmountCurDebit
= conPeek(readCon,2);
LedgerjournalTrans.OffsetAccountType
= LedgerJournalACType::Ledger;
LedgerjournalTrans.OffsetLedgerDimension =
AxdDimensionUtil::getLedgerAccountId(offsetDimensions);
LedgerjournalTrans.insert();
// currentMainAccountId =
dimAccountController.getValue(DimensionAttribute::getMainAccountDimensionAttribute());
}
}
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(ledgerjournaltable.JournalNum ));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
Vendor Opening Balance:
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)
{
icount++;
if (first)
{
LedgerjournalTable.clear();
LedgerjournalTable.JournalName
= JournalNameId;
LedgerjournalTable.initFromLedgerJournalName();
LedgerjournalTable.name
= journalName;
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(JournalNameId).NumberSequenceTable)).voucher();
LedgerjournalTrans.JournalNum
= LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode
=
CompanyInfo::standardCurrency();
LedgerjournalTrans.Txt
= journalTxt;
LedgerjournalTrans.ExchRate
= 100;
LedgerjournalTrans.TransDate
= Fromdate;
ledgerDimensions
= [ledgerdim, ledgerdim, 0];
//ledgerDimensions = [ledgerdim, 0];
offsetDimensions
= [offsetledgerdim, offsetledgerdim, 0];
LedgerjournalTrans.DocumentDate
= Fromdate;
LedgerjournalTrans.AccountType
= LedgerJournalACType::Vend;
dim =
DimensionStorage::getDynamicAccount(ledgerdim,enum2int(LedgerJournalACType::Vend));
//LedgerjournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
LedgerjournalTrans.LedgerDimension
= dim;
LedgerjournalTrans.AmountCurCredit
= conPeek(readCon,3);
LedgerjournalTrans.AmountCurDebit
= conPeek(readCon,2);
LedgerjournalTrans.OffsetAccountType
= LedgerJournalACType::Ledger;
LedgerjournalTrans.OffsetLedgerDimension =
AxdDimensionUtil::getLedgerAccountId(offsetDimensions);
LedgerjournalTrans.insert();
// currentMainAccountId =
dimAccountController.getValue(DimensionAttribute::getMainAccountDimensionAttribute());
}
}
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(ledgerjournaltable.JournalNum ));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
Bank opening Balance:
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)
{
icount++;
if (first)
{
LedgerjournalTable.clear();
LedgerjournalTable.JournalName
= JournalNameId;
LedgerjournalTable.initFromLedgerJournalName();
LedgerjournalTable.name
= journalName;
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(JournalNameId).NumberSequenceTable)).voucher();
LedgerjournalTrans.JournalNum
= LedgerjournalTable.JournalNum;
LedgerjournalTrans.CurrencyCode
=
CompanyInfo::standardCurrency();
LedgerjournalTrans.Txt
= journalTxt;
LedgerjournalTrans.ExchRate
= 100;
LedgerjournalTrans.TransDate
= Fromdate;
//
ledgerDimensions
= [ledgerdim, ledgerdim, 0];
ledgerDimensions
= [ledgerdim, 0];
offsetDimensions = [offsetledgerdim,
offsetledgerdim, 0];
LedgerjournalTrans.DocumentDate
= Fromdate;
LedgerjournalTrans.AccountType
= LedgerJournalACType::Bank;
dim =
DimensionStorage::getDynamicAccount(ledgerdim,enum2int(LedgerJournalACType::Bank));
//LedgerjournalTrans.LedgerDimension =
AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);
LedgerjournalTrans.LedgerDimension
= dim;
LedgerjournalTrans.AmountCurCredit
= conPeek(readCon,3);
LedgerjournalTrans.AmountCurDebit
= conPeek(readCon,2);
LedgerjournalTrans.OffsetAccountType
= LedgerJournalACType::Ledger;
LedgerjournalTrans.OffsetLedgerDimension =
AxdDimensionUtil::getLedgerAccountId(offsetDimensions);
LedgerjournalTrans.insert();
// currentMainAccountId =
dimAccountController.getValue(DimensionAttribute::getMainAccountDimensionAttribute());
}
}
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(ledgerjournaltable.JournalNum ));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
Fixed Asset Depr Balance:
NumberSequenceTable
numberSequenceTable;
Voucher
voucher;
str accountType;
Amount
amountCurDebit,amountCurCredit,amtcrdt,amtdebt;
container
conSplitValue,dimm,offdim;
str 64
custAccount,ledgerAccount;
str costcenter,department,revenueDimension,description;
LedgerJournalACTypE
acctype,offacctype;
DimensionStorage
DimensionStorage;
LedgerJournalTrans_Asset
ledgerJournalTransAssets;
AssetTable
assetTable ;
LedgerDimensionDefaultAccount
defaultAccount;
LedgerJournalEngine
ledgerJournalEngine;
AssetBook
assetBook;
str 64 assetid;
AssetTransTypeJournal
transtype;
LedgerJournalName
ledgerJournalName;
;
LedgerJournalNameId = Ledgerjournalnameid1;
TransDate= Fromdate;
csvFiles
= new CommaIO(filename, 'r');
try
{
if (csvFiles)
{
ttsbegin;
if(first) //Create
Journal Header
{
Select ledgerjournalname where ledgerjournalname.JournalName ==
LedgerJournalNameId;
if(!ledgerJournalName.RecId)
{
throw error ("ledgerJournalName doesn't exist");
}
ledgerJournalTable.clear();
ledgerJournalTable.initValue();
ledgerJournalTable.JournalNum =
JournalTableData::newTable(ledgerJournalTable).nextJournalId();
ledgerJournalTable.journalType =
LedgerJournalType::Daily;
ledgerJournalTable.JournalName =
ledgerJournalName.JournalName;
ledgerJournalTable.Name = journalName;
ledgerJournalTable.initFromLedgerJournalName(ledgerJournalName.JournalName);
ledgerJournalTable.insert();
first = false;
}
while (csvFiles.status() == IO_Status::OK)
{
readCon = csvFiles.read();
icount++;
amountCurDebit = 0;
amountCurCredit = 0;
numberSequenceTable =
NumberSequenceTable::find(LedgerJournalName::find(LedgerJournalNameId).NumberSequenceTable);
voucher =
NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
if (readCon && icount
)//dont insert first record of file : header
{
description = journalTxt;
currencycode = CompanyInfo::standardCurrency();
acctype = LedgerJournalACType::FixedAssets;
assetid = conPeek(readCon,1);
amountCurDebit = conPeek(readCon,2);
amountCurCredit = conPeek(readCon,3);
ledgerAccount = conPeek(readCon,4);
transtype = AssetTransTypeJournal::Depreciation;
ledgerJournalTrans.JournalNum
= ledgerJournalTable.JournalNum;
assetTable=assetTable::find(assetid);
select assetBook where assetBook.AssetId == assetid;
ledgerJournalTrans.CurrencyCode
= currencyCode;
ledgerJournalTrans.initValue();
ledgerJournalTrans.LedgerDimension =
DimensionStorage::getDynamicAccount(assetid,acctype);
ledgerJournalTrans.parmAccount(AssetId,
LedgerJournalACType::FixedAssets);
ledgerJournalTrans.TransDate
= transDate;
ledgerJournalTrans.Txt
= description;
ledgerJournalTrans.AccountType
= acctype;
ledgerJournalTrans.Voucher
= voucher;
ledgerJournalTrans.PostingProfile
=AssetParameters::find().PostingProfile;
ledgerJournalTrans.Company
= curext();
ledgerJournalTrans.OffsetCompany
= curext();
ledgerJournalTrans.OffsetDefaultDimension = 0;
dimm = [ledgeraccount,ledgeraccount,"",""];
ledgerJournalTrans.OffsetAccountType
= LedgerJournalACType::Ledger;
ledgerJournalTrans.AmountCurCredit
= amountCurCredit;
ledgerJournalTrans.AmountCurDebit
= amountCurDebit;
ledgerJournalTrans.DefaultDimension
= CustFinancialDimension::CreateDimension(AssetId);
ledgerJournalTrans.OffsetAccountType
= ledgerJournalTable.OffsetAccountType;
ledgerJournalTrans.OffsetLedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerJournalTable.OffsetLedgerDimension,
ledgerJournalTrans.DefaultDimension);
defaultAccount =
AssetTable::find(assetTable.AssetId).assetOffsetLedgerDimension(ledgerJournalTrans.PostingProfile,
AssetPost::assetTransTypeJournal2AssetTransType(AssetTransTypeJournal::Acquisition),
AssetBook.BookId);
ledgerJournalTrans.OffsetLedgerDimension =
this.getLedgerDimension(ledgerAccount);
ledgerJournalTrans.calcAmountMST();
ledgerJournalTrans.insert();
ledgerJournalTransAssets.BookId = assetBook.BookId;
ledgerJournalTransAssets.TransType
= AssetTransTypeJournal::Depreciation;
ledgerJournalTransAssets.AssetId
= ledgerJournalTrans.parmAccount();
ledgerJournalTransAssets.Company
= ledgerJournalTrans.Company;
ledgerJournalEngine = new
LedgerJournalEngine();
ledgerJournalEngine.initDefaultDimension(ledgerJournalTrans, ledgerJournalTransAssets);
ledgerJournalTransAssets.RefRecId
= ledgerJournalTrans.RecId;
ledgerJournalTransAssets.insert();
inserted++;
} // if ends
}
// while ends
ttsCommit;
} // if ends
icount--;
} // try ends
catch(Exception::Error)
{
info(strFmt("%1
%2",Exception::Error,icount));
}
args = new Args();
args.record(LedgerJournalTable::find(ledgerjournaltable.JournalNum ));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
Fixed Asses Acq
Balance:
NumberSequenceTable numberSequenceTable;
Voucher
voucher;
str accountType;
Amount
amountCurDebit,amountCurCredit,amtcrdt,amtdebt;
container
conSplitValue,dimm,offdim;
str 64
custAccount,ledgerAccount;
str
costcenter,department,revenueDimension,description;
LedgerJournalACTypE
acctype,offacctype;
DimensionStorage DimensionStorage;
LedgerJournalTrans_Asset
ledgerJournalTransAssets;
AssetTable
assetTable ;
LedgerDimensionDefaultAccount
defaultAccount;
LedgerJournalEngine
ledgerJournalEngine;
AssetBook
assetBook;
str 64 assetid;
AssetTransTypeJournal
transtype;
LedgerJournalName
ledgerJournalName;
;
LedgerJournalNameId = JournalNameId;
TransDate= Fromdate;
csvFiles
= new CommaIO(filename, 'r');
try
{
if (csvFiles)
{
ttsbegin;
if(first) //Create
Journal Header
{
Select ledgerjournalname where ledgerjournalname.JournalName ==
LedgerJournalNameId;
if(!ledgerJournalName.RecId)
{
throw error ("ledgerJournalName doesn't exist");
}
ledgerJournalTable.clear();
ledgerJournalTable.initValue();
ledgerJournalTable.JournalNum =
JournalTableData::newTable(ledgerJournalTable).nextJournalId();
ledgerJournalTable.journalType =
LedgerJournalType::Daily;
ledgerJournalTable.JournalName =
ledgerJournalName.JournalName;
ledgerJournalTable.Name =
journalName;
ledgerJournalTable.initFromLedgerJournalName(ledgerJournalName.JournalName);
ledgerJournalTable.insert();
first = false;
}
numberSequenceTable =
NumberSequenceTable::find(LedgerJournalName::find(LedgerJournalNameId).NumberSequenceTable);
voucher =
NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
while (csvFiles.status() == IO_Status::OK)
{
readCon = csvFiles.read();
icount++;
amountCurDebit = 0;
amountCurCredit = 0;
if (readCon && icount
)//dont insert first record of file : header
{
description = journalTxt;
currencycode =
CompanyInfo::standardCurrency();
acctype = LedgerJournalACType::FixedAssets;
assetid = conPeek(readCon,1);
amountCurDebit = conPeek(readCon,2);
amountCurCredit = conPeek(readCon,3);
ledgerAccount = conPeek(readCon,4);
transtype = AssetTransTypeJournal::Acquisition;
ledgerJournalTrans.JournalNum
= ledgerJournalTable.JournalNum;
assetTable=assetTable::find(assetid);
select
assetBook where assetBook.AssetId ==
assetid;
ledgerJournalTrans.CurrencyCode
= currencyCode;
ledgerJournalTrans.initValue();
ledgerJournalTrans.LedgerDimension
=
DimensionStorage::getDynamicAccount(assetid,acctype);
ledgerJournalTrans.parmAccount(AssetId,
LedgerJournalACType::FixedAssets);
ledgerJournalTrans.TransDate
= transDate;
ledgerJournalTrans.Txt
= description;
ledgerJournalTrans.AccountType
= acctype;
ledgerJournalTrans.Voucher
= voucher;
ledgerJournalTrans.PostingProfile
=AssetParameters::find().PostingProfile;
ledgerJournalTrans.Company
= curext();
ledgerJournalTrans.OffsetCompany
= curext();
ledgerJournalTrans.OffsetDefaultDimension
= 0;
dimm
= [ledgeraccount,ledgeraccount,"",""];
ledgerJournalTrans.OffsetAccountType
= LedgerJournalACType::Ledger;
ledgerJournalTrans.AmountCurCredit =
amountCurCredit;
ledgerJournalTrans.AmountCurDebit
= amountCurDebit;
ledgerJournalTrans.DefaultDimension
= CustFinancialDimension::CreateDimension(AssetId);
ledgerJournalTrans.OffsetAccountType
= ledgerJournalTable.OffsetAccountType;
ledgerJournalTrans.OffsetLedgerDimension =
DimensionDefaultingService::serviceCreateLedgerDimension(ledgerJournalTable.OffsetLedgerDimension,
ledgerJournalTrans.DefaultDimension);
defaultAccount =
AssetTable::find(assetTable.AssetId).assetOffsetLedgerDimension(ledgerJournalTrans.PostingProfile,
AssetPost::assetTransTypeJournal2AssetTransType(AssetTransTypeJournal::Acquisition),
AssetBook.BookId);
ledgerJournalTrans.OffsetLedgerDimension =
this.getLedgerDimension(ledgerAccount);
ledgerJournalTrans.calcAmountMST();
ledgerJournalTrans.insert();
ledgerJournalTransAssets.BookId
= assetBook.BookId;
ledgerJournalTransAssets.TransType
= AssetTransTypeJournal::Acquisition;
ledgerJournalTransAssets.AssetId
= ledgerJournalTrans.parmAccount();
ledgerJournalTransAssets.Company
= ledgerJournalTrans.Company;
ledgerJournalEngine = new
LedgerJournalEngine();
ledgerJournalEngine.initDefaultDimension(ledgerJournalTrans,
ledgerJournalTransAssets);
ledgerJournalTransAssets.RefRecId
= ledgerJournalTrans.RecId;
ledgerJournalTransAssets.insert();
inserted++;
} // if ends
}
// while ends
ttsCommit;
} // if ends
icount--;
} // try ends
catch(Exception::Error)
{
info(strFmt("%1
%2",Exception::Error,icount));
}
args = new Args();
args.record(LedgerJournalTable::find(ledgerjournaltable.JournalNum ));
new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
//
//
No comments:
Post a Comment