@things-factory/accounting 8.0.0-alpha.2 → 8.0.0-alpha.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/client/pages/bank/bank-importer.ts +90 -0
  2. package/client/pages/bank/bank-list-page.ts +398 -0
  3. package/client/pages/bank-account/bank-account-importer.ts +90 -0
  4. package/client/pages/bank-account/bank-account-list-page.ts +398 -0
  5. package/client/pages/financial-institution/financial-institution-importer.ts +90 -0
  6. package/client/pages/financial-institution/financial-institution-list-page.ts +398 -0
  7. package/dist-client/pages/bank/bank-importer.d.ts +23 -0
  8. package/dist-client/pages/bank/bank-importer.js +93 -0
  9. package/dist-client/pages/bank/bank-importer.js.map +1 -0
  10. package/dist-client/pages/bank/bank-list-page.d.ts +66 -0
  11. package/dist-client/pages/bank/bank-list-page.js +370 -0
  12. package/dist-client/pages/bank/bank-list-page.js.map +1 -0
  13. package/dist-client/pages/bank-account/bank-account-importer.d.ts +23 -0
  14. package/dist-client/pages/bank-account/bank-account-importer.js +93 -0
  15. package/dist-client/pages/bank-account/bank-account-importer.js.map +1 -0
  16. package/dist-client/pages/bank-account/bank-account-list-page.d.ts +66 -0
  17. package/dist-client/pages/bank-account/bank-account-list-page.js +370 -0
  18. package/dist-client/pages/bank-account/bank-account-list-page.js.map +1 -0
  19. package/dist-client/pages/financial-institution/financial-institution-importer.d.ts +23 -0
  20. package/dist-client/pages/financial-institution/financial-institution-importer.js +93 -0
  21. package/dist-client/pages/financial-institution/financial-institution-importer.js.map +1 -0
  22. package/dist-client/pages/financial-institution/financial-institution-list-page.d.ts +66 -0
  23. package/dist-client/pages/financial-institution/financial-institution-list-page.js +370 -0
  24. package/dist-client/pages/financial-institution/financial-institution-list-page.js.map +1 -0
  25. package/dist-client/tsconfig.tsbuildinfo +1 -1
  26. package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +5 -0
  27. package/dist-server/migrations/1725201567284-seed-country-codes.js +248 -0
  28. package/dist-server/migrations/1725201567284-seed-country-codes.js.map +1 -0
  29. package/dist-server/migrations/1725201667385-seed-financial-institutions.d.ts +5 -0
  30. package/dist-server/migrations/1725201667385-seed-financial-institutions.js +348 -0
  31. package/dist-server/migrations/1725201667385-seed-financial-institutions.js.map +1 -0
  32. package/dist-server/service/bank-account/bank-account-history.d.ts +34 -0
  33. package/dist-server/service/bank-account/bank-account-history.js +172 -0
  34. package/dist-server/service/bank-account/bank-account-history.js.map +1 -0
  35. package/dist-server/service/bank-account/bank-account-mutation.d.ts +10 -0
  36. package/dist-server/service/bank-account/bank-account-mutation.js +128 -0
  37. package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -0
  38. package/dist-server/service/bank-account/bank-account-query.d.ts +11 -0
  39. package/dist-server/service/bank-account/bank-account-query.js +79 -0
  40. package/dist-server/service/bank-account/bank-account-query.js.map +1 -0
  41. package/dist-server/service/bank-account/bank-account-type.d.ts +39 -0
  42. package/dist-server/service/bank-account/bank-account-type.js +153 -0
  43. package/dist-server/service/bank-account/bank-account-type.js.map +1 -0
  44. package/dist-server/service/bank-account/bank-account.d.ts +38 -0
  45. package/dist-server/service/bank-account/bank-account.js +164 -0
  46. package/dist-server/service/bank-account/bank-account.js.map +1 -0
  47. package/dist-server/service/bank-account/event-subscriber.d.ts +7 -0
  48. package/dist-server/service/bank-account/event-subscriber.js +21 -0
  49. package/dist-server/service/bank-account/event-subscriber.js.map +1 -0
  50. package/dist-server/service/bank-account/index.d.ts +7 -0
  51. package/dist-server/service/bank-account/index.js +12 -0
  52. package/dist-server/service/bank-account/index.js.map +1 -0
  53. package/dist-server/service/financial-institution/financial-institution-mutation.d.ts +10 -0
  54. package/dist-server/service/financial-institution/financial-institution-mutation.js +169 -0
  55. package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -0
  56. package/dist-server/service/financial-institution/financial-institution-query.d.ts +12 -0
  57. package/dist-server/service/financial-institution/financial-institution-query.js +97 -0
  58. package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -0
  59. package/dist-server/service/financial-institution/financial-institution-type.d.ts +32 -0
  60. package/dist-server/service/financial-institution/financial-institution-type.js +126 -0
  61. package/dist-server/service/financial-institution/financial-institution-type.js.map +1 -0
  62. package/dist-server/service/financial-institution/financial-institution.d.ts +34 -0
  63. package/dist-server/service/financial-institution/financial-institution.js +137 -0
  64. package/dist-server/service/financial-institution/financial-institution.js.map +1 -0
  65. package/dist-server/service/financial-institution/index.d.ts +6 -0
  66. package/dist-server/service/financial-institution/index.js +10 -0
  67. package/dist-server/service/financial-institution/index.js.map +1 -0
  68. package/dist-server/service/index.d.ts +1 -1
  69. package/dist-server/service/payment/index.d.ts +1 -2
  70. package/dist-server/service/payment/payment-history.d.ts +8 -1
  71. package/dist-server/service/payment/payment-history.js +41 -10
  72. package/dist-server/service/payment/payment-history.js.map +1 -1
  73. package/dist-server/service/payment/payment-type.d.ts +7 -1
  74. package/dist-server/service/payment/payment-type.js +24 -0
  75. package/dist-server/service/payment/payment-type.js.map +1 -1
  76. package/dist-server/service/payment/payment.d.ts +12 -0
  77. package/dist-server/service/payment/payment.js +36 -1
  78. package/dist-server/service/payment/payment.js.map +1 -1
  79. package/dist-server/tsconfig.tsbuildinfo +1 -1
  80. package/helps/accounting/bank-account.md +160 -0
  81. package/helps/accounting/bank.md +160 -0
  82. package/helps/accounting/financial-institution.md +160 -0
  83. package/package.json +5 -5
  84. package/server/migrations/1725201567284-seed-country-codes.ts +261 -0
  85. package/server/migrations/1725201667385-seed-financial-institutions.ts +348 -0
  86. package/server/service/bank-account/bank-account-history.ts +149 -0
  87. package/server/service/bank-account/bank-account-mutation.ts +137 -0
  88. package/server/service/bank-account/bank-account-query.ts +48 -0
  89. package/server/service/bank-account/bank-account-type.ts +112 -0
  90. package/server/service/bank-account/bank-account.ts +142 -0
  91. package/server/service/bank-account/event-subscriber.ts +17 -0
  92. package/server/service/bank-account/index.ts +9 -0
  93. package/server/service/financial-institution/financial-institution-mutation.ts +198 -0
  94. package/server/service/financial-institution/financial-institution-query.ts +62 -0
  95. package/server/service/financial-institution/financial-institution-type.ts +91 -0
  96. package/server/service/financial-institution/financial-institution.ts +122 -0
  97. package/server/service/financial-institution/index.ts +7 -0
  98. package/server/service/payment/payment-history.ts +41 -18
  99. package/server/service/payment/payment-type.ts +19 -1
  100. package/server/service/payment/payment.ts +31 -0
@@ -0,0 +1,198 @@
1
+ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+ import { getRepository } from '@things-factory/shell'
4
+
5
+ import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
6
+ import { FinancialInstitution } from './financial-institution'
7
+ import { NewFinancialInstitution, FinancialInstitutionPatch } from './financial-institution-type'
8
+
9
+ @Resolver(FinancialInstitution)
10
+ export class FinancialInstitutionMutation {
11
+ @Directive('@transaction')
12
+ @Mutation(returns => FinancialInstitution, { description: 'To create new FinancialInstitution' })
13
+ async createFinancialInstitution(@Arg('financialInstitution') financialInstitution: NewFinancialInstitution, @Ctx() context: ResolverContext): Promise<FinancialInstitution> {
14
+ const { domain, user, tx } = context.state
15
+
16
+ const result = await getRepository(FinancialInstitution, tx).save({
17
+ ...financialInstitution,
18
+ domain,
19
+ creator: user,
20
+ updater: user
21
+ })
22
+
23
+ if (financialInstitution.thumbnail) {
24
+ await createAttachment(
25
+ null,
26
+ {
27
+ attachment: {
28
+ file: financialInstitution.thumbnail,
29
+ refType: FinancialInstitution.name,
30
+ refBy: result.id
31
+ }
32
+ },
33
+ context
34
+ )
35
+ }
36
+
37
+ return result
38
+ }
39
+
40
+ @Directive('@transaction')
41
+ @Mutation(returns => FinancialInstitution, { description: 'To modify FinancialInstitution information' })
42
+ async updateFinancialInstitution(
43
+ @Arg('id') id: string,
44
+ @Arg('patch') patch: FinancialInstitutionPatch,
45
+ @Ctx() context: ResolverContext
46
+ ): Promise<FinancialInstitution> {
47
+ const { domain, user, tx } = context.state
48
+
49
+ const repository = getRepository(FinancialInstitution, tx)
50
+ const financialInstitution = await repository.findOne({
51
+ where: { domain: { id: domain.id }, id }
52
+ })
53
+
54
+ const result = await repository.save({
55
+ ...financialInstitution,
56
+ ...patch,
57
+ updater: user
58
+ })
59
+
60
+ if (patch.thumbnail) {
61
+ await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
62
+ await createAttachment(
63
+ null,
64
+ {
65
+ attachment: {
66
+ file: patch.thumbnail,
67
+ refType: FinancialInstitution.name,
68
+ refBy: result.id
69
+ }
70
+ },
71
+ context
72
+ )
73
+ }
74
+
75
+ return result
76
+ }
77
+
78
+ @Directive('@transaction')
79
+ @Mutation(returns => [FinancialInstitution], { description: "To modify multiple FinancialInstitutions' information" })
80
+ async updateMultipleFinancialInstitution(
81
+ @Arg('patches', type => [FinancialInstitutionPatch]) patches: FinancialInstitutionPatch[],
82
+ @Ctx() context: ResolverContext
83
+ ): Promise<FinancialInstitution[]> {
84
+ const { domain, user, tx } = context.state
85
+
86
+ let results = []
87
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
88
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
89
+ const financialInstitutionRepo = getRepository(FinancialInstitution, tx)
90
+
91
+ if (_createRecords.length > 0) {
92
+ for (let i = 0; i < _createRecords.length; i++) {
93
+ const newRecord = _createRecords[i]
94
+
95
+ const result = await financialInstitutionRepo.save({
96
+ ...newRecord,
97
+ domain,
98
+ creator: user,
99
+ updater: user
100
+ })
101
+
102
+ if (newRecord.thumbnail) {
103
+ await createAttachment(
104
+ null,
105
+ {
106
+ attachment: {
107
+ file: newRecord.thumbnail,
108
+ refType: FinancialInstitution.name,
109
+ refBy: result.id
110
+ }
111
+ },
112
+ context
113
+ )
114
+ }
115
+
116
+ results.push({ ...result, cuFlag: '+' })
117
+ }
118
+ }
119
+
120
+ if (_updateRecords.length > 0) {
121
+ for (let i = 0; i < _updateRecords.length; i++) {
122
+ const updateRecord = _updateRecords[i]
123
+ const financialInstitution = await financialInstitutionRepo.findOneBy({ id: updateRecord.id })
124
+
125
+ const result = await financialInstitutionRepo.save({
126
+ ...financialInstitution,
127
+ ...updateRecord,
128
+ updater: user
129
+ })
130
+
131
+ if (updateRecord.thumbnail) {
132
+ await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
133
+ await createAttachment(
134
+ null,
135
+ {
136
+ attachment: {
137
+ file: updateRecord.thumbnail,
138
+ refType: FinancialInstitution.name,
139
+ refBy: result.id
140
+ }
141
+ },
142
+ context
143
+ )
144
+ }
145
+
146
+ results.push({ ...result, cuFlag: 'M' })
147
+ }
148
+ }
149
+
150
+ return results
151
+ }
152
+
153
+ @Directive('@transaction')
154
+ @Mutation(returns => Boolean, { description: 'To delete FinancialInstitution' })
155
+ async deleteFinancialInstitution(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
156
+ const { domain, tx } = context.state
157
+
158
+ await getRepository(FinancialInstitution, tx).delete({ domain: { id: domain.id }, id })
159
+ await deleteAttachmentsByRef(null, { refBys: [id] }, context)
160
+
161
+ return true
162
+ }
163
+
164
+ @Directive('@transaction')
165
+ @Mutation(returns => Boolean, { description: 'To delete multiple FinancialInstitutions' })
166
+ async deleteFinancialInstitutions(
167
+ @Arg('ids', type => [String]) ids: string[],
168
+ @Ctx() context: ResolverContext
169
+ ): Promise<boolean> {
170
+ const { domain, tx } = context.state
171
+
172
+ await getRepository(FinancialInstitution, tx).delete({
173
+ domain: { id: domain.id },
174
+ id: In(ids)
175
+ })
176
+
177
+ await deleteAttachmentsByRef(null, { refBys: ids }, context)
178
+
179
+ return true
180
+ }
181
+
182
+ @Directive('@transaction')
183
+ @Mutation(returns => Boolean, { description: 'To import multiple FinancialInstitutions' })
184
+ async importFinancialInstitutions(
185
+ @Arg('financialInstitutions', type => [FinancialInstitutionPatch]) financialInstitutions: FinancialInstitutionPatch[],
186
+ @Ctx() context: ResolverContext
187
+ ): Promise<boolean> {
188
+ const { domain, tx } = context.state
189
+
190
+ await Promise.all(
191
+ financialInstitutions.map(async (financialInstitution: FinancialInstitutionPatch) => {
192
+ const createdFinancialInstitution: FinancialInstitution = await getRepository(FinancialInstitution, tx).save({ domain, ...financialInstitution })
193
+ })
194
+ )
195
+
196
+ return true
197
+ }
198
+ }
@@ -0,0 +1,62 @@
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
+ }
@@ -0,0 +1,91 @@
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
+ }
@@ -0,0 +1,122 @@
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
+ }
@@ -0,0 +1,7 @@
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 = []
@@ -12,7 +12,8 @@ import { config } from '@things-factory/env'
12
12
  import { Domain } from '@things-factory/shell'
13
13
 
14
14
  import { Transaction } from '../transaction/transaction'
15
- import { Payment, PaymentDirection } from './payment'
15
+ import { Payment, PaymentDirection, PaymentType } from './payment'
16
+ import { BankAccount } from 'service/bank-account/bank-account'
16
17
 
17
18
  const ORMCONFIG = config.get('ormconfig', {})
18
19
  const DATABASE_TYPE = ORMCONFIG.type
@@ -46,39 +47,61 @@ export class PaymentHistory implements HistoryEntityInterface<Payment> {
46
47
  domainId?: string
47
48
 
48
49
  @ManyToOne(type => Transaction, transaction => transaction.payments)
49
- @Field(type => Transaction)
50
- transaction: Transaction
50
+ @Field(type => Transaction, { description: 'The transaction associated with this payment' })
51
+ transaction: Transaction // 결제와 연결된 트랜잭션
51
52
 
52
53
  @RelationId((payment: Payment) => payment.transaction)
53
- transactionId: string
54
+ transactionId: string // 연결된 트랜잭션의 ID
55
+
56
+ @Column({ nullable: true })
57
+ @Field({ nullable: true, description: 'The currency used in the payment' })
58
+ currency?: string // 결제에 사용된 통화
54
59
 
55
60
  @Column({ nullable: false })
56
- @Field({ nullable: false })
57
- amount: number
61
+ @Field({ nullable: false, description: 'The amount of money involved in the payment' })
62
+ amount: number // 결제된 금액
63
+
64
+ @Column({ type: 'enum', enum: PaymentType, nullable: false })
65
+ @Field(type => PaymentType, { description: 'Type of the payment' })
66
+ paymentType: PaymentType // 결제 유형
67
+
68
+ @ManyToOne(type => BankAccount, { nullable: true })
69
+ @Field(type => BankAccount, { nullable: true, description: 'Source bank account for the payment' })
70
+ sourceBankAccount?: BankAccount
71
+
72
+ @RelationId((payment: Payment) => payment.sourceBankAccount)
73
+ sourceBankAccountId?: string
74
+
75
+ @ManyToOne(type => BankAccount, { nullable: true })
76
+ @Field(type => BankAccount, { nullable: true, description: 'Destination bank account for the payment' })
77
+ destinationBankAccount?: BankAccount
78
+
79
+ @RelationId((payment: Payment) => payment.destinationBankAccount)
80
+ destinationBankAccountId?: string
58
81
 
59
82
  @Column({ nullable: true })
60
- @Field({ nullable: true, description: 'fiscal year' })
61
- year?: number
83
+ @Field({ nullable: true, description: 'Fiscal year in which the payment was made' })
84
+ year?: number // 결제가 발생한 회계 연도
62
85
 
63
86
  @Column({ nullable: true })
64
- @Field({ nullable: true, description: 'fiscal quarter' })
65
- quarter?: number
87
+ @Field({ nullable: true, description: 'Fiscal quarter in which the payment was made' })
88
+ quarter?: number // 결제가 발생한 회계 분기
66
89
 
67
90
  @Column({ nullable: true })
68
- @Field({ nullable: true, description: 'fiscal month' })
69
- month?: number
91
+ @Field({ nullable: true, description: 'Fiscal month in which the payment was made' })
92
+ month?: number // 결제가 발생한 회계 월
70
93
 
71
94
  @Column({ nullable: false })
72
- @Field({ nullable: false })
73
- paidAt: Date
95
+ @Field({ nullable: false, description: 'The date and time when the payment was made' })
96
+ paidAt: Date // 결제가 이루어진 날짜 및 시간
74
97
 
75
98
  @Column({ nullable: false })
76
- @Field(type => PaymentDirection)
77
- direction: PaymentDirection
99
+ @Field(type => PaymentDirection, { description: 'Direction of the payment (Incoming or Outgoing)' })
100
+ direction: PaymentDirection // 결제 방향 (수금 또는 지출)
78
101
 
79
102
  @Column({ nullable: true })
80
- @Field({ nullable: true })
81
- note?: string
103
+ @Field({ nullable: true, description: 'Additional notes or comments about the payment' })
104
+ note?: string // 결제에 대한 추가 설명 또는 메모
82
105
 
83
106
  @Column({ nullable: true })
84
107
  @Field({ nullable: true })
@@ -4,7 +4,7 @@ import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-gr
4
4
 
5
5
  import { ObjectRef, ScalarObject } from '@things-factory/shell'
6
6
 
7
- import { Payment, PaymentDirection } from './payment'
7
+ import { Payment, PaymentDirection, PaymentType } from './payment'
8
8
 
9
9
  @InputType()
10
10
  export class NewPayment {
@@ -23,6 +23,15 @@ export class NewPayment {
23
23
  @Field(type => PaymentDirection)
24
24
  direction: PaymentDirection
25
25
 
26
+ @Field(type => PaymentType, { description: 'Type of the payment' })
27
+ paymentType: PaymentType // 결제 유형
28
+
29
+ @Field(type => ObjectRef, { nullable: true, description: 'Source bank account for the payment' })
30
+ sourceBankAccount?: ObjectRef
31
+
32
+ @Field(type => ObjectRef, { nullable: true, description: 'Destination bank account for the payment' })
33
+ destinationBankAccount?: ObjectRef
34
+
26
35
  @Field({ nullable: true })
27
36
  note?: string
28
37
  }
@@ -47,6 +56,15 @@ export class PaymentPatch {
47
56
  @Field(type => PaymentDirection)
48
57
  direction: PaymentDirection
49
58
 
59
+ @Field(type => PaymentType, { description: 'Type of the payment' })
60
+ paymentType: PaymentType // 결제 유형
61
+
62
+ @Field(type => ObjectRef, { nullable: true, description: 'Source bank account for the payment' })
63
+ sourceBankAccount?: ObjectRef
64
+
65
+ @Field(type => ObjectRef, { nullable: true, description: 'Destination bank account for the payment' })
66
+ destinationBankAccount?: ObjectRef
67
+
50
68
  @Field({ nullable: true })
51
69
  note?: string
52
70
 
@@ -15,6 +15,7 @@ import { ObjectType, Field, ID, registerEnumType } from 'type-graphql'
15
15
  import { Domain } from '@things-factory/shell'
16
16
  import { User } from '@things-factory/auth-base'
17
17
  import { Transaction } from '../transaction/transaction'
18
+ import { BankAccount } from 'service/bank-account/bank-account'
18
19
 
19
20
  export enum PaymentDirection {
20
21
  Incoming = 'Incoming', // 수금
@@ -26,6 +27,18 @@ registerEnumType(PaymentDirection, {
26
27
  description: 'Indicates whether the payment is incoming (received) or outgoing (paid)' // 결제 방향을 나타냅니다 (수금 또는 지출)
27
28
  })
28
29
 
30
+ export enum PaymentType {
31
+ Transfer = 'Transfer', // 계좌 이체
32
+ Cash = 'Cash', // 현금
33
+ CreditCard = 'CreditCard', // 신용카드
34
+ DebitCard = 'DebitCard' // 직불카드
35
+ }
36
+
37
+ registerEnumType(PaymentType, {
38
+ name: 'PaymentType',
39
+ description: 'Type of the payment (e.g., Transfer, Cash, CreditCard, DebitCard)' // 결제 유형을 나타냅니다
40
+ })
41
+
29
42
  @Entity()
30
43
  @Index('ix_payment_0', (payment: Payment) => [payment.domain, payment.transaction, payment.paidAt], {
31
44
  where: '"deleted_at" IS NULL',
@@ -71,6 +84,24 @@ export class Payment {
71
84
  @Field({ nullable: false, description: 'The amount of money involved in the payment' })
72
85
  amount: number // 결제된 금액
73
86
 
87
+ @Column({ type: 'enum', enum: PaymentType, nullable: false })
88
+ @Field(type => PaymentType, { description: 'Type of the payment' })
89
+ paymentType: PaymentType // 결제 유형
90
+
91
+ @ManyToOne(type => BankAccount, { nullable: true })
92
+ @Field(type => BankAccount, { nullable: true, description: 'Source bank account for the payment' })
93
+ sourceBankAccount?: BankAccount
94
+
95
+ @RelationId((payment: Payment) => payment.sourceBankAccount)
96
+ sourceBankAccountId?: string
97
+
98
+ @ManyToOne(type => BankAccount, { nullable: true })
99
+ @Field(type => BankAccount, { nullable: true, description: 'Destination bank account for the payment' })
100
+ destinationBankAccount?: BankAccount
101
+
102
+ @RelationId((payment: Payment) => payment.destinationBankAccount)
103
+ destinationBankAccountId?: string
104
+
74
105
  @Column({ nullable: true })
75
106
  @Field({ nullable: true, description: 'Fiscal year in which the payment was made' })
76
107
  year?: number // 결제가 발생한 회계 연도