Here I'm sharing code to import Vendor Opening Balances Lines.
Note : The below code import only Lines.
-> Copy and paste below code in AOT->Jobs(Compile Job before using)
->open excel and fill the data according to the below format and save in CSV format
->Run job and browse file and press ok
Csv Format :
column1 - Journal Number
column2 - MainAccountNum
column3 - Dimension1
column4 - Dimension2
column5 - Dimension3
column6 - Debit Amount
column7 - Credit Amount
column8 - Transaction Date
Column9 - Description
Column10 - InvoiceId
Column11 - PostingProfile
//Code Starts From Here- @ Rahul Talasila
static void VendorOpeningBalances(Args _args)
{
CommaIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
LedgerJournalACType ledgerJournalACType;
AxLedgerJournalTable axLedgerJournalTable ;
AxLedgerJournalTrans axLedgerJournalTrans;
container accPatternvend,accPatternledger;
container offSetPattern;
DimensionDynamicAccount ledgerdimension;
str transdate;
;
inserted =0;
#File
dialog = new Dialog("Pick the file");
// dialog
dfFileName = dialog.addField(extendedTypeStr(FileNameOpen));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if(dialog.run())
{
filename = dfFileName.value();
}
csvFile = new CommaIO(filename,'r');
if(csvFile)
{
ttsBegin;
while (csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
transdate = conPeek(readCon, 8);
axLedgerJournalTable = new AxLedgerJournalTable();
axLedgerJournalTrans = new AxLedgerJournalTrans();
axLedgerJournalTrans.parmJournalNum(conPeek(readCon, 1));
axLedgerJournalTrans.parmTransDate(str2Date(transdate,123));
axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Vend);
ledgerdimension = DimensionStorage::getDynamicAccount(conPeek(readCon, 2), LedgerJournalACType::Vend);
axLedgerJournalTrans.parmLedgerDimension(ledgerdimension);
axLedgerJournalTrans.parmDefaultDimension(LedgerJournalTable::find(conPeek(readCon, 1)).DefaultDimension);
axLedgerJournalTrans.parmAmountCurDebit(conPeek(readCon, 6));
accPatternledger = [conPeek(readCon,2) + conPeek(readCon,3) + conPeek(readCon,4) + conPeek(readCon,5), conPeek(readCon,2),conPeek(readCon,3),conPeek(readCon,4),conPeek(readCon,5)];
axLedgerJournalTrans.parmOffsetAccountType(LedgerJournalACType::Ledger);
axLedgerJournalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accPatternledger));
axLedgerJournalTrans.parmAmountCurCredit(conPeek(readCon, 7));
axLedgerJournalTrans.parmTxt(conPeek(readCon,9));
axLedgerJournalTrans.parmInvoice(conPeek(readCon,10));
axLedgerJournalTrans.parmPostingProfile(conPeek(readCon,11));
axLedgerJournalTrans.save();
icount++;
inserted++;
}
}
ttsCommit;
}
info(strfmt("%1 records Inserted out of %2",inserted,icount));
}
Note : Based on ledger account dimension structure your account pattern will change
@ Rahul Talasila