@things-factory/tax-invoice 6.2.84

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 (151) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/bootstrap.ts +0 -0
  4. package/client/index.ts +0 -0
  5. package/client/pages/main.ts +25 -0
  6. package/client/pages/tax-audit-result/tax-audit-result-importer.ts +97 -0
  7. package/client/pages/tax-audit-result/tax-audit-result-list-page.ts +355 -0
  8. package/client/pages/tax-invoice/tax-invoice-detail-popup.ts +424 -0
  9. package/client/pages/tax-invoice/tax-invoice-list-page.ts +517 -0
  10. package/client/pages/tax-invoice-api/tax-invoice-api-page.ts +428 -0
  11. package/client/pages/tax-invoice-company/tax-invoice-company-importer.ts +175 -0
  12. package/client/pages/tax-invoice-company/tax-invoice-company-list-page.ts +496 -0
  13. package/client/route.ts +23 -0
  14. package/client/tsconfig.json +11 -0
  15. package/dist-client/bootstrap.d.ts +0 -0
  16. package/dist-client/bootstrap.js +2 -0
  17. package/dist-client/bootstrap.js.map +1 -0
  18. package/dist-client/index.d.ts +0 -0
  19. package/dist-client/index.js +2 -0
  20. package/dist-client/index.js.map +1 -0
  21. package/dist-client/pages/main.d.ts +1 -0
  22. package/dist-client/pages/main.js +27 -0
  23. package/dist-client/pages/main.js.map +1 -0
  24. package/dist-client/pages/tax-audit-result/tax-audit-result-importer.d.ts +22 -0
  25. package/dist-client/pages/tax-audit-result/tax-audit-result-importer.js +100 -0
  26. package/dist-client/pages/tax-audit-result/tax-audit-result-importer.js.map +1 -0
  27. package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.d.ts +62 -0
  28. package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.js +331 -0
  29. package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.js.map +1 -0
  30. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.d.ts +14 -0
  31. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js +430 -0
  32. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js.map +1 -0
  33. package/dist-client/pages/tax-invoice/tax-invoice-list-page.d.ts +70 -0
  34. package/dist-client/pages/tax-invoice/tax-invoice-list-page.js +500 -0
  35. package/dist-client/pages/tax-invoice/tax-invoice-list-page.js.map +1 -0
  36. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.d.ts +36 -0
  37. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js +419 -0
  38. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js.map +1 -0
  39. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.d.ts +31 -0
  40. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js +182 -0
  41. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js.map +1 -0
  42. package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.d.ts +57 -0
  43. package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.js +477 -0
  44. package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.js.map +1 -0
  45. package/dist-client/route.d.ts +1 -0
  46. package/dist-client/route.js +20 -0
  47. package/dist-client/route.js.map +1 -0
  48. package/dist-client/tsconfig.tsbuildinfo +1 -0
  49. package/dist-server/index.js +6 -0
  50. package/dist-server/index.js.map +1 -0
  51. package/dist-server/routes.js +25 -0
  52. package/dist-server/routes.js.map +1 -0
  53. package/dist-server/service/index.js +37 -0
  54. package/dist-server/service/index.js.map +1 -0
  55. package/dist-server/service/tax-audit-result/event-subscriber.js +21 -0
  56. package/dist-server/service/tax-audit-result/event-subscriber.js.map +1 -0
  57. package/dist-server/service/tax-audit-result/index.js +12 -0
  58. package/dist-server/service/tax-audit-result/index.js.map +1 -0
  59. package/dist-server/service/tax-audit-result/tax-audit-result-history.js +123 -0
  60. package/dist-server/service/tax-audit-result/tax-audit-result-history.js.map +1 -0
  61. package/dist-server/service/tax-audit-result/tax-audit-result-mutation.js +168 -0
  62. package/dist-server/service/tax-audit-result/tax-audit-result-mutation.js.map +1 -0
  63. package/dist-server/service/tax-audit-result/tax-audit-result-query.js +97 -0
  64. package/dist-server/service/tax-audit-result/tax-audit-result-query.js.map +1 -0
  65. package/dist-server/service/tax-audit-result/tax-audit-result-type.js +86 -0
  66. package/dist-server/service/tax-audit-result/tax-audit-result-type.js.map +1 -0
  67. package/dist-server/service/tax-audit-result/tax-audit-result.js +110 -0
  68. package/dist-server/service/tax-audit-result/tax-audit-result.js.map +1 -0
  69. package/dist-server/service/tax-invoice/index.js +9 -0
  70. package/dist-server/service/tax-invoice/index.js.map +1 -0
  71. package/dist-server/service/tax-invoice/tax-invoice-mutation.js +127 -0
  72. package/dist-server/service/tax-invoice/tax-invoice-mutation.js.map +1 -0
  73. package/dist-server/service/tax-invoice/tax-invoice-query.js +90 -0
  74. package/dist-server/service/tax-invoice/tax-invoice-query.js.map +1 -0
  75. package/dist-server/service/tax-invoice/tax-invoice-type.js +553 -0
  76. package/dist-server/service/tax-invoice/tax-invoice-type.js.map +1 -0
  77. package/dist-server/service/tax-invoice/tax-invoice.js +465 -0
  78. package/dist-server/service/tax-invoice/tax-invoice.js.map +1 -0
  79. package/dist-server/service/tax-invoice-api/index.js +9 -0
  80. package/dist-server/service/tax-invoice-api/index.js.map +1 -0
  81. package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js +64 -0
  82. package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js.map +1 -0
  83. package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js +79 -0
  84. package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js.map +1 -0
  85. package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js +103 -0
  86. package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js.map +1 -0
  87. package/dist-server/service/tax-invoice-api/tax-invoice-api.js +163 -0
  88. package/dist-server/service/tax-invoice-api/tax-invoice-api.js.map +1 -0
  89. package/dist-server/service/tax-invoice-company/index.js +9 -0
  90. package/dist-server/service/tax-invoice-company/index.js.map +1 -0
  91. package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.js +80 -0
  92. package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.js.map +1 -0
  93. package/dist-server/service/tax-invoice-company/tax-invoice-company-query.js +89 -0
  94. package/dist-server/service/tax-invoice-company/tax-invoice-company-query.js.map +1 -0
  95. package/dist-server/service/tax-invoice-company/tax-invoice-company-type.js +100 -0
  96. package/dist-server/service/tax-invoice-company/tax-invoice-company-type.js.map +1 -0
  97. package/dist-server/service/tax-invoice-company/tax-invoice-company.js +166 -0
  98. package/dist-server/service/tax-invoice-company/tax-invoice-company.js.map +1 -0
  99. package/dist-server/service/tax-invoice-item/index.js +9 -0
  100. package/dist-server/service/tax-invoice-item/index.js.map +1 -0
  101. package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.js +127 -0
  102. package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.js.map +1 -0
  103. package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js +87 -0
  104. package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js.map +1 -0
  105. package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js +121 -0
  106. package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js.map +1 -0
  107. package/dist-server/service/tax-invoice-item/tax-invoice-item.js +115 -0
  108. package/dist-server/service/tax-invoice-item/tax-invoice-item.js.map +1 -0
  109. package/dist-server/tsconfig.tsbuildinfo +1 -0
  110. package/helps/tax-invoice/tax-audit-result.md +160 -0
  111. package/helps/tax-invoice/tax-invoice-api.md +160 -0
  112. package/helps/tax-invoice/tax-invoice-send.md +160 -0
  113. package/helps/tax-invoice/tax-invoice.md +160 -0
  114. package/package.json +37 -0
  115. package/server/index.ts +2 -0
  116. package/server/routes.ts +28 -0
  117. package/server/service/index.ts +36 -0
  118. package/server/service/tax-audit-result/event-subscriber.ts +17 -0
  119. package/server/service/tax-audit-result/index.ts +9 -0
  120. package/server/service/tax-audit-result/tax-audit-result-history.ts +110 -0
  121. package/server/service/tax-audit-result/tax-audit-result-mutation.ts +198 -0
  122. package/server/service/tax-audit-result/tax-audit-result-query.ts +62 -0
  123. package/server/service/tax-audit-result/tax-audit-result-type.ts +61 -0
  124. package/server/service/tax-audit-result/tax-audit-result.ts +95 -0
  125. package/server/service/tax-invoice/index.ts +6 -0
  126. package/server/service/tax-invoice/tax-invoice-mutation.ts +122 -0
  127. package/server/service/tax-invoice/tax-invoice-query.ts +54 -0
  128. package/server/service/tax-invoice/tax-invoice-type.ts +411 -0
  129. package/server/service/tax-invoice/tax-invoice.ts +389 -0
  130. package/server/service/tax-invoice-api/index.ts +6 -0
  131. package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +67 -0
  132. package/server/service/tax-invoice-api/tax-invoice-api-query.ts +48 -0
  133. package/server/service/tax-invoice-api/tax-invoice-api-type.ts +71 -0
  134. package/server/service/tax-invoice-api/tax-invoice-api.ts +137 -0
  135. package/server/service/tax-invoice-company/index.ts +6 -0
  136. package/server/service/tax-invoice-company/tax-invoice-company-mutation.ts +84 -0
  137. package/server/service/tax-invoice-company/tax-invoice-company-query.ts +53 -0
  138. package/server/service/tax-invoice-company/tax-invoice-company-type.ts +69 -0
  139. package/server/service/tax-invoice-company/tax-invoice-company.ts +142 -0
  140. package/server/service/tax-invoice-item/index.ts +6 -0
  141. package/server/service/tax-invoice-item/tax-invoice-item-mutation.ts +128 -0
  142. package/server/service/tax-invoice-item/tax-invoice-item-query.ts +57 -0
  143. package/server/service/tax-invoice-item/tax-invoice-item-type.ts +86 -0
  144. package/server/service/tax-invoice-item/tax-invoice-item.ts +85 -0
  145. package/server/tsconfig.json +10 -0
  146. package/things-factory.config.js +23 -0
  147. package/translations/en.json +1 -0
  148. package/translations/ja.json +1 -0
  149. package/translations/ko.json +71 -0
  150. package/translations/ms.json +1 -0
  151. package/translations/zh.json +1 -0
@@ -0,0 +1,137 @@
1
+ import {
2
+ CreateDateColumn,
3
+ UpdateDateColumn,
4
+ DeleteDateColumn,
5
+ Entity,
6
+ Index,
7
+ OneToOne,
8
+ Column,
9
+ RelationId,
10
+ ManyToOne,
11
+ PrimaryGeneratedColumn,
12
+ VersionColumn,
13
+ JoinColumn
14
+ } from 'typeorm'
15
+ import { ObjectType, Field, ID } from 'type-graphql'
16
+
17
+ import { Domain, ScalarObject, encryptTransformer } from '@things-factory/shell'
18
+ import { User } from '@things-factory/auth-base'
19
+
20
+ @Entity()
21
+ @Index('ix_tax_invoice_api_0', (taxInvoiceApi: TaxInvoiceApi) => [taxInvoiceApi.domain, taxInvoiceApi.name, taxInvoiceApi.deletedAt])
22
+ @Index('ix_tax_invoice_api_1', (taxInvoiceApi: TaxInvoiceApi) => [taxInvoiceApi.domain, taxInvoiceApi.description, taxInvoiceApi.deletedAt])
23
+ @ObjectType({ description: 'Entity for Tax Invoice Api' })
24
+ export class TaxInvoiceApi {
25
+ @PrimaryGeneratedColumn('uuid')
26
+ @Field(type => ID)
27
+ readonly id!: string
28
+
29
+ @VersionColumn()
30
+ @Field({ nullable: true })
31
+ version?: number = 1
32
+
33
+ @ManyToOne(type => Domain)
34
+ @Field({ nullable: true })
35
+ domain?: Domain
36
+
37
+ @RelationId((taxInvoiceApi: TaxInvoiceApi) => taxInvoiceApi.domain)
38
+ domainId?: string
39
+
40
+ @Field({ nullable: false })
41
+ @Column({ nullable: false })
42
+ name!: string
43
+
44
+ @Field({ nullable: true })
45
+ @Column({ nullable: true })
46
+ description?: string
47
+
48
+ @Column({ nullable: true, comment: 'API Key', transformer: encryptTransformer })
49
+ @Field({ nullable: true, description: 'API Key' })
50
+ apiKey?: string
51
+
52
+ @Column({ nullable: true, comment: 'API 계정 ID', transformer: encryptTransformer })
53
+ @Field({ nullable: true, description: 'API 계정 ID' })
54
+ apiAccountId?: string
55
+
56
+ @Column({ nullable: true, comment: 'API 계정 비밀번호', transformer: encryptTransformer })
57
+ @Field({ nullable: true, description: 'API 계정 비밀번호' })
58
+ apiAccountPassword?: string
59
+
60
+ @Column({ nullable: true, comment: '사업자등록번호', transformer: encryptTransformer })
61
+ @Field({ nullable: true, description: '사업자등록번호' })
62
+ businessRegistrationNumber?: string
63
+
64
+ @Column({ nullable: true, comment: '종사업장 식별 코드' })
65
+ @Field({ nullable: true, description: '종사업장 식별 코드' })
66
+ branchIdentification?: string
67
+
68
+ @Column({ nullable: true, comment: '사업자명' })
69
+ @Field({ nullable: true, description: '사업자명' })
70
+ businessName?: string
71
+
72
+ @Column({ nullable: true, comment: '대표자명' })
73
+ @Field({ nullable: true, description: '대표자명' })
74
+ representativeName?: string
75
+
76
+ @Column({ nullable: true, comment: '주소', transformer: encryptTransformer })
77
+ @Field({ nullable: true, description: '주소' })
78
+ address?: string
79
+
80
+ @Column({ nullable: true, comment: '업태' })
81
+ @Field({ nullable: true, description: '업태' })
82
+ businessType?: string
83
+
84
+ @Column({ nullable: true, comment: '업종' })
85
+ @Field({ nullable: true, description: '업종' })
86
+ industryType?: string
87
+
88
+ @Column({ nullable: true, comment: '담당 부서' })
89
+ @Field({ nullable: true, description: '담당 부서' })
90
+ department?: string
91
+
92
+ @Column({ nullable: true, comment: '담당자명', transformer: encryptTransformer })
93
+ @Field({ nullable: true, description: '담당자명' })
94
+ contactName?: string
95
+
96
+ @Column({ nullable: true, comment: '담당자 전화번호', transformer: encryptTransformer })
97
+ @Field({ nullable: true, description: '담당자 전화번호' })
98
+ contactPhone?: string
99
+
100
+ @Column({ nullable: true, comment: '담당자 이메일', transformer: encryptTransformer })
101
+ @Field({ nullable: true, description: '담당자 이메일' })
102
+ contactEmail?: string
103
+
104
+ @Column({ nullable: true, comment: '담당자 핸드폰 번호', transformer: encryptTransformer })
105
+ @Field({ nullable: true, description: '담당자 핸드폰 번호' })
106
+ contactCellPhone?: string
107
+
108
+ @Column('simple-json', { nullable: true })
109
+ @Field(type => ScalarObject, { nullable: true })
110
+ attributes?: any
111
+
112
+ @CreateDateColumn()
113
+ @Field({ nullable: true })
114
+ createdAt?: Date
115
+
116
+ @UpdateDateColumn()
117
+ @Field({ nullable: true })
118
+ updatedAt?: Date
119
+
120
+ @DeleteDateColumn()
121
+ @Field({ nullable: true })
122
+ deletedAt?: Date
123
+
124
+ @ManyToOne(type => User, { nullable: true })
125
+ @Field(type => User, { nullable: true })
126
+ creator?: User
127
+
128
+ @RelationId((taxInvoiceApi: TaxInvoiceApi) => taxInvoiceApi.creator)
129
+ creatorId?: string
130
+
131
+ @ManyToOne(type => User, { nullable: true })
132
+ @Field(type => User, { nullable: true })
133
+ updater?: User
134
+
135
+ @RelationId((taxInvoiceApi: TaxInvoiceApi) => taxInvoiceApi.updater)
136
+ updaterId?: string
137
+ }
@@ -0,0 +1,6 @@
1
+ import { TaxInvoiceCompany } from './tax-invoice-company'
2
+ import { TaxInvoiceCompanyQuery } from './tax-invoice-company-query'
3
+ import { TaxInvoiceCompanyMutation } from './tax-invoice-company-mutation'
4
+
5
+ export const entities = [TaxInvoiceCompany]
6
+ export const resolvers = [TaxInvoiceCompanyQuery, TaxInvoiceCompanyMutation]
@@ -0,0 +1,84 @@
1
+ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { TaxInvoiceCompany } from './tax-invoice-company'
5
+ import { TaxInvoiceCompanyPatch } from './tax-invoice-company-type'
6
+
7
+ @Resolver(TaxInvoiceCompany)
8
+ export class TaxInvoiceCompanyMutation {
9
+ @Directive('@transaction')
10
+ @Mutation(returns => [TaxInvoiceCompany], { description: "To modify multiple TaxInvoiceCompanies' information" })
11
+ async updateMultipleTaxInvoiceCompany(
12
+ @Arg('patches', type => [TaxInvoiceCompanyPatch]) patches: TaxInvoiceCompanyPatch[],
13
+ @Ctx() context: ResolverContext
14
+ ): Promise<TaxInvoiceCompany[]> {
15
+ const { domain, user, tx } = context.state
16
+
17
+ let results = []
18
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
19
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
20
+ const taxInvoiceCompanyRepo = tx.getRepository(TaxInvoiceCompany)
21
+
22
+ if (_createRecords.length > 0) {
23
+ for (let i = 0; i < _createRecords.length; i++) {
24
+ const newRecord = _createRecords[i]
25
+
26
+ const result = await taxInvoiceCompanyRepo.save({
27
+ ...newRecord,
28
+ domain,
29
+ creator: user,
30
+ updater: user
31
+ })
32
+
33
+ results.push({ ...result, cuFlag: '+' })
34
+ }
35
+ }
36
+
37
+ if (_updateRecords.length > 0) {
38
+ for (let i = 0; i < _updateRecords.length; i++) {
39
+ const updateRecord = _updateRecords[i]
40
+ const taxInvoiceCompany = await taxInvoiceCompanyRepo.findOneBy({ id: updateRecord.id })
41
+
42
+ const result = await taxInvoiceCompanyRepo.save({
43
+ ...taxInvoiceCompany,
44
+ ...updateRecord,
45
+ updater: user
46
+ })
47
+
48
+ results.push({ ...result, cuFlag: 'M' })
49
+ }
50
+ }
51
+
52
+ return results
53
+ }
54
+
55
+ @Directive('@transaction')
56
+ @Mutation(returns => Boolean, { description: 'To delete multiple TaxInvoiceCompanies' })
57
+ async deleteTaxInvoiceCompanies(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
58
+ const { domain, tx } = context.state
59
+
60
+ await tx.getRepository(TaxInvoiceCompany).delete({
61
+ domain: { id: domain.id },
62
+ id: In(ids)
63
+ })
64
+
65
+ return true
66
+ }
67
+
68
+ @Directive('@transaction')
69
+ @Mutation(returns => Boolean, { description: 'To import multiple TaxInvoiceCompanies' })
70
+ async importTaxInvoiceCompanies(
71
+ @Arg('taxInvoiceCompanies', type => [TaxInvoiceCompanyPatch]) taxInvoiceCompanies: TaxInvoiceCompanyPatch[],
72
+ @Ctx() context: ResolverContext
73
+ ): Promise<boolean> {
74
+ const { domain, tx } = context.state
75
+
76
+ await Promise.all(
77
+ taxInvoiceCompanies.map(async (taxInvoiceCompany: TaxInvoiceCompanyPatch) => {
78
+ const createdTaxInvoiceCompany: TaxInvoiceCompany = await tx.getRepository(TaxInvoiceCompany).save({ domain, ...taxInvoiceCompany })
79
+ })
80
+ )
81
+
82
+ return true
83
+ }
84
+ }
@@ -0,0 +1,53 @@
1
+ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
2
+ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
3
+ import { User } from '@things-factory/auth-base'
4
+ import { TaxInvoiceCompany, companyTypeLabel } from './tax-invoice-company'
5
+ import { TaxInvoiceCompanyList } from './tax-invoice-company-type'
6
+
7
+ @Resolver(TaxInvoiceCompany)
8
+ export class TaxInvoiceCompanyQuery {
9
+ @Query(returns => TaxInvoiceCompany!, { nullable: true, description: 'To fetch a Tax Invoice Company' })
10
+ async taxInvoiceCompany(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<TaxInvoiceCompany> {
11
+ const { domain } = context.state
12
+
13
+ return await getRepository(TaxInvoiceCompany).findOne({
14
+ where: { domain: { id: domain.id }, id }
15
+ })
16
+ }
17
+
18
+ @Query(returns => TaxInvoiceCompanyList, { description: 'To fetch multiple Tax Invoice Companies' })
19
+ async taxInvoiceCompanies(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<TaxInvoiceCompanyList> {
20
+ const { domain } = context.state
21
+
22
+ const queryBuilder = getQueryBuilderFromListParams({
23
+ domain,
24
+ params,
25
+ repository: await getRepository(TaxInvoiceCompany),
26
+ searchables: ['name', 'description']
27
+ })
28
+
29
+ const [items, total] = await queryBuilder.getManyAndCount()
30
+
31
+ return { items, total }
32
+ }
33
+
34
+ @FieldResolver(type => String)
35
+ async convertedType(@Root() taxInvoiceCompany: TaxInvoiceCompany): Promise<string> {
36
+ return companyTypeLabel[taxInvoiceCompany.type]
37
+ }
38
+
39
+ @FieldResolver(type => Domain)
40
+ async domain(@Root() taxInvoiceCompany: TaxInvoiceCompany): Promise<Domain> {
41
+ return taxInvoiceCompany.domainId && (await getRepository(Domain).findOneBy({ id: taxInvoiceCompany.domainId }))
42
+ }
43
+
44
+ @FieldResolver(type => User)
45
+ async updater(@Root() taxInvoiceCompany: TaxInvoiceCompany): Promise<User> {
46
+ return taxInvoiceCompany.updaterId && (await getRepository(User).findOneBy({ id: taxInvoiceCompany.updaterId }))
47
+ }
48
+
49
+ @FieldResolver(type => User)
50
+ async creator(@Root() taxInvoiceCompany: TaxInvoiceCompany): Promise<User> {
51
+ return taxInvoiceCompany.creatorId && (await getRepository(User).findOneBy({ id: taxInvoiceCompany.creatorId }))
52
+ }
53
+ }
@@ -0,0 +1,69 @@
1
+ import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
2
+ import { ScalarObject } from '@things-factory/shell'
3
+ import { CompanyType, TaxInvoiceCompany } from './tax-invoice-company'
4
+
5
+ @InputType()
6
+ export class TaxInvoiceCompanyPatch {
7
+ @Field(type => ID, { nullable: true })
8
+ id?: string
9
+
10
+ @Field({ nullable: true })
11
+ name?: string
12
+
13
+ @Field({ nullable: true })
14
+ description?: string
15
+
16
+ @Field({ nullable: true })
17
+ type?: CompanyType
18
+
19
+ @Field({ nullable: true })
20
+ businessRegistrationNumber?: string
21
+
22
+ @Field({ nullable: true })
23
+ branchIdentification?: string
24
+
25
+ @Field({ nullable: true })
26
+ businessName?: string
27
+
28
+ @Field({ nullable: true })
29
+ representativeName?: string
30
+
31
+ @Field({ nullable: true })
32
+ address?: string
33
+
34
+ @Field({ nullable: true })
35
+ businessType?: string
36
+
37
+ @Field({ nullable: true })
38
+ industryType?: string
39
+
40
+ @Field({ nullable: true })
41
+ department?: string
42
+
43
+ @Field({ nullable: true })
44
+ contactName?: string
45
+
46
+ @Field({ nullable: true })
47
+ contactPhone?: string
48
+
49
+ @Field({ nullable: true })
50
+ contactEmail?: string
51
+
52
+ @Field({ nullable: true })
53
+ contactCellPhone?: string
54
+
55
+ @Field(type => ScalarObject, { nullable: true })
56
+ attributes?: any
57
+
58
+ @Field({ nullable: true })
59
+ cuFlag?: string
60
+ }
61
+
62
+ @ObjectType()
63
+ export class TaxInvoiceCompanyList {
64
+ @Field(type => [TaxInvoiceCompany])
65
+ items: TaxInvoiceCompany[]
66
+
67
+ @Field(type => Int)
68
+ total: number
69
+ }
@@ -0,0 +1,142 @@
1
+ import {
2
+ CreateDateColumn,
3
+ UpdateDateColumn,
4
+ DeleteDateColumn,
5
+ Index,
6
+ Entity,
7
+ OneToOne,
8
+ Column,
9
+ RelationId,
10
+ ManyToOne,
11
+ PrimaryGeneratedColumn,
12
+ VersionColumn
13
+ } from 'typeorm'
14
+ import { ObjectType, Field, ID, registerEnumType } from 'type-graphql'
15
+
16
+ import { Domain, ScalarObject, encryptTransformer } from '@things-factory/shell'
17
+ import { User } from '@things-factory/auth-base'
18
+ import { TaxInvoiceApi } from '../tax-invoice-api/tax-invoice-api'
19
+
20
+ export enum CompanyType {
21
+ SUPPLIER = 10, // 공급자
22
+ BUYER = 20 // 거래처
23
+ }
24
+ export const companyTypeLabel = {
25
+ [CompanyType.SUPPLIER]: '공급자',
26
+ [CompanyType.BUYER]: '거래처'
27
+ }
28
+ registerEnumType(CompanyType, {
29
+ name: 'CompanyType',
30
+ description: 'company type'
31
+ })
32
+
33
+ @Entity()
34
+ @Index('ix_tax_invoice_company_0', (taxInvoiceCompany: TaxInvoiceCompany) => [taxInvoiceCompany.domain, taxInvoiceCompany.name, taxInvoiceCompany.deletedAt])
35
+ @Index('ix_tax_invoice_company_1', (taxInvoiceCompany: TaxInvoiceCompany) => [taxInvoiceCompany.domain, taxInvoiceCompany.description, taxInvoiceCompany.deletedAt])
36
+ @ObjectType({ description: 'Entity for TaxInvoice Company' })
37
+ export class TaxInvoiceCompany {
38
+ @PrimaryGeneratedColumn('uuid')
39
+ @Field(type => ID)
40
+ readonly id!: string
41
+
42
+ @VersionColumn()
43
+ @Field({ nullable: true })
44
+ version?: number = 1
45
+
46
+ @ManyToOne(type => Domain)
47
+ @Field({ nullable: true })
48
+ domain?: Domain
49
+
50
+ @RelationId((taxInvoiceCompany: TaxInvoiceCompany) => taxInvoiceCompany.domain)
51
+ domainId?: string
52
+
53
+ @Field({ nullable: false })
54
+ @Column({ nullable: false })
55
+ name!: string
56
+
57
+ @Field({ nullable: true })
58
+ @Column({ nullable: true })
59
+ description?: string
60
+
61
+ @Field({ nullable: false })
62
+ @Column({ nullable: false })
63
+ type!: CompanyType
64
+
65
+ @Column({ nullable: true, comment: '사업자등록번호', transformer: encryptTransformer })
66
+ @Field({ nullable: true, description: '사업자등록번호' })
67
+ businessRegistrationNumber?: string
68
+
69
+ @Column({ nullable: true, comment: '종사업장 식별 코드' })
70
+ @Field({ nullable: true, description: '종사업장 식별 코드' })
71
+ branchIdentification?: string
72
+
73
+ @Column({ nullable: true, comment: '사업자명' })
74
+ @Field({ nullable: true, description: '사업자명' })
75
+ businessName?: string
76
+
77
+ @Column({ nullable: true, comment: '대표자명' })
78
+ @Field({ nullable: true, description: '대표자명' })
79
+ representativeName?: string
80
+
81
+ @Column({ nullable: true, comment: '주소', transformer: encryptTransformer })
82
+ @Field({ nullable: true, description: '주소' })
83
+ address?: string
84
+
85
+ @Column({ nullable: true, comment: '업태' })
86
+ @Field({ nullable: true, description: '업태' })
87
+ businessType?: string
88
+
89
+ @Column({ nullable: true, comment: '업종' })
90
+ @Field({ nullable: true, description: '업종' })
91
+ industryType?: string
92
+
93
+ @Column({ nullable: true, comment: '담당 부서' })
94
+ @Field({ nullable: true, description: '담당 부서' })
95
+ department?: string
96
+
97
+ @Column({ nullable: true, comment: '담당자명', transformer: encryptTransformer })
98
+ @Field({ nullable: true, description: '담당자명' })
99
+ contactName?: string
100
+
101
+ @Column({ nullable: true, comment: '담당자 전화번호', transformer: encryptTransformer })
102
+ @Field({ nullable: true, description: '담당자 전화번호' })
103
+ contactPhone?: string
104
+
105
+ @Column({ nullable: true, comment: '담당자 이메일', transformer: encryptTransformer })
106
+ @Field({ nullable: true, description: '담당자 이메일' })
107
+ contactEmail?: string
108
+
109
+ @Column({ nullable: true, comment: '담당자 핸드폰 번호', transformer: encryptTransformer })
110
+ @Field({ nullable: true, description: '담당자 핸드폰 번호' })
111
+ contactCellPhone?: string
112
+
113
+ @Column('simple-json', { nullable: true })
114
+ @Field(type => ScalarObject, { nullable: true })
115
+ attributes?: any
116
+
117
+ @CreateDateColumn()
118
+ @Field({ nullable: true })
119
+ createdAt?: Date
120
+
121
+ @UpdateDateColumn()
122
+ @Field({ nullable: true })
123
+ updatedAt?: Date
124
+
125
+ @DeleteDateColumn()
126
+ @Field({ nullable: true })
127
+ deletedAt?: Date
128
+
129
+ @ManyToOne(type => User, { nullable: true })
130
+ @Field(type => User, { nullable: true })
131
+ creator?: User
132
+
133
+ @RelationId((taxInvoiceCompany: TaxInvoiceCompany) => taxInvoiceCompany.creator)
134
+ creatorId?: string
135
+
136
+ @ManyToOne(type => User, { nullable: true })
137
+ @Field(type => User, { nullable: true })
138
+ updater?: User
139
+
140
+ @RelationId((taxInvoiceCompany: TaxInvoiceCompany) => taxInvoiceCompany.updater)
141
+ updaterId?: string
142
+ }
@@ -0,0 +1,6 @@
1
+ import { TaxInvoiceItem } from './tax-invoice-item'
2
+ import { TaxInvoiceItemQuery } from './tax-invoice-item-query'
3
+ import { TaxInvoiceItemMutation } from './tax-invoice-item-mutation'
4
+
5
+ export const entities = [TaxInvoiceItem]
6
+ export const resolvers = [TaxInvoiceItemQuery, TaxInvoiceItemMutation]
@@ -0,0 +1,128 @@
1
+ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { TaxInvoiceItem } from './tax-invoice-item'
5
+ import { NewTaxInvoiceItem, TaxInvoiceItemPatch } from './tax-invoice-item-type'
6
+
7
+ @Resolver(TaxInvoiceItem)
8
+ export class TaxInvoiceItemMutation {
9
+ @Directive('@transaction')
10
+ @Mutation(returns => TaxInvoiceItem, { description: 'To create new TaxInvoiceItem' })
11
+ async createTaxInvoiceItem(@Arg('taxInvoiceItem') taxInvoiceItem: NewTaxInvoiceItem, @Ctx() context: ResolverContext): Promise<TaxInvoiceItem> {
12
+ const { domain, user, tx } = context.state
13
+
14
+ const result = await tx.getRepository(TaxInvoiceItem).save({
15
+ ...taxInvoiceItem,
16
+ domain,
17
+ creator: user,
18
+ updater: user
19
+ })
20
+
21
+ return result
22
+ }
23
+
24
+ @Directive('@transaction')
25
+ @Mutation(returns => TaxInvoiceItem, { description: 'To modify TaxInvoiceItem information' })
26
+ async updateTaxInvoiceItem(@Arg('id') id: string, @Arg('patch') patch: TaxInvoiceItemPatch, @Ctx() context: ResolverContext): Promise<TaxInvoiceItem> {
27
+ const { domain, user, tx } = context.state
28
+
29
+ const repository = tx.getRepository(TaxInvoiceItem)
30
+ const taxInvoiceItem = await repository.findOne({
31
+ where: { domain: { id: domain.id }, id }
32
+ })
33
+
34
+ const result = await repository.save({
35
+ ...taxInvoiceItem,
36
+ ...patch,
37
+ updater: user
38
+ })
39
+
40
+ return result
41
+ }
42
+
43
+ @Directive('@transaction')
44
+ @Mutation(returns => [TaxInvoiceItem], { description: "To modify multiple TaxInvoiceItems' information" })
45
+ async updateMultipleTaxInvoiceItem(
46
+ @Arg('patches', type => [TaxInvoiceItemPatch]) patches: TaxInvoiceItemPatch[],
47
+ @Ctx() context: ResolverContext
48
+ ): Promise<TaxInvoiceItem[]> {
49
+ const { domain, user, tx } = context.state
50
+
51
+ let results = []
52
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
53
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
54
+ const taxInvoiceItemRepo = tx.getRepository(TaxInvoiceItem)
55
+
56
+ if (_createRecords.length > 0) {
57
+ for (let i = 0; i < _createRecords.length; i++) {
58
+ const newRecord = _createRecords[i]
59
+
60
+ const result = await taxInvoiceItemRepo.save({
61
+ ...newRecord,
62
+ domain,
63
+ creator: user,
64
+ updater: user
65
+ })
66
+
67
+ results.push({ ...result, cuFlag: '+' })
68
+ }
69
+ }
70
+
71
+ if (_updateRecords.length > 0) {
72
+ for (let i = 0; i < _updateRecords.length; i++) {
73
+ const updateRecord = _updateRecords[i]
74
+ const taxInvoiceItem = await taxInvoiceItemRepo.findOneBy({ id: updateRecord.id })
75
+
76
+ const result = await taxInvoiceItemRepo.save({
77
+ ...taxInvoiceItem,
78
+ ...updateRecord,
79
+ updater: user
80
+ })
81
+
82
+ results.push({ ...result, cuFlag: 'M' })
83
+ }
84
+ }
85
+
86
+ return results
87
+ }
88
+
89
+ @Directive('@transaction')
90
+ @Mutation(returns => Boolean, { description: 'To delete TaxInvoiceItem' })
91
+ async deleteTaxInvoiceItem(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
92
+ const { domain, tx } = context.state
93
+
94
+ await tx.getRepository(TaxInvoiceItem).delete({ domain: { id: domain.id }, id })
95
+
96
+ return true
97
+ }
98
+
99
+ @Directive('@transaction')
100
+ @Mutation(returns => Boolean, { description: 'To delete multiple TaxInvoiceItems' })
101
+ async deleteTaxInvoiceItems(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
102
+ const { domain, tx } = context.state
103
+
104
+ await tx.getRepository(TaxInvoiceItem).delete({
105
+ domain: { id: domain.id },
106
+ id: In(ids)
107
+ })
108
+
109
+ return true
110
+ }
111
+
112
+ @Directive('@transaction')
113
+ @Mutation(returns => Boolean, { description: 'To import multiple TaxInvoiceItems' })
114
+ async importTaxInvoiceItems(
115
+ @Arg('taxInvoiceItems', type => [TaxInvoiceItemPatch]) taxInvoiceItems: TaxInvoiceItemPatch[],
116
+ @Ctx() context: ResolverContext
117
+ ): Promise<boolean> {
118
+ const { domain, tx } = context.state
119
+
120
+ await Promise.all(
121
+ taxInvoiceItems.map(async (taxInvoiceItem: TaxInvoiceItemPatch) => {
122
+ const createdTaxInvoiceItem: TaxInvoiceItem = await tx.getRepository(TaxInvoiceItem).save({ domain, ...taxInvoiceItem })
123
+ })
124
+ )
125
+
126
+ return true
127
+ }
128
+ }
@@ -0,0 +1,57 @@
1
+ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { Attachment } from '@things-factory/attachment-base'
3
+ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
+ import { User } from '@things-factory/auth-base'
5
+ import { TaxInvoiceItem } from './tax-invoice-item'
6
+ import { TaxInvoiceItemList } from './tax-invoice-item-type'
7
+
8
+ @Resolver(TaxInvoiceItem)
9
+ export class TaxInvoiceItemQuery {
10
+ @Query(returns => TaxInvoiceItem!, { nullable: true, description: 'To fetch a TaxInvoiceItem' })
11
+ async taxInvoiceItem(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<TaxInvoiceItem> {
12
+ const { domain } = context.state
13
+
14
+ return await getRepository(TaxInvoiceItem).findOne({
15
+ where: { domain: { id: domain.id }, id }
16
+ })
17
+ }
18
+
19
+ @Query(returns => TaxInvoiceItemList, { description: 'To fetch multiple TaxInvoiceItems' })
20
+ async taxInvoiceItems(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<TaxInvoiceItemList> {
21
+ const { domain } = context.state
22
+
23
+ const queryBuilder = getQueryBuilderFromListParams({
24
+ domain,
25
+ params,
26
+ repository: await getRepository(TaxInvoiceItem),
27
+ searchables: ['name', 'description']
28
+ })
29
+
30
+ const [items, total] = await queryBuilder.getManyAndCount()
31
+
32
+ return { items, total }
33
+ }
34
+
35
+ @FieldResolver(type => String)
36
+ async thumbnail(@Root() taxInvoiceItem: TaxInvoiceItem): Promise<string | undefined> {
37
+ const attachment: Attachment = await getRepository(Attachment).findOne({
38
+ where: {
39
+ domain: { id: taxInvoiceItem.domainId },
40
+ refType: TaxInvoiceItem.name,
41
+ refBy: taxInvoiceItem.id
42
+ }
43
+ })
44
+
45
+ return attachment?.fullpath
46
+ }
47
+
48
+ @FieldResolver(type => Domain)
49
+ async domain(@Root() taxInvoiceItem: TaxInvoiceItem): Promise<Domain> {
50
+ return taxInvoiceItem.domainId && (await getRepository(Domain).findOneBy({ id: taxInvoiceItem.domainId }))
51
+ }
52
+
53
+ @FieldResolver(type => User)
54
+ async creator(@Root() taxInvoiceItem: TaxInvoiceItem): Promise<User> {
55
+ return taxInvoiceItem.creatorId && (await getRepository(User).findOneBy({ id: taxInvoiceItem.creatorId }))
56
+ }
57
+ }