How to using to code import to GL journal[AX2012]
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]的更多相关文章
- How to using x++ code create GL journal[AX2012]
static void FAN_GLImport(Args _args) { AxLedgerJournalTable header = new AxLedgerJournalTable(); AxL ...
- 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 ...
- spring源码分析之@ImportSelector、@Import、ImportResource工作原理分析
1. @importSelector定义: /** * Interface to be implemented by types that determine which @{@link Config ...
- Python on VS Code
install python extension Press F1, and input "ext install python". Then the icon at the le ...
- 小白的Python之路 day5 python模块详解及import本质
一.定义 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能) 本质就是.py结尾的python文件(文件名:test.py,对应的模块名:test) 包:用来从逻辑上组织模块 ...
- Spring注解之@Import
/** * Indicates one or more {@link Configuration @Configuration} classes to import. * 表示import 一个或多个 ...
- python标准库介绍——30 code 模块详解
==code 模块== ``code`` 模块提供了一些用于模拟标准交互解释器行为的函数. ``compile_command`` 与内建 ``compile`` 函数行为相似, 但它会通过测试来保证 ...
- ES6中的import与export对class操作相关用法举例
两种用法: 一.指定输出类名 // export 输出 export class App extends React.Componet { // ..code } // import 引入 impor ...
- 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 ...
随机推荐
- Linux查看物理CPU个数、核数、逻辑CPU个数(转载)
# 总核数 = 物理CPU个数 X 每颗物理CPU的核数 # 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数 # 查看物理CPU个数cat /proc/cpuinfo| g ...
- php分享表单提交到本页的实例
我们在做表单提交时,一般都要设置表单的action属性,改属性用于指定表单提交到服务器上的哪个页面进行处理,但为空时,表示提交到本页进行处理,即提交给自己.本文章向大家分享表单提交给本页的实例. 实例 ...
- js和jQuery前台校验文件大小
1.支持Google 不支持IE <script type="text/javascript" src="${pageContext.request.context ...
- bootstrap风格的multiselect插件——类似邮箱收件人样式
在开发颗粒云邮箱的过程中,遇到了一个前端的问题,就是邮箱收件人的那个multiselect的input输入框.不仅能够多选,还要能够支持ajax搜索,把联系人搜索出来.就是类似下面的这个东西: 网上找 ...
- Tomcat源码分析——SERVER.XML文件的加载与解析
前言 作为Java程序员,对于Tomcat的server.xml想必都不陌生.本文基于Tomcat7.0的Java源码,对server.xml文件是如何加载和解析的进行分析. 加载 server.xm ...
- Kafka Quick Start
1.Download > tar -xzf kafka_2.11-0.10.0.0.tgz> cd kafka_2.11-0.10.0.0 2.启动zookeeper服务 Kafka使用的 ...
- 单链表(c++)
#include "stdafx.h"#include <iostream>using namespace std;const int MaxSize = 100; c ...
- [HttpException (0x80004005): The current identity
[HttpException (0x80004005): The current identity (IIS APPPOOL\NationalUnion.Shared) does not have w ...
- 内存泄漏检测工具Valgrind
1概述 1.1 介绍 Valgrind是一套Linux下,开放源代码(GPL V2)的仿真调试工具的集合.Valgrind由内核(core)以及基于内核的其他调试工具组成.内核类似于一个框架(fram ...
- iOS 国际化
1.在APPproject的新建一个Localizable.strings File->new file--->Resource --->strings File 2.添加需要的语言 ...