@things-factory/tax-invoice 8.0.78 → 8.0.80
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/dist-server/service/tax-invoice/tax-invoice-mutation.js +21 -3
- package/dist-server/service/tax-invoice/tax-invoice-mutation.js.map +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api.js +1 -1
- package/dist-server/service/tax-invoice-api/tax-invoice-api.js.map +1 -1
- package/dist-server/service/unipost-api/tax-invoice-inquiry.js +3 -0
- package/dist-server/service/unipost-api/tax-invoice-inquiry.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/service/tax-invoice/tax-invoice-mutation.ts +27 -3
- package/server/service/tax-invoice-api/tax-invoice-api.ts +1 -1
- package/server/service/unipost-api/tax-invoice-inquiry.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/tax-invoice",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.80",
|
|
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": "^8.0.64",
|
|
35
35
|
"@things-factory/shell": "^8.0.64"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f648b0289efffa73217f3304ddad21bec912a8a0"
|
|
38
38
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getTaxInvoiceByUniposApi
|
|
15
15
|
} from '../unipost-api/tax-invoice-inquiry'
|
|
16
16
|
import { parseTaxInvoiceByUnipostFormat } from './tax-invoice-util'
|
|
17
|
+
import { logger } from '@things-factory/env'
|
|
17
18
|
|
|
18
19
|
@Resolver(TaxInvoice)
|
|
19
20
|
export class TaxInvoiceMutation {
|
|
@@ -101,18 +102,36 @@ export class TaxInvoiceMutation {
|
|
|
101
102
|
@Directive('@transaction')
|
|
102
103
|
@Mutation(returns => Boolean, { description: 'create tax invoice data by API' })
|
|
103
104
|
async fetchTaxInvoiceByApi(@Ctx() context: ResolverContext): Promise<boolean> {
|
|
105
|
+
logger.info('fetchTaxInvoiceByApi')
|
|
104
106
|
const { domain, user, tx } = context.state
|
|
105
107
|
const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)
|
|
106
108
|
const taxInvoiceRepo = tx.getRepository(TaxInvoice)
|
|
107
109
|
const insertedData: ConfirmData[] = [] // API 호출 후 결과 회신용
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
// TODO 여기 기본값으로 가져와야하는거 아님?
|
|
112
|
+
const apiInfo = await taxInvoiceApiRepo
|
|
113
|
+
.createQueryBuilder('tia')
|
|
114
|
+
.leftJoinAndSelect('tia.domain', 'domain')
|
|
115
|
+
.where('domain.id = :domainId', { domainId: domain.id })
|
|
116
|
+
.andWhere('tia.isDefault = true')
|
|
117
|
+
.orderBy('tia.createdAt', 'DESC')
|
|
118
|
+
.getOne()
|
|
119
|
+
|
|
120
|
+
if (!apiInfo) {
|
|
121
|
+
throw new Error('기본 세금계산서 API 정보가 설정되어 있지 않습니다.')
|
|
122
|
+
}
|
|
123
|
+
|
|
110
124
|
const businessRegistrationNumber = apiInfo.businessRegistrationNumber
|
|
111
|
-
const { aid = '', bearer = '' } = apiInfo
|
|
125
|
+
const { aid = '', bearer = '' } = apiInfo.attributes || {}
|
|
126
|
+
|
|
127
|
+
logger.info(`apiInfo : ${JSON.stringify(apiInfo)}`)
|
|
112
128
|
|
|
113
129
|
// API 호출하여 세금계산서 데이터 가져옴
|
|
114
130
|
const { issueNoList, taxList } = await getTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer)
|
|
115
131
|
|
|
132
|
+
logger.info(`issueNoList : ${JSON.stringify(issueNoList)}`)
|
|
133
|
+
logger.info(`taxList : ${JSON.stringify(taxList)}`)
|
|
134
|
+
|
|
116
135
|
// 이미 있는 데이터 아이디 검색
|
|
117
136
|
const existingTaxInvoice = await taxInvoiceRepo.find({
|
|
118
137
|
select: ['issueNo'],
|
|
@@ -120,6 +139,8 @@ export class TaxInvoiceMutation {
|
|
|
120
139
|
})
|
|
121
140
|
const existingIds = existingTaxInvoice.map(taxInvoice => taxInvoice.issueNo)
|
|
122
141
|
|
|
142
|
+
logger.info(`existingTaxInvoice : ${JSON.stringify(existingTaxInvoice)}`)
|
|
143
|
+
|
|
123
144
|
// 매입, 매출 for문
|
|
124
145
|
for (let tax of taxList) {
|
|
125
146
|
// 있는지 없는지 확인 (이미 있는 세금계산서는 패스)
|
|
@@ -142,7 +163,10 @@ export class TaxInvoiceMutation {
|
|
|
142
163
|
}
|
|
143
164
|
|
|
144
165
|
// 유니 포스트에 조회 후 결과 회신 API 호출
|
|
145
|
-
callTaxInvoiceConfirm(businessRegistrationNumber, aid, bearer, insertedData)
|
|
166
|
+
const confirmResult = await callTaxInvoiceConfirm(businessRegistrationNumber, aid, bearer, insertedData)
|
|
167
|
+
|
|
168
|
+
logger.info(`insertedData : ${JSON.stringify(insertedData)}`)
|
|
169
|
+
logger.info(`confirmResult : ${JSON.stringify(confirmResult)}`)
|
|
146
170
|
|
|
147
171
|
return true
|
|
148
172
|
}
|
|
@@ -32,7 +32,7 @@ export class TaxInvoiceApi {
|
|
|
32
32
|
@RelationId((taxInvoiceApi: TaxInvoiceApi) => taxInvoiceApi.domain)
|
|
33
33
|
domainId?: string
|
|
34
34
|
|
|
35
|
-
@Column({ nullable: true, comment: '디폴트 여부' })
|
|
35
|
+
@Column({ type: 'boolean', nullable: true, comment: '디폴트 여부' })
|
|
36
36
|
@Field({ nullable: true, description: '디폴트 여부' })
|
|
37
37
|
isDefault?: boolean
|
|
38
38
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Category } from '../tax-invoice/tax-invoice'
|
|
2
2
|
import { config } from '@things-factory/env'
|
|
3
3
|
// import getTestTaxInvoiceData from './test-data'
|
|
4
|
+
import { logger } from '@things-factory/env'
|
|
4
5
|
|
|
5
6
|
const UNITAX_CONFIG = config.get('unitax', {})
|
|
6
7
|
// 세금계산서 조회 API
|
|
@@ -34,11 +35,15 @@ export async function getTaxInvoiceByUniposApi(businessRegistrationNumber: strin
|
|
|
34
35
|
for (const taxType of taxTypeArr) {
|
|
35
36
|
const response = await _callTaxInvoiceInquiry(businessRegistrationNumber, aid, bearer, taxType)
|
|
36
37
|
|
|
38
|
+
logger.info(`response : ${JSON.stringify(response)}`)
|
|
39
|
+
|
|
37
40
|
// 성공 일시 세금 계산서 데이터 배열에 추가
|
|
38
41
|
if (response.status === 200) {
|
|
39
42
|
const category = taxType === 'AR' ? Category.EXPORT : Category.IMPORT // 유니포스트의 타입 => 우리 솔루션 형태로 변환
|
|
40
43
|
const taxData = await response.json()
|
|
41
44
|
|
|
45
|
+
logger.info(`taxData : ${JSON.stringify(taxData)}`)
|
|
46
|
+
|
|
42
47
|
if (taxData.success === true) {
|
|
43
48
|
for (let tax of taxData.tAliceEntry) {
|
|
44
49
|
issueNoList.push(tax.exd_id)
|