@things-factory/accounting 8.0.0-beta.1 → 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,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
- }