@things-factory/accounting 8.0.0-beta.1 → 8.0.0-beta.4

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,62 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
- import { Attachment } from '@things-factory/attachment-base'
3
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
- import { User } from '@things-factory/auth-base'
5
- import { FinancialInstitution } from './financial-institution'
6
- import { FinancialInstitutionList } from './financial-institution-type'
7
-
8
- @Resolver(FinancialInstitution)
9
- export class FinancialInstitutionQuery {
10
- @Query(returns => FinancialInstitution!, { nullable: true, description: 'To fetch a FinancialInstitution' })
11
- async financialInstitution(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<FinancialInstitution> {
12
- const { domain } = context.state
13
-
14
- return await getRepository(FinancialInstitution).findOne({
15
- where: { domain: { id: domain.id }, id }
16
- })
17
- }
18
-
19
- @Query(returns => FinancialInstitutionList, { description: 'To fetch multiple FinancialInstitutions' })
20
- async financialInstitutions(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<FinancialInstitutionList> {
21
- const { domain } = context.state
22
-
23
- const queryBuilder = getQueryBuilderFromListParams({
24
- domain,
25
- params,
26
- repository: await getRepository(FinancialInstitution),
27
- searchables: ['name', 'description']
28
- })
29
-
30
- const [items, total] = await queryBuilder.getManyAndCount()
31
-
32
- return { items, total }
33
- }
34
-
35
- @FieldResolver(type => String)
36
- async thumbnail(@Root() financialInstitution: FinancialInstitution): Promise<string | undefined> {
37
- const attachment: Attachment = await getRepository(Attachment).findOne({
38
- where: {
39
- domain: { id: financialInstitution.domainId },
40
- refType: FinancialInstitution.name,
41
- refBy: financialInstitution.id
42
- }
43
- })
44
-
45
- return attachment?.fullpath
46
- }
47
-
48
- @FieldResolver(type => Domain)
49
- async domain(@Root() financialInstitution: FinancialInstitution): Promise<Domain> {
50
- return financialInstitution.domainId && (await getRepository(Domain).findOneBy({ id: financialInstitution.domainId }))
51
- }
52
-
53
- @FieldResolver(type => User)
54
- async updater(@Root() financialInstitution: FinancialInstitution): Promise<User> {
55
- return financialInstitution.updaterId && (await getRepository(User).findOneBy({ id: financialInstitution.updaterId }))
56
- }
57
-
58
- @FieldResolver(type => User)
59
- async creator(@Root() financialInstitution: FinancialInstitution): Promise<User> {
60
- return financialInstitution.creatorId && (await getRepository(User).findOneBy({ id: financialInstitution.creatorId }))
61
- }
62
- }
@@ -1,91 +0,0 @@
1
- import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
2
- import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
3
- import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
4
-
5
- import { ObjectRef, ScalarObject } from '@things-factory/shell'
6
-
7
- import { FinancialInstitution, FinancialInstitutionType } from './financial-institution'
8
-
9
- @InputType()
10
- export class NewFinancialInstitution {
11
- @Field()
12
- name: string
13
-
14
- @Field({ nullable: true })
15
- description?: string
16
-
17
- @Field(type => FinancialInstitutionType, {
18
- description: 'Type of the financial institution (e.g., Bank, Card Company, Insurance Company, etc.)'
19
- })
20
- type: FinancialInstitutionType
21
-
22
- @Field({ nullable: true, description: 'SWIFT code of the bank (if applicable)' })
23
- swiftCode?: string
24
-
25
- @Field({ nullable: true, description: 'Country of the financial institution' })
26
- country?: string
27
-
28
- @Field({ nullable: true, description: 'Contact number of the financial institution' })
29
- contactNumber?: string
30
-
31
- @Field({ nullable: true, description: 'Website of the financial institution' })
32
- website?: string
33
-
34
- @Field({ nullable: true, description: 'Address of the financial institution' })
35
- address?: string
36
-
37
- @Field({ nullable: true, description: 'Email of the financial institution' })
38
- email?: string
39
-
40
- @Field(type => GraphQLUpload, { nullable: true })
41
- thumbnail?: FileUpload
42
- }
43
-
44
- @InputType()
45
- export class FinancialInstitutionPatch {
46
- @Field(type => ID, { nullable: true })
47
- id?: string
48
-
49
- @Field({ nullable: true })
50
- name?: string
51
-
52
- @Field({ nullable: true })
53
- description?: string
54
-
55
- @Field(type => FinancialInstitutionType, {
56
- description: 'Type of the financial institution (e.g., Bank, Card Company, Insurance Company, etc.)'
57
- })
58
- type: FinancialInstitutionType
59
-
60
- @Field({ nullable: true, description: 'SWIFT code of the bank (if applicable)' })
61
- swiftCode?: string
62
-
63
- @Field({ nullable: true, description: 'Country of the financial institution' })
64
- country?: string
65
-
66
- @Field({ nullable: true, description: 'Contact number of the financial institution' })
67
- contactNumber?: string
68
-
69
- @Field({ nullable: true, description: 'Website of the financial institution' })
70
- website?: string
71
-
72
- @Field({ nullable: true, description: 'Address of the financial institution' })
73
- address?: string
74
-
75
- @Field({ nullable: true, description: 'Email of the financial institution' })
76
- email?: string
77
- @Field(type => GraphQLUpload, { nullable: true })
78
- thumbnail?: FileUpload
79
-
80
- @Field({ nullable: true })
81
- cuFlag?: string
82
- }
83
-
84
- @ObjectType()
85
- export class FinancialInstitutionList {
86
- @Field(type => [FinancialInstitution])
87
- items: FinancialInstitution[]
88
-
89
- @Field(type => Int)
90
- total: number
91
- }
@@ -1,122 +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, ID, registerEnumType } from 'type-graphql'
14
- import { Domain } from '@things-factory/shell'
15
- import { User } from '@things-factory/auth-base'
16
-
17
- export enum FinancialInstitutionType {
18
- Bank = 'Bank',
19
- CardCompany = 'CardCompany',
20
- InsuranceCompany = 'InsuranceCompany',
21
- InvestmentCompany = 'InvestmentCompany',
22
- SavingsBank = 'SavingsBank',
23
- CreditUnion = 'CreditUnion',
24
- LoanCompany = 'LoanCompany',
25
- SecuritiesFirm = 'SecuritiesFirm'
26
- }
27
-
28
- registerEnumType(FinancialInstitutionType, {
29
- name: 'FinancialInstitutionType',
30
- description: 'Type of the financial institution (e.g., Bank, Card Company, Insurance Company, etc.)'
31
- })
32
-
33
- @Entity()
34
- @Index(
35
- 'ix_financial_institution_0',
36
- (financialInstitution: FinancialInstitution) => [financialInstitution.domain, financialInstitution.name],
37
- {
38
- where: '"deleted_at" IS NULL',
39
- unique: true
40
- }
41
- )
42
- @ObjectType({ description: 'Entity for Financial Institution (e.g., Bank, Card Company, Insurance Company, etc.)' })
43
- export class FinancialInstitution {
44
- @PrimaryGeneratedColumn('uuid')
45
- @Field(type => ID)
46
- readonly id: string
47
-
48
- @ManyToOne(type => Domain)
49
- @Field({ nullable: true })
50
- domain?: Domain
51
-
52
- @RelationId((financialInstitution: FinancialInstitution) => financialInstitution.domain)
53
- domainId?: string
54
-
55
- @Column()
56
- @Field({ nullable: true })
57
- name?: string
58
-
59
- @Column({ nullable: true })
60
- @Field({ nullable: true })
61
- description?: string
62
-
63
- @Column({ type: 'enum', enum: FinancialInstitutionType })
64
- @Field(type => FinancialInstitutionType, {
65
- description: 'Type of the financial institution (e.g., Bank, Card Company, Insurance Company, etc.)'
66
- })
67
- type?: FinancialInstitutionType
68
-
69
- @Column({ nullable: true })
70
- @Field({ nullable: true, description: 'SWIFT code of the bank (if applicable)' })
71
- swiftCode?: string
72
-
73
- @Column({ nullable: true })
74
- @Field({ nullable: true, description: 'Country of the financial institution' })
75
- country?: string
76
-
77
- @Column({ nullable: true })
78
- @Field({ nullable: true, description: 'Contact number of the financial institution' })
79
- contactNumber?: string
80
-
81
- @Column({ nullable: true })
82
- @Field({ nullable: true, description: 'Website of the financial institution' })
83
- website?: string
84
-
85
- @Column({ nullable: true })
86
- @Field({ nullable: true, description: 'Address of the financial institution' })
87
- address?: string
88
-
89
- @Column({ nullable: true })
90
- @Field({ nullable: true, description: 'Email of the financial institution' })
91
- email?: string
92
-
93
- @CreateDateColumn()
94
- @Field({ nullable: true })
95
- createdAt?: Date
96
-
97
- @UpdateDateColumn()
98
- @Field({ nullable: true })
99
- updatedAt?: Date
100
-
101
- @DeleteDateColumn()
102
- @Field({ nullable: true })
103
- deletedAt?: Date
104
-
105
- @ManyToOne(type => User, { nullable: true })
106
- @Field(type => User, { nullable: true })
107
- creator?: User
108
-
109
- @RelationId((financialInstitution: FinancialInstitution) => financialInstitution.creator)
110
- creatorId?: string
111
-
112
- @ManyToOne(type => User, { nullable: true })
113
- @Field(type => User, { nullable: true })
114
- updater?: User
115
-
116
- @RelationId((financialInstitution: FinancialInstitution) => financialInstitution.updater)
117
- updaterId?: string
118
-
119
- @VersionColumn()
120
- @Field({ nullable: true })
121
- version?: number = 1
122
- }
@@ -1,7 +0,0 @@
1
- import { FinancialInstitution } from './financial-institution'
2
- import { FinancialInstitutionQuery } from './financial-institution-query'
3
- import { FinancialInstitutionMutation } from './financial-institution-mutation'
4
-
5
- export const entities = [FinancialInstitution]
6
- export const resolvers = [FinancialInstitutionQuery, FinancialInstitutionMutation]
7
- export const subscribers = []
@@ -1,17 +0,0 @@
1
- import { EventSubscriber } from 'typeorm'
2
-
3
- import { HistoryEntitySubscriber } from '@operato/typeorm-history'
4
-
5
- import { FinancialStatement } from './financial-statement'
6
- import { FinancialStatementHistory } from './financial-statement-history'
7
-
8
- @EventSubscriber()
9
- export class FinancialStatementHistoryEntitySubscriber extends HistoryEntitySubscriber<FinancialStatement, FinancialStatementHistory> {
10
- public get entity() {
11
- return FinancialStatement
12
- }
13
-
14
- public get historyEntity() {
15
- return FinancialStatementHistory
16
- }
17
- }
@@ -1,129 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Column, Entity, Index, ManyToOne, OneToMany, 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 { FinancialStatement } from './financial-statement'
15
- import { FinancialStatementLineItem } from './financial-statement-line-item'
16
-
17
- const ORMCONFIG = config.get('ormconfig', {})
18
- const DATABASE_TYPE = ORMCONFIG.type
19
-
20
- @Entity()
21
- @Index(
22
- 'ix_financial-statement_history_0',
23
- (financialStatementHistory: FinancialStatementHistory) => [
24
- financialStatementHistory.originalId,
25
- financialStatementHistory.version
26
- ],
27
- { unique: true }
28
- )
29
- @Index(
30
- 'ix_financial-statement_history_1',
31
- (financialStatementHistory: FinancialStatementHistory) => [
32
- financialStatementHistory.domain,
33
- financialStatementHistory.originalId,
34
- financialStatementHistory.version
35
- ],
36
- { unique: true }
37
- )
38
- @ObjectType({ description: 'History Entity of FinancialStatement' })
39
- export class FinancialStatementHistory implements HistoryEntityInterface<FinancialStatement> {
40
- @PrimaryGeneratedColumn('uuid')
41
- @Field(type => ID)
42
- readonly id: string
43
-
44
- @Column({ nullable: true, default: 1 })
45
- @Field({ nullable: true })
46
- version?: number = 1
47
-
48
- @ManyToOne(type => Domain)
49
- @Field({ nullable: true })
50
- domain?: Domain
51
-
52
- @RelationId((financialStatementHistory: FinancialStatementHistory) => financialStatementHistory.domain)
53
- domainId?: string
54
-
55
- @Column({ nullable: true })
56
- @Field({ nullable: true, description: 'Fiscal year of the financial statement' })
57
- year?: number // 회계 연도
58
-
59
- @Column({ nullable: true })
60
- @Field({ nullable: true, description: 'Fiscal quarter of the financial statement' })
61
- quarter?: number // 회계 분기
62
-
63
- @Column({ nullable: true })
64
- @Field({ nullable: true, description: 'Fiscal month of the financial statement' })
65
- month?: number // 회계 월
66
-
67
- @Column({ nullable: true })
68
- @Field({ nullable: true, description: 'Total assets recorded in the financial statement' })
69
- asset?: number // 재무제표에 기록된 총자산
70
-
71
- @Column({ nullable: true })
72
- @Field({ nullable: true, description: 'Total liabilities recorded in the financial statement' })
73
- liability?: number // 재무제표에 기록된 총부채
74
-
75
- @Column({ nullable: true })
76
- @Field({ nullable: true, description: 'Total equity recorded in the financial statement' })
77
- equity?: number // 재무제표에 기록된 총자본
78
-
79
- @OneToMany(type => FinancialStatementLineItem, lineItem => lineItem.statement)
80
- @Field(type => [FinancialStatementLineItem], { nullable: true })
81
- lineItems?: FinancialStatementLineItem[] // 계정별 브레이크다운
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({ nullable: true })
97
- creator?: User
98
-
99
- @RelationId((financialStatementHistory: FinancialStatementHistory) => financialStatementHistory.creator)
100
- creatorId?: string
101
-
102
- @ManyToOne(type => User, { nullable: true })
103
- @Field({ nullable: true })
104
- updater?: User
105
-
106
- @RelationId((financialStatementHistory: FinancialStatementHistory) => financialStatementHistory.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,82 +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, ID } from 'type-graphql'
14
-
15
- import { Domain } from '@things-factory/shell'
16
- import { User } from '@things-factory/auth-base'
17
- import { Account } from '../account/account'
18
- import { FinancialStatement } from './financial-statement'
19
-
20
- @ObjectType({ description: 'Line item for a financial statement, representing the breakdown of financial accounts' })
21
- @Entity()
22
- @Index(
23
- 'ix_financial_statement_line_item_0',
24
- (lineItem: FinancialStatementLineItem) => [lineItem.statement, lineItem.account],
25
- {
26
- unique: false,
27
- where: '"deleted_at" IS NULL'
28
- }
29
- )
30
- export class FinancialStatementLineItem {
31
- @PrimaryGeneratedColumn('uuid')
32
- @Field(type => ID)
33
- readonly id: string // 고유 식별자 (UUID)
34
-
35
- @ManyToOne(type => FinancialStatement, statement => statement.lineItems)
36
- @Field(type => FinancialStatement, { description: 'The financial statement this line item is associated with' })
37
- statement: FinancialStatement // 연결된 재무제표
38
-
39
- @RelationId((lineItem: FinancialStatementLineItem) => lineItem.statement)
40
- statementId: string // 재무제표의 ID
41
-
42
- @ManyToOne(type => Account)
43
- @Field(type => Account, { description: 'The financial account associated with this line item' })
44
- account: Account // 라인 아이템과 연결된 계정
45
-
46
- @RelationId((lineItem: FinancialStatementLineItem) => lineItem.account)
47
- accountId: string // 계정의 ID
48
-
49
- @Column({ nullable: false })
50
- @Field({ nullable: false, description: 'The monetary amount related to the financial account for this line item' })
51
- amount: number // 계정에 대한 금액
52
-
53
- @Column({ nullable: true })
54
- @Field({ nullable: true, description: 'Optional description or notes for this line item' })
55
- description?: string // 라인 아이템에 대한 선택적 설명 또는 메모
56
-
57
- @CreateDateColumn()
58
- @Field({ nullable: true, description: 'The date and time when this line item was created' })
59
- createdAt?: Date // 라인 아이템이 생성된 날짜 및 시간
60
-
61
- @UpdateDateColumn()
62
- @Field({ nullable: true, description: 'The date and time when this line item was last updated' })
63
- updatedAt?: Date // 라인 아이템이 마지막으로 업데이트된 날짜 및 시간
64
-
65
- @DeleteDateColumn()
66
- @Field({ nullable: true, description: 'The date and time when this line item was deleted' })
67
- deletedAt?: Date // 라인 아이템이 삭제된 날짜 및 시간
68
-
69
- @ManyToOne(type => User, { nullable: true })
70
- @Field(type => User, { nullable: true, description: 'The user who created this line item' })
71
- creator?: User // 라인 아이템을 생성한 사용자
72
-
73
- @RelationId((lineItem: FinancialStatementLineItem) => lineItem.creator)
74
- creatorId?: string // 생성자의 ID
75
-
76
- @ManyToOne(type => User, { nullable: true })
77
- @Field(type => User, { nullable: true, description: 'The user who last updated this line item' })
78
- updater?: User // 라인 아이템을 마지막으로 업데이트한 사용자
79
-
80
- @RelationId((lineItem: FinancialStatementLineItem) => lineItem.updater)
81
- updaterId?: string // 업데이트한 사용자의 ID
82
- }
@@ -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 { FinancialStatement } from './financial-statement'
7
- import { NewFinancialStatement, FinancialStatementPatch } from './financial-statement-type'
8
-
9
- @Resolver(FinancialStatement)
10
- export class FinancialStatementMutation {
11
- @Directive('@transaction')
12
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
13
- @Mutation(returns => FinancialStatement, { description: 'To create new FinancialStatement' })
14
- async createFinancialStatement(
15
- @Arg('financialStatement') financialStatement: NewFinancialStatement,
16
- @Ctx() context: ResolverContext
17
- ): Promise<FinancialStatement> {
18
- const { domain, user, tx } = context.state
19
-
20
- const result = await getRepository(FinancialStatement, tx).save({
21
- ...financialStatement,
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 => FinancialStatement, { description: 'To modify FinancialStatement information' })
33
- async updateFinancialStatement(
34
- @Arg('id') id: string,
35
- @Arg('patch') patch: FinancialStatementPatch,
36
- @Ctx() context: ResolverContext
37
- ): Promise<FinancialStatement> {
38
- const { domain, user, tx } = context.state
39
-
40
- const repository = getRepository(FinancialStatement, tx)
41
- const financialStatement = await repository.findOne({
42
- where: { domain: { id: domain.id }, id }
43
- })
44
-
45
- const result = await repository.save({
46
- ...financialStatement,
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 => [FinancialStatement], { description: "To modify multiple FinancialStatements' information" })
57
- async updateMultipleFinancialStatement(
58
- @Arg('patches', type => [FinancialStatementPatch]) patches: FinancialStatementPatch[],
59
- @Ctx() context: ResolverContext
60
- ): Promise<FinancialStatement[]> {
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 financialStatementRepo = getRepository(FinancialStatement, 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 financialStatementRepo.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 financialStatement = await financialStatementRepo.findOneBy({ id: updateRecord.id })
87
-
88
- const result = await financialStatementRepo.save({
89
- ...financialStatement,
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 FinancialStatement' })
104
- async deleteFinancialStatement(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
105
- const { domain, tx } = context.state
106
-
107
- await getRepository(FinancialStatement, 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 FinancialStatements' })
115
- async deleteFinancialStatements(
116
- @Arg('ids', type => [String]) ids: string[],
117
- @Ctx() context: ResolverContext
118
- ): Promise<boolean> {
119
- const { domain, tx } = context.state
120
-
121
- await getRepository(FinancialStatement, 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 FinancialStatements' })
132
- async importFinancialStatements(
133
- @Arg('financialStatements', type => [FinancialStatementPatch]) financialStatements: FinancialStatementPatch[],
134
- @Ctx() context: ResolverContext
135
- ): Promise<boolean> {
136
- const { domain, tx } = context.state
137
-
138
- await Promise.all(
139
- financialStatements.map(async (financialStatement: FinancialStatementPatch) => {
140
- const createdFinancialStatement: FinancialStatement = await tx
141
- .getRepository(FinancialStatement)
142
- .save({ domain, ...financialStatement })
143
- })
144
- )
145
-
146
- return true
147
- }
148
- }