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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. package/package.json +5 -5
  2. package/client/activities/activity-book-edit.ts +0 -88
  3. package/client/activities/activity-book-view.ts +0 -88
  4. package/client/activities/activity-expense-edit.ts +0 -88
  5. package/client/activities/activity-expense-view.ts +0 -88
  6. package/client/bootstrap.ts +0 -10
  7. package/client/components/accounting-category-selector.ts +0 -136
  8. package/client/components/accounting-category-view.ts +0 -75
  9. package/client/grist-editors/grist-editor-accounting-category-object.ts +0 -83
  10. package/client/grist-editors/grist-renderer-accounting-category-object.ts +0 -13
  11. package/client/index.ts +0 -0
  12. package/client/pages/account/account-importer.ts +0 -97
  13. package/client/pages/account/account-list-page.ts +0 -364
  14. package/client/pages/accounting-category/accounting-category-importer.ts +0 -97
  15. package/client/pages/accounting-category/accounting-category-list-page.ts +0 -368
  16. package/client/pages/accounting-category/accounting-category-tree-page.ts +0 -338
  17. package/client/pages/accounting-document/accounting-document-importer.ts +0 -90
  18. package/client/pages/accounting-document/accounting-document-list-page.ts +0 -398
  19. package/client/pages/bank/bank-importer.ts +0 -90
  20. package/client/pages/bank/bank-list-page.ts +0 -398
  21. package/client/pages/bank-account/bank-account-importer.ts +0 -90
  22. package/client/pages/bank-account/bank-account-list-page.ts +0 -398
  23. package/client/pages/financial-institution/financial-institution-importer.ts +0 -90
  24. package/client/pages/financial-institution/financial-institution-list-page.ts +0 -398
  25. package/client/pages/financial-statement/financial-statement-importer.ts +0 -97
  26. package/client/pages/financial-statement/financial-statement-list-page.ts +0 -338
  27. package/client/pages/fiscal-month/fiscal-month-importer.ts +0 -90
  28. package/client/pages/fiscal-month/fiscal-month-list-page.ts +0 -398
  29. package/client/pages/fiscal-quarter/fiscal-quarter-importer.ts +0 -90
  30. package/client/pages/fiscal-quarter/fiscal-quarter-list-page.ts +0 -398
  31. package/client/pages/fiscal-year/fiscal-year-importer.ts +0 -90
  32. package/client/pages/fiscal-year/fiscal-year-list-page.ts +0 -398
  33. package/client/pages/income-statement/income-statement-importer.ts +0 -97
  34. package/client/pages/income-statement/income-statement-list-page.ts +0 -338
  35. package/client/pages/payment/payment-importer.ts +0 -90
  36. package/client/pages/payment/payment-list-page.ts +0 -398
  37. package/client/pages/transaction/transaction-importer.ts +0 -97
  38. package/client/pages/transaction/transaction-list-page.ts +0 -338
  39. package/client/route.ts +0 -35
  40. package/client/tsconfig.json +0 -13
  41. package/client/types/accounting-category.ts +0 -23
  42. package/client/types/index.ts +0 -1
  43. package/server/activities/activity-book.ts +0 -172
  44. package/server/activities/activity-expense.ts +0 -149
  45. package/server/activities/index.ts +0 -18
  46. package/server/controllers/index.ts +0 -1
  47. package/server/controllers/summary-statements.ts +0 -166
  48. package/server/index.ts +0 -6
  49. package/server/middlewares/index.ts +0 -3
  50. package/server/migrations/1725200507196-seed-fiscal-entities.ts +0 -106
  51. package/server/migrations/1725201467183-seed-accounts.ts +0 -339
  52. package/server/migrations/1725201567284-seed-country-codes.ts +0 -261
  53. package/server/migrations/1725201667385-seed-financial-institutions.ts +0 -348
  54. package/server/migrations/index.ts +0 -9
  55. package/server/routes.ts +0 -26
  56. package/server/service/account/account-history.ts +0 -117
  57. package/server/service/account/account-mutation.ts +0 -140
  58. package/server/service/account/account-query.ts +0 -51
  59. package/server/service/account/account-type.ts +0 -44
  60. package/server/service/account/account.ts +0 -97
  61. package/server/service/account/event-subscriber.ts +0 -17
  62. package/server/service/account/index.ts +0 -9
  63. package/server/service/accounting-category/accounting-category-history.ts +0 -129
  64. package/server/service/accounting-category/accounting-category-mutation.ts +0 -148
  65. package/server/service/accounting-category/accounting-category-query.ts +0 -74
  66. package/server/service/accounting-category/accounting-category-type.ts +0 -48
  67. package/server/service/accounting-category/accounting-category.ts +0 -100
  68. package/server/service/accounting-category/event-subscriber.ts +0 -20
  69. package/server/service/accounting-category/index.ts +0 -9
  70. package/server/service/accounting-document/accounting-document-history.ts +0 -123
  71. package/server/service/accounting-document/accounting-document-mutation.ts +0 -137
  72. package/server/service/accounting-document/accounting-document-query.ts +0 -48
  73. package/server/service/accounting-document/accounting-document-type.ts +0 -52
  74. package/server/service/accounting-document/accounting-document.ts +0 -93
  75. package/server/service/accounting-document/event-subscriber.ts +0 -17
  76. package/server/service/accounting-document/index.ts +0 -9
  77. package/server/service/bank-account/bank-account-history.ts +0 -149
  78. package/server/service/bank-account/bank-account-mutation.ts +0 -137
  79. package/server/service/bank-account/bank-account-query.ts +0 -48
  80. package/server/service/bank-account/bank-account-type.ts +0 -112
  81. package/server/service/bank-account/bank-account.ts +0 -142
  82. package/server/service/bank-account/event-subscriber.ts +0 -17
  83. package/server/service/bank-account/index.ts +0 -9
  84. package/server/service/common-type.ts +0 -12
  85. package/server/service/financial-institution/financial-institution-mutation.ts +0 -198
  86. package/server/service/financial-institution/financial-institution-query.ts +0 -62
  87. package/server/service/financial-institution/financial-institution-type.ts +0 -91
  88. package/server/service/financial-institution/financial-institution.ts +0 -122
  89. package/server/service/financial-institution/index.ts +0 -7
  90. package/server/service/financial-statement/event-subscriber.ts +0 -17
  91. package/server/service/financial-statement/financial-statement-history.ts +0 -129
  92. package/server/service/financial-statement/financial-statement-line-item.ts +0 -82
  93. package/server/service/financial-statement/financial-statement-mutation.ts +0 -148
  94. package/server/service/financial-statement/financial-statement-query.ts +0 -53
  95. package/server/service/financial-statement/financial-statement-type.ts +0 -51
  96. package/server/service/financial-statement/financial-statement.ts +0 -116
  97. package/server/service/financial-statement/index.ts +0 -10
  98. package/server/service/fiscal-month/fiscal-month-mutation.ts +0 -145
  99. package/server/service/fiscal-month/fiscal-month-query.ts +0 -58
  100. package/server/service/fiscal-month/fiscal-month-type.ts +0 -66
  101. package/server/service/fiscal-month/fiscal-month.ts +0 -84
  102. package/server/service/fiscal-month/index.ts +0 -7
  103. package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +0 -148
  104. package/server/service/fiscal-quarter/fiscal-quarter-query.ts +0 -60
  105. package/server/service/fiscal-quarter/fiscal-quarter-type.ts +0 -60
  106. package/server/service/fiscal-quarter/fiscal-quarter.ts +0 -80
  107. package/server/service/fiscal-quarter/index.ts +0 -7
  108. package/server/service/fiscal-year/fiscal-year-mutation.ts +0 -145
  109. package/server/service/fiscal-year/fiscal-year-query.ts +0 -53
  110. package/server/service/fiscal-year/fiscal-year-type.ts +0 -54
  111. package/server/service/fiscal-year/fiscal-year.ts +0 -76
  112. package/server/service/fiscal-year/index.ts +0 -7
  113. package/server/service/income-statement/event-subscriber.ts +0 -17
  114. package/server/service/income-statement/income-statement-history.ts +0 -133
  115. package/server/service/income-statement/income-statement-line-item.ts +0 -84
  116. package/server/service/income-statement/income-statement-mutation.ts +0 -147
  117. package/server/service/income-statement/income-statement-query.ts +0 -50
  118. package/server/service/income-statement/income-statement-type.ts +0 -51
  119. package/server/service/income-statement/income-statement.ts +0 -120
  120. package/server/service/income-statement/index.ts +0 -10
  121. package/server/service/index.ts +0 -108
  122. package/server/service/payment/event-subscriber.ts +0 -17
  123. package/server/service/payment/index.ts +0 -9
  124. package/server/service/payment/payment-history.ts +0 -155
  125. package/server/service/payment/payment-mutation.ts +0 -139
  126. package/server/service/payment/payment-query.ts +0 -50
  127. package/server/service/payment/payment-type.ts +0 -82
  128. package/server/service/payment/payment.ts +0 -154
  129. package/server/service/transaction/event-subscriber.ts +0 -17
  130. package/server/service/transaction/index.ts +0 -9
  131. package/server/service/transaction/transaction-history.ts +0 -161
  132. package/server/service/transaction/transaction-mutation.ts +0 -146
  133. package/server/service/transaction/transaction-query.ts +0 -50
  134. package/server/service/transaction/transaction-type.ts +0 -48
  135. package/server/service/transaction/transaction.ts +0 -230
  136. package/server/tsconfig.json +0 -10
@@ -1,108 +0,0 @@
1
- /* EXPORT ENTITY TYPES */
2
- export * from './income-statement/income-statement'
3
- export * from './financial-statement/financial-statement'
4
- export * from './accounting-category/accounting-category'
5
- export * from './transaction/transaction'
6
- export * from './payment/payment'
7
- export * from './account/account'
8
- export * from './accounting-document/accounting-document'
9
- export * from './fiscal-month/fiscal-month'
10
- export * from './fiscal-quarter/fiscal-quarter'
11
- export * from './fiscal-year/fiscal-year'
12
-
13
- /* IMPORT ENTITIES AND RESOLVERS */
14
- import {
15
- entities as IncomeStatementEntities,
16
- resolvers as IncomeStatementResolvers,
17
- subscribers as IncomeStatementSubscribers
18
- } from './income-statement'
19
- import {
20
- entities as FinancialStatementEntities,
21
- resolvers as FinancialStatementResolvers,
22
- subscribers as FinancialStatementSubscribers
23
- } from './financial-statement'
24
- import {
25
- entities as AccountingCategoryEntities,
26
- resolvers as AccountingCategoryResolvers,
27
- subscribers as AccountingCategorySubscribers
28
- } from './accounting-category'
29
- import {
30
- entities as TransactionEntities,
31
- resolvers as TransactionResolvers,
32
- subscribers as TransactionSubscribers
33
- } from './transaction'
34
- import {
35
- entities as PaymentEntities,
36
- resolvers as PaymentResolvers,
37
- subscribers as PaymentSubscribers
38
- } from './payment'
39
- import {
40
- entities as AccountEntities,
41
- resolvers as AccountResolvers,
42
- subscribers as AccountSubscribers
43
- } from './account'
44
- import {
45
- entities as AccountingDocumentEntities,
46
- resolvers as AccountingDocumentResolvers,
47
- subscribers as AccountingDocumentSubscribers
48
- } from './accounting-document'
49
- import {
50
- entities as FiscalMonthEntities,
51
- resolvers as FiscalMonthResolvers,
52
- subscribers as FiscalMonthSubscribers
53
- } from './fiscal-month'
54
- import {
55
- entities as FiscalQuarterEntities,
56
- resolvers as FiscalQuarterResolvers,
57
- subscribers as FiscalQuarterSubscribers
58
- } from './fiscal-quarter'
59
- import {
60
- entities as FiscalYearEntities,
61
- resolvers as FiscalYearResolvers,
62
- subscribers as FiscalYearSubscribers
63
- } from './fiscal-year'
64
-
65
- export const entities = [
66
- /* ENTITIES */
67
- ...IncomeStatementEntities,
68
- ...FinancialStatementEntities,
69
- ...AccountingCategoryEntities,
70
- ...TransactionEntities,
71
- ...AccountEntities,
72
- ...AccountingDocumentEntities,
73
- ...PaymentEntities,
74
- ...FiscalMonthEntities,
75
- ...FiscalQuarterEntities,
76
- ...FiscalYearEntities
77
- ]
78
-
79
- export const subscribers = [
80
- /* SUBSCRIBERS */
81
- ...IncomeStatementSubscribers,
82
- ...FinancialStatementSubscribers,
83
- ...AccountingCategorySubscribers,
84
- ...TransactionSubscribers,
85
- ...PaymentSubscribers,
86
- ...AccountSubscribers,
87
- ...AccountingDocumentSubscribers,
88
- ...FiscalYearSubscribers,
89
- ...FiscalMonthSubscribers,
90
- ...FiscalQuarterSubscribers,
91
- ...FiscalYearSubscribers
92
- ]
93
-
94
- export const schema = {
95
- resolverClasses: [
96
- /* RESOLVER CLASSES */
97
- ...IncomeStatementResolvers,
98
- ...FinancialStatementResolvers,
99
- ...AccountingCategoryResolvers,
100
- ...TransactionResolvers,
101
- ...PaymentResolvers,
102
- ...AccountResolvers,
103
- ...AccountingDocumentResolvers,
104
- ...FiscalMonthResolvers,
105
- ...FiscalQuarterResolvers,
106
- ...FiscalYearResolvers
107
- ]
108
- }
@@ -1,17 +0,0 @@
1
- import { EventSubscriber } from 'typeorm'
2
-
3
- import { HistoryEntitySubscriber } from '@operato/typeorm-history'
4
-
5
- import { Payment } from './payment'
6
- import { PaymentHistory } from './payment-history'
7
-
8
- @EventSubscriber()
9
- export class PaymentHistoryEntitySubscriber extends HistoryEntitySubscriber<Payment, PaymentHistory> {
10
- public get entity() {
11
- return Payment
12
- }
13
-
14
- public get historyEntity() {
15
- return PaymentHistory
16
- }
17
- }
@@ -1,9 +0,0 @@
1
- import { Payment } from './payment'
2
- import { PaymentHistory } from './payment-history'
3
- import { PaymentHistoryEntitySubscriber } from './event-subscriber'
4
- import { PaymentQuery } from './payment-query'
5
- import { PaymentMutation } from './payment-mutation'
6
-
7
- export const entities = [Payment, PaymentHistory]
8
- export const resolvers = [PaymentQuery, PaymentMutation]
9
- export const subscribers = [PaymentHistoryEntitySubscriber]
@@ -1,155 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'
3
-
4
- import {
5
- HistoryActionColumn,
6
- HistoryActionType,
7
- HistoryEntityInterface,
8
- HistoryOriginalIdColumn
9
- } from '@operato/typeorm-history'
10
- import { Role, User } from '@things-factory/auth-base'
11
- import { config } from '@things-factory/env'
12
- import { Domain } from '@things-factory/shell'
13
-
14
- import { Transaction } from '../transaction/transaction'
15
- import { Payment, PaymentDirection, PaymentType } from './payment'
16
- import { BankAccount } from 'service/bank-account/bank-account'
17
-
18
- const ORMCONFIG = config.get('ormconfig', {})
19
- const DATABASE_TYPE = ORMCONFIG.type
20
-
21
- @Entity()
22
- @Index(
23
- 'ix_payment_history_0',
24
- (paymentHistory: PaymentHistory) => [paymentHistory.originalId, paymentHistory.version],
25
- { unique: true }
26
- )
27
- @Index(
28
- 'ix_payment_history_1',
29
- (paymentHistory: PaymentHistory) => [paymentHistory.domain, paymentHistory.originalId, paymentHistory.version],
30
- { unique: true }
31
- )
32
- @ObjectType({ description: 'History Entity of Payment' })
33
- export class PaymentHistory implements HistoryEntityInterface<Payment> {
34
- @PrimaryGeneratedColumn('uuid')
35
- @Field(type => ID)
36
- readonly id: string
37
-
38
- @Column({ nullable: true, default: 1 })
39
- @Field({ nullable: true })
40
- version?: number = 1
41
-
42
- @ManyToOne(type => Domain)
43
- @Field({ nullable: true })
44
- domain?: Domain
45
-
46
- @RelationId((payment: Payment) => payment.domain)
47
- domainId?: string
48
-
49
- @ManyToOne(type => Transaction, transaction => transaction.payments)
50
- @Field(type => Transaction, { description: 'The transaction associated with this payment' })
51
- transaction: Transaction // 결제와 연결된 트랜잭션
52
-
53
- @RelationId((payment: Payment) => payment.transaction)
54
- transactionId: string // 연결된 트랜잭션의 ID
55
-
56
- @Column({ nullable: true })
57
- @Field({ nullable: true, description: 'The currency used in the payment' })
58
- currency?: string // 결제에 사용된 통화
59
-
60
- @Column({ nullable: false })
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
81
-
82
- @Column({ nullable: true })
83
- @Field({ nullable: true, description: 'Fiscal year in which the payment was made' })
84
- year?: number // 결제가 발생한 회계 연도
85
-
86
- @Column({ nullable: true })
87
- @Field({ nullable: true, description: 'Fiscal quarter in which the payment was made' })
88
- quarter?: number // 결제가 발생한 회계 분기
89
-
90
- @Column({ nullable: true })
91
- @Field({ nullable: true, description: 'Fiscal month in which the payment was made' })
92
- month?: number // 결제가 발생한 회계 월
93
-
94
- @Column({ nullable: false })
95
- @Field({ nullable: false, description: 'The date and time when the payment was made' })
96
- paidAt: Date // 결제가 이루어진 날짜 및 시간
97
-
98
- @Column({ nullable: false })
99
- @Field(type => PaymentDirection, { description: 'Direction of the payment (Incoming or Outgoing)' })
100
- direction: PaymentDirection // 결제 방향 (수금 또는 지출)
101
-
102
- @Column({ nullable: true })
103
- @Field({ nullable: true, description: 'Additional notes or comments about the payment' })
104
- note?: string // 결제에 대한 추가 설명 또는 메모
105
-
106
- @Column({ nullable: true })
107
- @Field({ nullable: true })
108
- createdAt?: Date
109
-
110
- @Column({ nullable: true })
111
- @Field({ nullable: true })
112
- updatedAt?: Date
113
-
114
- @Column({ nullable: true })
115
- @Field({ nullable: true })
116
- deletedAt?: Date
117
-
118
- @ManyToOne(type => User, { nullable: true })
119
- @Field(type => User, { nullable: true })
120
- creator?: User
121
-
122
- @RelationId((payment: Payment) => payment.creator)
123
- creatorId?: string
124
-
125
- @ManyToOne(type => User, { nullable: true })
126
- @Field(type => User, { nullable: true })
127
- updater?: User
128
-
129
- @RelationId((payment: Payment) => payment.updater)
130
- updaterId?: string
131
-
132
- @Field(type => String, { nullable: true })
133
- thumbnail?: string
134
-
135
- @HistoryOriginalIdColumn()
136
- public originalId!: string
137
-
138
- @HistoryActionColumn({
139
- nullable: false,
140
- type:
141
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
142
- ? 'enum'
143
- : DATABASE_TYPE == 'oracle'
144
- ? 'varchar2'
145
- : DATABASE_TYPE == 'mssql'
146
- ? 'nvarchar'
147
- : 'varchar',
148
- enum:
149
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
150
- ? HistoryActionType
151
- : undefined,
152
- length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10
153
- })
154
- public action!: HistoryActionType
155
- }
@@ -1,139 +0,0 @@
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 { Payment } from './payment'
6
- import { NewPayment, PaymentPatch } from './payment-type'
7
-
8
- @Resolver(Payment)
9
- export class PaymentMutation {
10
- @Directive('@transaction')
11
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
12
- @Mutation(returns => Payment, { description: 'To create new Payment' })
13
- async createPayment(@Arg('payment') payment: NewPayment, @Ctx() context: ResolverContext): Promise<Payment> {
14
- const { domain, user, tx } = context.state
15
-
16
- const result = await getRepository(Payment, tx).save({
17
- ...payment,
18
- domain,
19
- creator: user,
20
- updater: user
21
- })
22
-
23
- return result
24
- }
25
-
26
- @Directive('@transaction')
27
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
28
- @Mutation(returns => Payment, { description: 'To modify Payment information' })
29
- async updatePayment(
30
- @Arg('id') id: string,
31
- @Arg('patch') patch: PaymentPatch,
32
- @Ctx() context: ResolverContext
33
- ): Promise<Payment> {
34
- const { domain, user, tx } = context.state
35
-
36
- const repository = getRepository(Payment, tx)
37
- const payment = await repository.findOne({
38
- where: { domain: { id: domain.id }, id }
39
- })
40
-
41
- const result = await repository.save({
42
- ...payment,
43
- ...patch,
44
- updater: user
45
- })
46
-
47
- return result
48
- }
49
-
50
- @Directive('@transaction')
51
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
52
- @Mutation(returns => [Payment], { description: "To modify multiple Payments' information" })
53
- async updateMultiplePayment(
54
- @Arg('patches', type => [PaymentPatch]) patches: PaymentPatch[],
55
- @Ctx() context: ResolverContext
56
- ): Promise<Payment[]> {
57
- const { domain, user, tx } = context.state
58
-
59
- let results = []
60
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
61
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
62
- const paymentRepo = getRepository(Payment, tx)
63
-
64
- if (_createRecords.length > 0) {
65
- for (let i = 0; i < _createRecords.length; i++) {
66
- const newRecord = _createRecords[i]
67
-
68
- const result = await paymentRepo.save({
69
- ...newRecord,
70
- domain,
71
- creator: user,
72
- updater: user
73
- })
74
-
75
- results.push({ ...result, cuFlag: '+' })
76
- }
77
- }
78
-
79
- if (_updateRecords.length > 0) {
80
- for (let i = 0; i < _updateRecords.length; i++) {
81
- const updateRecord = _updateRecords[i]
82
- const payment = await paymentRepo.findOneBy({ id: updateRecord.id })
83
-
84
- const result = await paymentRepo.save({
85
- ...payment,
86
- ...updateRecord,
87
- updater: user
88
- })
89
-
90
- results.push({ ...result, cuFlag: 'M' })
91
- }
92
- }
93
-
94
- return results
95
- }
96
-
97
- @Directive('@transaction')
98
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
99
- @Mutation(returns => Boolean, { description: 'To delete Payment' })
100
- async deletePayment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
101
- const { domain, tx } = context.state
102
-
103
- await getRepository(Payment, tx).delete({ domain: { id: domain.id }, id })
104
-
105
- return true
106
- }
107
-
108
- @Directive('@transaction')
109
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
110
- @Mutation(returns => Boolean, { description: 'To delete multiple Payments' })
111
- async deletePayments(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
112
- const { domain, tx } = context.state
113
-
114
- await getRepository(Payment, tx).delete({
115
- domain: { id: domain.id },
116
- id: In(ids)
117
- })
118
-
119
- return true
120
- }
121
-
122
- @Directive('@transaction')
123
- @Directive('@privilege(category: "accounting", privilege: "mutation")')
124
- @Mutation(returns => Boolean, { description: 'To import multiple Payments' })
125
- async importPayments(
126
- @Arg('payments', type => [PaymentPatch]) payments: PaymentPatch[],
127
- @Ctx() context: ResolverContext
128
- ): Promise<boolean> {
129
- const { domain, tx } = context.state
130
-
131
- await Promise.all(
132
- payments.map(async (payment: PaymentPatch) => {
133
- const createdPayment: Payment = await getRepository(Payment, tx).save({ domain, ...payment })
134
- })
135
- )
136
-
137
- return true
138
- }
139
- }
@@ -1,50 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
3
- import { User } from '@things-factory/auth-base'
4
- import { Payment } from './payment'
5
- import { PaymentList } from './payment-type'
6
-
7
- @Resolver(Payment)
8
- export class PaymentQuery {
9
- @Directive('@privilege(category: "accounting", privilege: "query")')
10
- @Query(returns => Payment!, { nullable: true, description: 'To fetch a Payment' })
11
- async payment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Payment> {
12
- const { domain } = context.state
13
-
14
- return await getRepository(Payment).findOne({
15
- where: { domain: { id: domain.id }, id }
16
- })
17
- }
18
-
19
- @Directive('@privilege(category: "accounting", privilege: "query")')
20
- @Query(returns => PaymentList, { description: 'To fetch multiple Payments' })
21
- async payments(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<PaymentList> {
22
- const { domain } = context.state
23
-
24
- const queryBuilder = getQueryBuilderFromListParams({
25
- domain,
26
- params,
27
- repository: await getRepository(Payment),
28
- searchables: []
29
- })
30
-
31
- const [items, total] = await queryBuilder.getManyAndCount()
32
-
33
- return { items, total }
34
- }
35
-
36
- @FieldResolver(type => Domain)
37
- async domain(@Root() payment: Payment): Promise<Domain> {
38
- return payment.domainId && (await getRepository(Domain).findOneBy({ id: payment.domainId }))
39
- }
40
-
41
- @FieldResolver(type => User)
42
- async updater(@Root() payment: Payment): Promise<User> {
43
- return payment.updaterId && (await getRepository(User).findOneBy({ id: payment.updaterId }))
44
- }
45
-
46
- @FieldResolver(type => User)
47
- async creator(@Root() payment: Payment): Promise<User> {
48
- return payment.creatorId && (await getRepository(User).findOneBy({ id: payment.creatorId }))
49
- }
50
- }
@@ -1,82 +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 { Payment, PaymentDirection, PaymentType } from './payment'
8
-
9
- @InputType()
10
- export class NewPayment {
11
- @Field(type => ObjectRef)
12
- transaction: ObjectRef
13
-
14
- @Field({ nullable: true })
15
- currency?: string
16
-
17
- @Field({ nullable: false })
18
- amount: number
19
-
20
- @Field({ nullable: false })
21
- paidAt: Date
22
-
23
- @Field(type => PaymentDirection)
24
- direction: PaymentDirection
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
-
35
- @Field({ nullable: true })
36
- note?: string
37
- }
38
-
39
- @InputType()
40
- export class PaymentPatch {
41
- @Field(type => ID, { nullable: true })
42
- id?: string
43
-
44
- @Field(type => ObjectRef)
45
- transaction: ObjectRef
46
-
47
- @Field({ nullable: true })
48
- currency?: string
49
-
50
- @Field({ nullable: false })
51
- amount: number
52
-
53
- @Field({ nullable: false })
54
- paidAt: Date
55
-
56
- @Field(type => PaymentDirection)
57
- direction: PaymentDirection
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
-
68
- @Field({ nullable: true })
69
- note?: string
70
-
71
- @Field({ nullable: true })
72
- cuFlag?: string
73
- }
74
-
75
- @ObjectType()
76
- export class PaymentList {
77
- @Field(type => [Payment])
78
- items: Payment[]
79
-
80
- @Field(type => Int)
81
- total: number
82
- }