load mainaccount

时间:2023-03-09 19:06:04
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;

;

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();

)

{

break;

}

)).RecId)

{

 

_MainAccount.clear();

_MainAccount.MainAccountId =

);

_MainAccount.LedgerChartOfAccounts =

;

))

{

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 =

);

_MainAccount.insert();

}

else

{

mainAccountId =

);

selectforUpdate _MainAccount

where _MainAccount.MainAccountId == mainAccountId;

if(_MainAccount)

{

))

{

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");

}