@things-factory/tax-invoice 8.0.78 → 8.0.79

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/tax-invoice",
3
- "version": "8.0.78",
3
+ "version": "8.0.79",
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": "28d6bf42a06e7b00b158199fbafe81c6ca54981f"
37
+ "gitHead": "d3e06a1f18781c320e9de3438f67db525e4e6a66"
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,24 @@ 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
 
111
+ // TODO 여기 기본값으로 가져와야하는거 아님?
109
112
  const apiInfo = (await taxInvoiceApiRepo.find())[0]
110
113
  const businessRegistrationNumber = apiInfo.businessRegistrationNumber
111
114
  const { aid = '', bearer = '' } = apiInfo?.attributes
112
115
 
116
+ logger.info('apiInfo : ', apiInfo)
117
+
113
118
  // API 호출하여 세금계산서 데이터 가져옴
114
119
  const { issueNoList, taxList } = await getTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer)
115
120
 
121
+ logger.info('issueNoList, taxList : ', issueNoList, taxList)
122
+
116
123
  // 이미 있는 데이터 아이디 검색
117
124
  const existingTaxInvoice = await taxInvoiceRepo.find({
118
125
  select: ['issueNo'],
@@ -120,6 +127,8 @@ export class TaxInvoiceMutation {
120
127
  })
121
128
  const existingIds = existingTaxInvoice.map(taxInvoice => taxInvoice.issueNo)
122
129
 
130
+ logger.info('existingTaxInvoice : ', existingTaxInvoice)
131
+
123
132
  // 매입, 매출 for문
124
133
  for (let tax of taxList) {
125
134
  // 있는지 없는지 확인 (이미 있는 세금계산서는 패스)
@@ -142,7 +151,10 @@ export class TaxInvoiceMutation {
142
151
  }
143
152
 
144
153
  // 유니 포스트에 조회 후 결과 회신 API 호출
145
- callTaxInvoiceConfirm(businessRegistrationNumber, aid, bearer, insertedData)
154
+ const confirmResult = await callTaxInvoiceConfirm(businessRegistrationNumber, aid, bearer, insertedData)
155
+
156
+ logger.info('insertedData : ', insertedData)
157
+ logger.info('confirmResult : ', confirmResult)
146
158
 
147
159
  return true
148
160
  }
@@ -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 : ', 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 : ', taxData)
46
+
42
47
  if (taxData.success === true) {
43
48
  for (let tax of taxData.tAliceEntry) {
44
49
  issueNoList.push(tax.exd_id)