Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 143529

Job upload General Journal - OffsetAccount not inserted.

$
0
0

Please help me, i have a job for upload General Journal.

Financial dimension ["MainAccount"+"DIVISI"].

Journal created, but only Account in AccountType, for Offset Account not inserted.

static void UploadGenJour(Args _args)
{
    container               accEntryPattern;
    container               offSetEntryPattern;

    LedgerJournalACType     LedgerJournalACType;
    LedgerJournalType       LedgerJournalType;
    ledgerJournalName       ledgerJournalName;
    LedgerJournalTable      _LedgerJournalTable;
    LedgerJournalTrans      _LedgerJournalTrans;
    journalID               JournalID;
    axLedgerJournalTable    journalTable;
    axledgerJournalTrans    journalTrans;
    LedgerJournalType       JournalType = ledgerJournalType::Daily;
    COMVariantType          type;
    Counter                 counter;

    SysExcelApplication     application = SysExcelApplication::construct();
    SysExcelWorkbooks       workbooks   = application.workbooks();
    SysExcelWorkbook        workbook;
    SysExcelWorksheets      workSheets;
    SysExcelWorksheet       workSheet;
    SysExcelCells           cells;
    SysExcelCell            cell;

    int                     row=1;
    int                     LineNum;

    Filename                filename;
    Dialog                  dialog;
    DialogField             dialogFilename, dialogJourName;
    ;

    startLengthyOperation();
    dialog = new Dialog('ExcelUpload');
    dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
    dialogFilename.label('File Path');
    dialog.filenameLookupTitle('Upload From Excel');
    dialog.caption('Upload Opening Balance');
    dialogFilename.value(filename);

    if(!dialog.run())
        return;

    filename    = dialogFilename.value();

    try
    {
        if (workbooks.open(filename, false, true))
        {
            workbook   = workbooks.item(1);
            workSheets = workbook.worksheets();
            workSheet  = workSheets.itemFromNum(1);
            cells      = workSheet.cells();

            journalTable = new axLedgerJournalTable();
            journalTable.parmJournalName("GJ");
            journalTable.parmJournalType(JournalType);
            journalTable.parmName("Upload opening balance");
            journalTable.save();

            JournalID = journalTable.parmJournalNum();

            row++;
            type = cells.item(row,1).value().variantType();

            ttsBegin;
            while (type != COMVariantType::VT_EMPTY)
            {
                counter++;

                journalTrans = new axLedgerJournalTrans();
                journalTrans.parmJournalNum(JournalID);

                journalTrans.parmTransDate(cells.item(row,1).value().date());
                journalTrans.parmAccountType(str2Enum(LedgerJournalACType,cells.item(row,2).value().bStr()));

                if(cells.item(row,2).value().bStr() == "Ledger")
                {
                    accEntryPattern = [cells.item(row,3).value().bStr()+"-"+"Disp"
                                      ,cells.item(row,3).value().bStr()
                                      ,1
                                      ,"DIVISI", cells.item(row,4).value().bStr()];
                    journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accEntryPattern));
                }

                if(cells.item(row,7).value().double() != 0)
                {
                    journalTrans.parmAmountCurDebit(cells.item(row,7).value().double());
                }
                if(cells.item(row,8).value().double() != 0)
                {
                    journalTrans.parmAmountCurCredit(cells.item(row,8).value().double());
                }

                journalTrans.parmtxt(cells.item(row,5).value().bStr());
                journalTrans.parmOffsetAccountType(str2Enum(LedgerJournalACType,cells.item(row,9).value().bStr()));

                if(cells.item(row,9).value().bStr() == "Ledger")
                {
                    offSetEntryPattern = [cells.item(row,10).value().bStr()+"-"+"Disp"
                                         ,cells.item(row,10).value().bStr()
                                         ,1
                                         ,"DIVISI", cells.item(row,11).value().bStr()];
                    journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offSetEntryPattern));
                }

                journalTrans.parmCurrencyCode(cells.item(row,6).value().bStr());
                journalTrans.save();

                row++;
                type = cells.item(row,1).value().variantType();
            }
            
            ttsCommit;
            info(strfmt("Inserted %1 rows",counter));
            application.quit();
        }
    }
    catch(Exception::Error)
    {
        info('Journal upload error');
        application.quit();
    }
}


Viewing all articles
Browse latest Browse all 143529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>