static void THK_importLedgerJournalTrans(Args _args)
{
Filename fileName = "C:\\Users\\ksiu3880\\Desktop\\GL Journal test.xlsx"; LedgerJournalId ledgerJournalId = "000425_010";
Name nameDimensionAttribute1 = "Department";
Name nameDimensionAttribute2 = "CostCenter";
Name nameDimensionAttribute3 = "ExpensePurpose"; LedgerJournalTrans_Asset ledgerJournalTrans_Asset; AxLedgerJournalTable axLedgerJournalTable;
AxLedgerJournalTrans axLedgerJournalTrans; DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage; SysExcelApplication application = SysExcelApplication::construct();
SysExcelWorkbooks workbooks = application.workbooks();
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells; COMVariantType type; TransDate transDate;
LedgerJournalACType ledgerJournalACType, ledgerJournalACTypeOffset;
MainAccountNum mainAccountNum, mainAccountNumOffset;
DimensionValue dimensionValue1, dimensionValue2, dimensionValue3;
LedgerJournalTransTxt ledgerJournalTransTxt;
CurrencyCode currencyCode;
AmountCur amountCur;
ExchRate exchRate, exchRateSecond;
InvoiceId invoiceId;
DocumentDate documentDate;
DueDate dueDate;
PaymTermId paymTermId;
AssetTransTypeJournal assetTransTypeJournal;
AssetBookIdPurchSalesInvent assetBookIdPurchSalesInvent; container con, conOffset;
int numOfDimension; int row = ; setPrefix("THK_importLedgerJournalTrans"); try
{
if (!LedgerJournalTable::checkExist(ledgerJournalId))
throw Exception::Error; workbooks.open(fileName); workbook = workbooks.item();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum();
cells = worksheet.cells(); ttsBegin; do
{
row++; print row; setPrefix(strFmt("Row %1", row)); transDate = cells.item(row, ).value().date();
mainAccountNum = strLRTrim(cells.item(row, ).value().bStr());
dimensionValue1 = strLRTrim(cells.item(row, ).value().bStr());
dimensionValue2 = strLRTrim(cells.item(row, ).value().bStr());
dimensionValue3 = strLRTrim(cells.item(row, ).value().bStr());
ledgerJournalTransTxt = strLRTrim(cells.item(row, ).value().bStr());
currencyCode = strLRTrim(cells.item(row, ).value().bStr());
amountCur = cells.item(row, ).value().double();
exchRate = cells.item(row, ).value().double();
exchRateSecond = cells.item(row, ).value().double();
invoiceId = strLRTrim(cells.item(row, ).value().bStr());
documentDate = cells.item(row, ).value().date();
dueDate = cells.item(row, ).value().date();
paymTermId = strLRTrim(cells.item(row, ).value().bStr());
assetBookIdPurchSalesInvent = strLRTrim(cells.item(row, ).value().bStr());
mainAccountNumOffset = strLRTrim(cells.item(row, ).value().bStr()); switch (strLRTrim(cells.item(row, ).value().bStr()))
{
case "Bank": ledgerJournalACType = ledgerJournalACType::Bank; break;
case "Customer": ledgerJournalACType = ledgerJournalACType::Cust; break;
case "Fixed Assets": ledgerJournalACType = ledgerJournalACType::FixedAssets; break;
case "Ledger": ledgerJournalACType = ledgerJournalACType::Ledger; break;
case "Project": ledgerJournalACType = ledgerJournalACType::Project; break;
case "Vendor": ledgerJournalACType = ledgerJournalACType::Vend; break;
default: ledgerJournalACType = ledgerJournalACType::Ledger; break;
} switch (strLRTrim(cells.item(row, ).value().bStr()))
{
case "Acquisition": assetTransTypeJournal = AssetTransTypeJournal::Acquisition; break;
case "Acquisition Adjustment": assetTransTypeJournal = AssetTransTypeJournal::AcquisitionAdj; break;
default: assetTransTypeJournal = AssetTransTypeJournal::Acquisition; break;
} switch (strLRTrim(cells.item(row, ).value().bStr()))
{
case "Bank": ledgerJournalACTypeOffset = ledgerJournalACType::Bank; break;
case "Customer": ledgerJournalACTypeOffset = ledgerJournalACType::Cust; break;
case "Fixed Assets": ledgerJournalACTypeOffset = ledgerJournalACType::FixedAssets; break;
case "Ledger": ledgerJournalACTypeOffset = ledgerJournalACType::Ledger; break;
case "Project": ledgerJournalACTypeOffset = ledgerJournalACType::Project; break;
case "Vendor": ledgerJournalACTypeOffset = ledgerJournalACType::Vend; break;
default: ledgerJournalACTypeOffset = ledgerJournalACType::Ledger; break;
} axLedgerJournalTrans = new AxLedgerJournalTrans();
con = [mainAccountNum, mainAccountNum];
conOffset = [mainAccountNumOffset, mainAccountNumOffset];
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
numOfDimension = ; if (dimensionValue1)
{
con += [nameDimensionAttribute1, dimensionValue1];
conOffset += [nameDimensionAttribute1, dimensionValue1];
numOfDimension ++; dimensionAttributeValueSetStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(nameDimensionAttribute1), dimensionValue1));
} if (dimensionValue2)
{
con += [nameDimensionAttribute2, dimensionValue2];
conOffset += [nameDimensionAttribute2, dimensionValue2];
numOfDimension ++; dimensionAttributeValueSetStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(nameDimensionAttribute2), dimensionValue2));
} if (dimensionValue3)
{
con += [nameDimensionAttribute3, dimensionValue3];
conOffset += [nameDimensionAttribute3, dimensionValue3];
numOfDimension ++; dimensionAttributeValueSetStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(nameDimensionAttribute3), dimensionValue3));
} con = conIns(con, , numOfDimension);
conOffset = conIns(conOffset, , numOfDimension); axLedgerJournalTrans.parmJournalNum(ledgerJournalId);
axLedgerJournalTrans.parmTransDate(transDate);
axLedgerJournalTrans.parmAccountType(ledgerJournalACType);
axLedgerJournalTrans.parmLedgerDimension(AxdDimensionUtil::getMultiTypeAccountId(enumNum(LedgerJournalACType), ledgerJournalACType, con));
axLedgerJournalTrans.parmTxt(ledgerJournalTransTxt);
axLedgerJournalTrans.parmCurrencyCode(currencyCode);
axLedgerJournalTrans.parmExchRate(exchRate * );
axLedgerJournalTrans.parmPaymId(num2str(exchRateSecond, , , , ));
axLedgerJournalTrans.parmInvoice(invoiceId);
axLedgerJournalTrans.parmDocumentDate(documentDate);
axLedgerJournalTrans.parmDue(dueDate);
axLedgerJournalTrans.parmPayment(paymTermId); if (ledgerJournalACType != LedgerJournalACType::Ledger)
axLedgerJournalTrans.parmDefaultDimension(dimensionAttributeValueSetStorage.save()); if (amountCur >= )
axLedgerJournalTrans.parmAmountCurDebit(amountCur);
else
axLedgerJournalTrans.parmAmountCurCredit(-amountCur); if (mainAccountNumOffset)
{
axLedgerJournalTrans.parmOffsetAccountType(ledgerJournalACTypeOffset);
axLedgerJournalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getMultiTypeAccountId(enumNum(LedgerJournalACType), ledgerJournalACTypeOffset, conOffset)); if (ledgerJournalACTypeOffset != LedgerJournalACType::Ledger)
axLedgerJournalTrans.parmOffsetDefaultDimension(dimensionAttributeValueSetStorage.save());
} axLedgerJournalTrans.save(); if (axLedgerJournalTrans.ledgerJournalTrans().isFixedAssetsTransaction())
{
ledgerJournalTrans_Asset.clear();
ledgerJournalTrans_Asset.initValue(); ledgerJournalTrans_Asset.RefRecId = axLedgerJournalTrans.ledgerJournalTrans().RecId;
ledgerJournalTrans_Asset.AssetId = axLedgerJournalTrans.ledgerJournalTrans().getAssetId();
ledgerJournalTrans_Asset.Company = axLedgerJournalTrans.ledgerJournalTrans().getAssetCompany();
ledgerJournalTrans_Asset.TransType = assetTransTypeJournal;
ledgerJournalTrans_Asset.BookId = assetBookIdPurchSalesInvent; if (!ledgerJournalTrans_Asset.validateWrite())
throw Exception::Error; ledgerJournalTrans_Asset.insert();
} type = cells.item(row + , ).value().variantType();
}
while (type != COMVariantType::VT_EMPTY); ttsCommit;
}
catch (Exception::Error)
{
} application.quit();
}

How to using to code import to GL journal[AX2012]的更多相关文章

  1. How to using x++ code create GL journal[AX2012]

    static void FAN_GLImport(Args _args) { AxLedgerJournalTable header = new AxLedgerJournalTable(); AxL ...

  2. R12: Improving Performance of General Ledger and Journal Import (Doc ID 858725.1 )

    In this Document   Purpose   Scope   Details   A) Database Init.ora Parameters   B) Concurrent Progr ...

  3. spring源码分析之@ImportSelector、@Import、ImportResource工作原理分析

    1. @importSelector定义: /** * Interface to be implemented by types that determine which @{@link Config ...

  4. Python on VS Code

    install python extension Press F1, and input "ext install python". Then the icon at the le ...

  5. 小白的Python之路 day5 python模块详解及import本质

    一.定义 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能) 本质就是.py结尾的python文件(文件名:test.py,对应的模块名:test) 包:用来从逻辑上组织模块 ...

  6. Spring注解之@Import

    /** * Indicates one or more {@link Configuration @Configuration} classes to import. * 表示import 一个或多个 ...

  7. python标准库介绍——30 code 模块详解

    ==code 模块== ``code`` 模块提供了一些用于模拟标准交互解释器行为的函数. ``compile_command`` 与内建 ``compile`` 函数行为相似, 但它会通过测试来保证 ...

  8. ES6中的import与export对class操作相关用法举例

    两种用法: 一.指定输出类名 // export 输出 export class App extends React.Componet { // ..code } // import 引入 impor ...

  9. 6 Easy Steps to Learn Naive Bayes Algorithm (with code in Python)

    6 Easy Steps to Learn Naive Bayes Algorithm (with code in Python) Introduction Here’s a situation yo ...

随机推荐

  1. iOS中常见的设计模式——单例模式\委托模式\观察者模式\MVC模式

    一.单例模式 1. 什么是单例模式? 在iOS应用的生命周期中,某个类只有一个实例. 2. 单例模式解决了什么问题? 想象一下,如果我们要读取文件配置信息,那么每次要读取,我们就要创建一个文件实例,然 ...

  2. Ceph–s ceph 集群状态

    [root@ceph-mon1 ~]# ceph -s cluster 03f3afd4-4cc6-4083-a34c-845446a59cd4 health HEALTH_OK monmap e1: ...

  3. redis学习(一)Redis应用场景

    Redis开创了一种新的数据存储思路,使用Redis,我们不用在面对功能单调的数据库时,把精力放在如何把大象放进冰箱这样的问题上,而是利用Redis灵活多变的数据结构和数据操作,为不同的大象构建不同的 ...

  4. BZOJ1029 建筑抢修

    Description 小刚在玩JSOI提供的一个称之为"建筑抢修"的电脑游戏:经过了一场激烈的战斗,T部落消灭了所有z部落的入侵者.但是T部落的基地里已经有N个建筑设施受到了严重 ...

  5. bzoj1433: [ZJOI2009]假期的宿舍

    1433: [ZJOI2009]假期的宿舍 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2286  Solved: 969[Submit][Stat ...

  6. cocos2dx 内存管理机制

    持续更新吧. 刚开始看了一些. 一,CCObject  提供引用计数 1,unsinged int m_uReference; //此为CCOBject的引用计数,初始化为 1: new CCObje ...

  7. git贡献代码流程

    1.本地创建ssh key: $ ssh-keygen -t rsa -C "your_email@youremail.com" 2.回到github,进入Account Sett ...

  8. php实现文件上传的源码

    php实现文件上传的源码,更多php技术开发就去php教程网,http://php.662p.com <?php ##author :Androidyue ##sina @androidyue ...

  9. .NET如何从配置文件中获取连接字符串

    一.设置配置文件 <configuration> <!--在configuration下创建一个connectionStrings--> <connectionStrin ...

  10. 解决mysql占用IO过高

    1.日志产生的性能影响:由于日志的记录带来的直接性能损耗就是数据库系统中最为昂贵的IO资源.MySQL的日志包括错误日志(ErrorLog),更新日志(UpdateLog),二进制日志(Binlog) ...