@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 { FiscalYear } from './fiscal-year'
6
+ import { NewFiscalYear, FiscalYearPatch } from './fiscal-year-type'
7
+
8
+ @Resolver(FiscalYear)
9
+ export class FiscalYearMutation {
10
+ @Directive('@transaction')
11
+ @Mutation(returns => FiscalYear, { description: 'To create new FiscalYear' })
12
+ async createFiscalYear(@Arg('fiscalYear') fiscalYear: NewFiscalYear, @Ctx() context: ResolverContext): Promise<FiscalYear> {
13
+ const { domain, user, tx } = context.state
14
+
15
+ const result = await getRepository(FiscalYear, tx).save({
16
+ ...fiscalYear,
17
+ domain,
18
+ creator: user,
19
+ updater: user
20
+ })
21
+
22
+ return result
23
+ }
24
+
25
+ @Directive('@transaction')
26
+ @Mutation(returns => FiscalYear, { description: 'To modify FiscalYear information' })
27
+ async updateFiscalYear(
28
+ @Arg('id') id: string,
29
+ @Arg('patch') patch: FiscalYearPatch,
30
+ @Ctx() context: ResolverContext
31
+ ): Promise<FiscalYear> {
32
+ const { domain, user, tx } = context.state
33
+
34
+ const repository = getRepository(FiscalYear, tx)
35
+ const fiscalYear = await repository.findOne({
36
+ where: { domain: { id: domain.id }, id }
37
+ })
38
+
39
+ const result = await repository.save({
40
+ ...fiscalYear,
41
+ ...patch,
42
+ updater: user
43
+ })
44
+
45
+ return result
46
+ }
47
+
48
+ @Directive('@transaction')
49
+ @Mutation(returns => [FiscalYear], { description: "To modify multiple FiscalYears' information" })
50
+ async updateMultipleFiscalYear(
51
+ @Arg('patches', type => [FiscalYearPatch]) patches: FiscalYearPatch[],
52
+ @Ctx() context: ResolverContext
53
+ ): Promise<FiscalYear[]> {
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 fiscalYearRepo = getRepository(FiscalYear, 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 fiscalYearRepo.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 fiscalYear = await fiscalYearRepo.findOneBy({ id: updateRecord.id })
80
+
81
+ const result = await fiscalYearRepo.save({
82
+ ...fiscalYear,
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 FiscalYear' })
96
+ async deleteFiscalYear(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
97
+ const { domain, tx } = context.state
98
+
99
+ await getRepository(FiscalYear, tx).delete({ domain: { id: domain.id }, id })
100
+
101
+ return true
102
+ }
103
+
104
+ @Directive('@transaction')
105
+ @Mutation(returns => Boolean, { description: 'To delete multiple FiscalYears' })
106
+ async deleteFiscalYears(
107
+ @Arg('ids', type => [String]) ids: string[],
108
+ @Ctx() context: ResolverContext
109
+ ): Promise<boolean> {
110
+ const { domain, tx } = context.state
111
+
112
+ await getRepository(FiscalYear, 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 FiscalYears' })
123
+ async importFiscalYears(
124
+ @Arg('fiscalYears', type => [FiscalYearPatch]) fiscalYears: FiscalYearPatch[],
125
+ @Ctx() context: ResolverContext
126
+ ): Promise<boolean> {
127
+ const { domain, tx } = context.state
128
+
129
+ await Promise.all(
130
+ fiscalYears.map(async (fiscalYear: FiscalYearPatch) => {
131
+ const createdFiscalYear: FiscalYear = await getRepository(FiscalYear, tx).save({ domain, ...fiscalYear })
132
+ })
133
+ )
134
+
135
+ return true
136
+ }
137
+ }
@@ -0,0 +1,51 @@
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 { FiscalYear } from './fiscal-year'
5
+ import { FiscalYearList } from './fiscal-year-type'
6
+
7
+ @Resolver(FiscalYear)
8
+ export class FiscalYearQuery {
9
+ @Query(returns => FiscalYear!, { nullable: true, description: 'To fetch a FiscalYear by year' })
10
+ async fiscalYear(@Arg('year') year: number, @Ctx() context: ResolverContext): Promise<FiscalYear | undefined> {
11
+ const { domain } = context.state
12
+
13
+ return await getRepository(FiscalYear).findOne({
14
+ where: { domain: { id: domain.id }, year }
15
+ })
16
+ }
17
+
18
+ @Query(returns => FiscalYearList, { description: 'To fetch multiple FiscalYears' })
19
+ async fiscalYears(
20
+ @Args(type => ListParam) params: ListParam,
21
+ @Ctx() context: ResolverContext
22
+ ): Promise<FiscalYearList> {
23
+ const { domain } = context.state
24
+
25
+ const queryBuilder = getQueryBuilderFromListParams({
26
+ domain,
27
+ params,
28
+ repository: await getRepository(FiscalYear),
29
+ searchables: []
30
+ })
31
+
32
+ const [items, total] = await queryBuilder.getManyAndCount()
33
+
34
+ return { items, total }
35
+ }
36
+
37
+ @FieldResolver(type => Domain)
38
+ async domain(@Root() fiscalYear: FiscalYear): Promise<Domain> {
39
+ return fiscalYear.domainId && (await getRepository(Domain).findOneBy({ id: fiscalYear.domainId }))
40
+ }
41
+
42
+ @FieldResolver(type => User)
43
+ async updater(@Root() fiscalYear: FiscalYear): Promise<User> {
44
+ return fiscalYear.updaterId && (await getRepository(User).findOneBy({ id: fiscalYear.updaterId }))
45
+ }
46
+
47
+ @FieldResolver(type => User)
48
+ async creator(@Root() fiscalYear: FiscalYear): Promise<User> {
49
+ return fiscalYear.creatorId && (await getRepository(User).findOneBy({ id: fiscalYear.creatorId }))
50
+ }
51
+ }
@@ -0,0 +1,54 @@
1
+ import { InputType, ObjectType, Field, ID, Int } from 'type-graphql'
2
+ import { FiscalYear } from './fiscal-year'
3
+ import { FiscalStatus } from '../common-type'
4
+
5
+ @InputType()
6
+ export class NewFiscalYear {
7
+ @Field(type => Int)
8
+ year: number // 회계연도 (예: 2023)
9
+
10
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
11
+ startDate: string // 월의 시작일
12
+
13
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
14
+ endDate: string // 월의 종료일
15
+
16
+ @Field(type => FiscalStatus, { nullable: true })
17
+ status?: FiscalStatus // 회계연도의 상태 (OPEN, CLOSED, FINALIZED)
18
+
19
+ @Field({ nullable: true })
20
+ notes?: string // 회계연도에 대한 설명이나 주석
21
+ }
22
+
23
+ @InputType()
24
+ export class FiscalYearPatch {
25
+ @Field(type => ID, { nullable: true })
26
+ id?: string
27
+
28
+ @Field(type => Int, { nullable: true })
29
+ year?: number // 회계연도 (예: 2023)
30
+
31
+ @Field(type => String, { description: 'The start date of the fiscal month in YYYY-MM-DD format' })
32
+ startDate: string // 월의 시작일
33
+
34
+ @Field(type => String, { description: 'The end date of the fiscal month in YYYY-MM-DD format' })
35
+ endDate: string // 월의 종료일
36
+
37
+ @Field(type => FiscalStatus, { nullable: true })
38
+ status?: FiscalStatus // 회계연도의 상태 (OPEN, CLOSED, FINALIZED)
39
+
40
+ @Field({ nullable: true })
41
+ notes?: string // 회계연도에 대한 설명이나 주석
42
+
43
+ @Field({ nullable: true })
44
+ cuFlag?: string // Create/Update Flag
45
+ }
46
+
47
+ @ObjectType()
48
+ export class FiscalYearList {
49
+ @Field(type => [FiscalYear])
50
+ items: FiscalYear[]
51
+
52
+ @Field(type => Int)
53
+ total: number
54
+ }
@@ -0,0 +1,76 @@
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 year' })
18
+ @Entity()
19
+ export class FiscalYear {
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((fiscalYear: FiscalYear) => fiscalYear.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 => String, { description: 'The start date of the fiscal year in YYYY-MM-DD format' })
37
+ startDate: string // 회계연도 시작일
38
+
39
+ @Column()
40
+ @Field(type => String, { description: 'The end date of the fiscal year in YYYY-MM-DD format' })
41
+ endDate: string // 회계연도 종료일
42
+
43
+ @Column({ type: 'enum', enum: FiscalStatus, default: FiscalStatus.OPEN })
44
+ @Field(type => FiscalStatus, { description: 'The status of the fiscal year (OPEN, CLOSED, FINALIZED)' })
45
+ status: FiscalStatus // 회계연도의 상태 (OPEN, CLOSED, FINALIZED)
46
+
47
+ @Column({ nullable: true })
48
+ @Field({ nullable: true, description: 'Notes or comments about the fiscal year' })
49
+ notes?: string // 회계연도에 대한 설명이나 주석
50
+
51
+ @CreateDateColumn()
52
+ @Field({ nullable: true })
53
+ createdAt?: Date
54
+
55
+ @UpdateDateColumn()
56
+ @Field({ nullable: true })
57
+ updatedAt?: Date
58
+
59
+ @DeleteDateColumn()
60
+ @Field({ nullable: true })
61
+ deletedAt?: Date
62
+
63
+ @ManyToOne(type => User, { nullable: true })
64
+ @Field(type => User, { nullable: true })
65
+ creator?: User
66
+
67
+ @RelationId((fiscalYear: FiscalYear) => fiscalYear.creator)
68
+ creatorId?: string
69
+
70
+ @ManyToOne(type => User, { nullable: true })
71
+ @Field(type => User, { nullable: true })
72
+ updater?: User
73
+
74
+ @RelationId((fiscalYear: FiscalYear) => fiscalYear.updater)
75
+ updaterId?: string
76
+ }
@@ -0,0 +1,7 @@
1
+ import { FiscalYear } from './fiscal-year'
2
+ import { FiscalYearQuery } from './fiscal-year-query'
3
+ import { FiscalYearMutation } from './fiscal-year-mutation'
4
+
5
+ export const entities = [FiscalYear]
6
+ export const resolvers = [FiscalYearQuery, FiscalYearMutation]
7
+ export const subscribers = []
@@ -45,7 +45,7 @@ export class IncomeStatementHistory implements HistoryEntityInterface<IncomeStat
45
45
  version?: number = 1
46
46
 
47
47
  @ManyToOne(type => Domain)
48
- @Field(type => Domain)
48
+ @Field({ nullable: true })
49
49
  domain?: Domain
50
50
 
51
51
  @RelationId((incomeStatement: IncomeStatement) => incomeStatement.domain)
@@ -84,14 +84,14 @@ export class IncomeStatementHistory implements HistoryEntityInterface<IncomeStat
84
84
  deletedAt?: Date
85
85
 
86
86
  @ManyToOne(type => User, { nullable: true })
87
- @Field(type => User, { nullable: true })
87
+ @Field({ nullable: true })
88
88
  creator?: User
89
89
 
90
90
  @RelationId((incomeStatement: IncomeStatement) => incomeStatement.creator)
91
91
  creatorId?: string
92
92
 
93
93
  @ManyToOne(type => User, { nullable: true })
94
- @Field(type => User, { nullable: true })
94
+ @Field({ nullable: true })
95
95
  updater?: User
96
96
 
97
97
  @RelationId((incomeStatement: IncomeStatement) => incomeStatement.updater)
@@ -106,8 +106,8 @@ export class IncomeStatementHistory implements HistoryEntityInterface<IncomeStat
106
106
  DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
107
107
  ? 'enum'
108
108
  : DATABASE_TYPE == 'oracle'
109
- ? 'varchar2'
110
- : 'smallint',
109
+ ? 'varchar2'
110
+ : 'smallint',
111
111
  enum: HistoryActionType
112
112
  })
113
113
  public action!: HistoryActionType
@@ -16,10 +16,7 @@ export class IncomeStatementQuery {
16
16
  }
17
17
 
18
18
  @Query(returns => IncomeStatementList, { description: 'To fetch multiple IncomeStatements' })
19
- async incomeStatements(
20
- @Args(type => ListParam) params: ListParam,
21
- @Ctx() context: ResolverContext
22
- ): Promise<IncomeStatementList> {
19
+ async incomeStatements(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<IncomeStatementList> {
23
20
  const { domain } = context.state
24
21
 
25
22
  const queryBuilder = getQueryBuilderFromListParams({
@@ -30,7 +30,7 @@ registerEnumType(IncomeStatementStatus, {
30
30
  @Index(
31
31
  'ix_income_statement_0',
32
32
  (incomeStatement: IncomeStatement) => [incomeStatement.domain, incomeStatement.deletedAt],
33
- { unique: true }
33
+ { unique: false, where: '"deleted_at" IS NULL' }
34
34
  )
35
35
  @ObjectType({ description: 'Entity for IncomeStatement' })
36
36
  export class IncomeStatement {
@@ -43,7 +43,7 @@ export class IncomeStatement {
43
43
  version?: number = 1
44
44
 
45
45
  @ManyToOne(type => Domain)
46
- @Field(type => Domain)
46
+ @Field({ nullable: true })
47
47
  domain?: Domain
48
48
 
49
49
  @RelationId((incomeStatement: IncomeStatement) => incomeStatement.domain)
@@ -58,7 +58,7 @@ export class IncomeStatement {
58
58
  quarter?: number
59
59
 
60
60
  @Column({ nullable: true })
61
- @Field({ nullable: true })
61
+ @Field({ nullable: true, description: 'fiscal month' })
62
62
  month?: number
63
63
 
64
64
  @Column({ nullable: true })
@@ -4,6 +4,9 @@ export * from './financial-statement/financial-statement'
4
4
  export * from './accounting-category/accounting-category'
5
5
  export * from './transaction/transaction'
6
6
  export * from './account/account'
7
+ export * from './fiscal-month/fiscal-month'
8
+ export * from './fiscal-quarter/fiscal-quarter'
9
+ export * from './fiscal-year/fiscal-year'
7
10
 
8
11
  /* IMPORT ENTITIES AND RESOLVERS */
9
12
  import {
@@ -31,6 +34,21 @@ import {
31
34
  resolvers as AccountResolvers,
32
35
  subscribers as AccountSubscribers
33
36
  } from './account'
37
+ import {
38
+ entities as FiscalMonthEntities,
39
+ resolvers as FiscalMonthResolvers,
40
+ subscribers as FiscalMonthSubscribers
41
+ } from './fiscal-month'
42
+ import {
43
+ entities as FiscalQuarterEntities,
44
+ resolvers as FiscalQuarterResolvers,
45
+ subscribers as FiscalQuarterSubscribers
46
+ } from './fiscal-quarter'
47
+ import {
48
+ entities as FiscalYearEntities,
49
+ resolvers as FiscalYearResolvers,
50
+ subscribers as FiscalYearSubscribers
51
+ } from './fiscal-year'
34
52
 
35
53
  export const entities = [
36
54
  /* ENTITIES */
@@ -38,7 +56,10 @@ export const entities = [
38
56
  ...FinancialStatementEntities,
39
57
  ...AccountingCategoryEntities,
40
58
  ...TransactionEntities,
41
- ...AccountEntities
59
+ ...AccountEntities,
60
+ ...FiscalMonthEntities,
61
+ ...FiscalQuarterEntities,
62
+ ...FiscalYearEntities
42
63
  ]
43
64
 
44
65
  export const subscribers = [
@@ -47,7 +68,11 @@ export const subscribers = [
47
68
  ...FinancialStatementSubscribers,
48
69
  ...AccountingCategorySubscribers,
49
70
  ...TransactionSubscribers,
50
- ...AccountSubscribers
71
+ ...AccountSubscribers,
72
+ ...FiscalYearSubscribers,
73
+ ...FiscalMonthSubscribers,
74
+ ...FiscalQuarterSubscribers,
75
+ ...FiscalYearSubscribers
51
76
  ]
52
77
 
53
78
  export const schema = {
@@ -57,6 +82,9 @@ export const schema = {
57
82
  ...FinancialStatementResolvers,
58
83
  ...AccountingCategoryResolvers,
59
84
  ...TransactionResolvers,
60
- ...AccountResolvers
85
+ ...AccountResolvers,
86
+ ...FiscalMonthResolvers,
87
+ ...FiscalQuarterResolvers,
88
+ ...FiscalYearResolvers
61
89
  ]
62
90
  }
@@ -12,6 +12,7 @@ import { config } from '@things-factory/env'
12
12
  import { Domain } from '@things-factory/shell'
13
13
 
14
14
  import { Transaction, TransactionType } from './transaction'
15
+ import { Account } from '../account/account'
15
16
 
16
17
  const ORMCONFIG = config.get('ormconfig', {})
17
18
  const DATABASE_TYPE = ORMCONFIG.type
@@ -42,20 +43,28 @@ export class TransactionHistory implements HistoryEntityInterface<Transaction> {
42
43
  version?: number = 1
43
44
 
44
45
  @ManyToOne(type => Domain)
45
- @Field(type => Domain)
46
+ @Field({ nullable: true })
46
47
  domain?: Domain
47
48
 
48
49
  @RelationId((transaction: Transaction) => transaction.domain)
49
50
  domainId?: string
50
51
 
51
52
  @Column()
52
- @Field()
53
- name: string
53
+ @Field({ nullable: true })
54
+ name?: string
54
55
 
55
56
  @Column({ nullable: true })
56
57
  @Field({ nullable: true })
57
58
  description?: string
58
59
 
60
+ @Column({ nullable: true })
61
+ @Field({ nullable: true })
62
+ currency?: string
63
+
64
+ @Column({ nullable: true })
65
+ @Field({ nullable: true })
66
+ amount?: number = 0
67
+
59
68
  @Column({ nullable: true })
60
69
  @Field({ nullable: true })
61
70
  active?: boolean
@@ -64,19 +73,38 @@ export class TransactionHistory implements HistoryEntityInterface<Transaction> {
64
73
  @Field({ nullable: true })
65
74
  type?: TransactionType
66
75
 
67
- @Column({ nullable: true })
76
+ @ManyToOne(type => Account)
68
77
  @Field({ nullable: true })
69
- params?: string
78
+ account?: Account
79
+
80
+ @RelationId((transaction: Transaction) => transaction.account)
81
+ accountId?: string
70
82
 
71
83
  @Column({ nullable: true })
84
+ @Field({ nullable: true, description: 'fiscal year' })
85
+ year?: number
86
+
87
+ @Column({ nullable: true })
88
+ @Field({ nullable: true, description: 'fiscal quarter' })
89
+ quarter?: number
90
+
91
+ @Column({ nullable: true })
92
+ @Field({ nullable: true, description: 'fiscal month' })
93
+ month?: number
94
+
95
+ @Column({ type: 'timestamp', nullable: false })
96
+ @Field({ nullable: false, description: 'The exact date and time the transaction occurred' })
97
+ occurredAt: Date // 트랜잭션이 발생한 실제 시점(날짜와 시간)
98
+
99
+ @Column()
72
100
  @Field({ nullable: true })
73
101
  createdAt?: Date
74
102
 
75
- @Column({ nullable: true })
103
+ @Column()
76
104
  @Field({ nullable: true })
77
105
  updatedAt?: Date
78
106
 
79
- @Column({ nullable: true })
107
+ @Column()
80
108
  @Field({ nullable: true })
81
109
  deletedAt?: Date
82
110
 
@@ -16,10 +16,7 @@ export class TransactionQuery {
16
16
  }
17
17
 
18
18
  @Query(returns => TransactionList, { description: 'To fetch multiple Transactions' })
19
- async transactions(
20
- @Args(type => ListParam) params: ListParam,
21
- @Ctx() context: ResolverContext
22
- ): Promise<TransactionList> {
19
+ async transactions(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<TransactionList> {
23
20
  const { domain } = context.state
24
21
 
25
22
  const queryBuilder = getQueryBuilderFromListParams({
@@ -17,25 +17,32 @@ import { User } from '@things-factory/auth-base'
17
17
  import { Account } from '../account/account'
18
18
 
19
19
  export enum TransactionType {
20
- Income, // 회사가 받은 돈을 나타냅니다. 예를 들어, 제품 판매 수익 등이 해당됩니다.
21
- Expense, // 회사가 지불한 돈을 나타냅니다. 예를 들어, 임금, 재고 구매 비용, 건물 임대료 등이 해당됩니다.
22
- Asset, // 회사가 소유한 자산을 나타냅니다. 예를 들어, 토지, 건물, 차량 등이 해당됩니다.
23
- Liability, // 회사가 지불해야 하는 부채를 나타냅니다. 예를 들어, 대출, 미지급금 등이 해당됩니다.
24
- Equity // 회사의 자본을 나타냅니다. 예를 들어, 자본금, 이익 잉여금 등이 해당됩니다.
20
+ Income,
21
+ Expense,
22
+ Asset,
23
+ Liability,
24
+ Equity
25
25
  }
26
26
 
27
27
  registerEnumType(TransactionType, {
28
28
  name: 'TransactionType',
29
- description: 'type enumeration of a transaction'
29
+ description: 'Type enumeration of a transaction'
30
30
  })
31
31
 
32
+ @ObjectType({ description: 'Entity for Transaction' })
32
33
  @Entity()
34
+ @Index('ix_transaction_0', (transaction: Transaction) => [transaction.domain, transaction.occurredAt], {
35
+ unique: true,
36
+ where: '"deleted_at" IS NULL'
37
+ })
33
38
  @Index(
34
- 'ix_transaction_0',
35
- (transaction: Transaction) => [transaction.domain, transaction.name, transaction.deletedAt],
36
- { unique: true }
39
+ 'ix_transaction_1',
40
+ (transaction: Transaction) => [transaction.domain, transaction.year, transaction.quarter, transaction.month],
41
+ {
42
+ unique: true,
43
+ where: '"deleted_at" IS NULL'
44
+ }
37
45
  )
38
- @ObjectType({ description: 'Entity for Transaction' })
39
46
  export class Transaction {
40
47
  @PrimaryGeneratedColumn('uuid')
41
48
  @Field(type => ID)
@@ -46,7 +53,7 @@ export class Transaction {
46
53
  version?: number = 1
47
54
 
48
55
  @ManyToOne(type => Domain)
49
- @Field(type => Domain)
56
+ @Field({ nullable: true })
50
57
  domain?: Domain
51
58
 
52
59
  @RelationId((transaction: Transaction) => transaction.domain)
@@ -60,10 +67,6 @@ export class Transaction {
60
67
  @Field({ nullable: true })
61
68
  description?: string
62
69
 
63
- @Column({ nullable: true })
64
- @Field({ nullable: true })
65
- date?: Date
66
-
67
70
  @Column({ nullable: true })
68
71
  @Field({ nullable: true })
69
72
  currency?: string
@@ -87,6 +90,22 @@ export class Transaction {
87
90
  @RelationId((transaction: Transaction) => transaction.account)
88
91
  accountId?: string
89
92
 
93
+ @Column({ nullable: true })
94
+ @Field({ nullable: true, description: 'fiscal year' })
95
+ year?: number
96
+
97
+ @Column({ nullable: true })
98
+ @Field({ nullable: true, description: 'fiscal quarter' })
99
+ quarter?: number
100
+
101
+ @Column({ nullable: true })
102
+ @Field({ nullable: true, description: 'fiscal month' })
103
+ month?: number
104
+
105
+ @Column({ type: 'timestamp', nullable: false })
106
+ @Field({ nullable: false, description: 'The exact date and time the transaction occurred' })
107
+ occurredAt: Date // 트랜잭션이 발생한 실제 시점(날짜와 시간)
108
+
90
109
  @CreateDateColumn()
91
110
  @Field({ nullable: true })
92
111
  createdAt?: Date
@@ -10,7 +10,9 @@ export default {
10
10
  { tagname: 'transaction-list-page', page: 'transaction-list' },
11
11
  { tagname: 'accounting-category-list-page', page: 'accounting-category-list' },
12
12
  { tagname: 'financial-statement-list-page', page: 'financial-statement-list' },
13
- { tagname: 'income-statement-list-page', page: 'income-statement-list' }
13
+ { tagname: 'income-statement-list-page', page: 'income-statement-list' },
14
+ { tagname: 'fiscal-year-list-page', page: 'fiscal-year-list' },
15
+ { tagname: 'fiscal-month-list-page', page: 'fiscal-month-list' }
14
16
  ],
15
17
  bootstrap
16
18
  }