@things-factory/tax-invoice 6.2.143 → 6.2.144
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 +34 -15
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.d.ts +7 -3
- package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js +28 -13
- 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 +20 -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 +25 -3
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.144",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"@things-factory/export-ui-excel": "^6.2.139",
|
|
35
35
|
"@things-factory/shell": "^6.2.139"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "43fe1dab4ba9c08c39a24bb9afeb4aca12a21c27"
|
|
38
38
|
}
|
|
@@ -4,7 +4,7 @@ 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 { Category, TaxInvoice } from '../tax-invoice/tax-invoice'
|
|
7
|
+
import { Category, InvoiceType, TaxInvoice } from '../tax-invoice/tax-invoice'
|
|
8
8
|
import { sendTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-send'
|
|
9
9
|
import { parseTaxInvoiceByUnipostFormat } from '../tax-invoice/tax-invoice-util'
|
|
10
10
|
|
|
@@ -86,6 +86,7 @@ export class TaxInvoiceApiMutation {
|
|
|
86
86
|
const businessRegistrationNumber = apiInfo.businessRegistrationNumber
|
|
87
87
|
const { aid = '', bearer = '', customer_no = '' } = apiInfo?.attributes
|
|
88
88
|
let failCount = 0
|
|
89
|
+
let failMessage = []
|
|
89
90
|
|
|
90
91
|
// 1. 밸리데이션 및 데이터 파싱
|
|
91
92
|
let newTaxInvoiceSendList = taxInvoiceSendList.map(taxInvoiceSend => this._parseTaxInvoiceSendForApi(taxInvoiceSend, aid, customer_no))
|
|
@@ -93,6 +94,7 @@ export class TaxInvoiceApiMutation {
|
|
|
93
94
|
// 2. 세금계산서 발행 API 호출
|
|
94
95
|
const apiResult = await sendTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer, newTaxInvoiceSendList)
|
|
95
96
|
if (apiResult === false) {
|
|
97
|
+
// TODO 로그 찍기
|
|
96
98
|
throw new Error('tax invoice send exception: api error')
|
|
97
99
|
}
|
|
98
100
|
|
|
@@ -115,12 +117,13 @@ export class TaxInvoiceApiMutation {
|
|
|
115
117
|
}
|
|
116
118
|
} else {
|
|
117
119
|
failCount++
|
|
120
|
+
failMessage.push(`${item.inv_seq}: ${item.message}`)
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
// 실패가 1개라도 있으면 에러
|
|
122
125
|
if (failCount > 0) {
|
|
123
|
-
throw new Error(failCount + '개의 계산서 등록에
|
|
126
|
+
throw new Error(failCount + '개의 계산서 등록에 실패하였습니다.\n' + failMessage.join('\n'))
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
return true
|
|
@@ -145,6 +148,16 @@ export class TaxInvoiceApiMutation {
|
|
|
145
148
|
throw new Error('tax invoice send exception: no essential value')
|
|
146
149
|
}
|
|
147
150
|
|
|
151
|
+
// 공급자 사업자 등록번호가 전부 숫자이며 10자리 인지 체크
|
|
152
|
+
if (isNaN(taxInvoice.supplierBusinessRegistrationNumber) || taxInvoice.supplierBusinessRegistrationNumber.length !== 10) {
|
|
153
|
+
throw new Error('tax invoice send exception: Supplier Business Registration Number is wrong')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 공급받는자 사업자 등록번호가 전부 숫자이며 10자리 인지 체크
|
|
157
|
+
if (isNaN(taxInvoice.buyerBusinessRegistrationNumber) || taxInvoice.buyerBusinessRegistrationNumber.length !== 10) {
|
|
158
|
+
throw new Error('tax invoice send exception: Buyer Business Registration Number is wrong')
|
|
159
|
+
}
|
|
160
|
+
|
|
148
161
|
// 작성일자가 오늘 날짜를 넘어가면 에러
|
|
149
162
|
if (taxInvoice.issueDate > today) {
|
|
150
163
|
throw new Error('tax invoice send exception: issueDate error')
|
|
@@ -153,11 +166,15 @@ export class TaxInvoiceApiMutation {
|
|
|
153
166
|
// 현금, 수표, 어음, 외상미수금이 있을시 총 합계금액과 금액 동일 체크
|
|
154
167
|
const paymentAmount: number =
|
|
155
168
|
taxInvoice.paymentAmountCash + taxInvoice.paymentAmountCheck + taxInvoice.paymentAmountPromissoryNote + taxInvoice.paymentAmountAccountsReceivable
|
|
156
|
-
|
|
157
169
|
if (paymentAmount > 0 && paymentAmount !== taxInvoice.totalAmount) {
|
|
158
170
|
throw new Error('tax invoice send exception: summary is not same')
|
|
159
171
|
}
|
|
160
172
|
|
|
173
|
+
// 영세업자인데 세금이 있으면 에러
|
|
174
|
+
if (taxInvoice.invoiceType === InvoiceType.ZERO_RATED_TAX_INVOICE && taxInvoice.taxAmount > 0) {
|
|
175
|
+
throw new Error('tax invoice send exception: tax price is exist')
|
|
176
|
+
}
|
|
177
|
+
|
|
161
178
|
for (let item of taxInvoiceItems) {
|
|
162
179
|
// 아이템 필수값 체크
|
|
163
180
|
if (!item.supplyDate || !item.itemName || !item.quantity || !item.unitPrice) {
|
|
@@ -169,6 +186,11 @@ export class TaxInvoiceApiMutation {
|
|
|
169
186
|
throw new Error('tax invoice send exception: item supplyDate is bigger than issueDate')
|
|
170
187
|
}
|
|
171
188
|
|
|
189
|
+
// 영세업자인데 아이템 세금이 있으면 에러
|
|
190
|
+
if (taxInvoice.invoiceType === InvoiceType.ZERO_RATED_TAX_INVOICE && item.taxPrice > 0) {
|
|
191
|
+
throw new Error('tax invoice send exception: item tax price is exist')
|
|
192
|
+
}
|
|
193
|
+
|
|
172
194
|
newTaxInvoiceItems.push({
|
|
173
195
|
tii_seqnumeric: item.sequence,
|
|
174
196
|
tii_purchaseexpirydatetime: item.supplyDate.replace(/-/g, ''),
|