@things-factory/accounting 8.0.39 → 9.0.0-9.0.0-beta.59.0

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 (196) hide show
  1. package/dist-client/pages/accounting-category/accounting-category-tree-page.js +1 -1
  2. package/dist-client/pages/accounting-category/accounting-category-tree-page.js.map +1 -1
  3. package/dist-client/pages/bank/bank-importer.d.ts +23 -0
  4. package/dist-client/pages/bank/bank-importer.js +93 -0
  5. package/dist-client/pages/bank/bank-importer.js.map +1 -0
  6. package/dist-client/pages/bank/bank-list-page.d.ts +66 -0
  7. package/dist-client/pages/bank/bank-list-page.js +370 -0
  8. package/dist-client/pages/bank/bank-list-page.js.map +1 -0
  9. package/dist-client/pages/bank-account/bank-account-importer.d.ts +23 -0
  10. package/dist-client/pages/bank-account/bank-account-importer.js +93 -0
  11. package/dist-client/pages/bank-account/bank-account-importer.js.map +1 -0
  12. package/dist-client/pages/bank-account/bank-account-list-page.d.ts +66 -0
  13. package/dist-client/pages/bank-account/bank-account-list-page.js +370 -0
  14. package/dist-client/pages/bank-account/bank-account-list-page.js.map +1 -0
  15. package/dist-client/pages/financial-institution/financial-institution-importer.d.ts +23 -0
  16. package/dist-client/pages/financial-institution/financial-institution-importer.js +93 -0
  17. package/dist-client/pages/financial-institution/financial-institution-importer.js.map +1 -0
  18. package/dist-client/pages/financial-institution/financial-institution-list-page.d.ts +66 -0
  19. package/dist-client/pages/financial-institution/financial-institution-list-page.js +370 -0
  20. package/dist-client/pages/financial-institution/financial-institution-list-page.js.map +1 -0
  21. package/dist-client/tsconfig.tsbuildinfo +1 -1
  22. package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +5 -0
  23. package/dist-server/migrations/1725201567284-seed-country-codes.js +248 -0
  24. package/dist-server/migrations/1725201567284-seed-country-codes.js.map +1 -0
  25. package/dist-server/migrations/1725201667385-seed-financial-institutions.d.ts +5 -0
  26. package/dist-server/migrations/1725201667385-seed-financial-institutions.js +348 -0
  27. package/dist-server/migrations/1725201667385-seed-financial-institutions.js.map +1 -0
  28. package/dist-server/service/bank-account/bank-account-history.d.ts +34 -0
  29. package/dist-server/service/bank-account/bank-account-history.js +172 -0
  30. package/dist-server/service/bank-account/bank-account-history.js.map +1 -0
  31. package/dist-server/service/bank-account/bank-account-mutation.d.ts +10 -0
  32. package/dist-server/service/bank-account/bank-account-mutation.js +128 -0
  33. package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -0
  34. package/dist-server/service/bank-account/bank-account-query.d.ts +11 -0
  35. package/dist-server/service/bank-account/bank-account-query.js +79 -0
  36. package/dist-server/service/bank-account/bank-account-query.js.map +1 -0
  37. package/dist-server/service/bank-account/bank-account-type.d.ts +39 -0
  38. package/dist-server/service/bank-account/bank-account-type.js +153 -0
  39. package/dist-server/service/bank-account/bank-account-type.js.map +1 -0
  40. package/dist-server/service/bank-account/bank-account.d.ts +38 -0
  41. package/dist-server/service/bank-account/bank-account.js +164 -0
  42. package/dist-server/service/bank-account/bank-account.js.map +1 -0
  43. package/dist-server/service/bank-account/event-subscriber.d.ts +7 -0
  44. package/dist-server/service/bank-account/event-subscriber.js +21 -0
  45. package/dist-server/service/bank-account/event-subscriber.js.map +1 -0
  46. package/dist-server/service/bank-account/index.d.ts +7 -0
  47. package/dist-server/service/bank-account/index.js +12 -0
  48. package/dist-server/service/bank-account/index.js.map +1 -0
  49. package/dist-server/service/financial-institution/financial-institution-mutation.d.ts +10 -0
  50. package/dist-server/service/financial-institution/financial-institution-mutation.js +169 -0
  51. package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -0
  52. package/dist-server/service/financial-institution/financial-institution-query.d.ts +12 -0
  53. package/dist-server/service/financial-institution/financial-institution-query.js +97 -0
  54. package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -0
  55. package/dist-server/service/financial-institution/financial-institution-type.d.ts +32 -0
  56. package/dist-server/service/financial-institution/financial-institution-type.js +126 -0
  57. package/dist-server/service/financial-institution/financial-institution-type.js.map +1 -0
  58. package/dist-server/service/financial-institution/financial-institution.d.ts +34 -0
  59. package/dist-server/service/financial-institution/financial-institution.js +137 -0
  60. package/dist-server/service/financial-institution/financial-institution.js.map +1 -0
  61. package/dist-server/service/financial-institution/index.d.ts +6 -0
  62. package/dist-server/service/financial-institution/index.js +10 -0
  63. package/dist-server/service/financial-institution/index.js.map +1 -0
  64. package/dist-server/service/index.d.ts +3 -2
  65. package/dist-server/service/index.js +5 -0
  66. package/dist-server/service/index.js.map +1 -1
  67. package/dist-server/service/payment/index.d.ts +1 -2
  68. package/dist-server/service/payment/payment-history.d.ts +8 -1
  69. package/dist-server/service/payment/payment-history.js +41 -10
  70. package/dist-server/service/payment/payment-history.js.map +1 -1
  71. package/dist-server/service/payment/payment-type.d.ts +7 -1
  72. package/dist-server/service/payment/payment-type.js +24 -0
  73. package/dist-server/service/payment/payment-type.js.map +1 -1
  74. package/dist-server/service/payment/payment.d.ts +12 -0
  75. package/dist-server/service/payment/payment.js +36 -1
  76. package/dist-server/service/payment/payment.js.map +1 -1
  77. package/dist-server/tsconfig.tsbuildinfo +1 -1
  78. package/helps/accounting/bank-account.md +160 -0
  79. package/helps/accounting/bank.md +160 -0
  80. package/helps/accounting/financial-institution.md +160 -0
  81. package/package.json +7 -7
  82. package/client/activities/activity-book-edit.ts +0 -88
  83. package/client/activities/activity-book-view.ts +0 -88
  84. package/client/activities/activity-expense-edit.ts +0 -88
  85. package/client/activities/activity-expense-view.ts +0 -88
  86. package/client/bootstrap.ts +0 -10
  87. package/client/components/accounting-category-selector.ts +0 -136
  88. package/client/components/accounting-category-view.ts +0 -75
  89. package/client/grist-editors/grist-editor-accounting-category-object.ts +0 -83
  90. package/client/grist-editors/grist-renderer-accounting-category-object.ts +0 -13
  91. package/client/index.ts +0 -0
  92. package/client/pages/account/account-importer.ts +0 -97
  93. package/client/pages/account/account-list-page.ts +0 -364
  94. package/client/pages/accounting-category/accounting-category-importer.ts +0 -97
  95. package/client/pages/accounting-category/accounting-category-list-page.ts +0 -368
  96. package/client/pages/accounting-category/accounting-category-tree-page.ts +0 -338
  97. package/client/pages/accounting-document/accounting-document-importer.ts +0 -90
  98. package/client/pages/accounting-document/accounting-document-list-page.ts +0 -398
  99. package/client/pages/financial-statement/financial-statement-importer.ts +0 -97
  100. package/client/pages/financial-statement/financial-statement-list-page.ts +0 -338
  101. package/client/pages/fiscal-month/fiscal-month-importer.ts +0 -90
  102. package/client/pages/fiscal-month/fiscal-month-list-page.ts +0 -398
  103. package/client/pages/fiscal-quarter/fiscal-quarter-importer.ts +0 -90
  104. package/client/pages/fiscal-quarter/fiscal-quarter-list-page.ts +0 -398
  105. package/client/pages/fiscal-year/fiscal-year-importer.ts +0 -90
  106. package/client/pages/fiscal-year/fiscal-year-list-page.ts +0 -398
  107. package/client/pages/income-statement/income-statement-importer.ts +0 -97
  108. package/client/pages/income-statement/income-statement-list-page.ts +0 -338
  109. package/client/pages/payment/payment-importer.ts +0 -90
  110. package/client/pages/payment/payment-list-page.ts +0 -398
  111. package/client/pages/transaction/transaction-importer.ts +0 -97
  112. package/client/pages/transaction/transaction-list-page.ts +0 -338
  113. package/client/route.ts +0 -35
  114. package/client/tsconfig.json +0 -13
  115. package/client/types/accounting-category.ts +0 -23
  116. package/client/types/index.ts +0 -1
  117. package/server/activities/activity-book.ts +0 -172
  118. package/server/activities/activity-expense.ts +0 -149
  119. package/server/activities/index.ts +0 -18
  120. package/server/controllers/index.ts +0 -1
  121. package/server/controllers/summary-statements.ts +0 -166
  122. package/server/index.ts +0 -6
  123. package/server/middlewares/index.ts +0 -3
  124. package/server/migrations/1725200507196-seed-fiscal-entities.ts +0 -106
  125. package/server/migrations/1725201467183-seed-accounts.ts +0 -339
  126. package/server/migrations/index.ts +0 -9
  127. package/server/routes.ts +0 -26
  128. package/server/service/account/account-history.ts +0 -117
  129. package/server/service/account/account-mutation.ts +0 -140
  130. package/server/service/account/account-query.ts +0 -51
  131. package/server/service/account/account-type.ts +0 -44
  132. package/server/service/account/account.ts +0 -97
  133. package/server/service/account/event-subscriber.ts +0 -17
  134. package/server/service/account/index.ts +0 -9
  135. package/server/service/accounting-category/accounting-category-history.ts +0 -129
  136. package/server/service/accounting-category/accounting-category-mutation.ts +0 -148
  137. package/server/service/accounting-category/accounting-category-query.ts +0 -74
  138. package/server/service/accounting-category/accounting-category-type.ts +0 -48
  139. package/server/service/accounting-category/accounting-category.ts +0 -100
  140. package/server/service/accounting-category/event-subscriber.ts +0 -20
  141. package/server/service/accounting-category/index.ts +0 -9
  142. package/server/service/accounting-document/accounting-document-history.ts +0 -123
  143. package/server/service/accounting-document/accounting-document-mutation.ts +0 -137
  144. package/server/service/accounting-document/accounting-document-query.ts +0 -48
  145. package/server/service/accounting-document/accounting-document-type.ts +0 -52
  146. package/server/service/accounting-document/accounting-document.ts +0 -93
  147. package/server/service/accounting-document/event-subscriber.ts +0 -17
  148. package/server/service/accounting-document/index.ts +0 -9
  149. package/server/service/common-type.ts +0 -12
  150. package/server/service/financial-statement/event-subscriber.ts +0 -17
  151. package/server/service/financial-statement/financial-statement-history.ts +0 -129
  152. package/server/service/financial-statement/financial-statement-line-item.ts +0 -82
  153. package/server/service/financial-statement/financial-statement-mutation.ts +0 -148
  154. package/server/service/financial-statement/financial-statement-query.ts +0 -53
  155. package/server/service/financial-statement/financial-statement-type.ts +0 -51
  156. package/server/service/financial-statement/financial-statement.ts +0 -116
  157. package/server/service/financial-statement/index.ts +0 -10
  158. package/server/service/fiscal-month/fiscal-month-mutation.ts +0 -145
  159. package/server/service/fiscal-month/fiscal-month-query.ts +0 -58
  160. package/server/service/fiscal-month/fiscal-month-type.ts +0 -66
  161. package/server/service/fiscal-month/fiscal-month.ts +0 -84
  162. package/server/service/fiscal-month/index.ts +0 -7
  163. package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +0 -148
  164. package/server/service/fiscal-quarter/fiscal-quarter-query.ts +0 -60
  165. package/server/service/fiscal-quarter/fiscal-quarter-type.ts +0 -60
  166. package/server/service/fiscal-quarter/fiscal-quarter.ts +0 -80
  167. package/server/service/fiscal-quarter/index.ts +0 -7
  168. package/server/service/fiscal-year/fiscal-year-mutation.ts +0 -145
  169. package/server/service/fiscal-year/fiscal-year-query.ts +0 -53
  170. package/server/service/fiscal-year/fiscal-year-type.ts +0 -54
  171. package/server/service/fiscal-year/fiscal-year.ts +0 -76
  172. package/server/service/fiscal-year/index.ts +0 -7
  173. package/server/service/income-statement/event-subscriber.ts +0 -17
  174. package/server/service/income-statement/income-statement-history.ts +0 -133
  175. package/server/service/income-statement/income-statement-line-item.ts +0 -84
  176. package/server/service/income-statement/income-statement-mutation.ts +0 -147
  177. package/server/service/income-statement/income-statement-query.ts +0 -50
  178. package/server/service/income-statement/income-statement-type.ts +0 -51
  179. package/server/service/income-statement/income-statement.ts +0 -120
  180. package/server/service/income-statement/index.ts +0 -10
  181. package/server/service/index.ts +0 -108
  182. package/server/service/payment/event-subscriber.ts +0 -17
  183. package/server/service/payment/index.ts +0 -9
  184. package/server/service/payment/payment-history.ts +0 -132
  185. package/server/service/payment/payment-mutation.ts +0 -139
  186. package/server/service/payment/payment-query.ts +0 -50
  187. package/server/service/payment/payment-type.ts +0 -64
  188. package/server/service/payment/payment.ts +0 -123
  189. package/server/service/transaction/event-subscriber.ts +0 -17
  190. package/server/service/transaction/index.ts +0 -9
  191. package/server/service/transaction/transaction-history.ts +0 -161
  192. package/server/service/transaction/transaction-mutation.ts +0 -146
  193. package/server/service/transaction/transaction-query.ts +0 -50
  194. package/server/service/transaction/transaction-type.ts +0 -48
  195. package/server/service/transaction/transaction.ts +0 -230
  196. package/server/tsconfig.json +0 -10
@@ -1,44 +0,0 @@
1
- import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
2
-
3
- import { ObjectRef, ScalarObject } from '@things-factory/shell'
4
-
5
- import { Account } from './account'
6
-
7
- @InputType()
8
- export class NewAccount {
9
- @Field()
10
- name: string
11
-
12
- @Field({ nullable: true })
13
- description?: string
14
-
15
- @Field({ nullable: true })
16
- active?: boolean
17
- }
18
-
19
- @InputType()
20
- export class AccountPatch {
21
- @Field(type => ID, { nullable: true })
22
- id?: string
23
-
24
- @Field({ nullable: true })
25
- name?: string
26
-
27
- @Field({ nullable: true })
28
- description?: string
29
-
30
- @Field({ nullable: true })
31
- active?: boolean
32
-
33
- @Field({ nullable: true })
34
- cuFlag?: string
35
- }
36
-
37
- @ObjectType()
38
- export class AccountList {
39
- @Field(type => [Account])
40
- items: Account[]
41
-
42
- @Field(type => Int)
43
- total: number
44
- }
@@ -1,97 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- DeleteDateColumn,
5
- Entity,
6
- Index,
7
- Column,
8
- RelationId,
9
- ManyToOne,
10
- PrimaryGeneratedColumn,
11
- VersionColumn
12
- } from 'typeorm'
13
- import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
14
-
15
- import { Domain } from '@things-factory/shell'
16
- import { User } from '@things-factory/auth-base'
17
- import { AccountingCategory } from '../accounting-category/accounting-category'
18
-
19
- @Entity()
20
- @Index('ix_account_0', (account: Account) => [account.domain, account.name], {
21
- unique: true,
22
- where: '"deleted_at" IS NULL'
23
- })
24
- @Index('ix_account_1', (account: Account) => [account.domain, account.code], {
25
- unique: true,
26
- where: '"deleted_at" IS NULL'
27
- })
28
- @Index('ix_account_2', (account: Account) => [account.domain, account.category], {
29
- unique: false,
30
- where: '"deleted_at" IS NULL'
31
- })
32
- @ObjectType({ description: 'Entity for Account' })
33
- export class Account {
34
- @PrimaryGeneratedColumn('uuid')
35
- @Field(type => ID)
36
- readonly id: string
37
-
38
- @VersionColumn()
39
- @Field({ nullable: true })
40
- version?: number = 1
41
-
42
- @ManyToOne(type => Domain)
43
- @Field({ nullable: true })
44
- domain?: Domain
45
-
46
- @RelationId((account: Account) => account.domain)
47
- domainId?: string
48
-
49
- @Column()
50
- @Field({ nullable: true, description: 'Account code number' })
51
- code?: string
52
-
53
- @Column()
54
- @Field({ nullable: true, description: 'Account name' })
55
- name?: string
56
-
57
- @Column({ nullable: true })
58
- @Field({ nullable: true })
59
- description?: string
60
-
61
- @Column({ nullable: true })
62
- @Field({ nullable: true })
63
- active?: boolean
64
-
65
- @ManyToOne(type => AccountingCategory)
66
- @Field(type => AccountingCategory, { nullable: true })
67
- category?: AccountingCategory
68
-
69
- @RelationId((account: Account) => account.category)
70
- categoryId?: string
71
-
72
- @CreateDateColumn()
73
- @Field({ nullable: true })
74
- createdAt?: Date
75
-
76
- @UpdateDateColumn()
77
- @Field({ nullable: true })
78
- updatedAt?: Date
79
-
80
- @DeleteDateColumn()
81
- @Field({ nullable: true })
82
- deletedAt?: Date
83
-
84
- @ManyToOne(type => User, { nullable: true })
85
- @Field(type => User, { nullable: true })
86
- creator?: User
87
-
88
- @RelationId((account: Account) => account.creator)
89
- creatorId?: string
90
-
91
- @ManyToOne(type => User, { nullable: true })
92
- @Field(type => User, { nullable: true })
93
- updater?: User
94
-
95
- @RelationId((account: Account) => account.updater)
96
- updaterId?: string
97
- }
@@ -1,17 +0,0 @@
1
- import { EventSubscriber } from 'typeorm'
2
-
3
- import { HistoryEntitySubscriber } from '@operato/typeorm-history'
4
-
5
- import { Account } from './account'
6
- import { AccountHistory } from './account-history'
7
-
8
- @EventSubscriber()
9
- export class AccountHistoryEntitySubscriber extends HistoryEntitySubscriber<Account, AccountHistory> {
10
- public get entity() {
11
- return Account
12
- }
13
-
14
- public get historyEntity() {
15
- return AccountHistory
16
- }
17
- }
@@ -1,9 +0,0 @@
1
- import { Account } from './account'
2
- import { AccountHistory } from './account-history'
3
- import { AccountQuery } from './account-query'
4
- import { AccountMutation } from './account-mutation'
5
- import { AccountHistoryEntitySubscriber } from './event-subscriber'
6
-
7
- export const entities = [Account, AccountHistory]
8
- export const resolvers = [AccountQuery, AccountMutation]
9
- export const subscribers = [AccountHistoryEntitySubscriber]
@@ -1,129 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Entity, Index, Column, ManyToOne, RelationId, PrimaryGeneratedColumn, OneToMany } 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 { AccountingCategory } from './accounting-category'
15
-
16
- const ORMCONFIG = config.get('ormconfig', {})
17
- const DATABASE_TYPE = ORMCONFIG.type
18
-
19
- @Entity()
20
- @Index(
21
- 'ix_accounting_category_history_0',
22
- (accountingCategoryHistory: AccountingCategoryHistory) => [
23
- accountingCategoryHistory.originalId,
24
- accountingCategoryHistory.version
25
- ],
26
- { unique: true }
27
- )
28
- @Index(
29
- 'ix_accounting_category_history_1',
30
- (accountingCategoryHistory: AccountingCategoryHistory) => [
31
- accountingCategoryHistory.domain,
32
- accountingCategoryHistory.originalId,
33
- accountingCategoryHistory.version
34
- ],
35
- { unique: true }
36
- )
37
- @ObjectType({ description: 'History Entity of Accounting Category' })
38
- export class AccountingCategoryHistory implements HistoryEntityInterface<AccountingCategory> {
39
- @PrimaryGeneratedColumn('uuid')
40
- @Field(type => ID)
41
- readonly id: string
42
-
43
- @Column({ nullable: true, default: 1 })
44
- @Field({ nullable: true })
45
- version?: number = 1
46
-
47
- @ManyToOne(type => Domain)
48
- @Field({ nullable: true })
49
- domain?: Domain
50
-
51
- @RelationId((accountingCategoryHistory: AccountingCategoryHistory) => accountingCategoryHistory.domain)
52
- domainId?: string
53
-
54
- @Column()
55
- @Field({ nullable: true, description: 'Account category code' })
56
- code?: string
57
-
58
- @Column()
59
- @Field({ nullable: true })
60
- name?: string
61
-
62
- @Column({ nullable: true })
63
- @Field({ nullable: true })
64
- description?: string
65
-
66
- @Column({ nullable: true })
67
- @Field({ nullable: true })
68
- active?: boolean
69
-
70
- @ManyToOne(type => AccountingCategoryHistory, accountingCategoryHistory => accountingCategoryHistory.children, {
71
- nullable: true
72
- })
73
- @Field({ nullable: true })
74
- parent?: AccountingCategoryHistory
75
-
76
- @RelationId((accountingCategoryHistory: AccountingCategoryHistory) => accountingCategoryHistory.parent)
77
- parentId?: string
78
-
79
- @OneToMany(type => AccountingCategoryHistory, accountingCategoryHistory => accountingCategoryHistory.parent)
80
- @Field(type => [AccountingCategoryHistory])
81
- children?: AccountingCategoryHistory[]
82
-
83
- @Column({ nullable: true })
84
- @Field({ nullable: true })
85
- createdAt?: Date
86
-
87
- @Column({ nullable: true })
88
- @Field({ nullable: true })
89
- updatedAt?: Date
90
-
91
- @Column({ nullable: true })
92
- @Field({ nullable: true })
93
- deletedAt?: Date
94
-
95
- @ManyToOne(type => User, { nullable: true })
96
- @Field(type => User, { nullable: true })
97
- creator?: User
98
-
99
- @RelationId((accountingCategory: AccountingCategoryHistory) => accountingCategory.creator)
100
- creatorId?: string
101
-
102
- @ManyToOne(type => User, { nullable: true })
103
- @Field(type => User, { nullable: true })
104
- updater?: User
105
-
106
- @RelationId((accountingCategory: AccountingCategoryHistory) => accountingCategory.updater)
107
- updaterId?: string
108
-
109
- @HistoryOriginalIdColumn()
110
- public originalId!: string
111
-
112
- @HistoryActionColumn({
113
- nullable: false,
114
- type:
115
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
116
- ? 'enum'
117
- : DATABASE_TYPE == 'oracle'
118
- ? 'varchar2'
119
- : DATABASE_TYPE == 'mssql'
120
- ? 'nvarchar'
121
- : 'varchar',
122
- enum:
123
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
124
- ? HistoryActionType
125
- : undefined,
126
- length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10
127
- })
128
- public action!: HistoryActionType
129
- }
@@ -1,148 +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 { AccountingCategory } from './accounting-category'
7
- import { NewAccountingCategory, AccountingCategoryPatch } from './accounting-category-type'
8
-
9
- @Resolver(AccountingCategory)
10
- export class AccountingCategoryMutation {
11
- @Directive('@transaction')
12
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
13
- @Mutation(returns => AccountingCategory, { description: 'To create new AccountingCategory' })
14
- async createAccountingCategory(
15
- @Arg('accountingCategory') accountingCategory: NewAccountingCategory,
16
- @Ctx() context: ResolverContext
17
- ): Promise<AccountingCategory> {
18
- const { domain, user, tx } = context.state
19
-
20
- const result = await getRepository(AccountingCategory, tx).save({
21
- ...accountingCategory,
22
- domain,
23
- creator: user,
24
- updater: user
25
- })
26
-
27
- return result
28
- }
29
-
30
- @Directive('@transaction')
31
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
32
- @Mutation(returns => AccountingCategory, { description: 'To modify AccountingCategory information' })
33
- async updateAccountingCategory(
34
- @Arg('id') id: string,
35
- @Arg('patch') patch: AccountingCategoryPatch,
36
- @Ctx() context: ResolverContext
37
- ): Promise<AccountingCategory> {
38
- const { domain, user, tx } = context.state
39
-
40
- const repository = getRepository(AccountingCategory, tx)
41
- const accountingCategory = await repository.findOne({
42
- where: { domain: { id: domain.id }, id }
43
- })
44
-
45
- const result = await repository.save({
46
- ...accountingCategory,
47
- ...patch,
48
- updater: user
49
- })
50
-
51
- return result
52
- }
53
-
54
- @Directive('@transaction')
55
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
56
- @Mutation(returns => [AccountingCategory], { description: "To modify multiple AccountingCategories' information" })
57
- async updateMultipleAccountingCategory(
58
- @Arg('patches', type => [AccountingCategoryPatch]) patches: AccountingCategoryPatch[],
59
- @Ctx() context: ResolverContext
60
- ): Promise<AccountingCategory[]> {
61
- const { domain, user, tx } = context.state
62
-
63
- let results = []
64
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
65
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
66
- const accountingCategoryRepo = getRepository(AccountingCategory, tx)
67
-
68
- if (_createRecords.length > 0) {
69
- for (let i = 0; i < _createRecords.length; i++) {
70
- const newRecord = _createRecords[i]
71
-
72
- const result = await accountingCategoryRepo.save({
73
- ...newRecord,
74
- domain,
75
- creator: user,
76
- updater: user
77
- })
78
-
79
- results.push({ ...result, cuFlag: '+' })
80
- }
81
- }
82
-
83
- if (_updateRecords.length > 0) {
84
- for (let i = 0; i < _updateRecords.length; i++) {
85
- const updateRecord = _updateRecords[i]
86
- const accountingCategory = await accountingCategoryRepo.findOneBy({ id: updateRecord.id })
87
-
88
- const result = await accountingCategoryRepo.save({
89
- ...accountingCategory,
90
- ...updateRecord,
91
- updater: user
92
- })
93
-
94
- results.push({ ...result, cuFlag: 'M' })
95
- }
96
- }
97
-
98
- return results
99
- }
100
-
101
- @Directive('@transaction')
102
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
103
- @Mutation(returns => Boolean, { description: 'To delete AccountingCategory' })
104
- async deleteAccountingCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
105
- const { domain, tx } = context.state
106
-
107
- await getRepository(AccountingCategory, tx).delete({ domain: { id: domain.id }, id })
108
-
109
- return true
110
- }
111
-
112
- @Directive('@transaction')
113
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
114
- @Mutation(returns => Boolean, { description: 'To delete multiple AccountingCategories' })
115
- async deleteAccountingCategories(
116
- @Arg('ids', type => [String]) ids: string[],
117
- @Ctx() context: ResolverContext
118
- ): Promise<boolean> {
119
- const { domain, tx } = context.state
120
-
121
- await getRepository(AccountingCategory, tx).delete({
122
- domain: { id: domain.id },
123
- id: In(ids)
124
- })
125
-
126
- return true
127
- }
128
-
129
- @Directive('@transaction')
130
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
131
- @Mutation(returns => Boolean, { description: 'To import multiple AccountingCategories' })
132
- async importAccountingCategories(
133
- @Arg('accountingCategories', type => [AccountingCategoryPatch]) accountingCategories: AccountingCategoryPatch[],
134
- @Ctx() context: ResolverContext
135
- ): Promise<boolean> {
136
- const { domain, tx } = context.state
137
-
138
- await Promise.all(
139
- accountingCategories.map(async (accountingCategory: AccountingCategoryPatch) => {
140
- const createdAccountingCategory: AccountingCategory = await tx
141
- .getRepository(AccountingCategory)
142
- .save({ domain, ...accountingCategory })
143
- })
144
- )
145
-
146
- return true
147
- }
148
- }
@@ -1,74 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
- import { IsNull } from 'typeorm'
3
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
- import { User } from '@things-factory/auth-base'
5
- import { AccountingCategory } from './accounting-category'
6
- import { AccountingCategoryList } from './accounting-category-type'
7
-
8
- @Resolver(AccountingCategory)
9
- export class AccountingCategoryQuery {
10
- @Directive('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)')
11
- @Query(returns => AccountingCategoryList, { nullable: true, description: 'To fetch a Root AccountingCategorys' })
12
- async accountingCategoryRoots(
13
- @Args(type => ListParam) params: ListParam,
14
- @Ctx() context: ResolverContext
15
- ): Promise<AccountingCategoryList> {
16
- const { domain } = context.state
17
-
18
- const queryBuilder = getQueryBuilderFromListParams({
19
- domain,
20
- params,
21
- repository: await getRepository(AccountingCategory),
22
- searchables: ['name', 'description', 'code']
23
- }).andWhere({ domain: { id: domain.id }, parent: { id: IsNull() } })
24
-
25
- const [items, total] = await queryBuilder.getManyAndCount()
26
-
27
- return { items, total }
28
- }
29
-
30
- @Directive('@privilege(category: "accounting", privilege: "query")')
31
- @Query(returns => AccountingCategory!, { nullable: true, description: 'To fetch a AccountingCategory' })
32
- async accountingCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<AccountingCategory> {
33
- const { domain } = context.state
34
-
35
- return await getRepository(AccountingCategory).findOne({
36
- where: { domain: { id: domain.id }, id }
37
- })
38
- }
39
-
40
- @Directive('@privilege(category: "accounting", privilege: "query")')
41
- @Query(returns => AccountingCategoryList, { description: 'To fetch multiple AccountingCategories' })
42
- async accountingCategories(
43
- @Args() params: ListParam,
44
- @Ctx() context: ResolverContext
45
- ): Promise<AccountingCategoryList> {
46
- const { domain } = context.state
47
-
48
- const queryBuilder = getQueryBuilderFromListParams({
49
- domain,
50
- params,
51
- repository: await getRepository(AccountingCategory),
52
- searchables: ['name', 'description']
53
- })
54
-
55
- const [items, total] = await queryBuilder.getManyAndCount()
56
-
57
- return { items, total }
58
- }
59
-
60
- @FieldResolver(type => Domain)
61
- async domain(@Root() accountingCategory: AccountingCategory): Promise<Domain> {
62
- return await getRepository(Domain).findOneBy({ id: accountingCategory.domainId })
63
- }
64
-
65
- @FieldResolver(type => User)
66
- async updater(@Root() accountingCategory: AccountingCategory): Promise<User> {
67
- return await getRepository(User).findOneBy({ id: accountingCategory.updaterId })
68
- }
69
-
70
- @FieldResolver(type => User)
71
- async creator(@Root() accountingCategory: AccountingCategory): Promise<User> {
72
- return await getRepository(User).findOneBy({ id: accountingCategory.creatorId })
73
- }
74
- }
@@ -1,48 +0,0 @@
1
- import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
2
-
3
- import { AccountingCategory } from './accounting-category'
4
-
5
- @InputType()
6
- export class NewAccountingCategory {
7
- @Field({ nullable: true, description: 'Account category code' })
8
- code: string
9
-
10
- @Field()
11
- name: string
12
-
13
- @Field({ nullable: true })
14
- description?: string
15
-
16
- @Field({ nullable: true })
17
- active?: boolean
18
- }
19
-
20
- @InputType()
21
- export class AccountingCategoryPatch {
22
- @Field(type => ID, { nullable: true })
23
- id?: string
24
-
25
- @Field({ nullable: true, description: 'Account category code' })
26
- code?: string
27
-
28
- @Field({ nullable: true })
29
- name?: string
30
-
31
- @Field({ nullable: true })
32
- description?: string
33
-
34
- @Field({ nullable: true })
35
- active?: boolean
36
-
37
- @Field({ nullable: true })
38
- cuFlag?: string
39
- }
40
-
41
- @ObjectType()
42
- export class AccountingCategoryList {
43
- @Field(type => [AccountingCategory])
44
- items: AccountingCategory[]
45
-
46
- @Field(type => Int)
47
- total: number
48
- }
@@ -1,100 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- DeleteDateColumn,
5
- Entity,
6
- Index,
7
- Column,
8
- RelationId,
9
- ManyToOne,
10
- OneToMany,
11
- PrimaryGeneratedColumn
12
- } from 'typeorm'
13
- import { ObjectType, Field, Int, ID } from 'type-graphql'
14
-
15
- import { Domain } from '@things-factory/shell'
16
- import { User } from '@things-factory/auth-base'
17
-
18
- @Entity()
19
- @Index(
20
- 'ix_accounting_category_0',
21
- (accountingCategory: AccountingCategory) => [accountingCategory.domain, accountingCategory.name],
22
- {
23
- unique: true,
24
- where: '"deleted_at" IS NULL'
25
- }
26
- )
27
- @Index(
28
- 'ix_accounting_category_1',
29
- (accountingCategory: AccountingCategory) => [accountingCategory.domain, accountingCategory.code],
30
- {
31
- unique: true,
32
- where: '"deleted_at" IS NULL'
33
- }
34
- )
35
- @ObjectType({ description: 'Entity for AccountingCategory' })
36
- export class AccountingCategory {
37
- @PrimaryGeneratedColumn('uuid')
38
- @Field(type => ID)
39
- readonly id: string
40
-
41
- @ManyToOne(type => Domain)
42
- @Field({ nullable: true })
43
- domain?: Domain
44
-
45
- @RelationId((accountingCategory: AccountingCategory) => accountingCategory.domain)
46
- domainId?: string
47
-
48
- @Column()
49
- @Field({ nullable: true, description: 'Account category code' })
50
- code?: string
51
-
52
- @Column()
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, accountingCategory => accountingCategory.children, { nullable: true })
65
- @Field({ nullable: true })
66
- parent?: AccountingCategory
67
-
68
- @RelationId((accountingCategory: AccountingCategory) => accountingCategory.parent)
69
- parentId?: string
70
-
71
- @OneToMany(type => AccountingCategory, accountingCategory => accountingCategory.parent)
72
- @Field(type => [AccountingCategory], { nullable: true })
73
- children?: AccountingCategory[]
74
-
75
- @CreateDateColumn()
76
- @Field({ nullable: true })
77
- createdAt?: Date
78
-
79
- @UpdateDateColumn()
80
- @Field({ nullable: true })
81
- updatedAt?: Date
82
-
83
- @ManyToOne(type => User, { nullable: true })
84
- @Field(type => User, { nullable: true })
85
- creator?: User
86
-
87
- @RelationId((accountingCategory: AccountingCategory) => accountingCategory.creator)
88
- creatorId?: string
89
-
90
- @ManyToOne(type => User, { nullable: true })
91
- @Field(type => User, { nullable: true })
92
- updater?: User
93
-
94
- @RelationId((accountingCategory: AccountingCategory) => accountingCategory.updater)
95
- updaterId?: string
96
-
97
- @DeleteDateColumn()
98
- @Field({ nullable: true })
99
- deletedAt?: Date
100
- }
@@ -1,20 +0,0 @@
1
- import { EventSubscriber } from 'typeorm'
2
-
3
- import { HistoryEntitySubscriber } from '@operato/typeorm-history'
4
-
5
- import { AccountingCategory } from './accounting-category'
6
- import { AccountingCategoryHistory } from './accounting-category-history'
7
-
8
- @EventSubscriber()
9
- export class AccountingCategoryHistoryEntitySubscriber extends HistoryEntitySubscriber<
10
- AccountingCategory,
11
- AccountingCategoryHistory
12
- > {
13
- public get entity() {
14
- return AccountingCategory
15
- }
16
-
17
- public get historyEntity() {
18
- return AccountingCategoryHistory
19
- }
20
- }