@things-factory/tax-invoice 6.2.86 → 6.2.90

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.
Files changed (61) hide show
  1. package/client/pages/tax-invoice/tax-invoice-detail-popup.ts +12 -6
  2. package/client/pages/tax-invoice/tax-invoice-list-page.ts +147 -176
  3. package/client/pages/tax-invoice-api/tax-invoice-api-page.ts +52 -114
  4. package/client/pages/tax-invoice-company/tax-invoice-company-importer.ts +2 -2
  5. package/client/pages/tax-invoice-send/tax-invoice-send-page.ts +580 -0
  6. package/client/route.ts +4 -4
  7. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js +18 -9
  8. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js.map +1 -1
  9. package/dist-client/pages/tax-invoice/tax-invoice-list-page.d.ts +63 -23
  10. package/dist-client/pages/tax-invoice/tax-invoice-list-page.js +149 -168
  11. package/dist-client/pages/tax-invoice/tax-invoice-list-page.js.map +1 -1
  12. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.d.ts +3 -5
  13. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js +52 -105
  14. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js.map +1 -1
  15. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js +2 -2
  16. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js.map +1 -1
  17. package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.d.ts +100 -0
  18. package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js +510 -0
  19. package/dist-client/pages/tax-invoice-send/tax-invoice-send-page.js.map +1 -0
  20. package/dist-client/route.d.ts +1 -1
  21. package/dist-client/route.js +3 -3
  22. package/dist-client/route.js.map +1 -1
  23. package/dist-client/tsconfig.tsbuildinfo +1 -1
  24. package/dist-server/service/tax-invoice/tax-invoice-mutation.js +132 -27
  25. package/dist-server/service/tax-invoice/tax-invoice-mutation.js.map +1 -1
  26. package/dist-server/service/tax-invoice/tax-invoice-query.js +24 -1
  27. package/dist-server/service/tax-invoice/tax-invoice-query.js.map +1 -1
  28. package/dist-server/service/tax-invoice/tax-invoice-type.js +22 -259
  29. package/dist-server/service/tax-invoice/tax-invoice-type.js.map +1 -1
  30. package/dist-server/service/tax-invoice/tax-invoice.js +22 -16
  31. package/dist-server/service/tax-invoice/tax-invoice.js.map +1 -1
  32. package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js +13 -21
  33. package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js.map +1 -1
  34. package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js +4 -25
  35. package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js.map +1 -1
  36. package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js +5 -0
  37. package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js.map +1 -1
  38. package/dist-server/service/tax-invoice-api/tax-invoice-api.js +7 -1
  39. package/dist-server/service/tax-invoice-api/tax-invoice-api.js.map +1 -1
  40. package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js.map +1 -1
  41. package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js +4 -4
  42. package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js.map +1 -1
  43. package/dist-server/service/tax-invoice-item/tax-invoice-item.js +3 -3
  44. package/dist-server/service/tax-invoice-item/tax-invoice-item.js.map +1 -1
  45. package/dist-server/service/unipost-api/tax-invoice-inquiry.js +90 -0
  46. package/dist-server/service/unipost-api/tax-invoice-inquiry.js.map +1 -0
  47. package/dist-server/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +5 -5
  49. package/server/service/tax-invoice/tax-invoice-mutation.ts +137 -36
  50. package/server/service/tax-invoice/tax-invoice-query.ts +21 -3
  51. package/server/service/tax-invoice/tax-invoice-type.ts +21 -199
  52. package/server/service/tax-invoice/tax-invoice.ts +38 -45
  53. package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +19 -33
  54. package/server/service/tax-invoice-api/tax-invoice-api-query.ts +4 -21
  55. package/server/service/tax-invoice-api/tax-invoice-api-type.ts +4 -0
  56. package/server/service/tax-invoice-api/tax-invoice-api.ts +7 -15
  57. package/server/service/tax-invoice-item/tax-invoice-item-query.ts +1 -1
  58. package/server/service/tax-invoice-item/tax-invoice-item-type.ts +4 -7
  59. package/server/service/tax-invoice-item/tax-invoice-item.ts +3 -3
  60. package/server/service/unipost-api/tax-invoice-inquiry.ts +103 -0
  61. package/translations/ko.json +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/tax-invoice",
3
- "version": "6.2.86",
3
+ "version": "6.2.90",
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.84",
33
- "@things-factory/export-ui-excel": "^6.2.84",
34
- "@things-factory/shell": "^6.2.84"
32
+ "@things-factory/auth-base": "^6.2.88",
33
+ "@things-factory/export-ui-excel": "^6.2.88",
34
+ "@things-factory/shell": "^6.2.88"
35
35
  },
36
- "gitHead": "f90a5c1ff2a93331bb6e375944972dc68dde8a1f"
36
+ "gitHead": "e3320460fa6f015851f8dc1d6d45ab3298c00ebc"
37
37
  }
@@ -1,10 +1,13 @@
1
1
  import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
2
  import { In } from 'typeorm'
3
3
 
4
- import { TaxInvoice } from './tax-invoice'
4
+ import { Category, TaxInvoice } from './tax-invoice'
5
5
  import { NewTaxInvoice, TaxInvoicePatch } from './tax-invoice-type'
6
6
  import { NewTaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item-type'
7
7
  import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
8
+ import { TaxInvoiceApi } from '../tax-invoice-api/tax-invoice-api'
9
+ import { AttributeSet } from '@things-factory/shell/dist-server/service/attribute-set/attribute-set'
10
+ import { ConfirmData, UnipostTaxType, callTaxInvoiceConfirm, getTaxInvoiceByUniposApi } from '../unipost-api/tax-invoice-inquiry'
8
11
 
9
12
  @Resolver(TaxInvoice)
10
13
  export class TaxInvoiceMutation {
@@ -32,50 +35,16 @@ export class TaxInvoiceMutation {
32
35
  return newTaxInvoice
33
36
  }
34
37
 
35
- @Directive('@transaction')
36
- @Mutation(returns => TaxInvoice, { description: 'To modify TaxInvoice information' })
37
- async updateTaxInvoice(@Arg('id') id: string, @Arg('patch') patch: TaxInvoicePatch, @Ctx() context: ResolverContext): Promise<TaxInvoice> {
38
- const { domain, user, tx } = context.state
39
-
40
- const repository = tx.getRepository(TaxInvoice)
41
- const taxInvoice = await repository.findOne({
42
- where: { domain: { id: domain.id }, id }
43
- })
44
-
45
- const result = await repository.save({
46
- ...taxInvoice,
47
- ...patch,
48
- updater: user
49
- })
50
-
51
- return result
52
- }
53
-
38
+ // 그리드에서 메모 수정용 으로만
54
39
  @Directive('@transaction')
55
40
  @Mutation(returns => [TaxInvoice], { description: "To modify multiple TaxInvoices' information" })
56
41
  async updateMultipleTaxInvoice(@Arg('patches', type => [TaxInvoicePatch]) patches: TaxInvoicePatch[], @Ctx() context: ResolverContext): Promise<TaxInvoice[]> {
57
42
  const { domain, user, tx } = context.state
58
43
 
59
44
  let results = []
60
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
61
45
  const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
62
46
  const taxInvoiceRepo = tx.getRepository(TaxInvoice)
63
47
 
64
- if (_createRecords.length > 0) {
65
- for (let i = 0; i < _createRecords.length; i++) {
66
- const newRecord = _createRecords[i]
67
-
68
- const result = await taxInvoiceRepo.save({
69
- ...newRecord,
70
- domain,
71
- creator: user,
72
- updater: user
73
- })
74
-
75
- results.push({ ...result, cuFlag: '+' })
76
- }
77
- }
78
-
79
48
  if (_updateRecords.length > 0) {
80
49
  for (let i = 0; i < _updateRecords.length; i++) {
81
50
  const updateRecord = _updateRecords[i]
@@ -116,4 +85,136 @@ export class TaxInvoiceMutation {
116
85
 
117
86
  return true
118
87
  }
88
+
89
+ @Directive('@transaction')
90
+ @Mutation(returns => Boolean, { description: 'create tax invoice data by API' })
91
+ async fetchTaxInvoiceByApi(@Ctx() context: ResolverContext): Promise<boolean> {
92
+ const { domain, user, tx } = context.state
93
+ const taxInvoiceApiRepo = tx.getRepository(TaxInvoiceApi)
94
+ const taxInvoiceRepo = tx.getRepository(TaxInvoice)
95
+ const insertedData: ConfirmData[] = [] // API 호출 후 결과 회신용
96
+
97
+ const apiInfo = (await taxInvoiceApiRepo.find()).at(0)
98
+ const businessRegistrationNumber = apiInfo.businessRegistrationNumber
99
+ const { aid = '', bearer = '' } = apiInfo?.attributes
100
+
101
+ // API 호출하여 세금계산서 데이터 가져옴
102
+ const { approvalNoList, taxList } = await getTaxInvoiceByUniposApi(businessRegistrationNumber, aid, bearer)
103
+
104
+ // 이미 있는 데이터 아이디 검색
105
+ const existingTaxInvoice = await taxInvoiceRepo.find({
106
+ select: ['approvalNo'],
107
+ where: { approvalNo: In(approvalNoList) }
108
+ })
109
+ const existingIds = existingTaxInvoice.map(taxInvoice => taxInvoice.approvalNo)
110
+
111
+ // 매입, 매출 for문
112
+ for (let tax of taxList) {
113
+ // 있는지 없는지 확인
114
+ if (existingIds.includes(tax.tid_issueid)) continue
115
+
116
+ // 세금계산서 데이터 객체 생성
117
+ const newTaxInvoice: NewTaxInvoice = {
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
+ }
198
+
199
+ // Insert
200
+ this.createTaxInvoice(newTaxInvoice, newTaxInvoiceItem, context)
201
+
202
+ // API 결과 회신 데이터 생성
203
+ insertedData.push({
204
+ aid: aid,
205
+ tax_type: tax.category == Category.EXPORT ? UnipostTaxType.EXPORT : UnipostTaxType.IMPORT,
206
+ tid_issueid: tax.tid_issueid,
207
+ success: true,
208
+ message: ''
209
+ })
210
+ }
211
+
212
+ // 유니 포스트에 조회 후 결과 회신 API 호출
213
+ callTaxInvoiceConfirm(businessRegistrationNumber, aid, bearer, insertedData)
214
+
215
+ return true
216
+ }
217
+
218
+ // YYYYMMDD => YYYY-MM-DD
219
+ private _dateFormat = date => date.replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3')
119
220
  }
@@ -2,7 +2,7 @@ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graph
2
2
  import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { TaxInvoice } from './tax-invoice'
5
- import { TaxInvoiceList } from './tax-invoice-type'
5
+ import { TaxInvoiceList, TaxInvoiceSummary } from './tax-invoice-type'
6
6
  import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
7
7
 
8
8
  @Resolver(TaxInvoice)
@@ -24,14 +24,32 @@ export class TaxInvoiceQuery {
24
24
  domain,
25
25
  params,
26
26
  repository: await getRepository(TaxInvoice),
27
- searchables: ['name']
27
+ searchables: ['memo']
28
28
  })
29
-
30
29
  const [items, total] = await queryBuilder.getManyAndCount()
31
30
 
32
31
  return { items, total }
33
32
  }
34
33
 
34
+ @Query(returns => TaxInvoiceSummary, { description: 'To fetch TaxInvoices Summary' })
35
+ async taxInvoicesSummary(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<TaxInvoiceSummary> {
36
+ const { domain } = context.state
37
+
38
+ const queryBuilder = getQueryBuilderFromListParams({
39
+ domain,
40
+ params: { ...params, pagination: {} },
41
+ repository: await getRepository(TaxInvoice)
42
+ })
43
+ const summary = await queryBuilder
44
+ .select('SUM(supply_amount)', 'supply_amount')
45
+ .addSelect('SUM(tax_amount)', 'tax_amount')
46
+ .addSelect('SUM(total_amount)', 'total_amount')
47
+ .addSelect('COUNT(id)', 'cnt')
48
+ .getRawOne()
49
+
50
+ return { summary }
51
+ }
52
+
35
53
  @FieldResolver(type => [TaxInvoiceItem])
36
54
  async taxInvoiceItems(@Root() taxInvoice: TaxInvoice): Promise<TaxInvoiceItem[]> {
37
55
  return taxInvoice.id && (await getRepository(TaxInvoiceItem).findBy({ taxInvoice: { id: taxInvoice.id } }))
@@ -1,14 +1,11 @@
1
- import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
2
- import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
3
1
  import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
4
-
5
2
  import { BusinessRegistrationCategory, Category, InvoiceType, Purpose, RevisedReason, TaxInvoice } from './tax-invoice'
6
- import { TaxInvoiceItem } from '../tax-invoice-item/tax-invoice-item'
3
+ import { ScalarObject } from '@things-factory/shell'
7
4
 
8
5
  @InputType()
9
6
  export class NewTaxInvoice {
10
7
  @Field({ nullable: true })
11
- name?: string
8
+ memo?: string
12
9
 
13
10
  @Field({ nullable: true })
14
11
  apiRefId?: string
@@ -16,6 +13,9 @@ export class NewTaxInvoice {
16
13
  @Field({ nullable: false })
17
14
  category: Category
18
15
 
16
+ @Field({ nullable: true })
17
+ issueNo?: string
18
+
19
19
  @Field({ nullable: true })
20
20
  approvalNo?: string
21
21
 
@@ -23,10 +23,10 @@ export class NewTaxInvoice {
23
23
  originalApprovalNo?: string
24
24
 
25
25
  @Field({ nullable: false })
26
- issueDate: string
26
+ issueDate: Date
27
27
 
28
28
  @Field({ nullable: true })
29
- signatureDate: string
29
+ signatureDate: Date
30
30
 
31
31
  @Field({ nullable: false })
32
32
  invoiceType: InvoiceType
@@ -46,7 +46,7 @@ export class NewTaxInvoice {
46
46
  @Field({ nullable: true })
47
47
  remark2?: string
48
48
 
49
- @Field({ nullable: false })
49
+ @Field({ nullable: true })
50
50
  supplierBusinessRegistrationCategory: BusinessRegistrationCategory
51
51
 
52
52
  @Field({ nullable: false })
@@ -85,7 +85,7 @@ export class NewTaxInvoice {
85
85
  @Field({ nullable: true })
86
86
  supplierContactCellPhone?: string
87
87
 
88
- @Field({ nullable: false })
88
+ @Field({ nullable: true })
89
89
  buyerBusinessRegistrationCategory: BusinessRegistrationCategory
90
90
 
91
91
  @Field({ nullable: false })
@@ -206,196 +206,7 @@ export class TaxInvoicePatch {
206
206
  id?: string
207
207
 
208
208
  @Field({ nullable: true })
209
- name?: string
210
-
211
- @Field({ nullable: true })
212
- apiRefId?: string
213
-
214
- @Field({ nullable: false })
215
- category: Category
216
-
217
- @Field({ nullable: true })
218
- approvalNo?: string
219
-
220
- @Field({ nullable: true })
221
- originalApprovalNo?: string
222
-
223
- @Field({ nullable: false })
224
- issueDate: string
225
-
226
- @Field({ nullable: true })
227
- signatureDate: string
228
-
229
- @Field({ nullable: false })
230
- invoiceType: InvoiceType
231
-
232
- @Field({ nullable: false })
233
- purpose: Purpose
234
-
235
- @Field({ nullable: true })
236
- revisedReason?: RevisedReason
237
-
238
- @Field({ nullable: true })
239
- remark0?: string
240
-
241
- @Field({ nullable: true })
242
- remark1?: string
243
-
244
- @Field({ nullable: true })
245
- remark2?: string
246
-
247
- @Field({ nullable: false })
248
- supplierBusinessRegistrationCategory: BusinessRegistrationCategory
249
-
250
- @Field({ nullable: false })
251
- supplierBusinessRegistrationNumber: string
252
-
253
- @Field({ nullable: true })
254
- supplierBranchIdentification?: string
255
-
256
- @Field({ nullable: false })
257
- supplierBusinessName: string
258
-
259
- @Field({ nullable: false })
260
- supplierRepresentativeName: string
261
-
262
- @Field({ nullable: true })
263
- supplierAddress?: string
264
-
265
- @Field({ nullable: true })
266
- supplierBusinessType?: string
267
-
268
- @Field({ nullable: true })
269
- supplierIndustryType?: string
270
-
271
- @Field({ nullable: true })
272
- supplierDepartment?: string
273
-
274
- @Field({ nullable: true })
275
- supplierContactName?: string
276
-
277
- @Field({ nullable: true })
278
- supplierContactPhone?: string
279
-
280
- @Field({ nullable: true })
281
- supplierContactEmail?: string
282
-
283
- @Field({ nullable: true })
284
- supplierContactCellPhone?: string
285
-
286
- @Field({ nullable: false })
287
- buyerBusinessRegistrationCategory: BusinessRegistrationCategory
288
-
289
- @Field({ nullable: false })
290
- buyerBusinessRegistrationNumber: string
291
-
292
- @Field({ nullable: true })
293
- buyerBranchIdentification?: string
294
-
295
- @Field({ nullable: false })
296
- buyerBusinessName: string
297
-
298
- @Field({ nullable: false })
299
- buyerRepresentativeName: string
300
-
301
- @Field({ nullable: true })
302
- buyerAddress?: string
303
-
304
- @Field({ nullable: true })
305
- buyerBusinessType?: string
306
-
307
- @Field({ nullable: true })
308
- buyerIndustryType?: string
309
-
310
- @Field({ nullable: true })
311
- buyer1stDepartment?: string
312
-
313
- @Field({ nullable: true })
314
- buyer1stContactName?: string
315
-
316
- @Field({ nullable: true })
317
- buyer1stContactPhone?: string
318
-
319
- @Field({ nullable: true })
320
- buyer1stContactEmail?: string
321
-
322
- @Field({ nullable: true })
323
- buyer1stContactCellPhone?: string
324
-
325
- @Field({ nullable: true })
326
- buyer2ndDepartment?: string
327
-
328
- @Field({ nullable: true })
329
- buyer2ndContactName?: string
330
-
331
- @Field({ nullable: true })
332
- buyer2ndContactPhone?: string
333
-
334
- @Field({ nullable: true })
335
- buyer2ndContactEmail?: string
336
-
337
- @Field({ nullable: true })
338
- buyer2ndContactCellPhone?: string
339
-
340
- @Field({ nullable: true })
341
- agentBusinessRegistrationCategory: BusinessRegistrationCategory
342
-
343
- @Field({ nullable: true })
344
- agentBusinessRegistrationNumber?: string
345
-
346
- @Field({ nullable: true })
347
- agentBranchIdentification?: string
348
-
349
- @Field({ nullable: true })
350
- agentBusinessName?: string
351
-
352
- @Field({ nullable: true })
353
- agentRepresentativeName?: string
354
-
355
- @Field({ nullable: true })
356
- agentAddress?: string
357
-
358
- @Field({ nullable: true })
359
- agentBusinessType?: string
360
-
361
- @Field({ nullable: true })
362
- agentIndustryType?: string
363
-
364
- @Field({ nullable: true })
365
- agentDepartment?: string
366
-
367
- @Field({ nullable: true })
368
- agentContactName?: string
369
-
370
- @Field({ nullable: true })
371
- agentContactPhone?: string
372
-
373
- @Field({ nullable: true })
374
- agentContactEmail?: string
375
-
376
- @Field({ nullable: true })
377
- agentContactCellPhone?: string
378
-
379
- @Field(type => Int, { nullable: true })
380
- paymentAmountCash?: number
381
-
382
- @Field(type => Int, { nullable: true })
383
- paymentAmountCheck?: number
384
-
385
- @Field(type => Int, { nullable: true })
386
- paymentAmountPromissoryNote?: number
387
-
388
- @Field(type => Int, { nullable: true })
389
- paymentAmountAccountsReceivable?: number
390
-
391
- @Field(type => Int, { nullable: false })
392
- supplyAmount: number
393
-
394
- @Field(type => Int, { nullable: true })
395
- taxAmount: number
396
-
397
- @Field(type => Int, { nullable: false })
398
- totalAmount: number
209
+ memo?: string
399
210
 
400
211
  @Field({ nullable: true })
401
212
  cuFlag?: string
@@ -409,3 +220,14 @@ export class TaxInvoiceList {
409
220
  @Field(type => Int)
410
221
  total: number
411
222
  }
223
+
224
+ @ObjectType()
225
+ export class TaxInvoiceSummary {
226
+ @Field(type => ScalarObject)
227
+ summary: {
228
+ supply_amount: number
229
+ tax_amount: number
230
+ total_amount: number
231
+ cnt: number
232
+ }
233
+ }
@@ -1,16 +1,4 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- DeleteDateColumn,
5
- Entity,
6
- Index,
7
- Column,
8
- RelationId,
9
- ManyToOne,
10
- OneToMany,
11
- PrimaryGeneratedColumn,
12
- VersionColumn
13
- } from 'typeorm'
1
+ import { CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Entity, Index, Column, RelationId, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
14
2
  import { ObjectType, Field, ID, registerEnumType } from 'type-graphql'
15
3
  import { encryptTransformer } from '@things-factory/shell'
16
4
 
@@ -25,21 +13,21 @@ export enum Category {
25
13
  }
26
14
  // 세금계산서 종류
27
15
  export enum InvoiceType {
28
- GENERAL_TAX_INVOICE = '0101', // 일반 세금계산서
29
- ZERO_RATED_TAX_INVOICE = '0102', // 영세율 세금계산서
30
- CONSIGNMENT_TAX_INVOICE = '0103', // 위수탁 세금계산서
31
- IMPORT__RATED_CONSIGNMENT_TAX_INVOICE = '0105', // 영세율 위수탁 세금계산서
32
- REVISED_GENERAL_TAX_INVOICE = '0201', // 수정 일반 세금계산서
33
- REVISED_ZERORATED_TAX_INVOICE = '0202', // 수정 영세율 세금계산서
34
- REVISED_CONSIGNMENT_TAX_INVOICE = '0203', // 수정 위수탁 세금계산서
35
- REVISED_IMPORT_TAX_INVOICE = '0204', // 수정 수입 세금계산서
36
- REVISED_ZERORATED_CONSIGNMENT_TAX_INVOICE = '0205', // 수정 영세율 위수탁 세금계산서
37
- GENERAL_INVOICE = '0301', // 일반 계산서
38
- CONSIGNMENT_INVOICE = '0303', // 위수탁 계산서
39
- IMPORT_INVOICE = '0304', // 수입 계산서
40
- REVISED_GENERAL_INVOICE = '0401', // 수정 일반 계산서
41
- REVISED_CONSIGNMENT_INVOICE = '0403', // 수정 위수탁 계산서
42
- REVISED_IMPORT_INVOICE = '0404' // 수정 수입 계산서
16
+ GENERAL_TAX_INVOICE = '0101', // 일반 전자세금계산서
17
+ ZERO_RATED_TAX_INVOICE = '0102', // 영세율 전자세금계산서
18
+ CONSIGNMENT_TAX_INVOICE = '0103', // 위수탁 전자세금계산서
19
+ IMPORT__RATED_CONSIGNMENT_TAX_INVOICE = '0105', // 영세율 위수탁 전자세금계산서
20
+ REVISED_GENERAL_TAX_INVOICE = '0201', // 수정 일반 전자세금계산서
21
+ REVISED_ZERORATED_TAX_INVOICE = '0202', // 수정 영세율 전자세금계산서
22
+ REVISED_CONSIGNMENT_TAX_INVOICE = '0203', // 수정 위수탁 전자세금계산서
23
+ REVISED_IMPORT_TAX_INVOICE = '0204', // 수정 수입 전자세금계산서
24
+ REVISED_ZERORATED_CONSIGNMENT_TAX_INVOICE = '0205', // 수정 영세율 위수탁 전자세금계산서
25
+ GENERAL_INVOICE = '0301', // 일반 전자계산서
26
+ CONSIGNMENT_INVOICE = '0303', // 위수탁 전자계산서
27
+ IMPORT_INVOICE = '0304', // 수입 전자계산서
28
+ REVISED_GENERAL_INVOICE = '0401', // 수정 일반 전자계산서
29
+ REVISED_CONSIGNMENT_INVOICE = '0403', // 수정 위수탁 전자계산서
30
+ REVISED_IMPORT_INVOICE = '0404' // 수정 수입 전자계산서
43
31
  }
44
32
  // 세금계산서 영수/청구 구분 지시자
45
33
  export enum Purpose {
@@ -88,6 +76,7 @@ registerEnumType(BusinessRegistrationCategory, {
88
76
  unique: true
89
77
  })
90
78
  @Index('ix_tax_invoice_1', (taxInvoice: TaxInvoice) => [taxInvoice.domain, taxInvoice.issueDate])
79
+ @Index('ix_approval_no', (taxInvoice: TaxInvoice) => [taxInvoice.domain, taxInvoice.approvalNo], { unique: true })
91
80
  @ObjectType({ description: 'Entity for TaxInvoice' })
92
81
  export class TaxInvoice {
93
82
  @PrimaryGeneratedColumn('uuid')
@@ -105,29 +94,33 @@ export class TaxInvoice {
105
94
  @Field(type => [TaxInvoiceItem], { nullable: true })
106
95
  taxInvoiceItems?: TaxInvoiceItem[]
107
96
 
108
- @Column({ nullable: true, comment: '이름' })
109
- @Field({ nullable: true, description: '이름' })
110
- name?: string
97
+ @Column({ nullable: true, comment: '메모' })
98
+ @Field({ nullable: true, description: '메모' })
99
+ memo?: string
111
100
 
112
101
  @Column({ nullable: false, comment: '세금계산서 구분 (매출: 10, 매입: 20, NTS: 30)' })
113
102
  @Field({ nullable: false, description: '세금계산서 구분 (매출: 10, 매입: 20, NTS: 30)' })
114
103
  category!: Category
115
104
 
116
- @Column({ nullable: true, comment: '승인 번호' })
117
- @Field({ nullable: true, description: '승인 번호' })
105
+ @Column({ nullable: true, comment: '연동 번호 (작성 시 번호, 승인번호와 동일)' })
106
+ @Field({ nullable: true, description: '연동 번호 (작성 시 번호, 승인번호와 동일)' })
107
+ issueNo?: string
108
+
109
+ @Column({ nullable: true, comment: '승인 번호 (24자리)' })
110
+ @Field({ nullable: true, description: '승인 번호 (24자리)' })
118
111
  approvalNo?: string
119
112
 
120
113
  @Column({ nullable: true, comment: '원 승인 번호 (계산서 수정시 원래의 승인 번호)' })
121
114
  @Field({ nullable: true, description: '원 승인 번호 (계산서 수정시 원래의 승인 번호)' })
122
115
  originalApprovalNo?: string
123
116
 
124
- @Column({ nullable: false, comment: '세금계산서 작성 일자 (YYYYMMDD)' })
125
- @Field({ nullable: false, description: '세금계산서 작성 일자 (YYYYMMDD)' })
126
- issueDate!: string
117
+ @Column({ nullable: false, comment: '세금계산서 작성 일자 (YYYY-MM-DD)' })
118
+ @Field({ nullable: false, description: '세금계산서 작성 일자 (YYYY-MM-DD)' })
119
+ issueDate!: Date
127
120
 
128
- @Column({ nullable: true, comment: '세금계산서 전자 서명 일자 (YYYYMMDD)' })
129
- @Field({ nullable: true, description: '세금계산서 전자 서명 일자 (YYYYMMDD)' })
130
- signatureDate?: string
121
+ @Column({ nullable: true, comment: '세금계산서 전자 서명 일자 (YYYY-MM-DD)' })
122
+ @Field({ nullable: true, description: '세금계산서 전자 서명 일자 (YYYY-MM-DD)' })
123
+ signatureDate?: Date
131
124
 
132
125
  @Column({ nullable: false, comment: '세금계산서 종류 코드 (일반, 영세율, 위수탁)' })
133
126
  @Field({ nullable: false, description: '세금계산서 종류 코드 (일반, 영세율, 위수탁)' })
@@ -153,9 +146,9 @@ export class TaxInvoice {
153
146
  @Field({ nullable: true, description: '비고2' })
154
147
  remark2?: string
155
148
 
156
- @Column({ nullable: false, comment: '공급자 사업자등록번호 구분 코드' })
157
- @Field({ nullable: false, description: '공급자 사업자등록번호 구분 코드' })
158
- supplierBusinessRegistrationCategory!: BusinessRegistrationCategory
149
+ @Column({ nullable: true, comment: '공급자 사업자등록번호 구분 코드' })
150
+ @Field({ nullable: true, description: '공급자 사업자등록번호 구분 코드' })
151
+ supplierBusinessRegistrationCategory?: BusinessRegistrationCategory
159
152
 
160
153
  @Column({ nullable: false, comment: '공급자 사업자등록번호', transformer: encryptTransformer })
161
154
  @Field({ nullable: false, description: '공급자 사업자등록번호' })
@@ -205,9 +198,9 @@ export class TaxInvoice {
205
198
  @Field({ nullable: true, description: '공급자 담당자 핸드폰 번호' })
206
199
  supplierContactCellPhone?: string
207
200
 
208
- @Column({ nullable: false, comment: '공급받는자 사업자등록번호 구분 코드' })
209
- @Field({ nullable: false, description: '공급받는자 사업자등록번호 구분 코드' })
210
- buyerBusinessRegistrationCategory!: BusinessRegistrationCategory
201
+ @Column({ nullable: true, comment: '공급받는자 사업자등록번호 구분 코드' })
202
+ @Field({ nullable: true, description: '공급받는자 사업자등록번호 구분 코드' })
203
+ buyerBusinessRegistrationCategory?: BusinessRegistrationCategory
211
204
 
212
205
  @Column({ nullable: false, comment: '공급받는자 사업자등록번호', transformer: encryptTransformer })
213
206
  @Field({ nullable: false, description: '공급받는자 사업자등록번호' })