@things-factory/accounting 8.0.0-beta.0 → 8.0.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. package/package.json +5 -5
  2. package/client/activities/activity-book-edit.ts +0 -88
  3. package/client/activities/activity-book-view.ts +0 -88
  4. package/client/activities/activity-expense-edit.ts +0 -88
  5. package/client/activities/activity-expense-view.ts +0 -88
  6. package/client/bootstrap.ts +0 -10
  7. package/client/components/accounting-category-selector.ts +0 -136
  8. package/client/components/accounting-category-view.ts +0 -75
  9. package/client/grist-editors/grist-editor-accounting-category-object.ts +0 -83
  10. package/client/grist-editors/grist-renderer-accounting-category-object.ts +0 -13
  11. package/client/index.ts +0 -0
  12. package/client/pages/account/account-importer.ts +0 -97
  13. package/client/pages/account/account-list-page.ts +0 -364
  14. package/client/pages/accounting-category/accounting-category-importer.ts +0 -97
  15. package/client/pages/accounting-category/accounting-category-list-page.ts +0 -368
  16. package/client/pages/accounting-category/accounting-category-tree-page.ts +0 -338
  17. package/client/pages/accounting-document/accounting-document-importer.ts +0 -90
  18. package/client/pages/accounting-document/accounting-document-list-page.ts +0 -398
  19. package/client/pages/bank/bank-importer.ts +0 -90
  20. package/client/pages/bank/bank-list-page.ts +0 -398
  21. package/client/pages/bank-account/bank-account-importer.ts +0 -90
  22. package/client/pages/bank-account/bank-account-list-page.ts +0 -398
  23. package/client/pages/financial-institution/financial-institution-importer.ts +0 -90
  24. package/client/pages/financial-institution/financial-institution-list-page.ts +0 -398
  25. package/client/pages/financial-statement/financial-statement-importer.ts +0 -97
  26. package/client/pages/financial-statement/financial-statement-list-page.ts +0 -338
  27. package/client/pages/fiscal-month/fiscal-month-importer.ts +0 -90
  28. package/client/pages/fiscal-month/fiscal-month-list-page.ts +0 -398
  29. package/client/pages/fiscal-quarter/fiscal-quarter-importer.ts +0 -90
  30. package/client/pages/fiscal-quarter/fiscal-quarter-list-page.ts +0 -398
  31. package/client/pages/fiscal-year/fiscal-year-importer.ts +0 -90
  32. package/client/pages/fiscal-year/fiscal-year-list-page.ts +0 -398
  33. package/client/pages/income-statement/income-statement-importer.ts +0 -97
  34. package/client/pages/income-statement/income-statement-list-page.ts +0 -338
  35. package/client/pages/payment/payment-importer.ts +0 -90
  36. package/client/pages/payment/payment-list-page.ts +0 -398
  37. package/client/pages/transaction/transaction-importer.ts +0 -97
  38. package/client/pages/transaction/transaction-list-page.ts +0 -338
  39. package/client/route.ts +0 -35
  40. package/client/tsconfig.json +0 -13
  41. package/client/types/accounting-category.ts +0 -23
  42. package/client/types/index.ts +0 -1
  43. package/server/activities/activity-book.ts +0 -172
  44. package/server/activities/activity-expense.ts +0 -149
  45. package/server/activities/index.ts +0 -18
  46. package/server/controllers/index.ts +0 -1
  47. package/server/controllers/summary-statements.ts +0 -166
  48. package/server/index.ts +0 -6
  49. package/server/middlewares/index.ts +0 -3
  50. package/server/migrations/1725200507196-seed-fiscal-entities.ts +0 -106
  51. package/server/migrations/1725201467183-seed-accounts.ts +0 -339
  52. package/server/migrations/1725201567284-seed-country-codes.ts +0 -261
  53. package/server/migrations/1725201667385-seed-financial-institutions.ts +0 -348
  54. package/server/migrations/index.ts +0 -9
  55. package/server/routes.ts +0 -26
  56. package/server/service/account/account-history.ts +0 -117
  57. package/server/service/account/account-mutation.ts +0 -140
  58. package/server/service/account/account-query.ts +0 -51
  59. package/server/service/account/account-type.ts +0 -44
  60. package/server/service/account/account.ts +0 -97
  61. package/server/service/account/event-subscriber.ts +0 -17
  62. package/server/service/account/index.ts +0 -9
  63. package/server/service/accounting-category/accounting-category-history.ts +0 -129
  64. package/server/service/accounting-category/accounting-category-mutation.ts +0 -148
  65. package/server/service/accounting-category/accounting-category-query.ts +0 -74
  66. package/server/service/accounting-category/accounting-category-type.ts +0 -48
  67. package/server/service/accounting-category/accounting-category.ts +0 -100
  68. package/server/service/accounting-category/event-subscriber.ts +0 -20
  69. package/server/service/accounting-category/index.ts +0 -9
  70. package/server/service/accounting-document/accounting-document-history.ts +0 -123
  71. package/server/service/accounting-document/accounting-document-mutation.ts +0 -137
  72. package/server/service/accounting-document/accounting-document-query.ts +0 -48
  73. package/server/service/accounting-document/accounting-document-type.ts +0 -52
  74. package/server/service/accounting-document/accounting-document.ts +0 -93
  75. package/server/service/accounting-document/event-subscriber.ts +0 -17
  76. package/server/service/accounting-document/index.ts +0 -9
  77. package/server/service/bank-account/bank-account-history.ts +0 -149
  78. package/server/service/bank-account/bank-account-mutation.ts +0 -137
  79. package/server/service/bank-account/bank-account-query.ts +0 -48
  80. package/server/service/bank-account/bank-account-type.ts +0 -112
  81. package/server/service/bank-account/bank-account.ts +0 -142
  82. package/server/service/bank-account/event-subscriber.ts +0 -17
  83. package/server/service/bank-account/index.ts +0 -9
  84. package/server/service/common-type.ts +0 -12
  85. package/server/service/financial-institution/financial-institution-mutation.ts +0 -198
  86. package/server/service/financial-institution/financial-institution-query.ts +0 -62
  87. package/server/service/financial-institution/financial-institution-type.ts +0 -91
  88. package/server/service/financial-institution/financial-institution.ts +0 -122
  89. package/server/service/financial-institution/index.ts +0 -7
  90. package/server/service/financial-statement/event-subscriber.ts +0 -17
  91. package/server/service/financial-statement/financial-statement-history.ts +0 -129
  92. package/server/service/financial-statement/financial-statement-line-item.ts +0 -82
  93. package/server/service/financial-statement/financial-statement-mutation.ts +0 -148
  94. package/server/service/financial-statement/financial-statement-query.ts +0 -53
  95. package/server/service/financial-statement/financial-statement-type.ts +0 -51
  96. package/server/service/financial-statement/financial-statement.ts +0 -116
  97. package/server/service/financial-statement/index.ts +0 -10
  98. package/server/service/fiscal-month/fiscal-month-mutation.ts +0 -145
  99. package/server/service/fiscal-month/fiscal-month-query.ts +0 -58
  100. package/server/service/fiscal-month/fiscal-month-type.ts +0 -66
  101. package/server/service/fiscal-month/fiscal-month.ts +0 -84
  102. package/server/service/fiscal-month/index.ts +0 -7
  103. package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +0 -148
  104. package/server/service/fiscal-quarter/fiscal-quarter-query.ts +0 -60
  105. package/server/service/fiscal-quarter/fiscal-quarter-type.ts +0 -60
  106. package/server/service/fiscal-quarter/fiscal-quarter.ts +0 -80
  107. package/server/service/fiscal-quarter/index.ts +0 -7
  108. package/server/service/fiscal-year/fiscal-year-mutation.ts +0 -145
  109. package/server/service/fiscal-year/fiscal-year-query.ts +0 -53
  110. package/server/service/fiscal-year/fiscal-year-type.ts +0 -54
  111. package/server/service/fiscal-year/fiscal-year.ts +0 -76
  112. package/server/service/fiscal-year/index.ts +0 -7
  113. package/server/service/income-statement/event-subscriber.ts +0 -17
  114. package/server/service/income-statement/income-statement-history.ts +0 -133
  115. package/server/service/income-statement/income-statement-line-item.ts +0 -84
  116. package/server/service/income-statement/income-statement-mutation.ts +0 -147
  117. package/server/service/income-statement/income-statement-query.ts +0 -50
  118. package/server/service/income-statement/income-statement-type.ts +0 -51
  119. package/server/service/income-statement/income-statement.ts +0 -120
  120. package/server/service/income-statement/index.ts +0 -10
  121. package/server/service/index.ts +0 -108
  122. package/server/service/payment/event-subscriber.ts +0 -17
  123. package/server/service/payment/index.ts +0 -9
  124. package/server/service/payment/payment-history.ts +0 -155
  125. package/server/service/payment/payment-mutation.ts +0 -139
  126. package/server/service/payment/payment-query.ts +0 -50
  127. package/server/service/payment/payment-type.ts +0 -82
  128. package/server/service/payment/payment.ts +0 -154
  129. package/server/service/transaction/event-subscriber.ts +0 -17
  130. package/server/service/transaction/index.ts +0 -9
  131. package/server/service/transaction/transaction-history.ts +0 -161
  132. package/server/service/transaction/transaction-mutation.ts +0 -146
  133. package/server/service/transaction/transaction-query.ts +0 -50
  134. package/server/service/transaction/transaction-type.ts +0 -48
  135. package/server/service/transaction/transaction.ts +0 -230
  136. package/server/tsconfig.json +0 -10
@@ -1,348 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from 'typeorm'
2
- import { getRepository } from '@things-factory/shell'
3
- import { FinancialInstitution, FinancialInstitutionType } from '../service/financial-institution/financial-institution'
4
-
5
- export class SeedFinancialInstitutions1725201667385 implements MigrationInterface {
6
- public async up(queryRunner: QueryRunner): Promise<void> {
7
- const financialInstitutionRepository = getRepository(FinancialInstitution)
8
-
9
- const institutions = [
10
- {
11
- name: 'KB국민은행',
12
- description: 'KB Kookmin Bank',
13
- swiftCode: 'CZNBKRSE',
14
- country: 'KR',
15
- type: FinancialInstitutionType.Bank
16
- },
17
- {
18
- name: '신한은행',
19
- description: 'Shinhan Bank',
20
- swiftCode: 'SHBKKRSE',
21
- country: 'KR',
22
- type: FinancialInstitutionType.Bank
23
- },
24
- {
25
- name: '우리은행',
26
- description: 'Woori Bank',
27
- swiftCode: 'HVBKKRSE',
28
- country: 'KR',
29
- type: FinancialInstitutionType.Bank
30
- },
31
- {
32
- name: '하나은행',
33
- description: 'Hana Bank',
34
- swiftCode: 'KOEXKRSE',
35
- country: 'KR',
36
- type: FinancialInstitutionType.Bank
37
- },
38
- {
39
- name: '농협은행',
40
- description: 'NH Bank',
41
- swiftCode: 'NACFKRSE',
42
- country: 'KR',
43
- type: FinancialInstitutionType.Bank
44
- },
45
- {
46
- name: '기업은행',
47
- description: 'Industrial Bank of Korea',
48
- swiftCode: 'IBKOKRSE',
49
- country: 'KR',
50
- type: FinancialInstitutionType.Bank
51
- },
52
- {
53
- name: '한국씨티은행',
54
- description: 'Citibank Korea',
55
- swiftCode: 'CITIKRSX',
56
- country: 'KR',
57
- type: FinancialInstitutionType.Bank
58
- },
59
- {
60
- name: '한국스탠다드차타드은행',
61
- description: 'Standard Chartered Bank Korea',
62
- swiftCode: 'SCBLKRSE',
63
- country: 'KR',
64
- type: FinancialInstitutionType.Bank
65
- },
66
- {
67
- name: '카카오뱅크',
68
- description: 'Kakao Bank',
69
- swiftCode: 'CITIKRSXKKO',
70
- country: 'KR',
71
- type: FinancialInstitutionType.Bank
72
- },
73
- {
74
- name: '케이뱅크',
75
- description: 'K Bank',
76
- swiftCode: 'KBANKRSE',
77
- country: 'KR',
78
- type: FinancialInstitutionType.Bank
79
- },
80
- {
81
- name: '토스뱅크',
82
- description: 'Toss Bank',
83
- swiftCode: 'TSBKKRSE',
84
- country: 'KR',
85
- type: FinancialInstitutionType.Bank
86
- },
87
- {
88
- name: '한국수출입은행',
89
- description: 'Export-Import Bank of Korea',
90
- swiftCode: 'EXIKKRSE',
91
- country: 'KR',
92
- type: FinancialInstitutionType.Bank
93
- },
94
- {
95
- name: '한국산업은행',
96
- description: 'Korea Development Bank',
97
- swiftCode: 'KODBKRSE',
98
- country: 'KR',
99
- type: FinancialInstitutionType.Bank
100
- },
101
- {
102
- name: '경남은행',
103
- description: 'BNK Kyongnam Bank',
104
- swiftCode: 'KYNAKR22',
105
- country: 'KR',
106
- type: FinancialInstitutionType.Bank
107
- },
108
- {
109
- name: '광주은행',
110
- description: 'Gwangju Bank',
111
- swiftCode: 'KWABKRSE',
112
- country: 'KR',
113
- type: FinancialInstitutionType.Bank
114
- },
115
- {
116
- name: '대구은행',
117
- description: 'DGB Daegu Bank',
118
- swiftCode: 'DAEBKR22',
119
- country: 'KR',
120
- type: FinancialInstitutionType.Bank
121
- },
122
- {
123
- name: '부산은행',
124
- description: 'BNK Busan Bank',
125
- swiftCode: 'PUSBKR2P',
126
- country: 'KR',
127
- type: FinancialInstitutionType.Bank
128
- },
129
- {
130
- name: '전북은행',
131
- description: 'Jeonbuk Bank',
132
- swiftCode: 'JEONKR22',
133
- country: 'KR',
134
- type: FinancialInstitutionType.Bank
135
- },
136
- {
137
- name: '제주은행',
138
- description: 'Jeju Bank',
139
- swiftCode: 'JEJUKR2P',
140
- country: 'KR',
141
- type: FinancialInstitutionType.Bank
142
- },
143
- {
144
- name: '새마을금고',
145
- description: 'MG Community Credit Cooperatives',
146
- swiftCode: 'KSDCKR21',
147
- country: 'KR',
148
- type: FinancialInstitutionType.Bank
149
- },
150
- {
151
- name: '신협',
152
- description: 'National Credit Union Federation of Korea',
153
- swiftCode: 'NFFCKRSE',
154
- country: 'KR',
155
- type: FinancialInstitutionType.Bank
156
- },
157
- // 미국 은행
158
- {
159
- name: 'JP모건 체이스',
160
- description: 'JPMorgan Chase',
161
- swiftCode: 'CHASUS33',
162
- country: 'US',
163
- type: FinancialInstitutionType.Bank
164
- },
165
- {
166
- name: '뱅크 오브 아메리카',
167
- description: 'Bank of America',
168
- swiftCode: 'BOFAUS3N',
169
- country: 'US',
170
- type: FinancialInstitutionType.Bank
171
- },
172
- {
173
- name: '웰스 파고',
174
- description: 'Wells Fargo',
175
- swiftCode: 'WFBIUS6S',
176
- country: 'US',
177
- type: FinancialInstitutionType.Bank
178
- },
179
- {
180
- name: '씨티그룹',
181
- description: 'Citigroup',
182
- swiftCode: 'CITIUS33',
183
- country: 'US',
184
- type: FinancialInstitutionType.Bank
185
- },
186
- // 영국 은행
187
- {
188
- name: 'HSBC',
189
- description: 'HSBC Holdings',
190
- swiftCode: 'MIDLGB22',
191
- country: 'GB',
192
- type: FinancialInstitutionType.Bank
193
- },
194
- {
195
- name: '바클레이스',
196
- description: 'Barclays',
197
- swiftCode: 'BARCGB22',
198
- country: 'GB',
199
- type: FinancialInstitutionType.Bank
200
- },
201
- {
202
- name: '로이즈 뱅킹 그룹',
203
- description: 'Lloyds Banking Group',
204
- swiftCode: 'LOYDGB2L',
205
- country: 'GB',
206
- type: FinancialInstitutionType.Bank
207
- },
208
- // 일본 은행
209
- {
210
- name: '미쓰비시 UFJ 파이낸셜 그룹',
211
- description: 'Mitsubishi UFJ Financial Group',
212
- swiftCode: 'BOTKJPJT',
213
- country: 'JP',
214
- type: FinancialInstitutionType.Bank
215
- },
216
- {
217
- name: '미즈호 파이낸셜 그룹',
218
- description: 'Mizuho Financial Group',
219
- swiftCode: 'MHCBJPJT',
220
- country: 'JP',
221
- type: FinancialInstitutionType.Bank
222
- },
223
- {
224
- name: '스미토모 미쓰이 파이낸셜 그룹',
225
- description: 'Sumitomo Mitsui Financial Group',
226
- swiftCode: 'SMBCJPJT',
227
- country: 'JP',
228
- type: FinancialInstitutionType.Bank
229
- },
230
- // 중국 은행
231
- {
232
- name: '중국공상은행',
233
- description: 'Industrial and Commercial Bank of China',
234
- swiftCode: 'ICBKCNBJ',
235
- country: 'CN',
236
- type: FinancialInstitutionType.Bank
237
- },
238
- {
239
- name: '중국건설은행',
240
- description: 'China Construction Bank',
241
- swiftCode: 'PCBCCNBJ',
242
- country: 'CN',
243
- type: FinancialInstitutionType.Bank
244
- },
245
- {
246
- name: '중국은행',
247
- description: 'Bank of China',
248
- swiftCode: 'BKCHCNBJ',
249
- country: 'CN',
250
- type: FinancialInstitutionType.Bank
251
- },
252
- // 독일 은행
253
- {
254
- name: '도이치 방크',
255
- description: 'Deutsche Bank',
256
- swiftCode: 'DEUTDEFF',
257
- country: 'DE',
258
- type: FinancialInstitutionType.Bank
259
- },
260
- {
261
- name: '코메르츠방크',
262
- description: 'Commerzbank',
263
- swiftCode: 'COBADEFF',
264
- country: 'DE',
265
- type: FinancialInstitutionType.Bank
266
- },
267
- // 프랑스 은행
268
- {
269
- name: 'BNP 파리바',
270
- description: 'BNP Paribas',
271
- swiftCode: 'BNPAFRPP',
272
- country: 'FR',
273
- type: FinancialInstitutionType.Bank
274
- },
275
- {
276
- name: '크레디 아그리콜',
277
- description: 'Crédit Agricole',
278
- swiftCode: 'AGRIFRPP',
279
- country: 'FR',
280
- type: FinancialInstitutionType.Bank
281
- },
282
- // 한국 카드사
283
- {
284
- name: '신한카드',
285
- description: 'Shinhan Card',
286
- swiftCode: null,
287
- country: 'KR',
288
- type: FinancialInstitutionType.CardCompany
289
- },
290
- {
291
- name: '삼성카드',
292
- description: 'Samsung Card',
293
- swiftCode: null,
294
- country: 'KR',
295
- type: FinancialInstitutionType.CardCompany
296
- },
297
- {
298
- name: 'KB국민카드',
299
- description: 'KB Kookmin Card',
300
- swiftCode: null,
301
- country: 'KR',
302
- type: FinancialInstitutionType.CardCompany
303
- },
304
- {
305
- name: '현대카드',
306
- description: 'Hyundai Card',
307
- swiftCode: null,
308
- country: 'KR',
309
- type: FinancialInstitutionType.CardCompany
310
- },
311
- {
312
- name: '롯데카드',
313
- description: 'Lotte Card',
314
- swiftCode: null,
315
- country: 'KR',
316
- type: FinancialInstitutionType.CardCompany
317
- },
318
- {
319
- name: '우리카드',
320
- description: 'Woori Card',
321
- swiftCode: null,
322
- country: 'KR',
323
- type: FinancialInstitutionType.CardCompany
324
- },
325
- {
326
- name: '하나카드',
327
- description: 'Hana Card',
328
- swiftCode: null,
329
- country: 'KR',
330
- type: FinancialInstitutionType.CardCompany
331
- },
332
- {
333
- name: 'BC카드',
334
- description: 'BC Card',
335
- swiftCode: null,
336
- country: 'KR',
337
- type: FinancialInstitutionType.CardCompany
338
- }
339
- ]
340
-
341
- await financialInstitutionRepository.save(institutions)
342
- }
343
-
344
- public async down(queryRunner: QueryRunner): Promise<void> {
345
- const financialInstitutionRepository = getRepository(FinancialInstitution)
346
- await financialInstitutionRepository.delete({})
347
- }
348
- }
@@ -1,9 +0,0 @@
1
- const glob = require('glob')
2
- const path = require('path')
3
-
4
- export var migrations = []
5
-
6
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
7
- if (file.indexOf('index.js') !== -1) return
8
- migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
9
- })
package/server/routes.ts DELETED
@@ -1,26 +0,0 @@
1
- process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
2
- /*
3
- * can add global public routes to application (auth not required, tenancy not required)
4
- *
5
- * ex) routes.get('/path', async(context, next) => {})
6
- * ex) routes.post('/path', async(context, next) => {})
7
- */
8
- })
9
-
10
- process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
11
- /*
12
- * can add global private routes to application (auth required, tenancy not required)
13
- */
14
- })
15
-
16
- process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
17
- /*
18
- * can add domain public routes to application (auth not required, tenancy required)
19
- */
20
- })
21
-
22
- process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
23
- /*
24
- * can add domain private routes to application (auth required, tenancy required)
25
- */
26
- })
@@ -1,117 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'
3
-
4
- import {
5
- HistoryActionColumn,
6
- HistoryActionType,
7
- HistoryEntityInterface,
8
- HistoryOriginalIdColumn
9
- } from '@operato/typeorm-history'
10
- import { Role, User } from '@things-factory/auth-base'
11
- import { config } from '@things-factory/env'
12
- import { Domain } from '@things-factory/shell'
13
-
14
- import { Account } from './account'
15
- import { AccountingCategory } from '../accounting-category/accounting-category'
16
-
17
- const ORMCONFIG = config.get('ormconfig', {})
18
- const DATABASE_TYPE = ORMCONFIG.type
19
-
20
- @Entity()
21
- @Index(
22
- 'ix_account_history_0',
23
- (accountHistory: AccountHistory) => [accountHistory.originalId, accountHistory.version],
24
- { unique: true }
25
- )
26
- @Index(
27
- 'ix_account_history_1',
28
- (accountHistory: AccountHistory) => [accountHistory.domain, accountHistory.originalId, accountHistory.version],
29
- { unique: true }
30
- )
31
- @ObjectType({ description: 'History Entity of Account' })
32
- export class AccountHistory implements HistoryEntityInterface<Account> {
33
- @PrimaryGeneratedColumn('uuid')
34
- @Field(type => ID)
35
- readonly id: string
36
-
37
- @Column({ nullable: true, default: 1 })
38
- @Field({ nullable: true })
39
- version?: number = 1
40
-
41
- @ManyToOne(type => Domain)
42
- @Field({ nullable: true })
43
- domain?: Domain
44
-
45
- @RelationId((accountHistory: AccountHistory) => accountHistory.domain)
46
- domainId?: string
47
-
48
- @Column({ nullable: true })
49
- @Field({ nullable: true })
50
- code?: string
51
-
52
- @Column({ nullable: true })
53
- @Field({ nullable: true })
54
- name?: string
55
-
56
- @Column({ nullable: true })
57
- @Field({ nullable: true })
58
- description?: string
59
-
60
- @Column({ nullable: true })
61
- @Field({ nullable: true })
62
- active?: boolean
63
-
64
- @ManyToOne(type => AccountingCategory)
65
- @Field(type => AccountingCategory, { nullable: true })
66
- category?: AccountingCategory
67
-
68
- @RelationId((accountHistory: AccountHistory) => accountHistory.category)
69
- categoryId?: string
70
-
71
- @Column({ nullable: true })
72
- @Field({ nullable: true })
73
- createdAt?: Date
74
-
75
- @Column({ nullable: true })
76
- @Field({ nullable: true })
77
- updatedAt?: Date
78
-
79
- @Column({ nullable: true })
80
- @Field({ nullable: true })
81
- deletedAt?: Date
82
-
83
- @ManyToOne(type => User, { nullable: true })
84
- @Field({ nullable: true })
85
- creator?: User
86
-
87
- @RelationId((accountHistory: AccountHistory) => accountHistory.creator)
88
- creatorId?: string
89
-
90
- @ManyToOne(type => User, { nullable: true })
91
- @Field({ nullable: true })
92
- updater?: User
93
-
94
- @RelationId((accountHistory: AccountHistory) => accountHistory.updater)
95
- updaterId?: string
96
-
97
- @HistoryOriginalIdColumn()
98
- public originalId!: string
99
-
100
- @HistoryActionColumn({
101
- nullable: false,
102
- type:
103
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
104
- ? 'enum'
105
- : DATABASE_TYPE == 'oracle'
106
- ? 'varchar2'
107
- : DATABASE_TYPE == 'mssql'
108
- ? 'nvarchar'
109
- : 'varchar',
110
- enum:
111
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
112
- ? HistoryActionType
113
- : undefined,
114
- length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10
115
- })
116
- public action!: HistoryActionType
117
- }
@@ -1,140 +0,0 @@
1
- import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
- import { In } from 'typeorm'
3
-
4
- import { getRepository } from '@things-factory/shell'
5
-
6
- import { Account } from './account'
7
- import { NewAccount, AccountPatch } from './account-type'
8
-
9
- @Resolver(Account)
10
- export class AccountMutation {
11
- @Directive('@transaction')
12
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
13
- @Mutation(returns => Account, { description: 'To create new Account' })
14
- async createAccount(@Arg('account') account: NewAccount, @Ctx() context: ResolverContext): Promise<Account> {
15
- const { domain, user, tx } = context.state
16
-
17
- const result = await getRepository(Account, tx).save({
18
- ...account,
19
- domain,
20
- creator: user,
21
- updater: user
22
- })
23
-
24
- return result
25
- }
26
-
27
- @Directive('@transaction')
28
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
29
- @Mutation(returns => Account, { description: 'To modify Account information' })
30
- async updateAccount(
31
- @Arg('id') id: string,
32
- @Arg('patch') patch: AccountPatch,
33
- @Ctx() context: ResolverContext
34
- ): Promise<Account> {
35
- const { domain, user, tx } = context.state
36
-
37
- const repository = getRepository(Account, tx)
38
- const account = await repository.findOne({
39
- where: { domain: { id: domain.id }, id }
40
- })
41
-
42
- const result = await repository.save({
43
- ...account,
44
- ...patch,
45
- updater: user
46
- })
47
-
48
- return result
49
- }
50
-
51
- @Directive('@transaction')
52
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
53
- @Mutation(returns => [Account], { description: "To modify multiple Accounts' information" })
54
- async updateMultipleAccount(
55
- @Arg('patches', type => [AccountPatch]) patches: AccountPatch[],
56
- @Ctx() context: ResolverContext
57
- ): Promise<Account[]> {
58
- const { domain, user, tx } = context.state
59
-
60
- let results = []
61
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
62
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
63
- const accountRepo = getRepository(Account, tx)
64
-
65
- if (_createRecords.length > 0) {
66
- for (let i = 0; i < _createRecords.length; i++) {
67
- const newRecord = _createRecords[i]
68
-
69
- const result = await accountRepo.save({
70
- ...newRecord,
71
- domain,
72
- creator: user,
73
- updater: user
74
- })
75
-
76
- results.push({ ...result, cuFlag: '+' })
77
- }
78
- }
79
-
80
- if (_updateRecords.length > 0) {
81
- for (let i = 0; i < _updateRecords.length; i++) {
82
- const updateRecord = _updateRecords[i]
83
- const account = await accountRepo.findOneBy({ id: updateRecord.id })
84
-
85
- const result = await accountRepo.save({
86
- ...account,
87
- ...updateRecord,
88
- updater: user
89
- })
90
-
91
- results.push({ ...result, cuFlag: 'M' })
92
- }
93
- }
94
-
95
- return results
96
- }
97
-
98
- @Directive('@transaction')
99
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
100
- @Mutation(returns => Boolean, { description: 'To delete Account' })
101
- async deleteAccount(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
102
- const { domain, tx } = context.state
103
-
104
- await getRepository(Account, tx).delete({ domain: { id: domain.id }, id })
105
-
106
- return true
107
- }
108
-
109
- @Directive('@transaction')
110
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
111
- @Mutation(returns => Boolean, { description: 'To delete multiple Accounts' })
112
- async deleteAccounts(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
113
- const { domain, tx } = context.state
114
-
115
- await getRepository(Account, tx).delete({
116
- domain: { id: domain.id },
117
- id: In(ids)
118
- })
119
-
120
- return true
121
- }
122
-
123
- @Directive('@transaction')
124
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
125
- @Mutation(returns => Boolean, { description: 'To import multiple Accounts' })
126
- async importAccounts(
127
- @Arg('accounts', type => [AccountPatch]) accounts: AccountPatch[],
128
- @Ctx() context: ResolverContext
129
- ): Promise<boolean> {
130
- const { domain, tx } = context.state
131
-
132
- await Promise.all(
133
- accounts.map(async (account: AccountPatch) => {
134
- const createdAccount: Account = await getRepository(Account, tx).save({ domain, ...account })
135
- })
136
- )
137
-
138
- return true
139
- }
140
- }
@@ -1,51 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
-
3
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
- import { User } from '@things-factory/auth-base'
5
- import { Account } from './account'
6
- import { AccountList } from './account-type'
7
-
8
- @Resolver(Account)
9
- export class AccountQuery {
10
- @Directive('@privilege(category: "accounting", privilege: "query")')
11
- @Query(returns => Account!, { nullable: true, description: 'To fetch a Account' })
12
- async account(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Account> {
13
- const { domain } = context.state
14
-
15
- return await getRepository(Account).findOne({
16
- where: { domain: { id: domain.id }, id }
17
- })
18
- }
19
-
20
- @Directive('@privilege(category: "accounting", privilege: "query")')
21
- @Query(returns => AccountList, { description: 'To fetch multiple Accounts' })
22
- async accounts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<AccountList> {
23
- const { domain } = context.state
24
-
25
- const queryBuilder = getQueryBuilderFromListParams({
26
- domain,
27
- params,
28
- repository: await getRepository(Account),
29
- searchables: ['name', 'description']
30
- })
31
-
32
- const [items, total] = await queryBuilder.getManyAndCount()
33
-
34
- return { items, total }
35
- }
36
-
37
- @FieldResolver(type => Domain)
38
- async domain(@Root() account: Account): Promise<Domain> {
39
- return await getRepository(Domain).findOneBy({ id: account.domainId })
40
- }
41
-
42
- @FieldResolver(type => User)
43
- async updater(@Root() account: Account): Promise<User> {
44
- return await getRepository(User).findOneBy({ id: account.updaterId })
45
- }
46
-
47
- @FieldResolver(type => User)
48
- async creator(@Root() account: Account): Promise<User> {
49
- return await getRepository(User).findOneBy({ id: account.creatorId })
50
- }
51
- }