@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/tax-invoice",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.125",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@operato/graphql": "^1.0.0",
|
|
31
31
|
"@operato/shell": "^1.0.0",
|
|
32
|
-
"@things-factory/auth-base": "^6.2.
|
|
33
|
-
"@things-factory/export-ui-excel": "^6.2.
|
|
34
|
-
"@things-factory/shell": "^6.2.
|
|
32
|
+
"@things-factory/auth-base": "^6.2.122",
|
|
33
|
+
"@things-factory/export-ui-excel": "^6.2.122",
|
|
34
|
+
"@things-factory/shell": "^6.2.122"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "7d694035e7e886593088face69dfefe70b8c0486"
|
|
37
37
|
}
|
|
@@ -8,6 +8,7 @@ import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
|
|
|
8
8
|
import { TaxInvoiceApi } from '../tax-invoice-api/tax-invoice-api'
|
|
9
9
|
import { AttributeSet } from '@things-factory/shell/dist-server/service/attribute-set/attribute-set'
|
|
10
10
|
import { ConfirmData, UnipostTaxType, callTaxInvoiceConfirm, getTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-inquiry'
|
|
11
|
+
import { parseTaxInvoiceByUnipostFormat } from './tax-invoice-util'
|
|
11
12
|
|
|
12
13
|
@Resolver(TaxInvoice)
|
|
13
14
|
export class TaxInvoiceMutation {
|
|
@@ -113,91 +114,11 @@ export class TaxInvoiceMutation {
|
|
|
113
114
|
// 있는지 없는지 확인 (이미 있는 세금계산서는 패스)
|
|
114
115
|
if (existingIds.includes(tax.exd_id)) continue
|
|
115
116
|
|
|
116
|
-
//
|
|
117
|
-
const
|
|
118
|
-
issueNo: tax.exd_id,
|
|
119
|
-
approvalNo: tax.tid_issueid,
|
|
120
|
-
originalApprovalNo: tax.tid_originalissueid,
|
|
121
|
-
issueDate: this._dateFormat(tax.tid_issuedatetime),
|
|
122
|
-
signatureDate: this._dateFormat(tax.exd_issuedatetime),
|
|
123
|
-
invoiceType: tax.tid_typecode,
|
|
124
|
-
purpose: tax.tid_purposecode,
|
|
125
|
-
revisedReason: tax.tid_amendcode,
|
|
126
|
-
remark0: tax.tid_desc0,
|
|
127
|
-
remark1: tax.tid_desc1,
|
|
128
|
-
remark2: tax.tid_desc2,
|
|
129
|
-
category: tax.category,
|
|
130
|
-
supplierBusinessRegistrationCategory: tax.tit_alice_specorg_biztypecode,
|
|
131
|
-
supplierBusinessRegistrationNumber: tax.tit_alice_id,
|
|
132
|
-
supplierBranchIdentification: tax.tit_alice_specorg_taxregid,
|
|
133
|
-
supplierBusinessName: tax.tit_alice_name,
|
|
134
|
-
supplierRepresentativeName: tax.tit_alice_specperson_name,
|
|
135
|
-
supplierAddress: tax.tit_alice_specaddr_lineone,
|
|
136
|
-
supplierBusinessType: tax.tit_alice_typecode,
|
|
137
|
-
supplierIndustryType: tax.tit_alice_classcode,
|
|
138
|
-
supplierDepartment: tax.tit_alice_defcont_deptname,
|
|
139
|
-
supplierContactName: tax.tit_alice_defcont_personname,
|
|
140
|
-
supplierContactPhone: tax.tit_alice_defcont_telcomm,
|
|
141
|
-
supplierContactEmail: tax.tit_alice_defcont_uricomm,
|
|
142
|
-
supplierContactCellPhone: tax.tit_alice_defcont_cellphone,
|
|
143
|
-
buyerBusinessRegistrationCategory: tax.tit_bob_specorg_biztypecode,
|
|
144
|
-
buyerBusinessRegistrationNumber: tax.tit_bob_id,
|
|
145
|
-
buyerBranchIdentification: tax.tit_bob_specorg_taxregid,
|
|
146
|
-
buyerBusinessName: tax.tit_bob_name,
|
|
147
|
-
buyerRepresentativeName: tax.tit_bob_specperson_name,
|
|
148
|
-
buyerAddress: tax.tit_bob_specaddr_lineone,
|
|
149
|
-
buyerBusinessType: tax.tit_bob_typecode,
|
|
150
|
-
buyerIndustryType: tax.tit_bob_classcode,
|
|
151
|
-
buyer1stDepartment: tax.tit_bob_1stdefcont_deptname,
|
|
152
|
-
buyer1stContactName: tax.tit_bob_1stdefcont_personname,
|
|
153
|
-
buyer1stContactPhone: tax.tit_bob_1stdefcont_telcomm,
|
|
154
|
-
buyer1stContactEmail: tax.tit_bob_1stdefcont_uricomm,
|
|
155
|
-
buyer1stContactCellPhone: tax.tit_bob_1stdefcont_cellphone,
|
|
156
|
-
buyer2ndDepartment: tax.tit_bob_2nddefcont_deptname,
|
|
157
|
-
buyer2ndContactName: tax.tit_bob_2nddefcont_personname,
|
|
158
|
-
buyer2ndContactPhone: tax.tit_bob_2nddefcont_telcomm,
|
|
159
|
-
buyer2ndContactEmail: tax.tit_bob_2nddefcont_uricomm,
|
|
160
|
-
buyer2ndContactCellPhone: tax.tit_bob_2nddefcont_cellphone,
|
|
161
|
-
agentBusinessRegistrationCategory: tax.tit_broker_specorg_biztypecode,
|
|
162
|
-
agentBusinessRegistrationNumber: tax.tit_broker_id,
|
|
163
|
-
agentBranchIdentification: tax.tit_broker_specorg_taxregid,
|
|
164
|
-
agentBusinessName: tax.tit_broker_name,
|
|
165
|
-
agentRepresentativeName: tax.tit_broker_specperson_name,
|
|
166
|
-
agentAddress: tax.tit_broker_specaddr_lineone,
|
|
167
|
-
agentBusinessType: tax.tit_broker_typecode,
|
|
168
|
-
agentIndustryType: tax.tit_broker_classcode,
|
|
169
|
-
agentDepartment: tax.tit_broker_defcont_deptname,
|
|
170
|
-
agentContactName: tax.tit_broker_defcont_personname,
|
|
171
|
-
agentContactPhone: tax.tit_broker_defcont_telcomm,
|
|
172
|
-
agentContactEmail: tax.tit_broker_defcont_uricomm,
|
|
173
|
-
agentContactCellPhone: tax.tit_broker_defcont_cellphone,
|
|
174
|
-
paymentAmountCash: tax.tit_specpay_paidamount10,
|
|
175
|
-
paymentAmountCheck: tax.tit_specpay_paidamount20,
|
|
176
|
-
paymentAmountPromissoryNote: tax.tit_specpay_paidamount30,
|
|
177
|
-
paymentAmountAccountsReceivable: tax.tit_specpay_paidamount40,
|
|
178
|
-
supplyAmount: tax.tit_specsum_chargeamount,
|
|
179
|
-
taxAmount: tax.tit_specsum_taxamount,
|
|
180
|
-
totalAmount: tax.tit_specsum_grandamount
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// 세금계산서 아이템 데이터 객체 생성
|
|
184
|
-
const newTaxInvoiceItem: NewTaxInvoiceItem[] = []
|
|
185
|
-
for (let item of tax.tAliceItemList) {
|
|
186
|
-
newTaxInvoiceItem.push({
|
|
187
|
-
sequence: item.tii_seqnumeric,
|
|
188
|
-
supplyDate: this._dateFormat(item.tii_purchaseexpirydatetime),
|
|
189
|
-
itemName: item.tii_nametext,
|
|
190
|
-
specification: item.tii_informationtext,
|
|
191
|
-
quantity: item.tii_chargeableunitquantity,
|
|
192
|
-
unitPrice: item.tii_unitprice_unitamount,
|
|
193
|
-
supplyPrice: item.tii_invoiceamount,
|
|
194
|
-
taxPrice: item.tii_totaltax_calcamount,
|
|
195
|
-
remark: item.tii_descriptiontext
|
|
196
|
-
})
|
|
197
|
-
}
|
|
117
|
+
// api로 받은 데이터를 DB 형태로 파싱
|
|
118
|
+
const { taxInvoice, taxInvoiceItems } = parseTaxInvoiceByUnipostFormat(tax, tax.tAliceItemList, tax.category)
|
|
198
119
|
|
|
199
120
|
// Insert
|
|
200
|
-
this.createTaxInvoice(
|
|
121
|
+
this.createTaxInvoice(taxInvoice, taxInvoiceItems, context)
|
|
201
122
|
|
|
202
123
|
// API 결과 회신 데이터 생성
|
|
203
124
|
insertedData.push({
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { NewTaxInvoiceItem } from 'service/tax-invoice-item/tax-invoice-item-type'
|
|
2
|
+
import { NewTaxInvoice } from './tax-invoice-type'
|
|
3
|
+
import { BusinessRegistrationCategory, Category, InvoiceType, Purpose, RevisedReason } from './tax-invoice'
|
|
4
|
+
|
|
5
|
+
interface UnipostTaxInvoice {
|
|
6
|
+
offset?: string
|
|
7
|
+
limit?: string
|
|
8
|
+
aid?: string
|
|
9
|
+
exd_id?: string
|
|
10
|
+
exd_refdoc_id?: string
|
|
11
|
+
exd_issuedatetime?: string
|
|
12
|
+
exd_issuedatetime_format?: string
|
|
13
|
+
tid_issueid?: string
|
|
14
|
+
tid_issuedatetime?: string
|
|
15
|
+
tid_issuedatetime_format?: string
|
|
16
|
+
tid_typecode?: InvoiceType
|
|
17
|
+
tid_typecode_desc?: string
|
|
18
|
+
tid_purposecode?: Purpose
|
|
19
|
+
tid_purposecode_desc?: string
|
|
20
|
+
tid_amendcode?: RevisedReason
|
|
21
|
+
tid_amendcode_desc?: string
|
|
22
|
+
tid_originalissueid?: string
|
|
23
|
+
tid_desc0?: string
|
|
24
|
+
tid_desc1?: string
|
|
25
|
+
tid_desc2?: string
|
|
26
|
+
tid_refimpdoc_id?: string
|
|
27
|
+
tid_refimpdoc_itemquantity?: string
|
|
28
|
+
tid_refimpdoc_accept_sdate?: string
|
|
29
|
+
tid_refimpdoc_accept_edate?: string
|
|
30
|
+
tit_alice_specorg_biztypecode?: BusinessRegistrationCategory
|
|
31
|
+
tit_alice_id?: string
|
|
32
|
+
tit_alice_specorg_taxregid?: string
|
|
33
|
+
tit_alice_name?: string
|
|
34
|
+
tit_alice_specperson_name?: string
|
|
35
|
+
tit_alice_specaddr_lineone?: string
|
|
36
|
+
tit_alice_typecode?: string
|
|
37
|
+
tit_alice_classcode?: string
|
|
38
|
+
tit_alice_defcont_deptname?: string
|
|
39
|
+
tit_alice_defcont_personname?: string
|
|
40
|
+
tit_alice_defcont_telcomm?: string
|
|
41
|
+
tit_alice_defcont_uricomm?: string
|
|
42
|
+
tit_alice_defcont_cellphone?: string
|
|
43
|
+
tit_bob_specorg_biztypecode?: BusinessRegistrationCategory
|
|
44
|
+
tit_bob_id?: string
|
|
45
|
+
tit_bob_specorg_taxregid?: string
|
|
46
|
+
tit_bob_name?: string
|
|
47
|
+
tit_bob_specperson_name?: string
|
|
48
|
+
tit_bob_specaddr_lineone?: string
|
|
49
|
+
tit_bob_typecode?: string
|
|
50
|
+
tit_bob_classcode?: string
|
|
51
|
+
tit_bob_1stdefcont_deptname?: string
|
|
52
|
+
tit_bob_1stdefcont_personname?: string
|
|
53
|
+
tit_bob_1stdefcont_telcomm?: string
|
|
54
|
+
tit_bob_1stdefcont_uricomm?: string
|
|
55
|
+
tit_bob_1stdefcont_cellphone?: string
|
|
56
|
+
tit_bob_2nddefcont_deptname?: string
|
|
57
|
+
tit_bob_2nddefcont_personname?: string
|
|
58
|
+
tit_bob_2nddefcont_telcomm?: string
|
|
59
|
+
tit_bob_2nddefcont_uricomm?: string
|
|
60
|
+
tit_bob_2nddefcont_cellphone?: string
|
|
61
|
+
tit_broker_specorg_biztypecode?: BusinessRegistrationCategory
|
|
62
|
+
tit_broker_id?: string
|
|
63
|
+
tit_broker_specorg_taxregid?: string
|
|
64
|
+
tit_broker_name?: string
|
|
65
|
+
tit_broker_specperson_name?: string
|
|
66
|
+
tit_broker_specaddr_lineone?: string
|
|
67
|
+
tit_broker_typecode?: string
|
|
68
|
+
tit_broker_classcode?: string
|
|
69
|
+
tit_broker_defcont_deptname?: string
|
|
70
|
+
tit_broker_defcont_personname?: string
|
|
71
|
+
tit_broker_defcont_telcomm?: string
|
|
72
|
+
tit_broker_defcont_uricomm?: string
|
|
73
|
+
tit_broker_defcont_cellphone?: string
|
|
74
|
+
tit_specpay_paidamount10?: number
|
|
75
|
+
tit_specpay_paidamount20?: number
|
|
76
|
+
tit_specpay_paidamount30?: number
|
|
77
|
+
tit_specpay_paidamount40?: number
|
|
78
|
+
tit_specpay_paidamount10_format?: string
|
|
79
|
+
tit_specpay_paidamount20_format?: string
|
|
80
|
+
tit_specpay_paidamount30_format?: string
|
|
81
|
+
tit_specpay_paidamount40_format?: string
|
|
82
|
+
tit_specsum_chargeamount?: number
|
|
83
|
+
tit_specsum_taxamount?: number
|
|
84
|
+
tit_specsum_grandamount?: number
|
|
85
|
+
tit_specsum_chargeamount_format?: string
|
|
86
|
+
tit_specsum_taxamount_format?: string
|
|
87
|
+
tit_specsum_grandamount_format?: string
|
|
88
|
+
biz_tocharlesconfirmstatus?: string
|
|
89
|
+
inv_sign?: string
|
|
90
|
+
mbill_send_status?: string
|
|
91
|
+
erp_sync_yn?: string
|
|
92
|
+
prt_yn?: string
|
|
93
|
+
prt_yn_desc?: string
|
|
94
|
+
inv_seq?: string
|
|
95
|
+
view_date?: string
|
|
96
|
+
reg_date?: string
|
|
97
|
+
sot_yn?: string
|
|
98
|
+
table_alias?: string
|
|
99
|
+
biz_no?: string
|
|
100
|
+
tAliceItemList?: Array<any>
|
|
101
|
+
tcTrItemList?: Array<any>
|
|
102
|
+
tAliceFileList?: Array<any>
|
|
103
|
+
tAliceDSig?: Object
|
|
104
|
+
tAliceStat?: Object
|
|
105
|
+
biz_tocharlesconfirmstatus_desc?: string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface UnipostTaxInvoiceItem {
|
|
109
|
+
offset?: number
|
|
110
|
+
limit?: number
|
|
111
|
+
aid?: string
|
|
112
|
+
exd_id?: string
|
|
113
|
+
tii_seqnumeric?: number
|
|
114
|
+
tii_purchaseexpirydatetime?: string
|
|
115
|
+
tii_purchaseexpirydatetime_format?: string
|
|
116
|
+
tii_purchaseexpirydatetime_format_month?: string
|
|
117
|
+
tii_purchaseexpirydatetime_format_day?: string
|
|
118
|
+
tii_nametext?: string
|
|
119
|
+
tii_informationtext?: string
|
|
120
|
+
tii_chargeableunitquantity?: number
|
|
121
|
+
tii_chargeableunitquantity_format?: string
|
|
122
|
+
tii_chargeableunittext?: string
|
|
123
|
+
tii_unitprice_unitamount?: number
|
|
124
|
+
tii_unitprice_unitamount_format?: string
|
|
125
|
+
tii_invoiceamount?: number
|
|
126
|
+
tii_invoiceamount_format?: string
|
|
127
|
+
tii_totaltax_calcamount?: number
|
|
128
|
+
tii_totaltax_calcamount_format?: string
|
|
129
|
+
tii_descriptiontext?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 유니포스트 데이터 포맷을 DB에 넣을수 있는 포맷으로 변경
|
|
133
|
+
export function parseTaxInvoiceByUnipostFormat(unipostTaxInvoice: UnipostTaxInvoice, unipostTaxInvoiceItems: UnipostTaxInvoiceItem[], category: Category) {
|
|
134
|
+
let taxInvoice: NewTaxInvoice
|
|
135
|
+
let taxInvoiceItems: NewTaxInvoiceItem[]
|
|
136
|
+
|
|
137
|
+
// 한개 라도 없으면 전부 빈값으로 리턴
|
|
138
|
+
if (!unipostTaxInvoice || !unipostTaxInvoiceItems) return { taxInvoice, taxInvoiceItems }
|
|
139
|
+
|
|
140
|
+
// exd_issuedatetime 이 두개는 조회 API에서는 yyyymmdd 로 오지만 발행에서는 yyyymmddhhmmss로 옴
|
|
141
|
+
taxInvoice = {
|
|
142
|
+
issueNo: unipostTaxInvoice.exd_id,
|
|
143
|
+
approvalNo: unipostTaxInvoice.tid_issueid,
|
|
144
|
+
originalApprovalNo: unipostTaxInvoice.tid_originalissueid,
|
|
145
|
+
issueDate: _dateFormat(unipostTaxInvoice.tid_issuedatetime),
|
|
146
|
+
signatureDate: _dateFormat(unipostTaxInvoice.exd_issuedatetime.substring(0, 8)),
|
|
147
|
+
invoiceType: unipostTaxInvoice.tid_typecode,
|
|
148
|
+
purpose: unipostTaxInvoice.tid_purposecode,
|
|
149
|
+
revisedReason: unipostTaxInvoice.tid_amendcode,
|
|
150
|
+
remark0: unipostTaxInvoice.tid_desc0,
|
|
151
|
+
remark1: unipostTaxInvoice.tid_desc1,
|
|
152
|
+
remark2: unipostTaxInvoice.tid_desc2,
|
|
153
|
+
category: category,
|
|
154
|
+
supplierBusinessRegistrationCategory: unipostTaxInvoice.tit_alice_specorg_biztypecode,
|
|
155
|
+
supplierBusinessRegistrationNumber: unipostTaxInvoice.tit_alice_id,
|
|
156
|
+
supplierBranchIdentification: unipostTaxInvoice.tit_alice_specorg_taxregid,
|
|
157
|
+
supplierBusinessName: unipostTaxInvoice.tit_alice_name,
|
|
158
|
+
supplierRepresentativeName: unipostTaxInvoice.tit_alice_specperson_name,
|
|
159
|
+
supplierAddress: unipostTaxInvoice.tit_alice_specaddr_lineone,
|
|
160
|
+
supplierBusinessType: unipostTaxInvoice.tit_alice_typecode,
|
|
161
|
+
supplierIndustryType: unipostTaxInvoice.tit_alice_classcode,
|
|
162
|
+
supplierDepartment: unipostTaxInvoice.tit_alice_defcont_deptname,
|
|
163
|
+
supplierContactName: unipostTaxInvoice.tit_alice_defcont_personname,
|
|
164
|
+
supplierContactPhone: unipostTaxInvoice.tit_alice_defcont_telcomm,
|
|
165
|
+
supplierContactEmail: unipostTaxInvoice.tit_alice_defcont_uricomm,
|
|
166
|
+
supplierContactCellPhone: unipostTaxInvoice.tit_alice_defcont_cellphone,
|
|
167
|
+
buyerBusinessRegistrationCategory: unipostTaxInvoice.tit_bob_specorg_biztypecode,
|
|
168
|
+
buyerBusinessRegistrationNumber: unipostTaxInvoice.tit_bob_id,
|
|
169
|
+
buyerBranchIdentification: unipostTaxInvoice.tit_bob_specorg_taxregid,
|
|
170
|
+
buyerBusinessName: unipostTaxInvoice.tit_bob_name,
|
|
171
|
+
buyerRepresentativeName: unipostTaxInvoice.tit_bob_specperson_name,
|
|
172
|
+
buyerAddress: unipostTaxInvoice.tit_bob_specaddr_lineone,
|
|
173
|
+
buyerBusinessType: unipostTaxInvoice.tit_bob_typecode,
|
|
174
|
+
buyerIndustryType: unipostTaxInvoice.tit_bob_classcode,
|
|
175
|
+
buyer1stDepartment: unipostTaxInvoice.tit_bob_1stdefcont_deptname,
|
|
176
|
+
buyer1stContactName: unipostTaxInvoice.tit_bob_1stdefcont_personname,
|
|
177
|
+
buyer1stContactPhone: unipostTaxInvoice.tit_bob_1stdefcont_telcomm,
|
|
178
|
+
buyer1stContactEmail: unipostTaxInvoice.tit_bob_1stdefcont_uricomm,
|
|
179
|
+
buyer1stContactCellPhone: unipostTaxInvoice.tit_bob_1stdefcont_cellphone,
|
|
180
|
+
buyer2ndDepartment: unipostTaxInvoice.tit_bob_2nddefcont_deptname,
|
|
181
|
+
buyer2ndContactName: unipostTaxInvoice.tit_bob_2nddefcont_personname,
|
|
182
|
+
buyer2ndContactPhone: unipostTaxInvoice.tit_bob_2nddefcont_telcomm,
|
|
183
|
+
buyer2ndContactEmail: unipostTaxInvoice.tit_bob_2nddefcont_uricomm,
|
|
184
|
+
buyer2ndContactCellPhone: unipostTaxInvoice.tit_bob_2nddefcont_cellphone,
|
|
185
|
+
agentBusinessRegistrationCategory: unipostTaxInvoice.tit_broker_specorg_biztypecode,
|
|
186
|
+
agentBusinessRegistrationNumber: unipostTaxInvoice.tit_broker_id,
|
|
187
|
+
agentBranchIdentification: unipostTaxInvoice.tit_broker_specorg_taxregid,
|
|
188
|
+
agentBusinessName: unipostTaxInvoice.tit_broker_name,
|
|
189
|
+
agentRepresentativeName: unipostTaxInvoice.tit_broker_specperson_name,
|
|
190
|
+
agentAddress: unipostTaxInvoice.tit_broker_specaddr_lineone,
|
|
191
|
+
agentBusinessType: unipostTaxInvoice.tit_broker_typecode,
|
|
192
|
+
agentIndustryType: unipostTaxInvoice.tit_broker_classcode,
|
|
193
|
+
agentDepartment: unipostTaxInvoice.tit_broker_defcont_deptname,
|
|
194
|
+
agentContactName: unipostTaxInvoice.tit_broker_defcont_personname,
|
|
195
|
+
agentContactPhone: unipostTaxInvoice.tit_broker_defcont_telcomm,
|
|
196
|
+
agentContactEmail: unipostTaxInvoice.tit_broker_defcont_uricomm,
|
|
197
|
+
agentContactCellPhone: unipostTaxInvoice.tit_broker_defcont_cellphone,
|
|
198
|
+
paymentAmountCash: unipostTaxInvoice.tit_specpay_paidamount10,
|
|
199
|
+
paymentAmountCheck: unipostTaxInvoice.tit_specpay_paidamount20,
|
|
200
|
+
paymentAmountPromissoryNote: unipostTaxInvoice.tit_specpay_paidamount30,
|
|
201
|
+
paymentAmountAccountsReceivable: unipostTaxInvoice.tit_specpay_paidamount40,
|
|
202
|
+
supplyAmount: unipostTaxInvoice.tit_specsum_chargeamount,
|
|
203
|
+
taxAmount: unipostTaxInvoice.tit_specsum_taxamount,
|
|
204
|
+
totalAmount: unipostTaxInvoice.tit_specsum_grandamount
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
taxInvoiceItems = unipostTaxInvoiceItems.map(item => ({
|
|
208
|
+
sequence: item.tii_seqnumeric,
|
|
209
|
+
supplyDate: _dateFormat(item.tii_purchaseexpirydatetime),
|
|
210
|
+
itemName: item.tii_nametext,
|
|
211
|
+
specification: item.tii_informationtext,
|
|
212
|
+
quantity: item.tii_chargeableunitquantity,
|
|
213
|
+
unitPrice: item.tii_unitprice_unitamount,
|
|
214
|
+
supplyPrice: item.tii_invoiceamount,
|
|
215
|
+
taxPrice: item.tii_totaltax_calcamount,
|
|
216
|
+
remark: item.tii_descriptiontext
|
|
217
|
+
}))
|
|
218
|
+
|
|
219
|
+
return { taxInvoice, taxInvoiceItems }
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// YYYYMMDD => YYYY-MM-DD
|
|
223
|
+
const _dateFormat = date => date.replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3')
|
|
@@ -110,7 +110,7 @@ export class TaxInvoice {
|
|
|
110
110
|
@Field({ nullable: true, description: '승인 번호 (24자리)' })
|
|
111
111
|
approvalNo?: string
|
|
112
112
|
|
|
113
|
-
@Column({ nullable: true, comment: '원 승인 번호 (계산서 수정시 원래의 승인 번호)' })
|
|
113
|
+
@Column({ nullable: true, default: '', comment: '원 승인 번호 (계산서 수정시 원래의 승인 번호)' })
|
|
114
114
|
@Field({ nullable: true, description: '원 승인 번호 (계산서 수정시 원래의 승인 번호)' })
|
|
115
115
|
originalApprovalNo?: string
|
|
116
116
|
|
|
@@ -154,7 +154,7 @@ export class TaxInvoice {
|
|
|
154
154
|
@Field({ nullable: false, description: '공급자 사업자등록번호' })
|
|
155
155
|
supplierBusinessRegistrationNumber!: string
|
|
156
156
|
|
|
157
|
-
@Column({ nullable: true, comment: '종사업장 식별 코드' })
|
|
157
|
+
@Column({ nullable: true, default: '0', comment: '종사업장 식별 코드' })
|
|
158
158
|
@Field({ nullable: true, description: '종사업장 식별 코드' })
|
|
159
159
|
supplierBranchIdentification?: string
|
|
160
160
|
|
|
@@ -206,7 +206,7 @@ export class TaxInvoice {
|
|
|
206
206
|
@Field({ nullable: false, description: '공급받는자 사업자등록번호' })
|
|
207
207
|
buyerBusinessRegistrationNumber!: string
|
|
208
208
|
|
|
209
|
-
@Column({ nullable: true, comment: '공급받는자 종사업장 식별 코드' })
|
|
209
|
+
@Column({ nullable: true, default: '0', comment: '공급받는자 종사업장 식별 코드' })
|
|
210
210
|
@Field({ nullable: true, description: '공급받는자 종사업장 식별 코드' })
|
|
211
211
|
buyerBranchIdentification?: string
|
|
212
212
|
|
|
@@ -278,7 +278,7 @@ export class TaxInvoice {
|
|
|
278
278
|
@Field({ nullable: true, description: '수탁사업자 사업자등록번호 (nnnnnnnnnn)' })
|
|
279
279
|
agentBusinessRegistrationNumber?: string
|
|
280
280
|
|
|
281
|
-
@Column({ nullable: true, comment: '수탁사업자 종사업장 식별코드' })
|
|
281
|
+
@Column({ nullable: true, default: '', comment: '수탁사업자 종사업장 식별코드' })
|
|
282
282
|
@Field({ nullable: true, description: '수탁사업자 종사업장 식별코드' })
|
|
283
283
|
agentBranchIdentification?: string
|
|
284
284
|
|
|
@@ -4,8 +4,9 @@ import { In } from 'typeorm'
|
|
|
4
4
|
import { TaxInvoiceApi } from './tax-invoice-api'
|
|
5
5
|
import { TaxInvoiceApiPatch, TaxInvoiceSend } from './tax-invoice-api-type'
|
|
6
6
|
import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
|
|
7
|
-
import { TaxInvoice } from '../tax-invoice/tax-invoice'
|
|
7
|
+
import { Category, TaxInvoice } from '../tax-invoice/tax-invoice'
|
|
8
8
|
import { sendTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-send'
|
|
9
|
+
import { parseTaxInvoiceByUnipostFormat } from '../tax-invoice/tax-invoice-util'
|
|
9
10
|
|
|
10
11
|
@Resolver(TaxInvoiceApi)
|
|
11
12
|
export class TaxInvoiceApiMutation {
|
|
@@ -55,11 +56,11 @@ export class TaxInvoiceApiMutation {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
@Directive('@transaction')
|
|
58
|
-
@Mutation(returns =>
|
|
59
|
+
@Mutation(returns => Boolean, { description: 'To Send Tax Invoices By Api' })
|
|
59
60
|
async sendTaxInvoicesByApi(
|
|
60
61
|
@Arg('taxInvoiceSendList', type => [TaxInvoiceSend]) taxInvoiceSendList: TaxInvoiceSend[],
|
|
61
62
|
@Ctx() context: ResolverContext
|
|
62
|
-
): Promise<
|
|
63
|
+
): Promise<boolean> {
|
|
63
64
|
if (taxInvoiceSendList.length === 0) throw new Error('tax invoice send exception: no list')
|
|
64
65
|
|
|
65
66
|
const { domain, user, tx } = context.state
|
|
@@ -70,23 +71,45 @@ export class TaxInvoiceApiMutation {
|
|
|
70
71
|
const apiInfo = (await taxInvoiceApiRepo.find()).at(0)
|
|
71
72
|
const businessRegistrationNumber = apiInfo.businessRegistrationNumber
|
|
72
73
|
const { aid = '', bearer = '', customer_no = '' } = apiInfo?.attributes
|
|
73
|
-
|
|
74
|
+
let failCount = 0
|
|
74
75
|
|
|
75
|
-
// 밸리데이션 및 데이터 파싱
|
|
76
|
+
// 1. 밸리데이션 및 데이터 파싱
|
|
76
77
|
let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no))
|
|
77
78
|
|
|
78
|
-
// 세금계산서 발행 API 호출
|
|
79
|
-
const apiResult = sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
// 2. 세금계산서 발행 API 호출
|
|
80
|
+
const apiResult = await sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)
|
|
81
|
+
|
|
82
|
+
// 3. 성공하면 세금계산서 DB에 저장
|
|
83
|
+
for (let item of apiResult) {
|
|
84
|
+
if (item?.success) {
|
|
85
|
+
const { taxInvoice, taxInvoiceItems } = parseTaxInvoiceByUnipostFormat(item?.tAliceEntry, item?.tAliceEntry?.tAliceItemList, Category.EXPORT)
|
|
86
|
+
|
|
87
|
+
// 세금계산서 저장
|
|
88
|
+
const newTaxInvoice = await taxInvoiceRepo.save({
|
|
89
|
+
...taxInvoice,
|
|
90
|
+
domain,
|
|
91
|
+
creator: user,
|
|
92
|
+
updater: user
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// 아이템 저장
|
|
96
|
+
for (const item of taxInvoiceItems) {
|
|
97
|
+
await taxInvoiceItemRepo.save({ ...item, taxInvoice: newTaxInvoice, domain, creator: user })
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
failCount++
|
|
101
|
+
}
|
|
82
102
|
}
|
|
83
103
|
|
|
84
|
-
//
|
|
85
|
-
|
|
104
|
+
// 실패가 1개라도 있으면 에러
|
|
105
|
+
if (failCount > 0) {
|
|
106
|
+
throw new Error(failCount + '개의 계산서 등록에 실패하였습니다.')
|
|
107
|
+
}
|
|
86
108
|
|
|
87
|
-
return
|
|
109
|
+
return true
|
|
88
110
|
}
|
|
89
111
|
|
|
112
|
+
// 유니스포트에 받을수 있는 포맷으로 데이터 파싱
|
|
90
113
|
private _parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no) {
|
|
91
114
|
const { taxInvoice, taxInvoiceItems } = taxInvoiceSend
|
|
92
115
|
let newTaxInvoiceItems: any = []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 세금계산서 발행 API
|
|
2
2
|
const SEND_URL = {
|
|
3
|
-
dev: 'https://
|
|
4
|
-
prod: 'https://
|
|
3
|
+
dev: 'https://inf2dev.unipost.co.kr:47543/mbill-etaxr-server/api/rest/v3/receivebill',
|
|
4
|
+
prod: 'https://inf1.unipost.co.kr/mbill-etaxr-server/api/rest/v3/receivebill'
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export async function sendTaxInvoiceByUniposApi(businessRegistrationNumber: string, aid: string, bearer: string, taxInvoiceSendList) {
|
|
@@ -11,32 +11,22 @@ export async function sendTaxInvoiceByUniposApi(businessRegistrationNumber: stri
|
|
|
11
11
|
|
|
12
12
|
const response = await _callTaxInvoiceSend(businessRegistrationNumber, aid, bearer, taxInvoiceSendList)
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
if (response.status === 200) {
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const result = await response.json()
|
|
19
|
-
|
|
20
|
-
console.log('response : ', response)
|
|
21
|
-
console.log('result : ', result)
|
|
22
|
-
|
|
23
|
-
return result.success
|
|
14
|
+
return response?.status === 200 ? await response.json() : false
|
|
24
15
|
}
|
|
25
16
|
|
|
26
17
|
async function _callTaxInvoiceSend(businessRegistrationNumber: string, aid: string, bearer: string, taxInvoiceSendList) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return response
|
|
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
|
+
} catch (e) {
|
|
30
|
+
console.log('e : ', e)
|
|
31
|
+
}
|
|
42
32
|
}
|
package/translations/ko.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"text.next tax invoice description payment": "함",
|
|
20
20
|
"text.tax invoice description purpose 01": "영수",
|
|
21
21
|
"text.tax invoice description purpose 02": "청구",
|
|
22
|
+
"text.success tax send": "세금계산서가 발행되었습니다.",
|
|
22
23
|
|
|
23
24
|
"field.memo": "메모",
|
|
24
25
|
"field.business registration number": "사업자등록번호",
|