@things-factory/tax-invoice 6.2.121 → 6.2.125
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 +2 -4
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js +2 -4
- 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/tax-invoice-mutation.js +4 -82
- package/dist-server/service/tax-invoice/tax-invoice-mutation.js.map +1 -1
- package/dist-server/service/tax-invoice/tax-invoice-util.js +93 -0
- package/dist-server/service/tax-invoice/tax-invoice-util.js.map +1 -0
- package/dist-server/service/tax-invoice/tax-invoice.js +4 -4
- package/dist-server/service/tax-invoice/tax-invoice.js.map +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js +27 -10
- package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js.map +1 -1
- package/dist-server/service/unipost-api/tax-invoice-send.js +18 -22
- package/dist-server/service/unipost-api/tax-invoice-send.js.map +1 -1
- package/dist-server/service/unipost-api/test-data.js +3812 -0
- package/dist-server/service/unipost-api/test-data.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/service/tax-invoice/tax-invoice-mutation.ts +4 -83
- package/server/service/tax-invoice/tax-invoice-util.ts +223 -0
- package/server/service/tax-invoice/tax-invoice.ts +4 -4
- package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +35 -12
- package/server/service/unipost-api/tax-invoice-send.ts +17 -27
- package/translations/ko.json +1 -0
|
@@ -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;AAC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CAAkB;;wEA4BpG;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;IACxD,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAS7E;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,+BAAa,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAEhF,mBAAA,IAAA,kBAAG,EAAC,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,qCAAc,CAAC,CAAC,CAAA;IACnD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEA2BP;AA7EU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,+BAAa,CAAC;GACX,qBAAqB,CA0MjC;AA1MY,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 { TaxInvoice } from '../tax-invoice/tax-invoice'\nimport { sendTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-send'\n\n@Resolver(TaxInvoiceApi)\nexport class TaxInvoiceApiMutation {\n @Directive('@transaction')\n @Mutation(returns => TaxInvoiceApi, { description: 'To modify Tax Invoice Api information' })\n async updateMultipleTaxInvoiceApi(@Arg('patch', type => TaxInvoiceApiPatch) patch: TaxInvoiceApiPatch, @Ctx() context: ResolverContext): Promise<TaxInvoiceApi> {\n const { domain, user, tx } = context.state\n const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)\n let results\n\n if (patch.cuFlag.toUpperCase() === '+') {\n const result = await taxInvoiceApiRepo.save({\n ...patch,\n domain,\n creator: user,\n updater: user\n })\n\n results = { ...result, cuFlag: '+' }\n }\n\n if (patch.cuFlag.toUpperCase() === 'M') {\n const taxInvoiceApi = await taxInvoiceApiRepo.findOneBy({ id: patch.id })\n const result = await taxInvoiceApiRepo.save({\n ...taxInvoiceApi,\n ...patch,\n updater: user\n })\n\n results = { ...result, cuFlag: 'M' }\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 => TaxInvoiceApi, { description: 'To Send Tax Invoices By Api' })\n async sendTaxInvoicesByApi(\n @Arg('taxInvoiceSendList', type => [TaxInvoiceSend]) taxInvoiceSendList: TaxInvoiceSend[],\n @Ctx() context: ResolverContext\n ): Promise<TaxInvoiceSend[]> {\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 console.log(apiInfo?.attributes)\n\n // 밸리데이션 및 데이터 파싱\n let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no))\n\n // 세금계산서 발행 API 호출\n const apiResult = sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)\n if (!apiResult) {\n throw new Error('tax invoice send exception: api problem')\n }\n\n // 세금계산서 저장 리졸버 호출\n // createTaxInvoice\n\n return apiResult\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,CAA2C,KAAyB,EAAS,OAAwB;QACpI,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,iBAAiB,GAAG,EAAE,CAAC,aAAa,CAAC,+BAAa,CAAC,CAAA;QACzD,IAAI,OAAO,CAAA;QAEX,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,EAAE;YACtC,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,iCACtC,KAAK,KACR,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;YAEF,OAAO,mCAAQ,MAAM,KAAE,MAAM,EAAE,GAAG,GAAE,CAAA;SACrC;QAED,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,EAAE;YACtC,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;YACzE,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,+CACtC,aAAa,GACb,KAAK,KACR,OAAO,EAAE,IAAI,IACb,CAAA;YAEF,OAAO,mCAAQ,MAAM,KAAE,MAAM,EAAE,GAAG,GAAE,CAAA;SACrC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAIK,AAAN,KAAK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;iEAS7E;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAE1E,mBAAA,IAAA,kBAAG,EAAC,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,qCAAc,CAAC,CAAC,CAAA;IACnD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAgDP;AAlGU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,+BAAa,CAAC;GACX,qBAAqB,CAgOjC;AAhOY,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(@Arg('patch', type => TaxInvoiceApiPatch) patch: TaxInvoiceApiPatch, @Ctx() context: ResolverContext): Promise<TaxInvoiceApi> {\n const { domain, user, tx } = context.state\n const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)\n let results\n\n if (patch.cuFlag.toUpperCase() === '+') {\n const result = await taxInvoiceApiRepo.save({\n ...patch,\n domain,\n creator: user,\n updater: user\n })\n\n results = { ...result, cuFlag: '+' }\n }\n\n if (patch.cuFlag.toUpperCase() === 'M') {\n const taxInvoiceApi = await taxInvoiceApiRepo.findOneBy({ id: patch.id })\n const result = await taxInvoiceApiRepo.save({\n ...taxInvoiceApi,\n ...patch,\n updater: user\n })\n\n results = { ...result, cuFlag: 'M' }\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"]}
|
|
@@ -3,36 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sendTaxInvoiceByUniposApi = void 0;
|
|
4
4
|
// 세금계산서 발행 API
|
|
5
5
|
const SEND_URL = {
|
|
6
|
-
dev: 'https://
|
|
7
|
-
prod: 'https://
|
|
6
|
+
dev: 'https://inf2dev.unipost.co.kr:47543/mbill-etaxr-server/api/rest/v3/receivebill',
|
|
7
|
+
prod: 'https://inf1.unipost.co.kr/mbill-etaxr-server/api/rest/v3/receivebill'
|
|
8
8
|
};
|
|
9
9
|
async function sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, taxInvoiceSendList) {
|
|
10
10
|
if (!businessRegistrationNumber || !aid || !bearer || !taxInvoiceSendList) {
|
|
11
11
|
throw new Error('no parameter in unipos api');
|
|
12
12
|
}
|
|
13
13
|
const response = await _callTaxInvoiceSend(businessRegistrationNumber, aid, bearer, taxInvoiceSendList);
|
|
14
|
-
|
|
15
|
-
if (response.status === 200) {
|
|
16
|
-
}
|
|
17
|
-
const result = await response.json();
|
|
18
|
-
console.log('response : ', response);
|
|
19
|
-
console.log('result : ', result);
|
|
20
|
-
return result.success;
|
|
14
|
+
return (response === null || response === void 0 ? void 0 : response.status) === 200 ? await response.json() : false;
|
|
21
15
|
}
|
|
22
16
|
exports.sendTaxInvoiceByUniposApi = sendTaxInvoiceByUniposApi;
|
|
23
17
|
async function _callTaxInvoiceSend(businessRegistrationNumber, aid, bearer, taxInvoiceSendList) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
try {
|
|
19
|
+
return await fetch(SEND_URL.dev, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
Authorization: 'Basic ' + bearer,
|
|
24
|
+
AID: aid,
|
|
25
|
+
COM_REGNO: businessRegistrationNumber
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify(taxInvoiceSendList)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.log('e : ', e);
|
|
32
|
+
}
|
|
37
33
|
}
|
|
38
34
|
//# sourceMappingURL=tax-invoice-send.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tax-invoice-send.js","sourceRoot":"","sources":["../../../server/service/unipost-api/tax-invoice-send.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"tax-invoice-send.js","sourceRoot":"","sources":["../../../server/service/unipost-api/tax-invoice-send.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE,gFAAgF;IACrF,IAAI,EAAE,uEAAuE;CAC9E,CAAA;AAEM,KAAK,UAAU,yBAAyB,CAAC,0BAAkC,EAAE,GAAW,EAAE,MAAc,EAAE,kBAAkB;IACjI,IAAI,CAAC,0BAA0B,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE;QACzE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;KAC9C;IAED,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,0BAA0B,EAAE,GAAG,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAEvG,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,MAAK,GAAG,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;AACjE,CAAC;AARD,8DAQC;AAED,KAAK,UAAU,mBAAmB,CAAC,0BAAkC,EAAE,GAAW,EAAE,MAAc,EAAE,kBAAkB;IACpH,IAAI;QACF,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;YAC/B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,QAAQ,GAAG,MAAM;gBAChC,GAAG,EAAE,GAAG;gBACR,SAAS,EAAE,0BAA0B;aACtC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;SACzC,CAAC,CAAA;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;KACvB;AACH,CAAC","sourcesContent":["// 세금계산서 발행 API\nconst SEND_URL = {\n dev: 'https://inf2dev.unipost.co.kr:47543/mbill-etaxr-server/api/rest/v3/receivebill',\n prod: 'https://inf1.unipost.co.kr/mbill-etaxr-server/api/rest/v3/receivebill'\n}\n\nexport async function sendTaxInvoiceByUniposApi(businessRegistrationNumber: string, aid: string, bearer: string, taxInvoiceSendList) {\n if (!businessRegistrationNumber || !aid || !bearer || !taxInvoiceSendList) {\n throw new Error('no parameter in unipos api')\n }\n\n const response = await _callTaxInvoiceSend(businessRegistrationNumber, aid, bearer, taxInvoiceSendList)\n\n return response?.status === 200 ? await response.json() : false\n}\n\nasync function _callTaxInvoiceSend(businessRegistrationNumber: string, aid: string, bearer: string, taxInvoiceSendList) {\n try {\n return await fetch(SEND_URL.dev, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: 'Basic ' + bearer,\n AID: aid,\n COM_REGNO: businessRegistrationNumber\n },\n body: JSON.stringify(taxInvoiceSendList)\n })\n } catch (e) {\n console.log('e : ', e)\n }\n}\n"]}
|