@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,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecurringCashItem = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const typeorm_1 = require("typeorm");
6
+ const type_graphql_1 = require("type-graphql");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const auth_base_1 = require("@things-factory/auth-base");
9
+ const biz_base_1 = require("@things-factory/biz-base");
10
+ const account_1 = require("../account/account");
11
+ const cash_flow_type_1 = require("../cash-flow-type");
12
+ /**
13
+ * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. Each month it
14
+ * falls in, it makes a forecast (§`Transaction.recurringItem`).
15
+ */
16
+ let RecurringCashItem = class RecurringCashItem {
17
+ };
18
+ exports.RecurringCashItem = RecurringCashItem;
19
+ tslib_1.__decorate([
20
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
21
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier' }),
22
+ tslib_1.__metadata("design:type", String)
23
+ ], RecurringCashItem.prototype, "id", void 0);
24
+ tslib_1.__decorate([
25
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
26
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain whose item it is' }),
27
+ tslib_1.__metadata("design:type", shell_1.Domain)
28
+ ], RecurringCashItem.prototype, "domain", void 0);
29
+ tslib_1.__decorate([
30
+ (0, typeorm_1.RelationId)((item) => item.domain),
31
+ tslib_1.__metadata("design:type", String)
32
+ ], RecurringCashItem.prototype, "domainId", void 0);
33
+ tslib_1.__decorate([
34
+ (0, typeorm_1.Column)(),
35
+ (0, type_graphql_1.Field)({ description: 'What it is - the forecasts it makes take this as their description' }),
36
+ tslib_1.__metadata("design:type", String)
37
+ ], RecurringCashItem.prototype, "name", void 0);
38
+ tslib_1.__decorate([
39
+ (0, typeorm_1.ManyToOne)(type => account_1.Account, { nullable: true, onDelete: 'SET NULL' }),
40
+ (0, type_graphql_1.Field)(type => account_1.Account, { nullable: true, description: 'The account subject it is booked to' }),
41
+ tslib_1.__metadata("design:type", account_1.Account)
42
+ ], RecurringCashItem.prototype, "account", void 0);
43
+ tslib_1.__decorate([
44
+ (0, typeorm_1.RelationId)((item) => item.account),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], RecurringCashItem.prototype, "accountId", void 0);
47
+ tslib_1.__decorate([
48
+ (0, typeorm_1.Column)({ default: cash_flow_type_1.CashFlowType.EXPENSE }),
49
+ (0, type_graphql_1.Field)(type => cash_flow_type_1.CashFlowType, { description: 'Money in or money out' }),
50
+ tslib_1.__metadata("design:type", String)
51
+ ], RecurringCashItem.prototype, "type", void 0);
52
+ tslib_1.__decorate([
53
+ (0, typeorm_1.Column)((0, shell_1.moneyColumn)()),
54
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Amount every month' }),
55
+ tslib_1.__metadata("design:type", Number)
56
+ ], RecurringCashItem.prototype, "amount", void 0);
57
+ tslib_1.__decorate([
58
+ (0, typeorm_1.Column)({ default: 'KRW' }),
59
+ (0, type_graphql_1.Field)({ description: 'ISO 4217 code' }),
60
+ tslib_1.__metadata("design:type", String)
61
+ ], RecurringCashItem.prototype, "currency", void 0);
62
+ tslib_1.__decorate([
63
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
64
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, {
65
+ nullable: true,
66
+ description: "1-31; a day past the month's end is its last day. Empty with lastDayOfMonth"
67
+ }),
68
+ tslib_1.__metadata("design:type", Number)
69
+ ], RecurringCashItem.prototype, "dayOfMonth", void 0);
70
+ tslib_1.__decorate([
71
+ (0, typeorm_1.Column)({ default: false }),
72
+ (0, type_graphql_1.Field)({ description: 'Falls on the last day of every month' }),
73
+ tslib_1.__metadata("design:type", Boolean)
74
+ ], RecurringCashItem.prototype, "lastDayOfMonth", void 0);
75
+ tslib_1.__decorate([
76
+ (0, typeorm_1.Column)(),
77
+ (0, type_graphql_1.Field)({ description: 'First month - YYYY-MM' }),
78
+ tslib_1.__metadata("design:type", String)
79
+ ], RecurringCashItem.prototype, "startMonth", void 0);
80
+ tslib_1.__decorate([
81
+ (0, typeorm_1.Column)({ nullable: true }),
82
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Last month; open-ended when empty - YYYY-MM' }),
83
+ tslib_1.__metadata("design:type", String)
84
+ ], RecurringCashItem.prototype, "endMonth", void 0);
85
+ tslib_1.__decorate([
86
+ (0, typeorm_1.ManyToOne)(type => biz_base_1.Counterparty, { nullable: true, onDelete: 'SET NULL' }),
87
+ (0, type_graphql_1.Field)(type => biz_base_1.Counterparty, { nullable: true, description: 'Who it is paid to or received from' }),
88
+ tslib_1.__metadata("design:type", biz_base_1.Counterparty)
89
+ ], RecurringCashItem.prototype, "counterparty", void 0);
90
+ tslib_1.__decorate([
91
+ (0, typeorm_1.RelationId)((item) => item.counterparty),
92
+ tslib_1.__metadata("design:type", String)
93
+ ], RecurringCashItem.prototype, "counterpartyId", void 0);
94
+ tslib_1.__decorate([
95
+ (0, typeorm_1.Column)({ default: true }),
96
+ (0, type_graphql_1.Field)({ description: 'An inactive item makes no more forecasts' }),
97
+ tslib_1.__metadata("design:type", Boolean)
98
+ ], RecurringCashItem.prototype, "active", void 0);
99
+ tslib_1.__decorate([
100
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
101
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
102
+ tslib_1.__metadata("design:type", String)
103
+ ], RecurringCashItem.prototype, "notes", void 0);
104
+ tslib_1.__decorate([
105
+ (0, typeorm_1.CreateDateColumn)(),
106
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it was created' }),
107
+ tslib_1.__metadata("design:type", Date)
108
+ ], RecurringCashItem.prototype, "createdAt", void 0);
109
+ tslib_1.__decorate([
110
+ (0, typeorm_1.UpdateDateColumn)(),
111
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it last changed' }),
112
+ tslib_1.__metadata("design:type", Date)
113
+ ], RecurringCashItem.prototype, "updatedAt", void 0);
114
+ tslib_1.__decorate([
115
+ (0, typeorm_1.DeleteDateColumn)(),
116
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it was deleted - the forecasts it made are kept' }),
117
+ tslib_1.__metadata("design:type", Date)
118
+ ], RecurringCashItem.prototype, "deletedAt", void 0);
119
+ tslib_1.__decorate([
120
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
121
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who created it' }),
122
+ tslib_1.__metadata("design:type", auth_base_1.User)
123
+ ], RecurringCashItem.prototype, "creator", void 0);
124
+ tslib_1.__decorate([
125
+ (0, typeorm_1.RelationId)((item) => item.creator),
126
+ tslib_1.__metadata("design:type", String)
127
+ ], RecurringCashItem.prototype, "creatorId", void 0);
128
+ tslib_1.__decorate([
129
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
130
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it' }),
131
+ tslib_1.__metadata("design:type", auth_base_1.User)
132
+ ], RecurringCashItem.prototype, "updater", void 0);
133
+ tslib_1.__decorate([
134
+ (0, typeorm_1.RelationId)((item) => item.updater),
135
+ tslib_1.__metadata("design:type", String)
136
+ ], RecurringCashItem.prototype, "updaterId", void 0);
137
+ exports.RecurringCashItem = RecurringCashItem = tslib_1.__decorate([
138
+ (0, typeorm_1.Entity)(),
139
+ (0, typeorm_1.Index)('ix_recurring_cash_item_0', (item) => [item.domain, item.active]),
140
+ (0, type_graphql_1.ObjectType)({ description: 'Money that comes in or goes out every month on a known day' })
141
+ ], RecurringCashItem);
142
+ //# sourceMappingURL=recurring-cash-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-cash-item.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAEhE,iDAA2D;AAC3D,yDAAgD;AAChD,uDAAuD;AAEvD,gDAA4C;AAC5C,sDAAgD;AAEhD;;;GAGG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CA8F7B,CAAA;AA9FY,8CAAiB;AAGnB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;;6CACrC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;sCAC7E,cAAM;iDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;mDACpC;AAIjB;IAF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7B","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\n\nimport { Domain, moneyColumn } 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 { CashFlowType } from '../cash-flow-type'\n\n/**\n * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. Each month it\n * falls in, it makes a forecast (§`Transaction.recurringItem`).\n */\n@Entity()\n@Index('ix_recurring_cash_item_0', (item: RecurringCashItem) => [item.domain, item.active])\n@ObjectType({ description: 'Money that comes in or goes out every month on a known day' })\nexport class RecurringCashItem {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain whose item it is' })\n domain?: Domain\n\n @RelationId((item: RecurringCashItem) => item.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'What it is - the forecasts it makes take this as their description' })\n name: string\n\n @ManyToOne(type => Account, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Account, { nullable: true, description: 'The account subject it is booked to' })\n account?: Account\n\n @RelationId((item: RecurringCashItem) => item.account)\n accountId?: string\n\n @Column({ default: CashFlowType.EXPENSE })\n @Field(type => CashFlowType, { description: 'Money in or money out' })\n type: CashFlowType\n\n @Column(moneyColumn())\n @Field(type => Float, { description: 'Amount every month' })\n amount: number\n\n @Column({ default: 'KRW' })\n @Field({ description: 'ISO 4217 code' })\n currency: string\n\n @Column({ type: 'int', nullable: true })\n @Field(type => Int, {\n nullable: true,\n description: \"1-31; a day past the month's end is its last day. Empty with lastDayOfMonth\"\n })\n dayOfMonth?: number\n\n @Column({ default: false })\n @Field({ description: 'Falls on the last day of every month' })\n lastDayOfMonth: boolean\n\n @Column()\n @Field({ description: 'First month - YYYY-MM' })\n startMonth: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Last month; open-ended when empty - YYYY-MM' })\n endMonth?: string\n\n @ManyToOne(type => Counterparty, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Counterparty, { nullable: true, description: 'Who it is paid to or received from' })\n counterparty?: Counterparty\n\n @RelationId((item: RecurringCashItem) => item.counterparty)\n counterpartyId?: string\n\n @Column({ default: true })\n @Field({ description: 'An inactive item makes no more forecasts' })\n active: boolean\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it was created' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When it last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When it was deleted - the forecasts it made are kept' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who created it' })\n creator?: User\n\n @RelationId((item: RecurringCashItem) => item.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((item: RecurringCashItem) => item.updater)\n updaterId?: string\n}\n"]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Which recurring items fall in a month, and the forecast line each one makes.
3
+ *
4
+ * An item falls in a month when it is active and the month lies within [startMonth, endMonth].
5
+ * Its timing is written the way the forecast ledger writes it — `21일`, `말일` — so the calendar
6
+ * places the line on that day (§`forecastDay`). An item with neither a day nor 말일 makes a line
7
+ * with no timing: the calendar shows it undated, as it does any line nobody gave a day.
8
+ *
9
+ * Pure.
10
+ */
11
+ export interface RecurringItem {
12
+ id: string;
13
+ name: string;
14
+ type: string;
15
+ amount: number;
16
+ currency?: string | null;
17
+ dayOfMonth?: number | null;
18
+ lastDayOfMonth?: boolean | null;
19
+ startMonth: string;
20
+ endMonth?: string | null;
21
+ active?: boolean | null;
22
+ }
23
+ export interface GeneratedLine {
24
+ recurringItemId: string;
25
+ year: number;
26
+ month: number;
27
+ type: string;
28
+ name: string;
29
+ amount: number;
30
+ currency: string;
31
+ timing: string | null;
32
+ }
33
+ export declare function fallsIn(item: RecurringItem, year: number, month: number): boolean;
34
+ export declare function timingOf(item: RecurringItem): string | null;
35
+ /** The lines to add for a month — leaving out items that already made one (`already`). */
36
+ export declare function linesFor(items: readonly RecurringItem[], year: number, month: number, already: ReadonlySet<string>): GeneratedLine[];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * Which recurring items fall in a month, and the forecast line each one makes.
4
+ *
5
+ * An item falls in a month when it is active and the month lies within [startMonth, endMonth].
6
+ * Its timing is written the way the forecast ledger writes it — `21일`, `말일` — so the calendar
7
+ * places the line on that day (§`forecastDay`). An item with neither a day nor 말일 makes a line
8
+ * with no timing: the calendar shows it undated, as it does any line nobody gave a day.
9
+ *
10
+ * Pure.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.fallsIn = fallsIn;
14
+ exports.timingOf = timingOf;
15
+ exports.linesFor = linesFor;
16
+ const monthKey = (year, month) => `${year}-${String(month).padStart(2, '0')}`;
17
+ function fallsIn(item, year, month) {
18
+ const key = monthKey(year, month);
19
+ return item.active !== false && item.startMonth <= key && (!item.endMonth || key <= item.endMonth);
20
+ }
21
+ function timingOf(item) {
22
+ if (item.lastDayOfMonth)
23
+ return '말일';
24
+ return item.dayOfMonth ? `${item.dayOfMonth}일` : null;
25
+ }
26
+ /** The lines to add for a month — leaving out items that already made one (`already`). */
27
+ function linesFor(items, year, month, already) {
28
+ return items
29
+ .filter(item => fallsIn(item, year, month) && !already.has(item.id))
30
+ .map(item => ({
31
+ recurringItemId: item.id,
32
+ year,
33
+ month,
34
+ type: item.type,
35
+ name: item.name,
36
+ amount: item.amount,
37
+ currency: item.currency || 'KRW',
38
+ timing: timingOf(item)
39
+ }));
40
+ }
41
+ //# sourceMappingURL=recurring-schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-schedule.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-schedule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AA4BH,0BAGC;AAED,4BAGC;AAGD,4BAkBC;AA/BD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA;AAE7F,SAAgB,OAAO,CAAC,IAAmB,EAAE,IAAY,EAAE,KAAa;IACtE,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACjC,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAA;AACpG,CAAC;AAED,SAAgB,QAAQ,CAAC,IAAmB;IAC1C,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AACvD,CAAC;AAED,0FAA0F;AAC1F,SAAgB,QAAQ,CACtB,KAA+B,EAC/B,IAAY,EACZ,KAAa,EACb,OAA4B;IAE5B,OAAO,KAAK;SACT,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACnE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,eAAe,EAAE,IAAI,CAAC,EAAE;QACxB,IAAI;QACJ,KAAK;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;KACvB,CAAC,CAAC,CAAA;AACP,CAAC","sourcesContent":["/**\n * Which recurring items fall in a month, and the forecast line each one makes.\n *\n * An item falls in a month when it is active and the month lies within [startMonth, endMonth].\n * Its timing is written the way the forecast ledger writes it — `21일`, `말일` — so the calendar\n * places the line on that day (§`forecastDay`). An item with neither a day nor 말일 makes a line\n * with no timing: the calendar shows it undated, as it does any line nobody gave a day.\n *\n * Pure.\n */\n\nexport interface RecurringItem {\n id: string\n name: string\n type: string\n amount: number\n currency?: string | null\n dayOfMonth?: number | null\n lastDayOfMonth?: boolean | null\n startMonth: string\n endMonth?: string | null\n active?: boolean | null\n}\n\nexport interface GeneratedLine {\n recurringItemId: string\n year: number\n month: number\n type: string\n name: string\n amount: number\n currency: string\n timing: string | null\n}\n\nconst monthKey = (year: number, month: number) => `${year}-${String(month).padStart(2, '0')}`\n\nexport function fallsIn(item: RecurringItem, year: number, month: number): boolean {\n const key = monthKey(year, month)\n return item.active !== false && item.startMonth <= key && (!item.endMonth || key <= item.endMonth)\n}\n\nexport function timingOf(item: RecurringItem): string | null {\n if (item.lastDayOfMonth) return '말일'\n return item.dayOfMonth ? `${item.dayOfMonth}일` : null\n}\n\n/** The lines to add for a month — leaving out items that already made one (`already`). */\nexport function linesFor(\n items: readonly RecurringItem[],\n year: number,\n month: number,\n already: ReadonlySet<string>\n): GeneratedLine[] {\n return items\n .filter(item => fallsIn(item, year, month) && !already.has(item.id))\n .map(item => ({\n recurringItemId: item.id,\n year,\n month,\n type: item.type,\n name: item.name,\n amount: item.amount,\n currency: item.currency || 'KRW',\n timing: timingOf(item)\n }))\n}\n"]}
@@ -1,29 +1,56 @@
1
1
  import { HistoryActionType, HistoryEntityInterface } from '@operato/typeorm-history';
2
2
  import { User } from '@things-factory/auth-base';
3
3
  import { Domain } from '@things-factory/shell';
4
- import { Transaction, TransactionCategory, TransactionStatus, TransactionType } from './transaction';
4
+ import { Counterparty } from '@things-factory/biz-base';
5
5
  import { Account } from '../account/account';
6
+ import { BankAccount } from '../bank-account/bank-account';
7
+ import { BankStatement } from '../bank-statement/bank-statement';
8
+ import { CashFlowType } from '../cash-flow-type';
9
+ import { RecurringCashItem } from '../recurring-cash-item/recurring-cash-item';
10
+ import { ForecastStatus, Transaction, TransactionCategory, TransactionSource } from './transaction';
11
+ /** Each version of a transaction, written when it changes. */
6
12
  export declare class TransactionHistory implements HistoryEntityInterface<Transaction> {
7
13
  readonly id: string;
8
14
  version?: number;
9
15
  domain?: Domain;
10
16
  domainId?: string;
11
- name?: string;
12
- description?: string;
13
- currency?: string;
14
- amount?: number;
15
- active?: boolean;
16
- type?: TransactionType;
17
17
  category: TransactionCategory;
18
- status: TransactionStatus;
19
- probability?: number;
20
- forecastNotes?: string;
21
- account?: Account;
22
- accountId?: string;
23
- year?: number;
24
- quarter?: number;
25
- month?: number;
18
+ type: CashFlowType;
19
+ bankAccount: BankAccount;
20
+ bankAccountId?: string;
26
21
  transactionDate: string;
22
+ transactionAt: string;
23
+ year: number;
24
+ month: number;
25
+ amount: number;
26
+ currency: string;
27
+ balance: number;
28
+ account: Account;
29
+ accountId?: string;
30
+ description: string;
31
+ ledgerCategory: string;
32
+ counterpartyName: string;
33
+ counterparty: Counterparty;
34
+ counterpartyId?: string;
35
+ source: TransactionSource;
36
+ bankStatement: BankStatement;
37
+ bankStatementId?: string;
38
+ sourceFile: string;
39
+ sourceRow: number;
40
+ bankSequence: number;
41
+ bankFingerprint: string;
42
+ bankDescription: string;
43
+ bankKind: string;
44
+ bankCounterpartyName: string;
45
+ bankCounterpartyAccount: string;
46
+ bankCounterpartyBank: string;
47
+ bankMemo: string;
48
+ timing: string;
49
+ status: ForecastStatus;
50
+ probability: number;
51
+ notes: string;
52
+ recurringItem: RecurringCashItem;
53
+ recurringItemId?: string;
27
54
  createdAt?: Date;
28
55
  updatedAt?: Date;
29
56
  deletedAt?: Date;
@@ -8,30 +8,35 @@ const typeorm_history_1 = require("@operato/typeorm-history");
8
8
  const auth_base_1 = require("@things-factory/auth-base");
9
9
  const env_1 = require("@things-factory/env");
10
10
  const shell_1 = require("@things-factory/shell");
11
- const transaction_1 = require("./transaction");
11
+ const biz_base_1 = require("@things-factory/biz-base");
12
12
  const account_1 = require("../account/account");
13
+ const bank_account_1 = require("../bank-account/bank-account");
14
+ const bank_statement_1 = require("../bank-statement/bank-statement");
15
+ const cash_flow_type_1 = require("../cash-flow-type");
16
+ const recurring_cash_item_1 = require("../recurring-cash-item/recurring-cash-item");
17
+ const transaction_1 = require("./transaction");
13
18
  const ORMCONFIG = env_1.config.get('ormconfig', {});
14
19
  const DATABASE_TYPE = ORMCONFIG.type;
20
+ /** Each version of a transaction, written when it changes. */
15
21
  let TransactionHistory = class TransactionHistory {
16
22
  constructor() {
17
23
  this.version = 1;
18
- this.amount = 0;
19
24
  }
20
25
  };
21
26
  exports.TransactionHistory = TransactionHistory;
22
27
  tslib_1.__decorate([
23
28
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
24
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
29
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier of the version' }),
25
30
  tslib_1.__metadata("design:type", String)
26
31
  ], TransactionHistory.prototype, "id", void 0);
27
32
  tslib_1.__decorate([
28
33
  (0, typeorm_1.Column)({ nullable: true, default: 1 }),
29
- (0, type_graphql_1.Field)({ nullable: true }),
34
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Version number' }),
30
35
  tslib_1.__metadata("design:type", Number)
31
36
  ], TransactionHistory.prototype, "version", void 0);
32
37
  tslib_1.__decorate([
33
38
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
34
- (0, type_graphql_1.Field)({ nullable: true }),
39
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain' }),
35
40
  tslib_1.__metadata("design:type", shell_1.Domain)
36
41
  ], TransactionHistory.prototype, "domain", void 0);
37
42
  tslib_1.__decorate([
@@ -39,102 +44,203 @@ tslib_1.__decorate([
39
44
  tslib_1.__metadata("design:type", String)
40
45
  ], TransactionHistory.prototype, "domainId", void 0);
41
46
  tslib_1.__decorate([
42
- (0, typeorm_1.Column)(),
43
- (0, type_graphql_1.Field)({ nullable: true }),
47
+ (0, typeorm_1.Column)({ nullable: true }),
48
+ (0, type_graphql_1.Field)(type => transaction_1.TransactionCategory, { nullable: true, description: 'category at this version' }),
44
49
  tslib_1.__metadata("design:type", String)
45
- ], TransactionHistory.prototype, "name", void 0);
50
+ ], TransactionHistory.prototype, "category", void 0);
46
51
  tslib_1.__decorate([
47
52
  (0, typeorm_1.Column)({ nullable: true }),
48
- (0, type_graphql_1.Field)({ nullable: true }),
53
+ (0, type_graphql_1.Field)(type => cash_flow_type_1.CashFlowType, { nullable: true, description: 'type at this version' }),
49
54
  tslib_1.__metadata("design:type", String)
50
- ], TransactionHistory.prototype, "description", void 0);
55
+ ], TransactionHistory.prototype, "type", void 0);
56
+ tslib_1.__decorate([
57
+ (0, typeorm_1.ManyToOne)(type => bank_account_1.BankAccount, { nullable: true, createForeignKeyConstraints: false }),
58
+ (0, type_graphql_1.Field)(type => bank_account_1.BankAccount, { nullable: true, description: 'bankAccount at this version' }),
59
+ tslib_1.__metadata("design:type", bank_account_1.BankAccount)
60
+ ], TransactionHistory.prototype, "bankAccount", void 0);
61
+ tslib_1.__decorate([
62
+ (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.bankAccount),
63
+ tslib_1.__metadata("design:type", String)
64
+ ], TransactionHistory.prototype, "bankAccountId", void 0);
51
65
  tslib_1.__decorate([
52
66
  (0, typeorm_1.Column)({ nullable: true }),
53
- (0, type_graphql_1.Field)({ nullable: true }),
67
+ (0, type_graphql_1.Field)({ nullable: true, description: 'transactionDate at this version' }),
54
68
  tslib_1.__metadata("design:type", String)
55
- ], TransactionHistory.prototype, "currency", void 0);
69
+ ], TransactionHistory.prototype, "transactionDate", void 0);
70
+ tslib_1.__decorate([
71
+ (0, typeorm_1.Column)({ nullable: true }),
72
+ (0, type_graphql_1.Field)({ nullable: true, description: 'transactionAt at this version' }),
73
+ tslib_1.__metadata("design:type", String)
74
+ ], TransactionHistory.prototype, "transactionAt", void 0);
75
+ tslib_1.__decorate([
76
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
77
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'year at this version' }),
78
+ tslib_1.__metadata("design:type", Number)
79
+ ], TransactionHistory.prototype, "year", void 0);
80
+ tslib_1.__decorate([
81
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
82
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'month at this version' }),
83
+ tslib_1.__metadata("design:type", Number)
84
+ ], TransactionHistory.prototype, "month", void 0);
56
85
  tslib_1.__decorate([
57
86
  (0, typeorm_1.Column)((0, shell_1.moneyColumn)({ nullable: true })),
58
- (0, type_graphql_1.Field)({ nullable: true }),
87
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'amount at this version' }),
59
88
  tslib_1.__metadata("design:type", Number)
60
89
  ], TransactionHistory.prototype, "amount", void 0);
61
90
  tslib_1.__decorate([
62
91
  (0, typeorm_1.Column)({ nullable: true }),
63
- (0, type_graphql_1.Field)({ nullable: true }),
64
- tslib_1.__metadata("design:type", Boolean)
65
- ], TransactionHistory.prototype, "active", void 0);
92
+ (0, type_graphql_1.Field)({ nullable: true, description: 'currency at this version' }),
93
+ tslib_1.__metadata("design:type", String)
94
+ ], TransactionHistory.prototype, "currency", void 0);
66
95
  tslib_1.__decorate([
67
- (0, typeorm_1.Column)({ nullable: true }),
68
- (0, type_graphql_1.Field)({ nullable: true }),
96
+ (0, typeorm_1.Column)((0, shell_1.moneyColumn)({ nullable: true })),
97
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'balance at this version' }),
69
98
  tslib_1.__metadata("design:type", Number)
70
- ], TransactionHistory.prototype, "type", void 0);
99
+ ], TransactionHistory.prototype, "balance", void 0);
100
+ tslib_1.__decorate([
101
+ (0, typeorm_1.ManyToOne)(type => account_1.Account, { nullable: true, createForeignKeyConstraints: false }),
102
+ (0, type_graphql_1.Field)(type => account_1.Account, { nullable: true, description: 'account at this version' }),
103
+ tslib_1.__metadata("design:type", account_1.Account)
104
+ ], TransactionHistory.prototype, "account", void 0);
71
105
  tslib_1.__decorate([
72
- (0, typeorm_1.Column)({ nullable: false }),
73
- (0, type_graphql_1.Field)(type => transaction_1.TransactionCategory, { nullable: false }),
106
+ (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.account),
74
107
  tslib_1.__metadata("design:type", String)
75
- ], TransactionHistory.prototype, "category", void 0);
108
+ ], TransactionHistory.prototype, "accountId", void 0);
76
109
  tslib_1.__decorate([
77
- (0, typeorm_1.Column)({ nullable: false }),
78
- (0, type_graphql_1.Field)(type => transaction_1.TransactionStatus, { nullable: false }),
110
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
111
+ (0, type_graphql_1.Field)({ nullable: true, description: 'description at this version' }),
79
112
  tslib_1.__metadata("design:type", String)
80
- ], TransactionHistory.prototype, "status", void 0);
113
+ ], TransactionHistory.prototype, "description", void 0);
81
114
  tslib_1.__decorate([
82
115
  (0, typeorm_1.Column)({ nullable: true }),
83
- (0, type_graphql_1.Field)({ nullable: true, description: 'The probability of the forecast being realized (0 to 100)' }),
84
- tslib_1.__metadata("design:type", Number)
85
- ], TransactionHistory.prototype, "probability", void 0);
116
+ (0, type_graphql_1.Field)({ nullable: true, description: 'ledgerCategory at this version' }),
117
+ tslib_1.__metadata("design:type", String)
118
+ ], TransactionHistory.prototype, "ledgerCategory", void 0);
86
119
  tslib_1.__decorate([
87
120
  (0, typeorm_1.Column)({ nullable: true }),
88
- (0, type_graphql_1.Field)({ nullable: true, description: 'Additional notes or comments about the forecast' }),
121
+ (0, type_graphql_1.Field)({ nullable: true, description: 'counterpartyName at this version' }),
89
122
  tslib_1.__metadata("design:type", String)
90
- ], TransactionHistory.prototype, "forecastNotes", void 0);
123
+ ], TransactionHistory.prototype, "counterpartyName", void 0);
91
124
  tslib_1.__decorate([
92
- (0, typeorm_1.ManyToOne)(type => account_1.Account),
93
- (0, type_graphql_1.Field)({ nullable: true }),
94
- tslib_1.__metadata("design:type", account_1.Account)
95
- ], TransactionHistory.prototype, "account", void 0);
125
+ (0, typeorm_1.ManyToOne)(type => biz_base_1.Counterparty, { nullable: true, createForeignKeyConstraints: false }),
126
+ (0, type_graphql_1.Field)(type => biz_base_1.Counterparty, { nullable: true, description: 'counterparty at this version' }),
127
+ tslib_1.__metadata("design:type", biz_base_1.Counterparty)
128
+ ], TransactionHistory.prototype, "counterparty", void 0);
96
129
  tslib_1.__decorate([
97
- (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.account),
130
+ (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.counterparty),
98
131
  tslib_1.__metadata("design:type", String)
99
- ], TransactionHistory.prototype, "accountId", void 0);
132
+ ], TransactionHistory.prototype, "counterpartyId", void 0);
100
133
  tslib_1.__decorate([
101
134
  (0, typeorm_1.Column)({ nullable: true }),
102
- (0, type_graphql_1.Field)({ nullable: true, description: 'fiscal year' }),
103
- tslib_1.__metadata("design:type", Number)
104
- ], TransactionHistory.prototype, "year", void 0);
135
+ (0, type_graphql_1.Field)(type => transaction_1.TransactionSource, { nullable: true, description: 'source at this version' }),
136
+ tslib_1.__metadata("design:type", String)
137
+ ], TransactionHistory.prototype, "source", void 0);
138
+ tslib_1.__decorate([
139
+ (0, typeorm_1.ManyToOne)(type => bank_statement_1.BankStatement, { nullable: true, createForeignKeyConstraints: false }),
140
+ (0, type_graphql_1.Field)(type => bank_statement_1.BankStatement, { nullable: true, description: 'bankStatement at this version' }),
141
+ tslib_1.__metadata("design:type", bank_statement_1.BankStatement)
142
+ ], TransactionHistory.prototype, "bankStatement", void 0);
143
+ tslib_1.__decorate([
144
+ (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.bankStatement),
145
+ tslib_1.__metadata("design:type", String)
146
+ ], TransactionHistory.prototype, "bankStatementId", void 0);
105
147
  tslib_1.__decorate([
106
148
  (0, typeorm_1.Column)({ nullable: true }),
107
- (0, type_graphql_1.Field)({ nullable: true, description: 'fiscal quarter' }),
149
+ (0, type_graphql_1.Field)({ nullable: true, description: 'sourceFile at this version' }),
150
+ tslib_1.__metadata("design:type", String)
151
+ ], TransactionHistory.prototype, "sourceFile", void 0);
152
+ tslib_1.__decorate([
153
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
154
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'sourceRow at this version' }),
108
155
  tslib_1.__metadata("design:type", Number)
109
- ], TransactionHistory.prototype, "quarter", void 0);
156
+ ], TransactionHistory.prototype, "sourceRow", void 0);
157
+ tslib_1.__decorate([
158
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
159
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'bankSequence at this version' }),
160
+ tslib_1.__metadata("design:type", Number)
161
+ ], TransactionHistory.prototype, "bankSequence", void 0);
162
+ tslib_1.__decorate([
163
+ (0, typeorm_1.Column)({ nullable: true }),
164
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankFingerprint at this version' }),
165
+ tslib_1.__metadata("design:type", String)
166
+ ], TransactionHistory.prototype, "bankFingerprint", void 0);
167
+ tslib_1.__decorate([
168
+ (0, typeorm_1.Column)({ nullable: true }),
169
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankDescription at this version' }),
170
+ tslib_1.__metadata("design:type", String)
171
+ ], TransactionHistory.prototype, "bankDescription", void 0);
172
+ tslib_1.__decorate([
173
+ (0, typeorm_1.Column)({ nullable: true }),
174
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankKind at this version' }),
175
+ tslib_1.__metadata("design:type", String)
176
+ ], TransactionHistory.prototype, "bankKind", void 0);
177
+ tslib_1.__decorate([
178
+ (0, typeorm_1.Column)({ nullable: true }),
179
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankCounterpartyName at this version' }),
180
+ tslib_1.__metadata("design:type", String)
181
+ ], TransactionHistory.prototype, "bankCounterpartyName", void 0);
182
+ tslib_1.__decorate([
183
+ (0, typeorm_1.Column)({ nullable: true }),
184
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankCounterpartyAccount at this version' }),
185
+ tslib_1.__metadata("design:type", String)
186
+ ], TransactionHistory.prototype, "bankCounterpartyAccount", void 0);
110
187
  tslib_1.__decorate([
111
188
  (0, typeorm_1.Column)({ nullable: true }),
112
- (0, type_graphql_1.Field)({ nullable: true, description: 'fiscal month' }),
189
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankCounterpartyBank at this version' }),
190
+ tslib_1.__metadata("design:type", String)
191
+ ], TransactionHistory.prototype, "bankCounterpartyBank", void 0);
192
+ tslib_1.__decorate([
193
+ (0, typeorm_1.Column)({ nullable: true }),
194
+ (0, type_graphql_1.Field)({ nullable: true, description: 'bankMemo at this version' }),
195
+ tslib_1.__metadata("design:type", String)
196
+ ], TransactionHistory.prototype, "bankMemo", void 0);
197
+ tslib_1.__decorate([
198
+ (0, typeorm_1.Column)({ nullable: true }),
199
+ (0, type_graphql_1.Field)({ nullable: true, description: 'timing at this version' }),
200
+ tslib_1.__metadata("design:type", String)
201
+ ], TransactionHistory.prototype, "timing", void 0);
202
+ tslib_1.__decorate([
203
+ (0, typeorm_1.Column)({ nullable: true }),
204
+ (0, type_graphql_1.Field)(type => transaction_1.ForecastStatus, { nullable: true, description: 'status at this version' }),
205
+ tslib_1.__metadata("design:type", String)
206
+ ], TransactionHistory.prototype, "status", void 0);
207
+ tslib_1.__decorate([
208
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
209
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'probability at this version' }),
113
210
  tslib_1.__metadata("design:type", Number)
114
- ], TransactionHistory.prototype, "month", void 0);
211
+ ], TransactionHistory.prototype, "probability", void 0);
115
212
  tslib_1.__decorate([
116
- (0, typeorm_1.Column)({ nullable: false }),
117
- (0, type_graphql_1.Field)({ nullable: false, description: 'The date the transaction occurs or is scheduled (in string format)' }),
213
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
214
+ (0, type_graphql_1.Field)({ nullable: true, description: 'notes at this version' }),
118
215
  tslib_1.__metadata("design:type", String)
119
- ], TransactionHistory.prototype, "transactionDate", void 0);
216
+ ], TransactionHistory.prototype, "notes", void 0);
217
+ tslib_1.__decorate([
218
+ (0, typeorm_1.ManyToOne)(type => recurring_cash_item_1.RecurringCashItem, { nullable: true, createForeignKeyConstraints: false }),
219
+ (0, type_graphql_1.Field)(type => recurring_cash_item_1.RecurringCashItem, { nullable: true, description: 'recurringItem at this version' }),
220
+ tslib_1.__metadata("design:type", recurring_cash_item_1.RecurringCashItem)
221
+ ], TransactionHistory.prototype, "recurringItem", void 0);
120
222
  tslib_1.__decorate([
121
- (0, typeorm_1.Column)(),
122
- (0, type_graphql_1.Field)({ nullable: true }),
223
+ (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.recurringItem),
224
+ tslib_1.__metadata("design:type", String)
225
+ ], TransactionHistory.prototype, "recurringItemId", void 0);
226
+ tslib_1.__decorate([
227
+ (0, typeorm_1.Column)({ nullable: true }),
228
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it was created' }),
123
229
  tslib_1.__metadata("design:type", Date)
124
230
  ], TransactionHistory.prototype, "createdAt", void 0);
125
231
  tslib_1.__decorate([
126
- (0, typeorm_1.Column)(),
127
- (0, type_graphql_1.Field)({ nullable: true }),
232
+ (0, typeorm_1.Column)({ nullable: true }),
233
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When this version was written' }),
128
234
  tslib_1.__metadata("design:type", Date)
129
235
  ], TransactionHistory.prototype, "updatedAt", void 0);
130
236
  tslib_1.__decorate([
131
- (0, typeorm_1.Column)(),
132
- (0, type_graphql_1.Field)({ nullable: true }),
237
+ (0, typeorm_1.Column)({ nullable: true }),
238
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it was deleted' }),
133
239
  tslib_1.__metadata("design:type", Date)
134
240
  ], TransactionHistory.prototype, "deletedAt", void 0);
135
241
  tslib_1.__decorate([
136
242
  (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
137
- (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
243
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who created it' }),
138
244
  tslib_1.__metadata("design:type", auth_base_1.User)
139
245
  ], TransactionHistory.prototype, "creator", void 0);
140
246
  tslib_1.__decorate([
@@ -143,7 +249,7 @@ tslib_1.__decorate([
143
249
  ], TransactionHistory.prototype, "creatorId", void 0);
144
250
  tslib_1.__decorate([
145
251
  (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
146
- (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
252
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who wrote this version' }),
147
253
  tslib_1.__metadata("design:type", auth_base_1.User)
148
254
  ], TransactionHistory.prototype, "updater", void 0);
149
255
  tslib_1.__decorate([