@things-factory/accounting 7.0.2 → 8.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/client/activities/activity-book-edit.ts +1 -1
  2. package/client/activities/activity-book-view.ts +1 -1
  3. package/client/activities/activity-expense-edit.ts +1 -1
  4. package/client/activities/activity-expense-view.ts +1 -1
  5. package/client/pages/account/account-importer.ts +19 -8
  6. package/client/pages/account/account-list-page.ts +5 -6
  7. package/client/pages/accounting-category/accounting-category-importer.ts +19 -8
  8. package/client/pages/accounting-category/accounting-category-list-page.ts +5 -5
  9. package/client/pages/financial-statement/financial-statement-importer.ts +19 -8
  10. package/client/pages/financial-statement/financial-statement-list-page.ts +5 -6
  11. package/client/pages/fiscal-month/fiscal-month-importer.ts +90 -0
  12. package/client/pages/fiscal-month/fiscal-month-list-page.ts +398 -0
  13. package/client/pages/fiscal-quarter/fiscal-quarter-importer.ts +90 -0
  14. package/client/pages/fiscal-quarter/fiscal-quarter-list-page.ts +398 -0
  15. package/client/pages/fiscal-year/fiscal-year-importer.ts +90 -0
  16. package/client/pages/fiscal-year/fiscal-year-list-page.ts +398 -0
  17. package/client/pages/income-statement/income-statement-importer.ts +19 -8
  18. package/client/pages/income-statement/income-statement-list-page.ts +5 -6
  19. package/client/pages/ledger/ledger-importer.ts +19 -8
  20. package/client/pages/ledger/ledger-list-page.ts +5 -6
  21. package/client/pages/transaction/transaction-importer.ts +19 -8
  22. package/client/pages/transaction/transaction-list-page.ts +5 -6
  23. package/client/route.ts +17 -5
  24. package/dist-client/activities/activity-book-edit.js +1 -1
  25. package/dist-client/activities/activity-book-edit.js.map +1 -1
  26. package/dist-client/activities/activity-book-view.js +1 -1
  27. package/dist-client/activities/activity-book-view.js.map +1 -1
  28. package/dist-client/activities/activity-expense-edit.js +1 -1
  29. package/dist-client/activities/activity-expense-edit.js.map +1 -1
  30. package/dist-client/activities/activity-expense-view.js +1 -1
  31. package/dist-client/activities/activity-expense-view.js.map +1 -1
  32. package/dist-client/pages/account/account-importer.d.ts +0 -1
  33. package/dist-client/pages/account/account-importer.js +12 -5
  34. package/dist-client/pages/account/account-importer.js.map +1 -1
  35. package/dist-client/pages/account/account-list-page.js +5 -6
  36. package/dist-client/pages/account/account-list-page.js.map +1 -1
  37. package/dist-client/pages/accounting-category/accounting-category-importer.d.ts +0 -1
  38. package/dist-client/pages/accounting-category/accounting-category-importer.js +12 -5
  39. package/dist-client/pages/accounting-category/accounting-category-importer.js.map +1 -1
  40. package/dist-client/pages/accounting-category/accounting-category-list-page.js +5 -5
  41. package/dist-client/pages/accounting-category/accounting-category-list-page.js.map +1 -1
  42. package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +0 -1
  43. package/dist-client/pages/financial-statement/financial-statement-importer.js +12 -5
  44. package/dist-client/pages/financial-statement/financial-statement-importer.js.map +1 -1
  45. package/dist-client/pages/financial-statement/financial-statement-list-page.js +5 -6
  46. package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +1 -1
  47. package/dist-client/pages/fiscal-month/fiscal-month-importer.d.ts +23 -0
  48. package/dist-client/pages/fiscal-month/fiscal-month-importer.js +93 -0
  49. package/dist-client/pages/fiscal-month/fiscal-month-importer.js.map +1 -0
  50. package/dist-client/pages/fiscal-month/fiscal-month-list-page.d.ts +66 -0
  51. package/dist-client/pages/fiscal-month/fiscal-month-list-page.js +370 -0
  52. package/dist-client/pages/fiscal-month/fiscal-month-list-page.js.map +1 -0
  53. package/dist-client/pages/fiscal-quarter/fiscal-quarter-importer.d.ts +23 -0
  54. package/dist-client/pages/fiscal-quarter/fiscal-quarter-importer.js +93 -0
  55. package/dist-client/pages/fiscal-quarter/fiscal-quarter-importer.js.map +1 -0
  56. package/dist-client/pages/fiscal-quarter/fiscal-quarter-list-page.d.ts +66 -0
  57. package/dist-client/pages/fiscal-quarter/fiscal-quarter-list-page.js +370 -0
  58. package/dist-client/pages/fiscal-quarter/fiscal-quarter-list-page.js.map +1 -0
  59. package/dist-client/pages/fiscal-year/fiscal-year-importer.d.ts +23 -0
  60. package/dist-client/pages/fiscal-year/fiscal-year-importer.js +93 -0
  61. package/dist-client/pages/fiscal-year/fiscal-year-importer.js.map +1 -0
  62. package/dist-client/pages/fiscal-year/fiscal-year-list-page.d.ts +66 -0
  63. package/dist-client/pages/fiscal-year/fiscal-year-list-page.js +370 -0
  64. package/dist-client/pages/fiscal-year/fiscal-year-list-page.js.map +1 -0
  65. package/dist-client/pages/income-statement/income-statement-importer.d.ts +0 -1
  66. package/dist-client/pages/income-statement/income-statement-importer.js +12 -5
  67. package/dist-client/pages/income-statement/income-statement-importer.js.map +1 -1
  68. package/dist-client/pages/income-statement/income-statement-list-page.js +5 -6
  69. package/dist-client/pages/income-statement/income-statement-list-page.js.map +1 -1
  70. package/dist-client/pages/ledger/ledger-importer.d.ts +0 -1
  71. package/dist-client/pages/ledger/ledger-importer.js +12 -5
  72. package/dist-client/pages/ledger/ledger-importer.js.map +1 -1
  73. package/dist-client/pages/ledger/ledger-list-page.js +5 -6
  74. package/dist-client/pages/ledger/ledger-list-page.js.map +1 -1
  75. package/dist-client/pages/transaction/transaction-importer.d.ts +0 -1
  76. package/dist-client/pages/transaction/transaction-importer.js +12 -5
  77. package/dist-client/pages/transaction/transaction-importer.js.map +1 -1
  78. package/dist-client/pages/transaction/transaction-list-page.js +5 -6
  79. package/dist-client/pages/transaction/transaction-list-page.js.map +1 -1
  80. package/dist-client/route.d.ts +1 -1
  81. package/dist-client/route.js +9 -0
  82. package/dist-client/route.js.map +1 -1
  83. package/dist-client/tsconfig.tsbuildinfo +1 -1
  84. package/dist-server/controllers/index.d.ts +1 -0
  85. package/dist-server/controllers/index.js +4 -0
  86. package/dist-server/controllers/index.js.map +1 -1
  87. package/dist-server/controllers/summary-statements.d.ts +4 -0
  88. package/dist-server/controllers/summary-statements.js +143 -0
  89. package/dist-server/controllers/summary-statements.js.map +1 -0
  90. package/dist-server/index.d.ts +1 -0
  91. package/dist-server/index.js +1 -0
  92. package/dist-server/index.js.map +1 -1
  93. package/dist-server/migrations/1725200507196-seed-fiscal-entities.d.ts +5 -0
  94. package/dist-server/migrations/1725200507196-seed-fiscal-entities.js +95 -0
  95. package/dist-server/migrations/1725200507196-seed-fiscal-entities.js.map +1 -0
  96. package/dist-server/migrations/1725201467183-seed-accounts.d.ts +5 -0
  97. package/dist-server/migrations/1725201467183-seed-accounts.js +318 -0
  98. package/dist-server/migrations/1725201467183-seed-accounts.js.map +1 -0
  99. package/dist-server/routes.d.ts +1 -0
  100. package/dist-server/routes.js +1 -0
  101. package/dist-server/routes.js.map +1 -1
  102. package/dist-server/service/account/account-history.js +3 -3
  103. package/dist-server/service/account/account-history.js.map +1 -1
  104. package/dist-server/service/account/account-query.js +1 -1
  105. package/dist-server/service/account/account-query.js.map +1 -1
  106. package/dist-server/service/account/account.js +1 -1
  107. package/dist-server/service/account/account.js.map +1 -1
  108. package/dist-server/service/accounting-category/accounting-category-query.js +1 -1
  109. package/dist-server/service/accounting-category/accounting-category-query.js.map +1 -1
  110. package/dist-server/service/accounting-category/accounting-category-type.d.ts +2 -0
  111. package/dist-server/service/accounting-category/accounting-category-type.js +8 -0
  112. package/dist-server/service/accounting-category/accounting-category-type.js.map +1 -1
  113. package/dist-server/service/accounting-category/accounting-category.d.ts +1 -0
  114. package/dist-server/service/accounting-category/accounting-category.js +7 -1
  115. package/dist-server/service/accounting-category/accounting-category.js.map +1 -1
  116. package/dist-server/service/common-type.d.ts +5 -0
  117. package/dist-server/service/common-type.js +15 -0
  118. package/dist-server/service/common-type.js.map +1 -0
  119. package/dist-server/service/financial-statement/financial-statement-history.js +3 -3
  120. package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
  121. package/dist-server/service/financial-statement/financial-statement-query.js +1 -1
  122. package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
  123. package/dist-server/service/financial-statement/financial-statement.js +1 -1
  124. package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
  125. package/dist-server/service/fiscal-month/fiscal-month-mutation.d.ts +10 -0
  126. package/dist-server/service/fiscal-month/fiscal-month-mutation.js +128 -0
  127. package/dist-server/service/fiscal-month/fiscal-month-mutation.js.map +1 -0
  128. package/dist-server/service/fiscal-month/fiscal-month-query.d.ts +11 -0
  129. package/dist-server/service/fiscal-month/fiscal-month-query.js +81 -0
  130. package/dist-server/service/fiscal-month/fiscal-month-query.js.map +1 -0
  131. package/dist-server/service/fiscal-month/fiscal-month-type.d.ts +26 -0
  132. package/dist-server/service/fiscal-month/fiscal-month-type.js +98 -0
  133. package/dist-server/service/fiscal-month/fiscal-month-type.js.map +1 -0
  134. package/dist-server/service/fiscal-month/fiscal-month.d.ts +22 -0
  135. package/dist-server/service/fiscal-month/fiscal-month.js +99 -0
  136. package/dist-server/service/fiscal-month/fiscal-month.js.map +1 -0
  137. package/dist-server/service/fiscal-month/index.d.ts +6 -0
  138. package/dist-server/service/fiscal-month/index.js +10 -0
  139. package/dist-server/service/fiscal-month/index.js.map +1 -0
  140. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.d.ts +10 -0
  141. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.js +128 -0
  142. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.js.map +1 -0
  143. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.d.ts +11 -0
  144. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.js +83 -0
  145. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.js.map +1 -0
  146. package/dist-server/service/fiscal-quarter/fiscal-quarter-type.d.ts +24 -0
  147. package/dist-server/service/fiscal-quarter/fiscal-quarter-type.js +90 -0
  148. package/dist-server/service/fiscal-quarter/fiscal-quarter-type.js.map +1 -0
  149. package/dist-server/service/fiscal-quarter/fiscal-quarter.d.ts +21 -0
  150. package/dist-server/service/fiscal-quarter/fiscal-quarter.js +94 -0
  151. package/dist-server/service/fiscal-quarter/fiscal-quarter.js.map +1 -0
  152. package/dist-server/service/fiscal-quarter/index.d.ts +6 -0
  153. package/dist-server/service/fiscal-quarter/index.js +10 -0
  154. package/dist-server/service/fiscal-quarter/index.js.map +1 -0
  155. package/dist-server/service/fiscal-year/fiscal-year-mutation.d.ts +10 -0
  156. package/dist-server/service/fiscal-year/fiscal-year-mutation.js +128 -0
  157. package/dist-server/service/fiscal-year/fiscal-year-mutation.js.map +1 -0
  158. package/dist-server/service/fiscal-year/fiscal-year-query.d.ts +11 -0
  159. package/dist-server/service/fiscal-year/fiscal-year-query.js +79 -0
  160. package/dist-server/service/fiscal-year/fiscal-year-query.js.map +1 -0
  161. package/dist-server/service/fiscal-year/fiscal-year-type.d.ts +22 -0
  162. package/dist-server/service/fiscal-year/fiscal-year-type.js +82 -0
  163. package/dist-server/service/fiscal-year/fiscal-year-type.js.map +1 -0
  164. package/dist-server/service/fiscal-year/fiscal-year.d.ts +20 -0
  165. package/dist-server/service/fiscal-year/fiscal-year.js +89 -0
  166. package/dist-server/service/fiscal-year/fiscal-year.js.map +1 -0
  167. package/dist-server/service/fiscal-year/index.d.ts +6 -0
  168. package/dist-server/service/fiscal-year/index.js +10 -0
  169. package/dist-server/service/fiscal-year/index.js.map +1 -0
  170. package/dist-server/service/income-statement/income-statement-history.js +3 -3
  171. package/dist-server/service/income-statement/income-statement-history.js.map +1 -1
  172. package/dist-server/service/income-statement/income-statement-query.js +1 -1
  173. package/dist-server/service/income-statement/income-statement-query.js.map +1 -1
  174. package/dist-server/service/income-statement/income-statement.js +3 -3
  175. package/dist-server/service/income-statement/income-statement.js.map +1 -1
  176. package/dist-server/service/index.d.ts +5 -2
  177. package/dist-server/service/index.js +19 -3
  178. package/dist-server/service/index.js.map +1 -1
  179. package/dist-server/service/transaction/index.d.ts +1 -2
  180. package/dist-server/service/transaction/transaction-history.d.ts +10 -2
  181. package/dist-server/service/transaction/transaction-history.js +43 -6
  182. package/dist-server/service/transaction/transaction-history.js.map +1 -1
  183. package/dist-server/service/transaction/transaction-query.js +1 -1
  184. package/dist-server/service/transaction/transaction-query.js.map +1 -1
  185. package/dist-server/service/transaction/transaction.d.ts +8 -5
  186. package/dist-server/service/transaction/transaction.js +33 -10
  187. package/dist-server/service/transaction/transaction.js.map +1 -1
  188. package/dist-server/tsconfig.tsbuildinfo +1 -1
  189. package/helps/accounting/fiscal-month.md +160 -0
  190. package/helps/accounting/fiscal-quarter.md +160 -0
  191. package/helps/accounting/fiscal-year.md +160 -0
  192. package/package.json +9 -8
  193. package/server/controllers/index.ts +1 -0
  194. package/server/controllers/summary-statements.ts +160 -0
  195. package/server/index.ts +1 -0
  196. package/server/migrations/1725200507196-seed-fiscal-entities.ts +106 -0
  197. package/server/migrations/1725201467183-seed-accounts.ts +339 -0
  198. package/server/routes.ts +2 -0
  199. package/server/service/account/account-history.ts +5 -5
  200. package/server/service/account/account-query.ts +1 -1
  201. package/server/service/account/account.ts +1 -1
  202. package/server/service/accounting-category/accounting-category-query.ts +1 -1
  203. package/server/service/accounting-category/accounting-category-type.ts +6 -0
  204. package/server/service/accounting-category/accounting-category.ts +10 -1
  205. package/server/service/common-type.ts +12 -0
  206. package/server/service/financial-statement/financial-statement-history.ts +5 -5
  207. package/server/service/financial-statement/financial-statement-query.ts +1 -1
  208. package/server/service/financial-statement/financial-statement.ts +1 -1
  209. package/server/service/fiscal-month/fiscal-month-mutation.ts +137 -0
  210. package/server/service/fiscal-month/fiscal-month-query.ts +56 -0
  211. package/server/service/fiscal-month/fiscal-month-type.ts +66 -0
  212. package/server/service/fiscal-month/fiscal-month.ts +84 -0
  213. package/server/service/fiscal-month/index.ts +7 -0
  214. package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +137 -0
  215. package/server/service/fiscal-quarter/fiscal-quarter-query.ts +58 -0
  216. package/server/service/fiscal-quarter/fiscal-quarter-type.ts +60 -0
  217. package/server/service/fiscal-quarter/fiscal-quarter.ts +80 -0
  218. package/server/service/fiscal-quarter/index.ts +7 -0
  219. package/server/service/fiscal-year/fiscal-year-mutation.ts +137 -0
  220. package/server/service/fiscal-year/fiscal-year-query.ts +51 -0
  221. package/server/service/fiscal-year/fiscal-year-type.ts +54 -0
  222. package/server/service/fiscal-year/fiscal-year.ts +76 -0
  223. package/server/service/fiscal-year/index.ts +7 -0
  224. package/server/service/income-statement/income-statement-history.ts +5 -5
  225. package/server/service/income-statement/income-statement-query.ts +1 -4
  226. package/server/service/income-statement/income-statement.ts +3 -3
  227. package/server/service/index.ts +31 -3
  228. package/server/service/transaction/transaction-history.ts +35 -7
  229. package/server/service/transaction/transaction-query.ts +1 -4
  230. package/server/service/transaction/transaction.ts +34 -15
  231. package/things-factory.config.js +3 -1
@@ -0,0 +1,137 @@
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 { FiscalMonth } from './fiscal-month'
6
+ import { NewFiscalMonth, FiscalMonthPatch } from './fiscal-month-type'
7
+
8
+ @Resolver(FiscalMonth)
9
+ export class FiscalMonthMutation {
10
+ @Directive('@transaction')
11
+ @Mutation(returns => FiscalMonth, { description: 'To create new FiscalMonth' })
12
+ async createFiscalMonth(@Arg('fiscalMonth') fiscalMonth: NewFiscalMonth, @Ctx() context: ResolverContext): Promise<FiscalMonth> {
13
+ const { domain, user, tx } = context.state
14
+
15
+ const result = await getRepository(FiscalMonth, tx).save({
16
+ ...fiscalMonth,
17
+ domain,
18
+ creator: user,
19
+ updater: user
20
+ })
21
+
22
+ return result
23
+ }
24
+
25
+ @Directive('@transaction')
26
+ @Mutation(returns => FiscalMonth, { description: 'To modify FiscalMonth information' })
27
+ async updateFiscalMonth(
28
+ @Arg('id') id: string,
29
+ @Arg('patch') patch: FiscalMonthPatch,
30
+ @Ctx() context: ResolverContext
31
+ ): Promise<FiscalMonth> {
32
+ const { domain, user, tx } = context.state
33
+
34
+ const repository = getRepository(FiscalMonth, tx)
35
+ const fiscalMonth = await repository.findOne({
36
+ where: { domain: { id: domain.id }, id }
37
+ })
38
+
39
+ const result = await repository.save({
40
+ ...fiscalMonth,
41
+ ...patch,
42
+ updater: user
43
+ })
44
+
45
+ return result
46
+ }
47
+
48
+ @Directive('@transaction')
49
+ @Mutation(returns => [FiscalMonth], { description: "To modify multiple FiscalMonths' information" })
50
+ async updateMultipleFiscalMonth(
51
+ @Arg('patches', type => [FiscalMonthPatch]) patches: FiscalMonthPatch[],
52
+ @Ctx() context: ResolverContext
53
+ ): Promise<FiscalMonth[]> {
54
+ const { domain, user, tx } = context.state
55
+
56
+ let results = []
57
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
58
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
59
+ const fiscalMonthRepo = getRepository(FiscalMonth, tx)
60
+
61
+ if (_createRecords.length > 0) {
62
+ for (let i = 0; i < _createRecords.length; i++) {
63
+ const newRecord = _createRecords[i]
64
+
65
+ const result = await fiscalMonthRepo.save({
66
+ ...newRecord,
67
+ domain,
68
+ creator: user,
69
+ updater: user
70
+ })
71
+
72
+ results.push({ ...result, cuFlag: '+' })
73
+ }
74
+ }
75
+
76
+ if (_updateRecords.length > 0) {
77
+ for (let i = 0; i < _updateRecords.length; i++) {
78
+ const updateRecord = _updateRecords[i]
79
+ const fiscalMonth = await fiscalMonthRepo.findOneBy({ id: updateRecord.id })
80
+
81
+ const result = await fiscalMonthRepo.save({
82
+ ...fiscalMonth,
83
+ ...updateRecord,
84
+ updater: user
85
+ })
86
+
87
+ results.push({ ...result, cuFlag: 'M' })
88
+ }
89
+ }
90
+
91
+ return results
92
+ }
93
+
94
+ @Directive('@transaction')
95
+ @Mutation(returns => Boolean, { description: 'To delete FiscalMonth' })
96
+ async deleteFiscalMonth(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
97
+ const { domain, tx } = context.state
98
+
99
+ await getRepository(FiscalMonth, tx).delete({ domain: { id: domain.id }, id })
100
+
101
+ return true
102
+ }
103
+
104
+ @Directive('@transaction')
105
+ @Mutation(returns => Boolean, { description: 'To delete multiple FiscalMonths' })
106
+ async deleteFiscalMonths(
107
+ @Arg('ids', type => [String]) ids: string[],
108
+ @Ctx() context: ResolverContext
109
+ ): Promise<boolean> {
110
+ const { domain, tx } = context.state
111
+
112
+ await getRepository(FiscalMonth, tx).delete({
113
+ domain: { id: domain.id },
114
+ id: In(ids)
115
+ })
116
+
117
+
118
+ return true
119
+ }
120
+
121
+ @Directive('@transaction')
122
+ @Mutation(returns => Boolean, { description: 'To import multiple FiscalMonths' })
123
+ async importFiscalMonths(
124
+ @Arg('fiscalMonths', type => [FiscalMonthPatch]) fiscalMonths: FiscalMonthPatch[],
125
+ @Ctx() context: ResolverContext
126
+ ): Promise<boolean> {
127
+ const { domain, tx } = context.state
128
+
129
+ await Promise.all(
130
+ fiscalMonths.map(async (fiscalMonth: FiscalMonthPatch) => {
131
+ const createdFiscalMonth: FiscalMonth = await getRepository(FiscalMonth, tx).save({ domain, ...fiscalMonth })
132
+ })
133
+ )
134
+
135
+ return true
136
+ }
137
+ }
@@ -0,0 +1,56 @@
1
+ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
2
+ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
3
+ import { User } from '@things-factory/auth-base'
4
+ import { FiscalMonth } from './fiscal-month'
5
+ import { FiscalMonthList } from './fiscal-month-type'
6
+
7
+ @Resolver(FiscalMonth)
8
+ export class FiscalMonthQuery {
9
+ @Query(returns => FiscalMonth!, { nullable: true, description: 'To fetch a FiscalMonth by year, quarter, and month' })
10
+ async fiscalMonth(
11
+ @Arg('year') year: number,
12
+ @Arg('quarter') quarter: number,
13
+ @Arg('month') month: number,
14
+ @Ctx() context: ResolverContext
15
+ ): Promise<FiscalMonth | undefined> {
16
+ const { domain } = context.state
17
+
18
+ return await getRepository(FiscalMonth).findOne({
19
+ where: { domain: { id: domain.id }, year, quarter, month }
20
+ })
21
+ }
22
+
23
+ @Query(returns => FiscalMonthList, { description: 'To fetch multiple FiscalMonths' })
24
+ async fiscalMonths(
25
+ @Args(type => ListParam) params: ListParam,
26
+ @Ctx() context: ResolverContext
27
+ ): Promise<FiscalMonthList> {
28
+ const { domain } = context.state
29
+
30
+ const queryBuilder = getQueryBuilderFromListParams({
31
+ domain,
32
+ params,
33
+ repository: await getRepository(FiscalMonth),
34
+ searchables: []
35
+ })
36
+
37
+ const [items, total] = await queryBuilder.getManyAndCount()
38
+
39
+ return { items, total }
40
+ }
41
+
42
+ @FieldResolver(type => Domain)
43
+ async domain(@Root() fiscalMonth: FiscalMonth): Promise<Domain> {
44
+ return fiscalMonth.domainId && (await getRepository(Domain).findOneBy({ id: fiscalMonth.domainId }))
45
+ }
46
+
47
+ @FieldResolver(type => User)
48
+ async updater(@Root() fiscalMonth: FiscalMonth): Promise<User> {
49
+ return fiscalMonth.updaterId && (await getRepository(User).findOneBy({ id: fiscalMonth.updaterId }))
50
+ }
51
+
52
+ @FieldResolver(type => User)
53
+ async creator(@Root() fiscalMonth: FiscalMonth): Promise<User> {
54
+ return fiscalMonth.creatorId && (await getRepository(User).findOneBy({ id: fiscalMonth.creatorId }))
55
+ }
56
+ }
@@ -0,0 +1,66 @@
1
+ import { InputType, Field, Int, ID, ObjectType } from 'type-graphql'
2
+ import { FiscalStatus } from '../common-type'
3
+ import { FiscalMonth } from './fiscal-month'
4
+
5
+ @InputType()
6
+ export class NewFiscalMonth {
7
+ @Field(type => Int)
8
+ year: number // 회계연도 (예: 2023)
9
+
10
+ @Field(type => Int)
11
+ quarter: number // 1, 2, 3, 4 분기
12
+
13
+ @Field(type => Int)
14
+ month: number // 1 ~ 12월
15
+
16
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
17
+ startDate: string // 월의 시작일
18
+
19
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
20
+ endDate: string // 월의 종료일
21
+
22
+ @Field(type => FiscalStatus, { nullable: true })
23
+ status?: FiscalStatus // 월의 상태 (OPEN, CLOSED, FINALIZED)
24
+
25
+ @Field({ nullable: true })
26
+ notes?: string // 월에 대한 설명이나 주석
27
+ }
28
+
29
+ @InputType()
30
+ export class FiscalMonthPatch {
31
+ @Field(type => ID, { nullable: true })
32
+ id?: string
33
+
34
+ @Field(type => Int, { nullable: true })
35
+ year?: number // 회계연도 (예: 2023)
36
+
37
+ @Field(type => Int, { nullable: true })
38
+ quarter?: number // 1, 2, 3, 4 분기
39
+
40
+ @Field(type => Int, { nullable: true })
41
+ month?: number // 1 ~ 12월
42
+
43
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
44
+ startDate: string // 월의 시작일
45
+
46
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
47
+ endDate: string // 월의 종료일
48
+
49
+ @Field(type => FiscalStatus, { nullable: true })
50
+ status?: FiscalStatus // 월의 상태 (OPEN, CLOSED, FINALIZED)
51
+
52
+ @Field({ nullable: true })
53
+ notes?: string // 월에 대한 설명이나 주석
54
+
55
+ @Field({ nullable: true })
56
+ cuFlag?: string // Create/Update Flag
57
+ }
58
+
59
+ @ObjectType()
60
+ export class FiscalMonthList {
61
+ @Field(type => [FiscalMonth])
62
+ items: FiscalMonth[]
63
+
64
+ @Field(type => Int)
65
+ total: number
66
+ }
@@ -0,0 +1,84 @@
1
+ import {
2
+ CreateDateColumn,
3
+ DeleteDateColumn,
4
+ UpdateDateColumn,
5
+ Entity,
6
+ Index,
7
+ Column,
8
+ ManyToOne,
9
+ RelationId,
10
+ PrimaryGeneratedColumn
11
+ } from 'typeorm'
12
+ import { ObjectType, Field, Int, ID } from 'type-graphql'
13
+ import { Domain } from '@things-factory/shell'
14
+ import { User } from '@things-factory/auth-base'
15
+ import { FiscalStatus } from '../common-type'
16
+
17
+ @ObjectType({ description: 'Entity representing a fiscal month' })
18
+ @Entity()
19
+ export class FiscalMonth {
20
+ @PrimaryGeneratedColumn('uuid')
21
+ @Field(type => ID)
22
+ readonly id: string
23
+
24
+ @ManyToOne(type => Domain)
25
+ @Field({ nullable: true })
26
+ domain?: Domain
27
+
28
+ @RelationId((fiscalMonth: FiscalMonth) => fiscalMonth.domain)
29
+ domainId?: string
30
+
31
+ @Column()
32
+ @Field(type => Int, { description: 'The fiscal year (e.g., 2023)' })
33
+ year: number // 회계연도 (예: 2023)
34
+
35
+ @Column()
36
+ @Field(type => Int, { description: 'The quarter number (1, 2, 3, or 4)' })
37
+ quarter: number // 1, 2, 3, 4 분기
38
+
39
+ @Column()
40
+ @Field(type => Int, { description: 'The month number (1 to 12)' })
41
+ month: number // 1 ~ 12월
42
+
43
+ @Column()
44
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
45
+ startDate: string // 월의 시작일
46
+
47
+ @Column()
48
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
49
+ endDate: string // 월의 종료일
50
+
51
+ @Column({ type: 'enum', enum: FiscalStatus, default: FiscalStatus.OPEN })
52
+ @Field(type => FiscalStatus, { description: 'The status of the fiscal month (OPEN, CLOSED, FINALIZED)' })
53
+ status: FiscalStatus // 월의 상태 (OPEN, CLOSED, FINALIZED)
54
+
55
+ @Column({ nullable: true })
56
+ @Field({ nullable: true, description: 'Notes or comments about the fiscal month' })
57
+ notes?: string // 월에 대한 설명이나 주석
58
+
59
+ @CreateDateColumn()
60
+ @Field({ nullable: true })
61
+ createdAt?: Date
62
+
63
+ @UpdateDateColumn()
64
+ @Field({ nullable: true })
65
+ updatedAt?: Date
66
+
67
+ @DeleteDateColumn()
68
+ @Field({ nullable: true })
69
+ deletedAt?: Date
70
+
71
+ @ManyToOne(type => User, { nullable: true })
72
+ @Field(type => User, { nullable: true })
73
+ creator?: User
74
+
75
+ @RelationId((fiscalMonth: FiscalMonth) => fiscalMonth.creator)
76
+ creatorId?: string
77
+
78
+ @ManyToOne(type => User, { nullable: true })
79
+ @Field(type => User, { nullable: true })
80
+ updater?: User
81
+
82
+ @RelationId((fiscalMonth: FiscalMonth) => fiscalMonth.updater)
83
+ updaterId?: string
84
+ }
@@ -0,0 +1,7 @@
1
+ import { FiscalMonth } from './fiscal-month'
2
+ import { FiscalMonthQuery } from './fiscal-month-query'
3
+ import { FiscalMonthMutation } from './fiscal-month-mutation'
4
+
5
+ export const entities = [FiscalMonth]
6
+ export const resolvers = [FiscalMonthQuery, FiscalMonthMutation]
7
+ export const subscribers = []
@@ -0,0 +1,137 @@
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 { FiscalQuarter } from './fiscal-quarter'
6
+ import { NewFiscalQuarter, FiscalQuarterPatch } from './fiscal-quarter-type'
7
+
8
+ @Resolver(FiscalQuarter)
9
+ export class FiscalQuarterMutation {
10
+ @Directive('@transaction')
11
+ @Mutation(returns => FiscalQuarter, { description: 'To create new FiscalQuarter' })
12
+ async createFiscalQuarter(@Arg('fiscalQuarter') fiscalQuarter: NewFiscalQuarter, @Ctx() context: ResolverContext): Promise<FiscalQuarter> {
13
+ const { domain, user, tx } = context.state
14
+
15
+ const result = await getRepository(FiscalQuarter, tx).save({
16
+ ...fiscalQuarter,
17
+ domain,
18
+ creator: user,
19
+ updater: user
20
+ })
21
+
22
+ return result
23
+ }
24
+
25
+ @Directive('@transaction')
26
+ @Mutation(returns => FiscalQuarter, { description: 'To modify FiscalQuarter information' })
27
+ async updateFiscalQuarter(
28
+ @Arg('id') id: string,
29
+ @Arg('patch') patch: FiscalQuarterPatch,
30
+ @Ctx() context: ResolverContext
31
+ ): Promise<FiscalQuarter> {
32
+ const { domain, user, tx } = context.state
33
+
34
+ const repository = getRepository(FiscalQuarter, tx)
35
+ const fiscalQuarter = await repository.findOne({
36
+ where: { domain: { id: domain.id }, id }
37
+ })
38
+
39
+ const result = await repository.save({
40
+ ...fiscalQuarter,
41
+ ...patch,
42
+ updater: user
43
+ })
44
+
45
+ return result
46
+ }
47
+
48
+ @Directive('@transaction')
49
+ @Mutation(returns => [FiscalQuarter], { description: "To modify multiple FiscalQuarters' information" })
50
+ async updateMultipleFiscalQuarter(
51
+ @Arg('patches', type => [FiscalQuarterPatch]) patches: FiscalQuarterPatch[],
52
+ @Ctx() context: ResolverContext
53
+ ): Promise<FiscalQuarter[]> {
54
+ const { domain, user, tx } = context.state
55
+
56
+ let results = []
57
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
58
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
59
+ const fiscalQuarterRepo = getRepository(FiscalQuarter, tx)
60
+
61
+ if (_createRecords.length > 0) {
62
+ for (let i = 0; i < _createRecords.length; i++) {
63
+ const newRecord = _createRecords[i]
64
+
65
+ const result = await fiscalQuarterRepo.save({
66
+ ...newRecord,
67
+ domain,
68
+ creator: user,
69
+ updater: user
70
+ })
71
+
72
+ results.push({ ...result, cuFlag: '+' })
73
+ }
74
+ }
75
+
76
+ if (_updateRecords.length > 0) {
77
+ for (let i = 0; i < _updateRecords.length; i++) {
78
+ const updateRecord = _updateRecords[i]
79
+ const fiscalQuarter = await fiscalQuarterRepo.findOneBy({ id: updateRecord.id })
80
+
81
+ const result = await fiscalQuarterRepo.save({
82
+ ...fiscalQuarter,
83
+ ...updateRecord,
84
+ updater: user
85
+ })
86
+
87
+ results.push({ ...result, cuFlag: 'M' })
88
+ }
89
+ }
90
+
91
+ return results
92
+ }
93
+
94
+ @Directive('@transaction')
95
+ @Mutation(returns => Boolean, { description: 'To delete FiscalQuarter' })
96
+ async deleteFiscalQuarter(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
97
+ const { domain, tx } = context.state
98
+
99
+ await getRepository(FiscalQuarter, tx).delete({ domain: { id: domain.id }, id })
100
+
101
+ return true
102
+ }
103
+
104
+ @Directive('@transaction')
105
+ @Mutation(returns => Boolean, { description: 'To delete multiple FiscalQuarters' })
106
+ async deleteFiscalQuarters(
107
+ @Arg('ids', type => [String]) ids: string[],
108
+ @Ctx() context: ResolverContext
109
+ ): Promise<boolean> {
110
+ const { domain, tx } = context.state
111
+
112
+ await getRepository(FiscalQuarter, tx).delete({
113
+ domain: { id: domain.id },
114
+ id: In(ids)
115
+ })
116
+
117
+
118
+ return true
119
+ }
120
+
121
+ @Directive('@transaction')
122
+ @Mutation(returns => Boolean, { description: 'To import multiple FiscalQuarters' })
123
+ async importFiscalQuarters(
124
+ @Arg('fiscalQuarters', type => [FiscalQuarterPatch]) fiscalQuarters: FiscalQuarterPatch[],
125
+ @Ctx() context: ResolverContext
126
+ ): Promise<boolean> {
127
+ const { domain, tx } = context.state
128
+
129
+ await Promise.all(
130
+ fiscalQuarters.map(async (fiscalQuarter: FiscalQuarterPatch) => {
131
+ const createdFiscalQuarter: FiscalQuarter = await getRepository(FiscalQuarter, tx).save({ domain, ...fiscalQuarter })
132
+ })
133
+ )
134
+
135
+ return true
136
+ }
137
+ }
@@ -0,0 +1,58 @@
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 { FiscalQuarter } from './fiscal-quarter'
5
+ import { FiscalQuarterList } from './fiscal-quarter-type'
6
+
7
+ @Resolver(FiscalQuarter)
8
+ export class FiscalQuarterQuery {
9
+ @Query(returns => FiscalQuarter!, {
10
+ nullable: true,
11
+ description: 'To fetch a FiscalQuarter by year and quarter number'
12
+ })
13
+ async fiscalQuarter(
14
+ @Arg('year') year: number,
15
+ @Arg('quarter') quarter: number,
16
+ @Ctx() context: ResolverContext
17
+ ): Promise<FiscalQuarter | undefined> {
18
+ const { domain } = context.state
19
+
20
+ return await getRepository(FiscalQuarter).findOne({
21
+ where: { domain: { id: domain.id }, year, quarter }
22
+ })
23
+ }
24
+
25
+ @Query(returns => FiscalQuarterList, { description: 'To fetch multiple FiscalQuarters' })
26
+ async fiscalQuarters(
27
+ @Args(type => ListParam) params: ListParam,
28
+ @Ctx() context: ResolverContext
29
+ ): Promise<FiscalQuarterList> {
30
+ const { domain } = context.state
31
+
32
+ const queryBuilder = getQueryBuilderFromListParams({
33
+ domain,
34
+ params,
35
+ repository: await getRepository(FiscalQuarter),
36
+ searchables: []
37
+ })
38
+
39
+ const [items, total] = await queryBuilder.getManyAndCount()
40
+
41
+ return { items, total }
42
+ }
43
+
44
+ @FieldResolver(type => Domain)
45
+ async domain(@Root() fiscalQuarter: FiscalQuarter): Promise<Domain> {
46
+ return fiscalQuarter.domainId && (await getRepository(Domain).findOneBy({ id: fiscalQuarter.domainId }))
47
+ }
48
+
49
+ @FieldResolver(type => User)
50
+ async updater(@Root() fiscalQuarter: FiscalQuarter): Promise<User> {
51
+ return fiscalQuarter.updaterId && (await getRepository(User).findOneBy({ id: fiscalQuarter.updaterId }))
52
+ }
53
+
54
+ @FieldResolver(type => User)
55
+ async creator(@Root() fiscalQuarter: FiscalQuarter): Promise<User> {
56
+ return fiscalQuarter.creatorId && (await getRepository(User).findOneBy({ id: fiscalQuarter.creatorId }))
57
+ }
58
+ }
@@ -0,0 +1,60 @@
1
+ import { InputType, Field, Int, ID, ObjectType } from 'type-graphql'
2
+ import { FiscalStatus } from '../common-type'
3
+ import { FiscalQuarter } from './fiscal-quarter'
4
+
5
+ @InputType()
6
+ export class NewFiscalQuarter {
7
+ @Field(type => Int)
8
+ year: number // 회계연도 (예: 2023)
9
+
10
+ @Field(type => Int)
11
+ quarter: number // 1, 2, 3, 4 분기
12
+
13
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
14
+ startDate: string // 월의 시작일
15
+
16
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
17
+ endDate: string // 월의 종료일
18
+
19
+ @Field(type => FiscalStatus, { nullable: true })
20
+ status?: FiscalStatus // 분기의 상태 (OPEN, CLOSED, FINALIZED)
21
+
22
+ @Field({ nullable: true })
23
+ notes?: string // 분기에 대한 설명이나 주석
24
+ }
25
+
26
+ @InputType()
27
+ export class FiscalQuarterPatch {
28
+ @Field(type => ID, { nullable: true })
29
+ id?: string
30
+
31
+ @Field(type => Int, { nullable: true })
32
+ year?: number // 회계연도 (예: 2023)
33
+
34
+ @Field(type => Int, { nullable: true })
35
+ quarter?: number // 1, 2, 3, 4 분기
36
+
37
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
38
+ startDate: string // 월의 시작일
39
+
40
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
41
+ endDate: string // 월의 종료일
42
+
43
+ @Field(type => FiscalStatus, { nullable: true })
44
+ status?: FiscalStatus // 분기의 상태 (OPEN, CLOSED, FINALIZED)
45
+
46
+ @Field({ nullable: true })
47
+ notes?: string // 분기에 대한 설명이나 주석
48
+
49
+ @Field({ nullable: true })
50
+ cuFlag?: string // Create/Update Flag
51
+ }
52
+
53
+ @ObjectType()
54
+ export class FiscalQuarterList {
55
+ @Field(type => [FiscalQuarter])
56
+ items: FiscalQuarter[]
57
+
58
+ @Field(type => Int)
59
+ total: number
60
+ }
@@ -0,0 +1,80 @@
1
+ import {
2
+ CreateDateColumn,
3
+ DeleteDateColumn,
4
+ UpdateDateColumn,
5
+ Entity,
6
+ Index,
7
+ Column,
8
+ ManyToOne,
9
+ RelationId,
10
+ PrimaryGeneratedColumn
11
+ } from 'typeorm'
12
+ import { ObjectType, Field, Int, ID } from 'type-graphql'
13
+ import { Domain } from '@things-factory/shell'
14
+ import { User } from '@things-factory/auth-base'
15
+ import { FiscalStatus } from '../common-type'
16
+
17
+ @ObjectType({ description: 'Entity representing a fiscal quarter' })
18
+ @Entity()
19
+ export class FiscalQuarter {
20
+ @PrimaryGeneratedColumn('uuid')
21
+ @Field(type => ID)
22
+ readonly id: string
23
+
24
+ @ManyToOne(type => Domain)
25
+ @Field({ nullable: true })
26
+ domain?: Domain
27
+
28
+ @RelationId((fiscalQuarter: FiscalQuarter) => fiscalQuarter.domain)
29
+ domainId?: string
30
+
31
+ @Column()
32
+ @Field(type => Int, { description: 'The fiscal year (e.g., 2023)' })
33
+ year: number // 회계연도 (예: 2023)
34
+
35
+ @Column()
36
+ @Field(type => Int, { description: 'The quarter number (1, 2, 3, or 4)' })
37
+ quarter: number // 1, 2, 3, 4 분기
38
+
39
+ @Column()
40
+ @Field(type => String, { description: 'The start date of the fiscal quarter in YYYY-MM-DD format' })
41
+ startDate: string // 분기 시작일
42
+
43
+ @Column()
44
+ @Field(type => String, { description: 'The end date of the fiscal quarter in YYYY-MM-DD format' })
45
+ endDate: string // 분기 종료일
46
+
47
+ @Column({ type: 'enum', enum: FiscalStatus, default: FiscalStatus.OPEN })
48
+ @Field(type => FiscalStatus, { description: 'The status of the fiscal quarter (OPEN, CLOSED, FINALIZED)' })
49
+ status: FiscalStatus // 분기의 상태 (OPEN, CLOSED, FINALIZED)
50
+
51
+ @Column({ nullable: true })
52
+ @Field({ nullable: true, description: 'Notes or comments about the fiscal quarter' })
53
+ notes?: string // 분기에 대한 설명이나 주석
54
+
55
+ @CreateDateColumn()
56
+ @Field({ nullable: true })
57
+ createdAt?: Date
58
+
59
+ @UpdateDateColumn()
60
+ @Field({ nullable: true })
61
+ updatedAt?: Date
62
+
63
+ @DeleteDateColumn()
64
+ @Field({ nullable: true })
65
+ deletedAt?: Date
66
+
67
+ @ManyToOne(type => User, { nullable: true })
68
+ @Field(type => User, { nullable: true })
69
+ creator?: User
70
+
71
+ @RelationId((fiscalQuarter: FiscalQuarter) => fiscalQuarter.creator)
72
+ creatorId?: string
73
+
74
+ @ManyToOne(type => User, { nullable: true })
75
+ @Field(type => User, { nullable: true })
76
+ updater?: User
77
+
78
+ @RelationId((fiscalQuarter: FiscalQuarter) => fiscalQuarter.updater)
79
+ updaterId?: string
80
+ }
@@ -0,0 +1,7 @@
1
+ import { FiscalQuarter } from './fiscal-quarter'
2
+ import { FiscalQuarterQuery } from './fiscal-quarter-query'
3
+ import { FiscalQuarterMutation } from './fiscal-quarter-mutation'
4
+
5
+ export const entities = [FiscalQuarter]
6
+ export const resolvers = [FiscalQuarterQuery, FiscalQuarterMutation]
7
+ export const subscribers = []