• load mainaccount


    static

    void LoadMainAccountCSV(Args _args)

    {

           

    /*

            SysExcelApplication        excel;

            SysExcelWorkbooks      workbooks;

            SysExcelWorkbook        workbook,_workbook;

            SysExcelWorksheets    worksheets,_worksheets;

            SysExcelWorksheet      worksheet,_worksheet;

            SysExcelCells              cells,_cells;

            */

            CommaIo           csvFile;

            COMVariantType              type,_type;

           

    int                        row = 1;

            MainAccount                   _MainAccount;

            MainAccountLegalEntity        _MainAccountLegalEntity;

            FileName                      fileName;

           

    container                     readCon = conNull();

            AccountNum                 mainAccountId;

            ;

            filename =

    @'C:\COA_live.csv';

            csvFile =

    new CommaIo(filename, 'r');

            csvFile.inFieldDelimiter(

    ','); // Delimiter...

           

    /*

            #define.filename(@'C:\chartofaccount.xlsx')

            excel = SysExcelApplication::construct();

            workbooks = excel.workbooks();

            try

            {

                    workbooks.open(#filename);

            }

            catch (Exception::Error)

            {

                    throw error("File cannot be opened");

            }

            workbook      = workbooks.item(1);

            worksheets = workbook.worksheets();

            worksheet    = worksheets.itemFromNum(1);

            cells            = worksheet.cells();

            //row = row + 1;

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

            //通过循环读取导入信息

            */

           

    ttsBegin;

           

    //delete_from _MainAccount;

           

    if (csvFile)

            {

                readCon = csvFile.read();

               

    while (csvFile.status() == IO_Status::OK)

                {

                    readCon = csvFile.read();

                       

    if(conLen(readcon) < 1)

                    {

                       

    break;

                    }

                   

    if(!MainAccount::findByMainAccountId(conPeek(readCon,1)).RecId)

                    {

     

                        _MainAccount.clear();

                        _MainAccount.MainAccountId =

    conPeek(readCon,1);

                        _MainAccount.LedgerChartOfAccounts =

    5637144576;

                       

    switch(conPeek(readCon,2))

                        {

                           

    case"Total":

                                _MainAccount.Type = DimensionLedgerAccountType::Total;

                               

    break;

                           

    case"Asset":

                                _MainAccount.Type = DimensionLedgerAccountType::Asset;

                               

    break;

                           

    case"Liability":

                                _MainAccount.Type = DimensionLedgerAccountType::Liability;

                               

    break;

                           

    case"Equity":

                                _MainAccount.Type = DimensionLedgerAccountType::Equity;

                               

    break;

                           

    case"BalanceSheet":

                                _MainAccount.Type = DimensionLedgerAccountType::BalanceSheet;

                               

    break;

                           

    case"Expense":

                                _MainAccount.Type = DimensionLedgerAccountType::Expense;

                               

    break;

                           

    case"Revenue":

                                _MainAccount.Type = DimensionLedgerAccountType::Revenue;

                               

    break;

                           

    case"ProfitAndLoss":

    _MainAccount.Type = DimensionLedgerAccountType::ProfitAndLoss;

                               

    break;

                           

    case"Blank":

                                _MainAccount.Type = DimensionLedgerAccountType::Blank;

                               

    break;

                           

    case"Reporting":

                                _MainAccount.Type = DimensionLedgerAccountType::Reporting;

                               

    break;

                           

    case"Common_CN":

                                _MainAccount.Type = DimensionLedgerAccountType::Common_CN;

                               

    break;

                        }

                        _MainAccount.Name =

    conPeek(readcon,3);

                        _MainAccount.insert();

                    }

                   

    else

                    {

                        mainAccountId =

    conPeek(readCon,1);

                       

    selectforUpdate _MainAccount

                       

    where _MainAccount.MainAccountId == mainAccountId;

                       

    if(_MainAccount)

                        {

                           

    switch(conPeek(readCon,2))

                            {

                               

    case"Total":

                                    _MainAccount.Type = DimensionLedgerAccountType::Total;

                                   

    break;

                               

    case"Asset":

                                    _MainAccount.Type = DimensionLedgerAccountType::Asset;

                                   

    break;

                               

    case"Liability":

                                    _MainAccount.Type = DimensionLedgerAccountType::Liability;

                                   

    break;

                               

    case"Equity":

                                    _MainAccount.Type = DimensionLedgerAccountType::Equity;

                                   

    break;

                               

    case"BalanceSheet":

                                    _MainAccount.Type = DimensionLedgerAccountType::BalanceSheet;

                                   

    break;

                               

    case"Expense":

                                    _MainAccount.Type = DimensionLedgerAccountType::Expense;

                                   

    break;

                               

    case"Revenue":

                                    _MainAccount.Type = DimensionLedgerAccountType::Revenue;

                                   

    break;

                               

    case"ProfitAndLoss":

    _MainAccount.Type = DimensionLedgerAccountType::ProfitAndLoss;

                                   

    break;

                               

    case"Blank":

                                    _MainAccount.Type = DimensionLedgerAccountType::Blank;

                                   

    break;

                               

    case"Reporting":

                                    _MainAccount.Type = DimensionLedgerAccountType::Reporting;

                                   

    break;

                               

    case"Common_CN":

                                    _MainAccount.Type = DimensionLedgerAccountType::Common_CN;

                                   

    break;

                            }

                        }

                        _MainAccount.update();

                    }

                }

     

            }

           

    ttsCommit;

     

       

    /*

        ttsBegin;

        //delete_from _MainAccountLegalEntity;

        while select _MainAccount

        {

            _MainAccountLegalEntity.clear();

            _MainAccountLegalEntity.LegalEntity = 5637144577;

            _MainAccountLegalEntity.MainAccount = _MainAccount.RecId;

            _MainAccountLegalEntity.insert();

        }

        ttsCommit;

        */

            info(

    "ok");

    }

  • 相关阅读:
    实例使用总结
    AI vs PS 矢量 VS 位图
    快捷键总结
    总结常用公共模块
    No module named MySQLdb
    Ubuntu上mysql, 通过python连接报错Can't connect to MySQL server on xxx (10061)
    移动端Vue组件库-Vant学习
    CKEditor与定制
    js如何将一个数组按照自己固定的顺序排序?
    js如何替换字符串中匹配到多处中某一指定节点?
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/4924591.html
Copyright © 2020-2023  润新知