@things-factory/accounting 10.1.134 → 10.1.136

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 (240) hide show
  1. package/dist-client/route.d.ts +1 -1
  2. package/dist-client/route.js +0 -12
  3. package/dist-client/route.js.map +1 -1
  4. package/dist-client/tsconfig.tsbuildinfo +1 -1
  5. package/dist-server/index.d.ts +0 -1
  6. package/dist-server/index.js +0 -1
  7. package/dist-server/index.js.map +1 -1
  8. package/dist-server/service/account/account-history.d.ts +13 -6
  9. package/dist-server/service/account/account-history.js +44 -17
  10. package/dist-server/service/account/account-history.js.map +1 -1
  11. package/dist-server/service/account/account-mutation.js +2 -2
  12. package/dist-server/service/account/account-mutation.js.map +1 -1
  13. package/dist-server/service/account/account-query.d.ts +2 -0
  14. package/dist-server/service/account/account-query.js +12 -1
  15. package/dist-server/service/account/account-query.js.map +1 -1
  16. package/dist-server/service/account/account-type.d.ts +16 -0
  17. package/dist-server/service/account/account-type.js +71 -13
  18. package/dist-server/service/account/account-type.js.map +1 -1
  19. package/dist-server/service/account/account.d.ts +9 -3
  20. package/dist-server/service/account/account.js +34 -8
  21. package/dist-server/service/account/account.js.map +1 -1
  22. package/dist-server/service/accounting-category/accounting-category-mutation.js +2 -2
  23. package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -1
  24. package/dist-server/service/accounting-category/accounting-category-query.d.ts +1 -0
  25. package/dist-server/service/accounting-category/accounting-category-query.js +10 -0
  26. package/dist-server/service/accounting-category/accounting-category-query.js.map +1 -1
  27. package/dist-server/service/accounting-document/accounting-document-mutation.js +12 -3
  28. package/dist-server/service/accounting-document/accounting-document-mutation.js.map +1 -1
  29. package/dist-server/service/accounting-document/accounting-document-query.js +2 -0
  30. package/dist-server/service/accounting-document/accounting-document-query.js.map +1 -1
  31. package/dist-server/service/bank-account/bank-account-history.d.ts +11 -14
  32. package/dist-server/service/bank-account/bank-account-history.js +46 -59
  33. package/dist-server/service/bank-account/bank-account-history.js.map +1 -1
  34. package/dist-server/service/bank-account/bank-account-mutation.d.ts +1 -2
  35. package/dist-server/service/bank-account/bank-account-mutation.js +25 -69
  36. package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -1
  37. package/dist-server/service/bank-account/bank-account-query.js +3 -1
  38. package/dist-server/service/bank-account/bank-account-query.js.map +1 -1
  39. package/dist-server/service/bank-account/bank-account-service.d.ts +5 -0
  40. package/dist-server/service/bank-account/bank-account-service.js +21 -0
  41. package/dist-server/service/bank-account/bank-account-service.js.map +1 -0
  42. package/dist-server/service/bank-account/bank-account-type.d.ts +13 -19
  43. package/dist-server/service/bank-account/bank-account-type.js +45 -69
  44. package/dist-server/service/bank-account/bank-account-type.js.map +1 -1
  45. package/dist-server/service/bank-account/bank-account.d.ts +14 -17
  46. package/dist-server/service/bank-account/bank-account.js +45 -57
  47. package/dist-server/service/bank-account/bank-account.js.map +1 -1
  48. package/dist-server/service/bank-statement/bank-statement-query.d.ts +14 -0
  49. package/dist-server/service/bank-statement/bank-statement-query.js +92 -0
  50. package/dist-server/service/bank-statement/bank-statement-query.js.map +1 -0
  51. package/dist-server/service/bank-statement/bank-statement.d.ts +26 -0
  52. package/dist-server/service/bank-statement/bank-statement.js +109 -0
  53. package/dist-server/service/bank-statement/bank-statement.js.map +1 -0
  54. package/dist-server/service/bank-statement/index.d.ts +5 -0
  55. package/dist-server/service/bank-statement/index.js +9 -0
  56. package/dist-server/service/bank-statement/index.js.map +1 -0
  57. package/dist-server/service/cash-flow-type.d.ts +5 -0
  58. package/dist-server/service/cash-flow-type.js +15 -0
  59. package/dist-server/service/cash-flow-type.js.map +1 -0
  60. package/dist-server/service/financial-institution/financial-institution-mutation.js +10 -1
  61. package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -1
  62. package/dist-server/service/financial-institution/financial-institution-query.js +14 -6
  63. package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -1
  64. package/dist-server/service/financial-institution/index.d.ts +1 -1
  65. package/dist-server/service/financial-statement/financial-statement-history.d.ts +11 -9
  66. package/dist-server/service/financial-statement/financial-statement-history.js +47 -36
  67. package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
  68. package/dist-server/service/financial-statement/financial-statement-line.d.ts +24 -0
  69. package/dist-server/service/financial-statement/financial-statement-line.js +108 -0
  70. package/dist-server/service/financial-statement/financial-statement-line.js.map +1 -0
  71. package/dist-server/service/financial-statement/financial-statement-mutation.d.ts +1 -8
  72. package/dist-server/service/financial-statement/financial-statement-mutation.js +10 -135
  73. package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -1
  74. package/dist-server/service/financial-statement/financial-statement-query.d.ts +14 -7
  75. package/dist-server/service/financial-statement/financial-statement-query.js +87 -31
  76. package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
  77. package/dist-server/service/financial-statement/financial-statement-service.d.ts +33 -0
  78. package/dist-server/service/financial-statement/financial-statement-service.js +44 -0
  79. package/dist-server/service/financial-statement/financial-statement-service.js.map +1 -0
  80. package/dist-server/service/financial-statement/financial-statement.d.ts +19 -11
  81. package/dist-server/service/financial-statement/financial-statement.js +73 -65
  82. package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
  83. package/dist-server/service/financial-statement/index.d.ts +5 -4
  84. package/dist-server/service/financial-statement/index.js +3 -3
  85. package/dist-server/service/financial-statement/index.js.map +1 -1
  86. package/dist-server/service/index.d.ts +15 -3
  87. package/dist-server/service/index.js +30 -13
  88. package/dist-server/service/index.js.map +1 -1
  89. package/dist-server/service/payment/index.d.ts +1 -0
  90. package/dist-server/service/payment/index.js +1 -0
  91. package/dist-server/service/payment/index.js.map +1 -1
  92. package/dist-server/service/payment/payment-history.d.ts +9 -16
  93. package/dist-server/service/payment/payment-history.js +36 -70
  94. package/dist-server/service/payment/payment-history.js.map +1 -1
  95. package/dist-server/service/payment/payment-mutation.d.ts +0 -1
  96. package/dist-server/service/payment/payment-mutation.js +14 -79
  97. package/dist-server/service/payment/payment-mutation.js.map +1 -1
  98. package/dist-server/service/payment/payment-query.d.ts +3 -0
  99. package/dist-server/service/payment/payment-query.js +30 -1
  100. package/dist-server/service/payment/payment-query.js.map +1 -1
  101. package/dist-server/service/payment/payment-service.d.ts +16 -0
  102. package/dist-server/service/payment/payment-service.js +140 -0
  103. package/dist-server/service/payment/payment-service.js.map +1 -0
  104. package/dist-server/service/payment/payment-targets.d.ts +31 -0
  105. package/dist-server/service/payment/payment-targets.js +19 -0
  106. package/dist-server/service/payment/payment-targets.js.map +1 -0
  107. package/dist-server/service/payment/payment-type.d.ts +13 -17
  108. package/dist-server/service/payment/payment-type.js +35 -51
  109. package/dist-server/service/payment/payment-type.js.map +1 -1
  110. package/dist-server/service/payment/payment.d.ts +23 -22
  111. package/dist-server/service/payment/payment.js +66 -94
  112. package/dist-server/service/payment/payment.js.map +1 -1
  113. package/dist-server/service/payment/transfer-target.d.ts +1 -0
  114. package/dist-server/service/payment/transfer-target.js +43 -0
  115. package/dist-server/service/payment/transfer-target.js.map +1 -0
  116. package/dist-server/service/recurring-cash-item/index.d.ts +6 -0
  117. package/dist-server/service/recurring-cash-item/index.js +10 -0
  118. package/dist-server/service/recurring-cash-item/index.js.map +1 -0
  119. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.d.ts +7 -0
  120. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js +63 -0
  121. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js.map +1 -0
  122. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.d.ts +15 -0
  123. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js +101 -0
  124. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js.map +1 -0
  125. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.d.ts +23 -0
  126. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js +91 -0
  127. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js.map +1 -0
  128. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.d.ts +23 -0
  129. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js +85 -0
  130. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js.map +1 -0
  131. package/dist-server/service/recurring-cash-item/recurring-cash-item.d.ts +35 -0
  132. package/dist-server/service/recurring-cash-item/recurring-cash-item.js +142 -0
  133. package/dist-server/service/recurring-cash-item/recurring-cash-item.js.map +1 -0
  134. package/dist-server/service/recurring-cash-item/recurring-schedule.d.ts +36 -0
  135. package/dist-server/service/recurring-cash-item/recurring-schedule.js +41 -0
  136. package/dist-server/service/recurring-cash-item/recurring-schedule.js.map +1 -0
  137. package/dist-server/service/transaction/transaction-history.d.ts +42 -15
  138. package/dist-server/service/transaction/transaction-history.js +160 -54
  139. package/dist-server/service/transaction/transaction-history.js.map +1 -1
  140. package/dist-server/service/transaction/transaction-mutation.d.ts +0 -1
  141. package/dist-server/service/transaction/transaction-mutation.js +13 -78
  142. package/dist-server/service/transaction/transaction-mutation.js.map +1 -1
  143. package/dist-server/service/transaction/transaction-period.d.ts +16 -0
  144. package/dist-server/service/transaction/transaction-period.js +49 -0
  145. package/dist-server/service/transaction/transaction-period.js.map +1 -0
  146. package/dist-server/service/transaction/transaction-query.d.ts +12 -0
  147. package/dist-server/service/transaction/transaction-query.js +84 -2
  148. package/dist-server/service/transaction/transaction-query.js.map +1 -1
  149. package/dist-server/service/transaction/transaction-service.d.ts +30 -0
  150. package/dist-server/service/transaction/transaction-service.js +130 -0
  151. package/dist-server/service/transaction/transaction-service.js.map +1 -0
  152. package/dist-server/service/transaction/transaction-type.d.ts +39 -7
  153. package/dist-server/service/transaction/transaction-type.js +145 -23
  154. package/dist-server/service/transaction/transaction-type.js.map +1 -1
  155. package/dist-server/service/transaction/transaction.d.ts +58 -31
  156. package/dist-server/service/transaction/transaction.js +216 -102
  157. package/dist-server/service/transaction/transaction.js.map +1 -1
  158. package/dist-server/tsconfig.tsbuildinfo +1 -1
  159. package/package.json +5 -3
  160. package/things-factory.config.js +0 -4
  161. package/translations/en.json +34 -2
  162. package/translations/ja.json +0 -1
  163. package/translations/ko.json +34 -2
  164. package/translations/ms.json +0 -1
  165. package/translations/zh.json +0 -1
  166. package/dist-client/pages/account/account-importer.d.ts +0 -22
  167. package/dist-client/pages/account/account-importer.js +0 -99
  168. package/dist-client/pages/account/account-importer.js.map +0 -1
  169. package/dist-client/pages/account/account-list-page.d.ts +0 -57
  170. package/dist-client/pages/account/account-list-page.js +0 -306
  171. package/dist-client/pages/account/account-list-page.js.map +0 -1
  172. package/dist-client/pages/bank-account/bank-account-importer.d.ts +0 -23
  173. package/dist-client/pages/bank-account/bank-account-importer.js +0 -92
  174. package/dist-client/pages/bank-account/bank-account-importer.js.map +0 -1
  175. package/dist-client/pages/bank-account/bank-account-list-page.d.ts +0 -60
  176. package/dist-client/pages/bank-account/bank-account-list-page.js +0 -317
  177. package/dist-client/pages/bank-account/bank-account-list-page.js.map +0 -1
  178. package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +0 -22
  179. package/dist-client/pages/financial-statement/financial-statement-importer.js +0 -99
  180. package/dist-client/pages/financial-statement/financial-statement-importer.js.map +0 -1
  181. package/dist-client/pages/financial-statement/financial-statement-list-page.d.ts +0 -57
  182. package/dist-client/pages/financial-statement/financial-statement-list-page.js +0 -280
  183. package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +0 -1
  184. package/dist-client/pages/income-statement/income-statement-importer.d.ts +0 -22
  185. package/dist-client/pages/income-statement/income-statement-importer.js +0 -99
  186. package/dist-client/pages/income-statement/income-statement-importer.js.map +0 -1
  187. package/dist-client/pages/income-statement/income-statement-list-page.d.ts +0 -57
  188. package/dist-client/pages/income-statement/income-statement-list-page.js +0 -280
  189. package/dist-client/pages/income-statement/income-statement-list-page.js.map +0 -1
  190. package/dist-client/pages/payment/payment-importer.d.ts +0 -23
  191. package/dist-client/pages/payment/payment-importer.js +0 -92
  192. package/dist-client/pages/payment/payment-importer.js.map +0 -1
  193. package/dist-client/pages/payment/payment-list-page.d.ts +0 -60
  194. package/dist-client/pages/payment/payment-list-page.js +0 -317
  195. package/dist-client/pages/payment/payment-list-page.js.map +0 -1
  196. package/dist-client/pages/transaction/transaction-importer.d.ts +0 -22
  197. package/dist-client/pages/transaction/transaction-importer.js +0 -99
  198. package/dist-client/pages/transaction/transaction-importer.js.map +0 -1
  199. package/dist-client/pages/transaction/transaction-list-page.d.ts +0 -57
  200. package/dist-client/pages/transaction/transaction-list-page.js +0 -280
  201. package/dist-client/pages/transaction/transaction-list-page.js.map +0 -1
  202. package/dist-server/controllers/index.d.ts +0 -1
  203. package/dist-server/controllers/index.js +0 -5
  204. package/dist-server/controllers/index.js.map +0 -1
  205. package/dist-server/controllers/summary-statements.d.ts +0 -4
  206. package/dist-server/controllers/summary-statements.js +0 -149
  207. package/dist-server/controllers/summary-statements.js.map +0 -1
  208. package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +0 -5
  209. package/dist-server/migrations/1725201567284-seed-country-codes.js +0 -255
  210. package/dist-server/migrations/1725201567284-seed-country-codes.js.map +0 -1
  211. package/dist-server/service/financial-statement/financial-statement-line-item.d.ts +0 -19
  212. package/dist-server/service/financial-statement/financial-statement-line-item.js +0 -95
  213. package/dist-server/service/financial-statement/financial-statement-line-item.js.map +0 -1
  214. package/dist-server/service/financial-statement/financial-statement-type.d.ts +0 -20
  215. package/dist-server/service/financial-statement/financial-statement-type.js +0 -77
  216. package/dist-server/service/financial-statement/financial-statement-type.js.map +0 -1
  217. package/dist-server/service/income-statement/event-subscriber.d.ts +0 -7
  218. package/dist-server/service/income-statement/event-subscriber.js +0 -21
  219. package/dist-server/service/income-statement/event-subscriber.js.map +0 -1
  220. package/dist-server/service/income-statement/income-statement-history.d.ts +0 -28
  221. package/dist-server/service/income-statement/income-statement-history.js +0 -146
  222. package/dist-server/service/income-statement/income-statement-history.js.map +0 -1
  223. package/dist-server/service/income-statement/income-statement-line-item.d.ts +0 -19
  224. package/dist-server/service/income-statement/income-statement-line-item.js +0 -97
  225. package/dist-server/service/income-statement/income-statement-line-item.js.map +0 -1
  226. package/dist-server/service/income-statement/income-statement-mutation.d.ts +0 -10
  227. package/dist-server/service/income-statement/income-statement-mutation.js +0 -159
  228. package/dist-server/service/income-statement/income-statement-mutation.js.map +0 -1
  229. package/dist-server/service/income-statement/income-statement-query.d.ts +0 -11
  230. package/dist-server/service/income-statement/income-statement-query.js +0 -81
  231. package/dist-server/service/income-statement/income-statement-query.js.map +0 -1
  232. package/dist-server/service/income-statement/income-statement-type.d.ts +0 -20
  233. package/dist-server/service/income-statement/income-statement-type.js +0 -77
  234. package/dist-server/service/income-statement/income-statement-type.js.map +0 -1
  235. package/dist-server/service/income-statement/income-statement.d.ts +0 -28
  236. package/dist-server/service/income-statement/income-statement.js +0 -137
  237. package/dist-server/service/income-statement/income-statement.js.map +0 -1
  238. package/dist-server/service/income-statement/index.d.ts +0 -8
  239. package/dist-server/service/income-statement/index.js +0 -13
  240. package/dist-server/service/income-statement/index.js.map +0 -1
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecurringCashItemMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const recurring_cash_item_1 = require("./recurring-cash-item");
8
+ const recurring_cash_item_service_1 = require("./recurring-cash-item-service");
9
+ const recurring_cash_item_type_1 = require("./recurring-cash-item-type");
10
+ let RecurringCashItemMutation = class RecurringCashItemMutation {
11
+ async updateMultipleRecurringCashItem(patches, context) {
12
+ const { domain, user, tx } = context.state;
13
+ return await (0, recurring_cash_item_service_1.saveRecurringCashItems)(tx, domain, user, patches);
14
+ }
15
+ async deleteRecurringCashItems(ids, context) {
16
+ const { domain, user, tx } = context.state;
17
+ await (0, recurring_cash_item_service_1.saveRecurringCashItems)(tx, domain, user, ids.map(id => ({ id, cuFlag: '-' })));
18
+ return true;
19
+ }
20
+ async generateForecasts(year, month, context) {
21
+ const { domain, user, tx } = context.state;
22
+ return await (0, recurring_cash_item_service_1.makeForecasts)(tx, domain, user, year, month);
23
+ }
24
+ };
25
+ exports.RecurringCashItemMutation = RecurringCashItemMutation;
26
+ tslib_1.__decorate([
27
+ (0, type_graphql_1.Directive)('@transaction'),
28
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
29
+ (0, type_graphql_1.Mutation)(returns => [recurring_cash_item_1.RecurringCashItem], { description: 'To add, modify and delete multiple RecurringCashItems' }),
30
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [recurring_cash_item_type_1.RecurringCashItemPatch])),
31
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
32
+ tslib_1.__metadata("design:type", Function),
33
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
34
+ tslib_1.__metadata("design:returntype", Promise)
35
+ ], RecurringCashItemMutation.prototype, "updateMultipleRecurringCashItem", null);
36
+ tslib_1.__decorate([
37
+ (0, type_graphql_1.Directive)('@transaction'),
38
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
39
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple RecurringCashItems' }),
40
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
41
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
42
+ tslib_1.__metadata("design:type", Function),
43
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
44
+ tslib_1.__metadata("design:returntype", Promise)
45
+ ], RecurringCashItemMutation.prototype, "deleteRecurringCashItems", null);
46
+ tslib_1.__decorate([
47
+ (0, type_graphql_1.Directive)('@transaction'),
48
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
49
+ (0, type_graphql_1.Mutation)(returns => type_graphql_1.Int, {
50
+ description: "Make a month's forecasts from the recurring items; returns how many were made"
51
+ }),
52
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('year', type => type_graphql_1.Int)),
53
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('month', type => type_graphql_1.Int)),
54
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
55
+ tslib_1.__metadata("design:type", Function),
56
+ tslib_1.__metadata("design:paramtypes", [Number, Number, Object]),
57
+ tslib_1.__metadata("design:returntype", Promise)
58
+ ], RecurringCashItemMutation.prototype, "generateForecasts", null);
59
+ exports.RecurringCashItemMutation = RecurringCashItemMutation = tslib_1.__decorate([
60
+ (0, type_graphql_1.Resolver)(recurring_cash_item_1.RecurringCashItem),
61
+ (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
62
+ ], RecurringCashItemMutation);
63
+ //# sourceMappingURL=recurring-cash-item-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-cash-item-mutation.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA0F;AAE1F,iDAAqD;AAErD,+DAAyD;AACzD,+EAAqF;AACrF,yEAAmE;AAI5D,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAI9B,AAAN,KAAK,CAAC,+BAA+B,CACe,OAAiC,EAC5E,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,IAAA,oDAAsB,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAChE,CAAC;IAKK,AAAN,KAAK,CAAC,wBAAwB,CACE,GAAa,EACpC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,IAAA,oDAAsB,EAC1B,EAAE,EACF,MAAM,EACN,IAAI,EACJ,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EA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BAAG,EAAE;QACxB,WAAW,EAAE,+EAA+E;KAC7F,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IACxB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IACzB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kEAKP;oCA5CU,yBAAyB;IAFrC,IAAA,uBAAQ,EAAC,uCAAiB,CAAC;IAC3B,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,yBAAyB,CA6CrC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive, Int, UseMiddleware } from 'type-graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { RecurringCashItem } from './recurring-cash-item'\nimport { makeForecasts, saveRecurringCashItems } from './recurring-cash-item-service'\nimport { RecurringCashItemPatch } from './recurring-cash-item-type'\n\n@Resolver(RecurringCashItem)\n@UseMiddleware(SpeakRefusals)\nexport class RecurringCashItemMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [RecurringCashItem], { description: 'To add, modify and delete multiple RecurringCashItems' })\n async updateMultipleRecurringCashItem(\n @Arg('patches', type => [RecurringCashItemPatch]) patches: RecurringCashItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<RecurringCashItem[]> {\n const { domain, user, tx } = context.state\n\n return await saveRecurringCashItems(tx, domain, user, patches)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple RecurringCashItems' })\n async deleteRecurringCashItems(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, user, tx } = context.state\n await saveRecurringCashItems(\n tx,\n domain,\n user,\n ids.map(id => ({ id, cuFlag: '-' }))\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Int, {\n description: \"Make a month's forecasts from the recurring items; returns how many were made\"\n })\n async generateForecasts(\n @Arg('year', type => Int) year: number,\n @Arg('month', type => Int) month: number,\n @Ctx() context: ResolverContext\n ): Promise<number> {\n const { domain, user, tx } = context.state\n\n return await makeForecasts(tx, domain, user, year, month)\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { Domain, ListParam } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Counterparty } from '@things-factory/biz-base';
4
+ import { Account } from '../account/account';
5
+ import { RecurringCashItem } from './recurring-cash-item';
6
+ import { RecurringCashItemList } from './recurring-cash-item-type';
7
+ export declare class RecurringCashItemQuery {
8
+ recurringCashItem(id: string, context: ResolverContext): Promise<RecurringCashItem | null>;
9
+ recurringCashItems(params: ListParam, context: ResolverContext): Promise<RecurringCashItemList>;
10
+ account(item: RecurringCashItem): Promise<Account | null>;
11
+ counterparty(item: RecurringCashItem): Promise<Counterparty | null>;
12
+ domain(item: RecurringCashItem): Promise<Domain>;
13
+ creator(item: RecurringCashItem): Promise<User | null>;
14
+ updater(item: RecurringCashItem): Promise<User | null>;
15
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecurringCashItemQuery = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const auth_base_1 = require("@things-factory/auth-base");
8
+ const biz_base_1 = require("@things-factory/biz-base");
9
+ const account_1 = require("../account/account");
10
+ const recurring_cash_item_1 = require("./recurring-cash-item");
11
+ const recurring_cash_item_type_1 = require("./recurring-cash-item-type");
12
+ let RecurringCashItemQuery = class RecurringCashItemQuery {
13
+ async recurringCashItem(id, context) {
14
+ const { domain } = context.state;
15
+ return await (0, shell_1.getRepository)(recurring_cash_item_1.RecurringCashItem).findOne({ where: { domain: { id: domain.id }, id } });
16
+ }
17
+ async recurringCashItems(params, context) {
18
+ const { domain } = context.state;
19
+ const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
20
+ domain,
21
+ params,
22
+ repository: (0, shell_1.getRepository)(recurring_cash_item_1.RecurringCashItem),
23
+ searchables: ['name', 'notes']
24
+ });
25
+ const [items, total] = await queryBuilder.getManyAndCount();
26
+ return { items, total };
27
+ }
28
+ async account(item) {
29
+ return item.accountId ? await (0, shell_1.getRepository)(account_1.Account).findOneBy({ id: item.accountId }) : null;
30
+ }
31
+ async counterparty(item) {
32
+ return item.counterpartyId ? await (0, shell_1.getRepository)(biz_base_1.Counterparty).findOneBy({ id: item.counterpartyId }) : null;
33
+ }
34
+ async domain(item) {
35
+ return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: item.domainId });
36
+ }
37
+ async creator(item) {
38
+ return item.creatorId ? await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: item.creatorId }) : null;
39
+ }
40
+ async updater(item) {
41
+ return item.updaterId ? await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: item.updaterId }) : null;
42
+ }
43
+ };
44
+ exports.RecurringCashItemQuery = RecurringCashItemQuery;
45
+ tslib_1.__decorate([
46
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
47
+ (0, type_graphql_1.Query)(returns => recurring_cash_item_1.RecurringCashItem, { nullable: true, description: 'To fetch a RecurringCashItem' }),
48
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
49
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
50
+ tslib_1.__metadata("design:type", Function),
51
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
52
+ tslib_1.__metadata("design:returntype", Promise)
53
+ ], RecurringCashItemQuery.prototype, "recurringCashItem", null);
54
+ tslib_1.__decorate([
55
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
56
+ (0, type_graphql_1.Query)(returns => recurring_cash_item_type_1.RecurringCashItemList, { description: 'To fetch multiple RecurringCashItems' }),
57
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
58
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
59
+ tslib_1.__metadata("design:type", Function),
60
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
61
+ tslib_1.__metadata("design:returntype", Promise)
62
+ ], RecurringCashItemQuery.prototype, "recurringCashItems", null);
63
+ tslib_1.__decorate([
64
+ (0, type_graphql_1.FieldResolver)(type => account_1.Account, { nullable: true }),
65
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
66
+ tslib_1.__metadata("design:type", Function),
67
+ tslib_1.__metadata("design:paramtypes", [recurring_cash_item_1.RecurringCashItem]),
68
+ tslib_1.__metadata("design:returntype", Promise)
69
+ ], RecurringCashItemQuery.prototype, "account", null);
70
+ tslib_1.__decorate([
71
+ (0, type_graphql_1.FieldResolver)(type => biz_base_1.Counterparty, { nullable: true }),
72
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
73
+ tslib_1.__metadata("design:type", Function),
74
+ tslib_1.__metadata("design:paramtypes", [recurring_cash_item_1.RecurringCashItem]),
75
+ tslib_1.__metadata("design:returntype", Promise)
76
+ ], RecurringCashItemQuery.prototype, "counterparty", null);
77
+ tslib_1.__decorate([
78
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
79
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
80
+ tslib_1.__metadata("design:type", Function),
81
+ tslib_1.__metadata("design:paramtypes", [recurring_cash_item_1.RecurringCashItem]),
82
+ tslib_1.__metadata("design:returntype", Promise)
83
+ ], RecurringCashItemQuery.prototype, "domain", null);
84
+ tslib_1.__decorate([
85
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
86
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
87
+ tslib_1.__metadata("design:type", Function),
88
+ tslib_1.__metadata("design:paramtypes", [recurring_cash_item_1.RecurringCashItem]),
89
+ tslib_1.__metadata("design:returntype", Promise)
90
+ ], RecurringCashItemQuery.prototype, "creator", null);
91
+ tslib_1.__decorate([
92
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
93
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
94
+ tslib_1.__metadata("design:type", Function),
95
+ tslib_1.__metadata("design:paramtypes", [recurring_cash_item_1.RecurringCashItem]),
96
+ tslib_1.__metadata("design:returntype", Promise)
97
+ ], RecurringCashItemQuery.prototype, "updater", null);
98
+ exports.RecurringCashItemQuery = RecurringCashItemQuery = tslib_1.__decorate([
99
+ (0, type_graphql_1.Resolver)(recurring_cash_item_1.RecurringCashItem)
100
+ ], RecurringCashItemQuery);
101
+ //# sourceMappingURL=recurring-cash-item-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-cash-item-query.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AACvG,yDAAgD;AAChD,uDAAuD;AAEvD,gDAA4C;AAC5C,+DAAyD;AACzD,yEAAkE;AAG3D,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAG3B,AAAN,KAAK,CAAC,iBAAiB,CAAY,EAAU,EAAS,OAAwB;QAC5E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,uCAAiB,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACrG,CAAC;IAIK,AAAN,KAAK,CAAC,kBAAkB,CACG,MAAiB,EACnC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B;;0DAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,uCAAiB;;oDAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,uCAAiB;;qDAE5C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,uCAAiB;;qDAE5C;iCAlDU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,uCAAiB,CAAC;GACf,sBAAsB,CAmDlC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\n\nimport { Account } from '../account/account'\nimport { RecurringCashItem } from './recurring-cash-item'\nimport { RecurringCashItemList } from './recurring-cash-item-type'\n\n@Resolver(RecurringCashItem)\nexport class RecurringCashItemQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => RecurringCashItem, { nullable: true, description: 'To fetch a RecurringCashItem' })\n async recurringCashItem(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<RecurringCashItem | null> {\n const { domain } = context.state\n\n return await getRepository(RecurringCashItem).findOne({ where: { domain: { id: domain.id }, id } })\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => RecurringCashItemList, { description: 'To fetch multiple RecurringCashItems' })\n async recurringCashItems(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<RecurringCashItemList> {\n const { domain } = context.state\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(RecurringCashItem),\n searchables: ['name', 'notes']\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Account, { nullable: true })\n async account(@Root() item: RecurringCashItem): Promise<Account | null> {\n return item.accountId ? await getRepository(Account).findOneBy({ id: item.accountId }) : null\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n async counterparty(@Root() item: RecurringCashItem): Promise<Counterparty | null> {\n return item.counterpartyId ? await getRepository(Counterparty).findOneBy({ id: item.counterpartyId }) : null\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() item: RecurringCashItem): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: item.domainId })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() item: RecurringCashItem): Promise<User | null> {\n return item.creatorId ? await getRepository(User).findOneBy({ id: item.creatorId }) : null\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() item: RecurringCashItem): Promise<User | null> {\n return item.updaterId ? await getRepository(User).findOneBy({ id: item.updaterId }) : null\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { RecurringCashItem } from './recurring-cash-item';
3
+ export type RecurringCashItemInput = Partial<Omit<RecurringCashItem, 'account' | 'counterparty'>> & {
4
+ id?: string;
5
+ cuFlag?: string;
6
+ account?: {
7
+ id: string;
8
+ } | null;
9
+ counterparty?: {
10
+ id: string;
11
+ } | null;
12
+ };
13
+ /** Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). */
14
+ export declare function saveRecurringCashItems(tx: EntityManager, domain: {
15
+ id: string;
16
+ }, user: any, inputs: RecurringCashItemInput[]): Promise<RecurringCashItem[]>;
17
+ /**
18
+ * Make the month's forecasts from the recurring items. A forecast already made from an item for that month is not
19
+ * made again, so running it twice changes nothing. Returns how many were made.
20
+ */
21
+ export declare function makeForecasts(tx: EntityManager, domain: {
22
+ id: string;
23
+ }, user: any, year: number, month: number): Promise<number>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveRecurringCashItems = saveRecurringCashItems;
4
+ exports.makeForecasts = makeForecasts;
5
+ const typeorm_1 = require("typeorm");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const transaction_1 = require("../transaction/transaction");
8
+ const transaction_service_1 = require("../transaction/transaction-service");
9
+ const recurring_cash_item_1 = require("./recurring-cash-item");
10
+ const recurring_schedule_1 = require("./recurring-schedule");
11
+ const MONTH = /^\d{4}-(0[1-9]|1[0-2])$/;
12
+ function rowOf(input, current) {
13
+ const { id, cuFlag, ...row } = input;
14
+ const merged = { ...current, ...row };
15
+ if (!String(merged.name ?? '').trim())
16
+ throw new shell_1.Refusal('recurring-name-required', {}, 'name: what it is');
17
+ if (!merged.type)
18
+ throw new shell_1.Refusal('transaction-type-required', {}, 'type: money in or money out');
19
+ if (!MONTH.test(String(merged.startMonth ?? '')))
20
+ throw new shell_1.Refusal('recurring-start-required', {}, 'startMonth: YYYY-MM');
21
+ if (merged.endMonth && !MONTH.test(merged.endMonth))
22
+ throw new shell_1.Refusal('recurring-end-not-a-month', {}, 'endMonth: YYYY-MM');
23
+ if (merged.endMonth && merged.endMonth < merged.startMonth)
24
+ throw new shell_1.Refusal('recurring-end-before-start', {}, 'endMonth: before startMonth');
25
+ if (merged.dayOfMonth !== null &&
26
+ merged.dayOfMonth !== undefined &&
27
+ !(merged.dayOfMonth >= 1 && merged.dayOfMonth <= 31)) {
28
+ throw new shell_1.Refusal('day-of-month-out-of-range', {}, 'dayOfMonth: must be 1 to 31');
29
+ }
30
+ if (!current && (row.amount === undefined || row.amount === null))
31
+ throw new shell_1.Refusal('recurring-amount-required', {}, 'amount: every month');
32
+ return row;
33
+ }
34
+ /** Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). */
35
+ async function saveRecurringCashItems(tx, domain, user, inputs) {
36
+ const repo = tx.getRepository(recurring_cash_item_1.RecurringCashItem);
37
+ const deletes = [...new Set(inputs.filter(one => one.cuFlag === '-' && one.id).map(one => one.id))];
38
+ if (deletes.length) {
39
+ const found = await repo.find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(deletes) } });
40
+ if (found.length !== deletes.length)
41
+ throw new shell_1.Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again');
42
+ await repo.softRemove(found);
43
+ }
44
+ const saved = [];
45
+ for (const input of inputs.filter(one => one.cuFlag !== '-')) {
46
+ const isNew = !input.id || input.cuFlag === '+';
47
+ const current = isNew ? undefined : await repo.findOne({ where: { domain: { id: domain.id }, id: input.id } });
48
+ if (!isNew && !current)
49
+ throw new shell_1.Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again');
50
+ saved.push(await repo.save({
51
+ ...(current ?? { domain, creator: user }),
52
+ ...rowOf(input, current),
53
+ updater: user
54
+ }));
55
+ }
56
+ return saved;
57
+ }
58
+ /**
59
+ * Make the month's forecasts from the recurring items. A forecast already made from an item for that month is not
60
+ * made again, so running it twice changes nothing. Returns how many were made.
61
+ */
62
+ async function makeForecasts(tx, domain, user, year, month) {
63
+ if (!(month >= 1 && month <= 12))
64
+ throw new shell_1.Refusal('month-out-of-range', { month }, 'month: must be 1 to 12');
65
+ const items = await tx.getRepository(recurring_cash_item_1.RecurringCashItem).find({ where: { domain: { id: domain.id } } });
66
+ const made = await tx
67
+ .getRepository(transaction_1.Transaction)
68
+ .find({
69
+ where: { domain: { id: domain.id }, category: transaction_1.TransactionCategory.FORECAST, year, month },
70
+ relations: ['recurringItem']
71
+ });
72
+ const already = new Set(made.map(one => one.recurringItem?.id).filter(Boolean));
73
+ const lines = (0, recurring_schedule_1.linesFor)(items, year, month, already);
74
+ await (0, transaction_service_1.saveTransactions)(tx, domain, user, lines.map(line => {
75
+ return {
76
+ cuFlag: '+',
77
+ category: transaction_1.TransactionCategory.FORECAST,
78
+ type: line.type,
79
+ year: line.year,
80
+ month: line.month,
81
+ description: line.name,
82
+ amount: line.amount,
83
+ currency: line.currency,
84
+ timing: line.timing ?? undefined,
85
+ status: transaction_1.ForecastStatus.PLANNED,
86
+ recurringItem: { id: line.recurringItemId }
87
+ };
88
+ }));
89
+ return lines.length;
90
+ }
91
+ //# sourceMappingURL=recurring-cash-item-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-cash-item-service.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-service.ts"],"names":[],"mappings":";;AA0CA,wDA8BC;AAMD,sCAyCC;AAvHD,qCAA2C;AAE3C,iDAA+C;AAE/C,4DAA6F;AAC7F,4EAAqE;AACrE,+DAAyD;AACzD,6DAA+C;AAE/C,MAAM,KAAK,GAAG,yBAAyB,CAAA;AASvC,SAAS,KAAK,CAAC,KAA6B,EAAE,OAAsC;IAClF,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,KAA4B,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,EAAE,CAAA;IACrC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAAE,MAAM,IAAI,eAAO,CAAC,yBAAyB,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAA;IAC3G,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,MAAM,IAAI,eAAO,CAAC,2BAA2B,EAAE,EAAE,EAAE,6BAA6B,CAAC,CAAA;IACnG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QAC9C,MAAM,IAAI,eAAO,CAAC,0BAA0B,EAAE,EAAE,EAAE,qBAAqB,CAAC,CAAA;IAC1E,IAAI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,GAAG;YACX,QAAQ,EAAE,iCAAmB,CAAC,QAAQ;YACtC,IAAI,EAAE,IAAI,CAAC,IAAW;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,IAAI;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;YAChC,MAAM,EAAE,4BAAc,CAAC,OAAO;YAC9B,aAAa,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE;SAC5C,CAAA;IACH,CAAC,CAAC,CACH,CAAA;IAED,OAAO,KAAK,CAAC,MAAM,CAAA;AACrB,CAAC","sourcesContent":["import { EntityManager, In } from 'typeorm'\n\nimport { Refusal } from '@things-factory/shell'\n\nimport { ForecastStatus, Transaction, TransactionCategory } from '../transaction/transaction'\nimport { saveTransactions } from '../transaction/transaction-service'\nimport { RecurringCashItem } from './recurring-cash-item'\nimport { linesFor } from './recurring-schedule'\n\nconst MONTH = /^\\d{4}-(0[1-9]|1[0-2])$/\n\nexport type RecurringCashItemInput = Partial<Omit<RecurringCashItem, 'account' | 'counterparty'>> & {\n id?: string\n cuFlag?: string\n account?: { id: string } | null\n counterparty?: { id: string } | null\n}\n\nfunction rowOf(input: RecurringCashItemInput, current: RecurringCashItem | undefined): Record<string, any> {\n const { id, cuFlag, ...row } = input as Record<string, any>\n const merged = { ...current, ...row }\n if (!String(merged.name ?? '').trim()) throw new Refusal('recurring-name-required', {}, 'name: what it is')\n if (!merged.type) throw new Refusal('transaction-type-required', {}, 'type: money in or money out')\n if (!MONTH.test(String(merged.startMonth ?? '')))\n throw new Refusal('recurring-start-required', {}, 'startMonth: YYYY-MM')\n if (merged.endMonth && !MONTH.test(merged.endMonth))\n throw new Refusal('recurring-end-not-a-month', {}, 'endMonth: YYYY-MM')\n if (merged.endMonth && merged.endMonth < merged.startMonth)\n throw new Refusal('recurring-end-before-start', {}, 'endMonth: before startMonth')\n if (\n merged.dayOfMonth !== null &&\n merged.dayOfMonth !== undefined &&\n !(merged.dayOfMonth >= 1 && merged.dayOfMonth <= 31)\n ) {\n throw new Refusal('day-of-month-out-of-range', {}, 'dayOfMonth: must be 1 to 31')\n }\n if (!current && (row.amount === undefined || row.amount === null))\n throw new Refusal('recurring-amount-required', {}, 'amount: every month')\n return row\n}\n\n/** Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). */\nexport async function saveRecurringCashItems(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n inputs: RecurringCashItemInput[]\n): Promise<RecurringCashItem[]> {\n const repo = tx.getRepository(RecurringCashItem)\n const deletes = [...new Set(inputs.filter(one => one.cuFlag === '-' && one.id).map(one => one.id!))]\n if (deletes.length) {\n const found = await repo.find({ where: { domain: { id: domain.id }, id: In(deletes) } })\n if (found.length !== deletes.length)\n throw new Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again')\n await repo.softRemove(found)\n }\n\n const saved: RecurringCashItem[] = []\n for (const input of inputs.filter(one => one.cuFlag !== '-')) {\n const isNew = !input.id || input.cuFlag === '+'\n const current = isNew ? undefined : await repo.findOne({ where: { domain: { id: domain.id }, id: input.id } })\n if (!isNew && !current)\n throw new Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again')\n saved.push(\n await repo.save({\n ...(current ?? { domain, creator: user }),\n ...rowOf(input, current),\n updater: user\n } as RecurringCashItem)\n )\n }\n return saved\n}\n\n/**\n * Make the month's forecasts from the recurring items. A forecast already made from an item for that month is not\n * made again, so running it twice changes nothing. Returns how many were made.\n */\nexport async function makeForecasts(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n year: number,\n month: number\n): Promise<number> {\n if (!(month >= 1 && month <= 12)) throw new Refusal('month-out-of-range', { month }, 'month: must be 1 to 12')\n\n const items = await tx.getRepository(RecurringCashItem).find({ where: { domain: { id: domain.id } } })\n const made = await tx\n .getRepository(Transaction)\n .find({\n where: { domain: { id: domain.id }, category: TransactionCategory.FORECAST, year, month },\n relations: ['recurringItem']\n })\n const already = new Set(made.map(one => one.recurringItem?.id).filter(Boolean) as string[])\n\n const lines = linesFor(items, year, month, already)\n await saveTransactions(\n tx,\n domain,\n user,\n lines.map(line => {\n return {\n cuFlag: '+',\n category: TransactionCategory.FORECAST,\n type: line.type as any,\n year: line.year,\n month: line.month,\n description: line.name,\n amount: line.amount,\n currency: line.currency,\n timing: line.timing ?? undefined,\n status: ForecastStatus.PLANNED,\n recurringItem: { id: line.recurringItemId }\n }\n })\n )\n\n return lines.length\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { ObjectRef } from '@things-factory/shell';
2
+ import { CashFlowType } from '../cash-flow-type';
3
+ import { RecurringCashItem } from './recurring-cash-item';
4
+ export declare class RecurringCashItemPatch {
5
+ id?: string;
6
+ name?: string;
7
+ account?: ObjectRef;
8
+ type?: CashFlowType;
9
+ amount?: number;
10
+ currency?: string;
11
+ dayOfMonth?: number;
12
+ lastDayOfMonth?: boolean;
13
+ startMonth?: string;
14
+ endMonth?: string;
15
+ counterparty?: ObjectRef;
16
+ active?: boolean;
17
+ notes?: string;
18
+ cuFlag?: string;
19
+ }
20
+ export declare class RecurringCashItemList {
21
+ items: RecurringCashItem[];
22
+ total: number;
23
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecurringCashItemList = exports.RecurringCashItemPatch = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const cash_flow_type_1 = require("../cash-flow-type");
8
+ const recurring_cash_item_1 = require("./recurring-cash-item");
9
+ let RecurringCashItemPatch = class RecurringCashItemPatch {
10
+ };
11
+ exports.RecurringCashItemPatch = RecurringCashItemPatch;
12
+ tslib_1.__decorate([
13
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'The item to change or delete' }),
14
+ tslib_1.__metadata("design:type", String)
15
+ ], RecurringCashItemPatch.prototype, "id", void 0);
16
+ tslib_1.__decorate([
17
+ (0, type_graphql_1.Field)({ nullable: true, description: 'What it is' }),
18
+ tslib_1.__metadata("design:type", String)
19
+ ], RecurringCashItemPatch.prototype, "name", void 0);
20
+ tslib_1.__decorate([
21
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'The account subject it is booked to' }),
22
+ tslib_1.__metadata("design:type", shell_1.ObjectRef)
23
+ ], RecurringCashItemPatch.prototype, "account", void 0);
24
+ tslib_1.__decorate([
25
+ (0, type_graphql_1.Field)(type => cash_flow_type_1.CashFlowType, { nullable: true, description: 'Money in or money out' }),
26
+ tslib_1.__metadata("design:type", String)
27
+ ], RecurringCashItemPatch.prototype, "type", void 0);
28
+ tslib_1.__decorate([
29
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Amount every month' }),
30
+ tslib_1.__metadata("design:type", Number)
31
+ ], RecurringCashItemPatch.prototype, "amount", void 0);
32
+ tslib_1.__decorate([
33
+ (0, type_graphql_1.Field)({ nullable: true, description: 'ISO 4217 code' }),
34
+ tslib_1.__metadata("design:type", String)
35
+ ], RecurringCashItemPatch.prototype, "currency", void 0);
36
+ tslib_1.__decorate([
37
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: '1-31' }),
38
+ tslib_1.__metadata("design:type", Number)
39
+ ], RecurringCashItemPatch.prototype, "dayOfMonth", void 0);
40
+ tslib_1.__decorate([
41
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Falls on the last day of every month' }),
42
+ tslib_1.__metadata("design:type", Boolean)
43
+ ], RecurringCashItemPatch.prototype, "lastDayOfMonth", void 0);
44
+ tslib_1.__decorate([
45
+ (0, type_graphql_1.Field)({ nullable: true, description: 'First month - YYYY-MM' }),
46
+ tslib_1.__metadata("design:type", String)
47
+ ], RecurringCashItemPatch.prototype, "startMonth", void 0);
48
+ tslib_1.__decorate([
49
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Last month - YYYY-MM' }),
50
+ tslib_1.__metadata("design:type", String)
51
+ ], RecurringCashItemPatch.prototype, "endMonth", void 0);
52
+ tslib_1.__decorate([
53
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Who it is paid to or received from' }),
54
+ tslib_1.__metadata("design:type", shell_1.ObjectRef)
55
+ ], RecurringCashItemPatch.prototype, "counterparty", void 0);
56
+ tslib_1.__decorate([
57
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Whether it still makes forecasts' }),
58
+ tslib_1.__metadata("design:type", Boolean)
59
+ ], RecurringCashItemPatch.prototype, "active", void 0);
60
+ tslib_1.__decorate([
61
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
62
+ tslib_1.__metadata("design:type", String)
63
+ ], RecurringCashItemPatch.prototype, "notes", void 0);
64
+ tslib_1.__decorate([
65
+ (0, type_graphql_1.Field)({ nullable: true, description: '+ adds, M changes, - deletes' }),
66
+ tslib_1.__metadata("design:type", String)
67
+ ], RecurringCashItemPatch.prototype, "cuFlag", void 0);
68
+ exports.RecurringCashItemPatch = RecurringCashItemPatch = tslib_1.__decorate([
69
+ (0, type_graphql_1.InputType)({ description: 'A recurring item, or a grid row: cuFlag + adds, M changes, - deletes' })
70
+ ], RecurringCashItemPatch);
71
+ let RecurringCashItemList = class RecurringCashItemList {
72
+ };
73
+ exports.RecurringCashItemList = RecurringCashItemList;
74
+ tslib_1.__decorate([
75
+ (0, type_graphql_1.Field)(type => [recurring_cash_item_1.RecurringCashItem], { description: 'The items on this page' }),
76
+ tslib_1.__metadata("design:type", Array)
77
+ ], RecurringCashItemList.prototype, "items", void 0);
78
+ tslib_1.__decorate([
79
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'How many there are in all' }),
80
+ tslib_1.__metadata("design:type", Number)
81
+ ], RecurringCashItemList.prototype, "total", void 0);
82
+ exports.RecurringCashItemList = RecurringCashItemList = tslib_1.__decorate([
83
+ (0, type_graphql_1.ObjectType)({ description: 'A page of recurring items' })
84
+ ], RecurringCashItemList);
85
+ //# sourceMappingURL=recurring-cash-item-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-cash-item-type.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-type.ts"],"names":[],"mappings":";;;;AAAA,+CAA2E;AAE3E,iDAAiD;AAEjD,sDAAgD;AAChD,+DAAyD;AAGlD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CA0ClC,CAAA;AA1CY,wDAAsB;AAEjC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;;kDACxE;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;oDACxC;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;sCACvF,iBAAS;uDAAA;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,6BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;;oDACnE;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;;sDAC7D;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;;wDACvC;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,C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kBAAG,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;oDACpD;gCALF,qBAAqB;IADjC,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;GAC5C,qBAAqB,CAMjC","sourcesContent":["import { ObjectType, Field, Float, InputType, Int, ID } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { CashFlowType } from '../cash-flow-type'\nimport { RecurringCashItem } from './recurring-cash-item'\n\n@InputType({ description: 'A recurring item, or a grid row: cuFlag + adds, M changes, - deletes' })\nexport class RecurringCashItemPatch {\n @Field(type => ID, { nullable: true, description: 'The item to change or delete' })\n id?: string\n\n @Field({ nullable: true, description: 'What it is' })\n name?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'The account subject it is booked to' })\n account?: ObjectRef\n\n @Field(type => CashFlowType, { nullable: true, description: 'Money in or money out' })\n type?: CashFlowType\n\n @Field(type => Float, { nullable: true, description: 'Amount every month' })\n amount?: number\n\n @Field({ nullable: true, description: 'ISO 4217 code' })\n currency?: string\n\n @Field(type => Int, { nullable: true, description: '1-31' })\n dayOfMonth?: number\n\n @Field({ nullable: true, description: 'Falls on the last day of every month' })\n lastDayOfMonth?: boolean\n\n @Field({ nullable: true, description: 'First month - YYYY-MM' })\n startMonth?: string\n\n @Field({ nullable: true, description: 'Last month - YYYY-MM' })\n endMonth?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'Who it is paid to or received from' })\n counterparty?: ObjectRef\n\n @Field({ nullable: true, description: 'Whether it still makes forecasts' })\n active?: boolean\n\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @Field({ nullable: true, description: '+ adds, M changes, - deletes' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A page of recurring items' })\nexport class RecurringCashItemList {\n @Field(type => [RecurringCashItem], { description: 'The items on this page' })\n items: RecurringCashItem[]\n\n @Field(type => Int, { description: 'How many there are in all' })\n total: number\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import { Domain } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Counterparty } from '@things-factory/biz-base';
4
+ import { Account } from '../account/account';
5
+ import { CashFlowType } from '../cash-flow-type';
6
+ /**
7
+ * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. Each month it
8
+ * falls in, it makes a forecast (§`Transaction.recurringItem`).
9
+ */
10
+ export declare class RecurringCashItem {
11
+ readonly id: string;
12
+ domain?: Domain;
13
+ domainId?: string;
14
+ name: string;
15
+ account?: Account;
16
+ accountId?: string;
17
+ type: CashFlowType;
18
+ amount: number;
19
+ currency: string;
20
+ dayOfMonth?: number;
21
+ lastDayOfMonth: boolean;
22
+ startMonth: string;
23
+ endMonth?: string;
24
+ counterparty?: Counterparty;
25
+ counterpartyId?: string;
26
+ active: boolean;
27
+ notes?: string;
28
+ createdAt?: Date;
29
+ updatedAt?: Date;
30
+ deletedAt?: Date;
31
+ creator?: User;
32
+ creatorId?: string;
33
+ updater?: User;
34
+ updaterId?: string;
35
+ }