@things-factory/tax-invoice 6.2.142 → 6.2.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/tax-invoice-send/tax-invoice-send-page.ts +62 -31
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js +57 -26
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js +4 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +4 -1
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.d.ts +0 -22
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js +0 -172
- package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js.map +0 -1
- package/dist-client/pages/tax-invoice-send/supplier-list-popup.d.ts +0 -77
- package/dist-client/pages/tax-invoice-send/supplier-list-popup.js +0 -209
- package/dist-client/pages/tax-invoice-send/supplier-list-popup.js.map +0 -1
|
@@ -50,7 +50,7 @@ let TaxInvoiceApiMutation = class TaxInvoiceApiMutation {
|
|
|
50
50
|
const taxInvoiceRepo = tx.getRepository(tax_invoice_1.TaxInvoice);
|
|
51
51
|
const taxInvoiceItemRepo = tx.getRepository(tax_invoice_item_1.TaxInvoiceItem);
|
|
52
52
|
const taxInvoiceApiRepo = tx.getRepository(tax_invoice_api_1.TaxInvoiceApi);
|
|
53
|
-
const apiInfo =
|
|
53
|
+
const apiInfo = await taxInvoiceApiRepo.findOneBy({ isDefault: true });
|
|
54
54
|
const businessRegistrationNumber = apiInfo.businessRegistrationNumber;
|
|
55
55
|
const { aid = '', bearer = '', customer_no = '' } = apiInfo === null || apiInfo === void 0 ? void 0 : apiInfo.attributes;
|
|
56
56
|
let failCount = 0;
|
|
@@ -58,6 +58,9 @@ let TaxInvoiceApiMutation = class TaxInvoiceApiMutation {
|
|
|
58
58
|
let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no));
|
|
59
59
|
// 2. 세금계산서 발행 API 호출
|
|
60
60
|
const apiResult = await (0, tax_invoice_send_1.sendTaxInvoiceByUniposApi)(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList);
|
|
61
|
+
if (apiResult === false) {
|
|
62
|
+
throw new Error('tax invoice send exception: api error');
|
|
63
|
+
}
|
|
61
64
|
// 3. 성공하면 세금계산서 DB에 저장
|
|
62
65
|
for (let item of apiResult) {
|
|
63
66
|
if (item === null || item === void 0 ? void 0 : item.success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tax-invoice-api-mutation.js","sourceRoot":"","sources":["../../../server/service/tax-invoice-api/tax-invoice-api-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,uDAAiD;AACjD,iEAA2E;AAC3E,2EAAqE;AACrE,4DAAiE;AACjE,sEAA2E;AAC3E,sEAAgF;AAGzE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG1B,AAAN,KAAK,CAAC,2BAA2B,CACe,OAA6B,EACpE,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;QACzF,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,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E,mBAAA,IAAA,kBAAG,EAAC,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,qCAAc,CAAC,CAAC,CAAA;IACnD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAgDP;AAhHU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,+BAAa,CAAC;GACX,qBAAqB,CA8OjC;AA9OY,sDAAqB","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { TaxInvoiceApi } from './tax-invoice-api'\nimport { TaxInvoiceApiPatch, TaxInvoiceSend } from './tax-invoice-api-type'\nimport { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'\nimport { Category, TaxInvoice } from '../tax-invoice/tax-invoice'\nimport { sendTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-send'\nimport { parseTaxInvoiceByUnipostFormat } from '../tax-invoice/tax-invoice-util'\n\n@Resolver(TaxInvoiceApi)\nexport class TaxInvoiceApiMutation {\n @Directive('@transaction')\n @Mutation(returns => [TaxInvoiceApi], { description: 'To modify Tax Invoice Api information' })\n async updateMultipleTaxInvoiceApi(\n @Arg('patches', type => [TaxInvoiceApiPatch]) patches: TaxInvoiceApiPatch[],\n @Ctx() context: ResolverContext\n ): Promise<TaxInvoiceApi[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await taxInvoiceApiRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const taxAuditResult = await taxInvoiceApiRepo.findOneBy({ id: updateRecord.id })\n\n const result = await taxInvoiceApiRepo.save({\n ...taxAuditResult,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Tax Invoice Api' })\n async deleteTaxInvoiceApis(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(TaxInvoiceApi).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To Send Tax Invoices By Api' })\n async sendTaxInvoicesByApi(\n @Arg('taxInvoiceSendList', type => [TaxInvoiceSend]) taxInvoiceSendList: TaxInvoiceSend[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n if (taxInvoiceSendList.length === 0) throw new Error('tax invoice send exception: no list')\n\n const { domain, user, tx } = context.state\n const taxInvoiceRepo = tx.getRepository(TaxInvoice)\n const taxInvoiceItemRepo = tx.getRepository(TaxInvoiceItem)\n const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)\n\n const apiInfo = (await taxInvoiceApiRepo.find()).at(0)\n const businessRegistrationNumber = apiInfo.businessRegistrationNumber\n const { aid = '', bearer = '', customer_no = '' } = apiInfo?.attributes\n let failCount = 0\n\n // 1. 밸리데이션 및 데이터 파싱\n let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no))\n\n // 2. 세금계산서 발행 API 호출\n const apiResult = await sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)\n\n // 3. 성공하면 세금계산서 DB에 저장\n for (let item of apiResult) {\n if (item?.success) {\n const { taxInvoice, taxInvoiceItems } = parseTaxInvoiceByUnipostFormat(item?.tAliceEntry, item?.tAliceEntry?.tAliceItemList, Category.EXPORT)\n\n // 세금계산서 저장\n const newTaxInvoice = await taxInvoiceRepo.save({\n ...taxInvoice,\n domain,\n creator: user,\n updater: user\n })\n\n // 아이템 저장\n for (const item of taxInvoiceItems) {\n await taxInvoiceItemRepo.save({ ...item, taxInvoice: newTaxInvoice, domain, creator: user })\n }\n } else {\n failCount++\n }\n }\n\n // 실패가 1개라도 있으면 에러\n if (failCount > 0) {\n throw new Error(failCount + '개의 계산서 등록에 실패하였습니다.')\n }\n\n return true\n }\n\n // 유니스포트에 받을수 있는 포맷으로 데이터 파싱\n private _parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no) {\n const { taxInvoice, taxInvoiceItems } = taxInvoiceSend\n let newTaxInvoiceItems: any = []\n const today = new Intl.DateTimeFormat('fr-CA', { timeZone: 'Asia/Seoul' }).format(new Date()) // YYYY-MM-DD\n\n // 필수값 체크\n if (\n !taxInvoice.supplierBusinessRegistrationNumber ||\n !taxInvoice.supplierBusinessName ||\n !taxInvoice.supplierRepresentativeName ||\n !taxInvoice.buyerBusinessRegistrationNumber ||\n !taxInvoice.buyerBusinessName ||\n !taxInvoice.buyerRepresentativeName ||\n !taxInvoice.issueDate\n ) {\n throw new Error('tax invoice send exception: no essential value')\n }\n\n // 작성일자가 오늘 날짜를 넘어가면 에러\n if (taxInvoice.issueDate > today) {\n throw new Error('tax invoice send exception: issueDate error')\n }\n\n // 현금, 수표, 어음, 외상미수금이 있을시 총 합계금액과 금액 동일 체크\n const paymentAmount: number =\n taxInvoice.paymentAmountCash + taxInvoice.paymentAmountCheck + taxInvoice.paymentAmountPromissoryNote + taxInvoice.paymentAmountAccountsReceivable\n\n if (paymentAmount > 0 && paymentAmount !== taxInvoice.totalAmount) {\n throw new Error('tax invoice send exception: summary is not same')\n }\n\n for (let item of taxInvoiceItems) {\n // 아이템 필수값 체크\n if (!item.supplyDate || !item.itemName || !item.quantity || !item.unitPrice) {\n throw new Error('tax invoice send exception: no item essential value')\n }\n\n // 아이템의 일자가 작성일자보다 크면 에러\n if (taxInvoice.issueDate < item.supplyDate) {\n throw new Error('tax invoice send exception: item supplyDate is bigger than issueDate')\n }\n\n newTaxInvoiceItems.push({\n tii_seqnumeric: item.sequence,\n tii_purchaseexpirydatetime: item.supplyDate.replace(/-/g, ''),\n tii_nametext: item.itemName,\n tii_informationtext: item.specification,\n tii_chargeableunitquantity: item.quantity,\n tii_unitprice_unitamount: item.unitPrice,\n tii_invoiceamount: item.supplyPrice,\n tii_totaltax_calcamount: item.taxPrice,\n tii_descriptiontext: item.remark\n })\n }\n\n return {\n aid: aid,\n inv_seq: today.replace(/-/g, '') + customer_no,\n exd_refdoc_id: null,\n tid_issuedatetime: taxInvoice.issueDate.replace(/-/g, ''),\n tid_typecode: taxInvoice.invoiceType,\n tid_purposecode: taxInvoice.purpose,\n tid_amendcode: taxInvoice.revisedReason,\n tid_originalissueid: null,\n tid_desc0: taxInvoice.remark0,\n tid_desc1: null,\n tid_desc2: null,\n tit_alice_specorg_biztypecode: taxInvoice.supplierBusinessRegistrationCategory,\n tit_alice_id: taxInvoice.supplierBusinessRegistrationNumber,\n tit_alice_specorg_taxregid: taxInvoice.supplierBranchIdentification,\n tit_alice_name: taxInvoice.supplierBusinessName,\n tit_alice_specperson_name: taxInvoice.supplierRepresentativeName,\n tit_alice_specaddr_lineone: taxInvoice.supplierAddress,\n tit_alice_typecode: taxInvoice.supplierBusinessType,\n tit_alice_classcode: taxInvoice.supplierIndustryType,\n tit_alice_defcont_deptname: taxInvoice.supplierDepartment,\n tit_alice_defcont_personname: taxInvoice.supplierContactName,\n tit_alice_defcont_telcomm: taxInvoice.supplierContactPhone,\n tit_alice_defcont_uricomm: taxInvoice.supplierContactEmail,\n tit_alice_defcont_cellphone: taxInvoice.supplierContactCellPhone,\n tit_bob_specorg_biztypecode: taxInvoice.buyerBusinessRegistrationCategory,\n tit_bob_id: taxInvoice.buyerBusinessRegistrationNumber,\n tit_bob_specorg_taxregid: taxInvoice.buyerBranchIdentification,\n tit_bob_name: taxInvoice.buyerBusinessName,\n tit_bob_specperson_name: taxInvoice.buyerRepresentativeName,\n tit_bob_specaddr_lineone: taxInvoice.buyerAddress,\n tit_bob_typecode: taxInvoice.buyerBusinessType,\n tit_bob_classcode: taxInvoice.buyerIndustryType,\n tit_bob_1stdefcont_deptname: taxInvoice.buyer1stDepartment,\n tit_bob_1stdefcont_personname: taxInvoice.buyer1stContactName,\n tit_bob_1stdefcont_telcomm: taxInvoice.buyer1stContactPhone,\n tit_bob_1stdefcont_uricomm: taxInvoice.buyer1stContactEmail,\n tit_bob_1stdefcont_cellphone: taxInvoice.buyer1stContactCellPhone,\n tit_bob_2nddefcont_deptname: taxInvoice.buyer2ndDepartment,\n tit_bob_2nddefcont_personname: taxInvoice.buyer2ndContactName,\n tit_bob_2nddefcont_telcomm: taxInvoice.buyer2ndContactPhone,\n tit_bob_2nddefcont_uricomm: taxInvoice.buyer2ndContactEmail,\n tit_bob_2nddefcont_cellphone: taxInvoice.buyer2ndContactCellPhone,\n tit_broker_specorg_biztypecode: taxInvoice.agentBusinessRegistrationCategory,\n tit_broker_id: taxInvoice.agentBusinessRegistrationNumber,\n tit_broker_specorg_taxregid: taxInvoice.agentBranchIdentification,\n tit_broker_name: taxInvoice.agentBusinessName,\n tit_broker_specperson_name: taxInvoice.agentRepresentativeName,\n tit_broker_specaddr_lineone: taxInvoice.agentAddress,\n tit_broker_typecode: taxInvoice.agentBusinessType,\n tit_broker_classcode: taxInvoice.agentIndustryType,\n tit_broker_defcont_deptname: taxInvoice.agentDepartment,\n tit_broker_defcont_personname: taxInvoice.agentContactName,\n tit_broker_defcont_telcomm: taxInvoice.agentContactPhone,\n tit_broker_defcont_uricomm: taxInvoice.agentContactEmail,\n tit_broker_defcont_cellphone: taxInvoice.agentContactCellPhone,\n tit_specpay_paidamount10: taxInvoice.paymentAmountCash,\n tit_specpay_paidamount20: taxInvoice.paymentAmountCheck,\n tit_specpay_paidamount30: taxInvoice.paymentAmountPromissoryNote,\n tit_specpay_paidamount40: taxInvoice.paymentAmountAccountsReceivable,\n tit_specsum_chargeamount: taxInvoice.supplyAmount,\n tit_specsum_taxamount: taxInvoice.taxAmount,\n tit_specsum_grandamount: taxInvoice.totalAmount,\n inv_sign: '',\n biz_tocharlesconfirmstatus: null,\n tAliceItemList: newTaxInvoiceItems\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tax-invoice-api-mutation.js","sourceRoot":"","sources":["../../../server/service/tax-invoice-api/tax-invoice-api-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,uDAAiD;AACjD,iEAA2E;AAC3E,2EAAqE;AACrE,4DAAiE;AACjE,sEAA2E;AAC3E,sEAAgF;AAGzE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG1B,AAAN,KAAK,CAAC,2BAA2B,CACe,OAA6B,EACpE,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;QACzF,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;QACzF,MAAM,iBAAiB,GAAG,EAAE,CAAC,aAAa,CAAC,+BAAa,CAAC,CAAA;QAEzD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CA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+BAAa,CAAC;GACX,qBAAqB,CAiPjC;AAjPY,sDAAqB","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { TaxInvoiceApi } from './tax-invoice-api'\nimport { TaxInvoiceApiPatch, TaxInvoiceSend } from './tax-invoice-api-type'\nimport { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'\nimport { Category, TaxInvoice } from '../tax-invoice/tax-invoice'\nimport { sendTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-send'\nimport { parseTaxInvoiceByUnipostFormat } from '../tax-invoice/tax-invoice-util'\n\n@Resolver(TaxInvoiceApi)\nexport class TaxInvoiceApiMutation {\n @Directive('@transaction')\n @Mutation(returns => [TaxInvoiceApi], { description: 'To modify Tax Invoice Api information' })\n async updateMultipleTaxInvoiceApi(\n @Arg('patches', type => [TaxInvoiceApiPatch]) patches: TaxInvoiceApiPatch[],\n @Ctx() context: ResolverContext\n ): Promise<TaxInvoiceApi[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await taxInvoiceApiRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const taxAuditResult = await taxInvoiceApiRepo.findOneBy({ id: updateRecord.id })\n\n const result = await taxInvoiceApiRepo.save({\n ...taxAuditResult,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Tax Invoice Api' })\n async deleteTaxInvoiceApis(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(TaxInvoiceApi).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To Send Tax Invoices By Api' })\n async sendTaxInvoicesByApi(\n @Arg('taxInvoiceSendList', type => [TaxInvoiceSend]) taxInvoiceSendList: TaxInvoiceSend[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n if (taxInvoiceSendList.length === 0) throw new Error('tax invoice send exception: no list')\n\n const { domain, user, tx } = context.state\n const taxInvoiceRepo = tx.getRepository(TaxInvoice)\n const taxInvoiceItemRepo = tx.getRepository(TaxInvoiceItem)\n const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)\n\n const apiInfo = await taxInvoiceApiRepo.findOneBy({ isDefault: true })\n const businessRegistrationNumber = apiInfo.businessRegistrationNumber\n const { aid = '', bearer = '', customer_no = '' } = apiInfo?.attributes\n let failCount = 0\n\n // 1. 밸리데이션 및 데이터 파싱\n let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no))\n\n // 2. 세금계산서 발행 API 호출\n const apiResult = await sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)\n if (apiResult === false) {\n throw new Error('tax invoice send exception: api error')\n }\n\n // 3. 성공하면 세금계산서 DB에 저장\n for (let item of apiResult) {\n if (item?.success) {\n const { taxInvoice, taxInvoiceItems } = parseTaxInvoiceByUnipostFormat(item?.tAliceEntry, item?.tAliceEntry?.tAliceItemList, Category.EXPORT)\n\n // 세금계산서 저장\n const newTaxInvoice = await taxInvoiceRepo.save({\n ...taxInvoice,\n domain,\n creator: user,\n updater: user\n })\n\n // 아이템 저장\n for (const item of taxInvoiceItems) {\n await taxInvoiceItemRepo.save({ ...item, taxInvoice: newTaxInvoice, domain, creator: user })\n }\n } else {\n failCount++\n }\n }\n\n // 실패가 1개라도 있으면 에러\n if (failCount > 0) {\n throw new Error(failCount + '개의 계산서 등록에 실패하였습니다.')\n }\n\n return true\n }\n\n // 유니스포트에 받을수 있는 포맷으로 데이터 파싱\n private _parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no) {\n const { taxInvoice, taxInvoiceItems } = taxInvoiceSend\n let newTaxInvoiceItems: any = []\n const today = new Intl.DateTimeFormat('fr-CA', { timeZone: 'Asia/Seoul' }).format(new Date()) // YYYY-MM-DD\n\n // 필수값 체크\n if (\n !taxInvoice.supplierBusinessRegistrationNumber ||\n !taxInvoice.supplierBusinessName ||\n !taxInvoice.supplierRepresentativeName ||\n !taxInvoice.buyerBusinessRegistrationNumber ||\n !taxInvoice.buyerBusinessName ||\n !taxInvoice.buyerRepresentativeName ||\n !taxInvoice.issueDate\n ) {\n throw new Error('tax invoice send exception: no essential value')\n }\n\n // 작성일자가 오늘 날짜를 넘어가면 에러\n if (taxInvoice.issueDate > today) {\n throw new Error('tax invoice send exception: issueDate error')\n }\n\n // 현금, 수표, 어음, 외상미수금이 있을시 총 합계금액과 금액 동일 체크\n const paymentAmount: number =\n taxInvoice.paymentAmountCash + taxInvoice.paymentAmountCheck + taxInvoice.paymentAmountPromissoryNote + taxInvoice.paymentAmountAccountsReceivable\n\n if (paymentAmount > 0 && paymentAmount !== taxInvoice.totalAmount) {\n throw new Error('tax invoice send exception: summary is not same')\n }\n\n for (let item of taxInvoiceItems) {\n // 아이템 필수값 체크\n if (!item.supplyDate || !item.itemName || !item.quantity || !item.unitPrice) {\n throw new Error('tax invoice send exception: no item essential value')\n }\n\n // 아이템의 일자가 작성일자보다 크면 에러\n if (taxInvoice.issueDate < item.supplyDate) {\n throw new Error('tax invoice send exception: item supplyDate is bigger than issueDate')\n }\n\n newTaxInvoiceItems.push({\n tii_seqnumeric: item.sequence,\n tii_purchaseexpirydatetime: item.supplyDate.replace(/-/g, ''),\n tii_nametext: item.itemName,\n tii_informationtext: item.specification,\n tii_chargeableunitquantity: item.quantity,\n tii_unitprice_unitamount: item.unitPrice,\n tii_invoiceamount: item.supplyPrice,\n tii_totaltax_calcamount: item.taxPrice,\n tii_descriptiontext: item.remark\n })\n }\n\n return {\n aid: aid,\n inv_seq: today.replace(/-/g, '') + customer_no,\n exd_refdoc_id: null,\n tid_issuedatetime: taxInvoice.issueDate.replace(/-/g, ''),\n tid_typecode: taxInvoice.invoiceType,\n tid_purposecode: taxInvoice.purpose,\n tid_amendcode: taxInvoice.revisedReason,\n tid_originalissueid: null,\n tid_desc0: taxInvoice.remark0,\n tid_desc1: null,\n tid_desc2: null,\n tit_alice_specorg_biztypecode: taxInvoice.supplierBusinessRegistrationCategory,\n tit_alice_id: taxInvoice.supplierBusinessRegistrationNumber,\n tit_alice_specorg_taxregid: taxInvoice.supplierBranchIdentification,\n tit_alice_name: taxInvoice.supplierBusinessName,\n tit_alice_specperson_name: taxInvoice.supplierRepresentativeName,\n tit_alice_specaddr_lineone: taxInvoice.supplierAddress,\n tit_alice_typecode: taxInvoice.supplierBusinessType,\n tit_alice_classcode: taxInvoice.supplierIndustryType,\n tit_alice_defcont_deptname: taxInvoice.supplierDepartment,\n tit_alice_defcont_personname: taxInvoice.supplierContactName,\n tit_alice_defcont_telcomm: taxInvoice.supplierContactPhone,\n tit_alice_defcont_uricomm: taxInvoice.supplierContactEmail,\n tit_alice_defcont_cellphone: taxInvoice.supplierContactCellPhone,\n tit_bob_specorg_biztypecode: taxInvoice.buyerBusinessRegistrationCategory,\n tit_bob_id: taxInvoice.buyerBusinessRegistrationNumber,\n tit_bob_specorg_taxregid: taxInvoice.buyerBranchIdentification,\n tit_bob_name: taxInvoice.buyerBusinessName,\n tit_bob_specperson_name: taxInvoice.buyerRepresentativeName,\n tit_bob_specaddr_lineone: taxInvoice.buyerAddress,\n tit_bob_typecode: taxInvoice.buyerBusinessType,\n tit_bob_classcode: taxInvoice.buyerIndustryType,\n tit_bob_1stdefcont_deptname: taxInvoice.buyer1stDepartment,\n tit_bob_1stdefcont_personname: taxInvoice.buyer1stContactName,\n tit_bob_1stdefcont_telcomm: taxInvoice.buyer1stContactPhone,\n tit_bob_1stdefcont_uricomm: taxInvoice.buyer1stContactEmail,\n tit_bob_1stdefcont_cellphone: taxInvoice.buyer1stContactCellPhone,\n tit_bob_2nddefcont_deptname: taxInvoice.buyer2ndDepartment,\n tit_bob_2nddefcont_personname: taxInvoice.buyer2ndContactName,\n tit_bob_2nddefcont_telcomm: taxInvoice.buyer2ndContactPhone,\n tit_bob_2nddefcont_uricomm: taxInvoice.buyer2ndContactEmail,\n tit_bob_2nddefcont_cellphone: taxInvoice.buyer2ndContactCellPhone,\n tit_broker_specorg_biztypecode: taxInvoice.agentBusinessRegistrationCategory,\n tit_broker_id: taxInvoice.agentBusinessRegistrationNumber,\n tit_broker_specorg_taxregid: taxInvoice.agentBranchIdentification,\n tit_broker_name: taxInvoice.agentBusinessName,\n tit_broker_specperson_name: taxInvoice.agentRepresentativeName,\n tit_broker_specaddr_lineone: taxInvoice.agentAddress,\n tit_broker_typecode: taxInvoice.agentBusinessType,\n tit_broker_classcode: taxInvoice.agentIndustryType,\n tit_broker_defcont_deptname: taxInvoice.agentDepartment,\n tit_broker_defcont_personname: taxInvoice.agentContactName,\n tit_broker_defcont_telcomm: taxInvoice.agentContactPhone,\n tit_broker_defcont_uricomm: taxInvoice.agentContactEmail,\n tit_broker_defcont_cellphone: taxInvoice.agentContactCellPhone,\n tit_specpay_paidamount10: taxInvoice.paymentAmountCash,\n tit_specpay_paidamount20: taxInvoice.paymentAmountCheck,\n tit_specpay_paidamount30: taxInvoice.paymentAmountPromissoryNote,\n tit_specpay_paidamount40: taxInvoice.paymentAmountAccountsReceivable,\n tit_specsum_chargeamount: taxInvoice.supplyAmount,\n tit_specsum_taxamount: taxInvoice.taxAmount,\n tit_specsum_grandamount: taxInvoice.totalAmount,\n inv_sign: '',\n biz_tocharlesconfirmstatus: null,\n tAliceItemList: newTaxInvoiceItems\n }\n }\n}\n"]}
|