@things-factory/accounting 10.1.134 → 10.1.135

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 (234) 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-type.d.ts +16 -0
  14. package/dist-server/service/account/account-type.js +71 -13
  15. package/dist-server/service/account/account-type.js.map +1 -1
  16. package/dist-server/service/account/account.d.ts +9 -3
  17. package/dist-server/service/account/account.js +34 -8
  18. package/dist-server/service/account/account.js.map +1 -1
  19. package/dist-server/service/accounting-category/accounting-category-mutation.js +2 -2
  20. package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -1
  21. package/dist-server/service/accounting-document/accounting-document-mutation.js +12 -3
  22. package/dist-server/service/accounting-document/accounting-document-mutation.js.map +1 -1
  23. package/dist-server/service/accounting-document/accounting-document-query.js +2 -0
  24. package/dist-server/service/accounting-document/accounting-document-query.js.map +1 -1
  25. package/dist-server/service/bank-account/bank-account-history.d.ts +11 -14
  26. package/dist-server/service/bank-account/bank-account-history.js +46 -59
  27. package/dist-server/service/bank-account/bank-account-history.js.map +1 -1
  28. package/dist-server/service/bank-account/bank-account-mutation.d.ts +1 -2
  29. package/dist-server/service/bank-account/bank-account-mutation.js +25 -69
  30. package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -1
  31. package/dist-server/service/bank-account/bank-account-query.js +2 -0
  32. package/dist-server/service/bank-account/bank-account-query.js.map +1 -1
  33. package/dist-server/service/bank-account/bank-account-service.d.ts +5 -0
  34. package/dist-server/service/bank-account/bank-account-service.js +21 -0
  35. package/dist-server/service/bank-account/bank-account-service.js.map +1 -0
  36. package/dist-server/service/bank-account/bank-account-type.d.ts +13 -19
  37. package/dist-server/service/bank-account/bank-account-type.js +45 -69
  38. package/dist-server/service/bank-account/bank-account-type.js.map +1 -1
  39. package/dist-server/service/bank-account/bank-account.d.ts +14 -17
  40. package/dist-server/service/bank-account/bank-account.js +45 -57
  41. package/dist-server/service/bank-account/bank-account.js.map +1 -1
  42. package/dist-server/service/bank-statement/bank-statement-query.d.ts +14 -0
  43. package/dist-server/service/bank-statement/bank-statement-query.js +92 -0
  44. package/dist-server/service/bank-statement/bank-statement-query.js.map +1 -0
  45. package/dist-server/service/bank-statement/bank-statement.d.ts +26 -0
  46. package/dist-server/service/bank-statement/bank-statement.js +109 -0
  47. package/dist-server/service/bank-statement/bank-statement.js.map +1 -0
  48. package/dist-server/service/bank-statement/index.d.ts +5 -0
  49. package/dist-server/service/bank-statement/index.js +9 -0
  50. package/dist-server/service/bank-statement/index.js.map +1 -0
  51. package/dist-server/service/cash-flow-type.d.ts +5 -0
  52. package/dist-server/service/cash-flow-type.js +15 -0
  53. package/dist-server/service/cash-flow-type.js.map +1 -0
  54. package/dist-server/service/financial-institution/financial-institution-mutation.js +10 -1
  55. package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -1
  56. package/dist-server/service/financial-institution/financial-institution-query.js +14 -6
  57. package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -1
  58. package/dist-server/service/financial-institution/index.d.ts +1 -1
  59. package/dist-server/service/financial-statement/financial-statement-history.d.ts +11 -9
  60. package/dist-server/service/financial-statement/financial-statement-history.js +47 -36
  61. package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
  62. package/dist-server/service/financial-statement/financial-statement-line.d.ts +24 -0
  63. package/dist-server/service/financial-statement/financial-statement-line.js +108 -0
  64. package/dist-server/service/financial-statement/financial-statement-line.js.map +1 -0
  65. package/dist-server/service/financial-statement/financial-statement-mutation.d.ts +1 -8
  66. package/dist-server/service/financial-statement/financial-statement-mutation.js +10 -135
  67. package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -1
  68. package/dist-server/service/financial-statement/financial-statement-query.d.ts +8 -7
  69. package/dist-server/service/financial-statement/financial-statement-query.js +40 -30
  70. package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
  71. package/dist-server/service/financial-statement/financial-statement-service.d.ts +33 -0
  72. package/dist-server/service/financial-statement/financial-statement-service.js +44 -0
  73. package/dist-server/service/financial-statement/financial-statement-service.js.map +1 -0
  74. package/dist-server/service/financial-statement/financial-statement.d.ts +19 -11
  75. package/dist-server/service/financial-statement/financial-statement.js +73 -65
  76. package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
  77. package/dist-server/service/financial-statement/index.d.ts +3 -2
  78. package/dist-server/service/financial-statement/index.js +2 -2
  79. package/dist-server/service/financial-statement/index.js.map +1 -1
  80. package/dist-server/service/index.d.ts +15 -3
  81. package/dist-server/service/index.js +30 -13
  82. package/dist-server/service/index.js.map +1 -1
  83. package/dist-server/service/payment/index.d.ts +1 -0
  84. package/dist-server/service/payment/index.js +1 -0
  85. package/dist-server/service/payment/index.js.map +1 -1
  86. package/dist-server/service/payment/payment-history.d.ts +9 -16
  87. package/dist-server/service/payment/payment-history.js +36 -70
  88. package/dist-server/service/payment/payment-history.js.map +1 -1
  89. package/dist-server/service/payment/payment-mutation.d.ts +0 -1
  90. package/dist-server/service/payment/payment-mutation.js +14 -79
  91. package/dist-server/service/payment/payment-mutation.js.map +1 -1
  92. package/dist-server/service/payment/payment-query.d.ts +3 -0
  93. package/dist-server/service/payment/payment-query.js +30 -1
  94. package/dist-server/service/payment/payment-query.js.map +1 -1
  95. package/dist-server/service/payment/payment-service.d.ts +16 -0
  96. package/dist-server/service/payment/payment-service.js +140 -0
  97. package/dist-server/service/payment/payment-service.js.map +1 -0
  98. package/dist-server/service/payment/payment-targets.d.ts +31 -0
  99. package/dist-server/service/payment/payment-targets.js +19 -0
  100. package/dist-server/service/payment/payment-targets.js.map +1 -0
  101. package/dist-server/service/payment/payment-type.d.ts +13 -17
  102. package/dist-server/service/payment/payment-type.js +35 -51
  103. package/dist-server/service/payment/payment-type.js.map +1 -1
  104. package/dist-server/service/payment/payment.d.ts +23 -22
  105. package/dist-server/service/payment/payment.js +66 -94
  106. package/dist-server/service/payment/payment.js.map +1 -1
  107. package/dist-server/service/payment/transfer-target.d.ts +1 -0
  108. package/dist-server/service/payment/transfer-target.js +43 -0
  109. package/dist-server/service/payment/transfer-target.js.map +1 -0
  110. package/dist-server/service/recurring-cash-item/index.d.ts +6 -0
  111. package/dist-server/service/recurring-cash-item/index.js +10 -0
  112. package/dist-server/service/recurring-cash-item/index.js.map +1 -0
  113. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.d.ts +7 -0
  114. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js +63 -0
  115. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js.map +1 -0
  116. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.d.ts +15 -0
  117. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js +101 -0
  118. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js.map +1 -0
  119. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.d.ts +23 -0
  120. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js +91 -0
  121. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js.map +1 -0
  122. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.d.ts +23 -0
  123. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js +85 -0
  124. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js.map +1 -0
  125. package/dist-server/service/recurring-cash-item/recurring-cash-item.d.ts +35 -0
  126. package/dist-server/service/recurring-cash-item/recurring-cash-item.js +142 -0
  127. package/dist-server/service/recurring-cash-item/recurring-cash-item.js.map +1 -0
  128. package/dist-server/service/recurring-cash-item/recurring-schedule.d.ts +36 -0
  129. package/dist-server/service/recurring-cash-item/recurring-schedule.js +41 -0
  130. package/dist-server/service/recurring-cash-item/recurring-schedule.js.map +1 -0
  131. package/dist-server/service/transaction/transaction-history.d.ts +42 -15
  132. package/dist-server/service/transaction/transaction-history.js +160 -54
  133. package/dist-server/service/transaction/transaction-history.js.map +1 -1
  134. package/dist-server/service/transaction/transaction-mutation.d.ts +0 -1
  135. package/dist-server/service/transaction/transaction-mutation.js +13 -78
  136. package/dist-server/service/transaction/transaction-mutation.js.map +1 -1
  137. package/dist-server/service/transaction/transaction-period.d.ts +16 -0
  138. package/dist-server/service/transaction/transaction-period.js +49 -0
  139. package/dist-server/service/transaction/transaction-period.js.map +1 -0
  140. package/dist-server/service/transaction/transaction-query.d.ts +12 -0
  141. package/dist-server/service/transaction/transaction-query.js +84 -2
  142. package/dist-server/service/transaction/transaction-query.js.map +1 -1
  143. package/dist-server/service/transaction/transaction-service.d.ts +30 -0
  144. package/dist-server/service/transaction/transaction-service.js +130 -0
  145. package/dist-server/service/transaction/transaction-service.js.map +1 -0
  146. package/dist-server/service/transaction/transaction-type.d.ts +39 -7
  147. package/dist-server/service/transaction/transaction-type.js +145 -23
  148. package/dist-server/service/transaction/transaction-type.js.map +1 -1
  149. package/dist-server/service/transaction/transaction.d.ts +58 -31
  150. package/dist-server/service/transaction/transaction.js +216 -102
  151. package/dist-server/service/transaction/transaction.js.map +1 -1
  152. package/dist-server/tsconfig.tsbuildinfo +1 -1
  153. package/package.json +5 -3
  154. package/things-factory.config.js +0 -4
  155. package/translations/en.json +34 -2
  156. package/translations/ja.json +0 -1
  157. package/translations/ko.json +34 -2
  158. package/translations/ms.json +0 -1
  159. package/translations/zh.json +0 -1
  160. package/dist-client/pages/account/account-importer.d.ts +0 -22
  161. package/dist-client/pages/account/account-importer.js +0 -99
  162. package/dist-client/pages/account/account-importer.js.map +0 -1
  163. package/dist-client/pages/account/account-list-page.d.ts +0 -57
  164. package/dist-client/pages/account/account-list-page.js +0 -306
  165. package/dist-client/pages/account/account-list-page.js.map +0 -1
  166. package/dist-client/pages/bank-account/bank-account-importer.d.ts +0 -23
  167. package/dist-client/pages/bank-account/bank-account-importer.js +0 -92
  168. package/dist-client/pages/bank-account/bank-account-importer.js.map +0 -1
  169. package/dist-client/pages/bank-account/bank-account-list-page.d.ts +0 -60
  170. package/dist-client/pages/bank-account/bank-account-list-page.js +0 -317
  171. package/dist-client/pages/bank-account/bank-account-list-page.js.map +0 -1
  172. package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +0 -22
  173. package/dist-client/pages/financial-statement/financial-statement-importer.js +0 -99
  174. package/dist-client/pages/financial-statement/financial-statement-importer.js.map +0 -1
  175. package/dist-client/pages/financial-statement/financial-statement-list-page.d.ts +0 -57
  176. package/dist-client/pages/financial-statement/financial-statement-list-page.js +0 -280
  177. package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +0 -1
  178. package/dist-client/pages/income-statement/income-statement-importer.d.ts +0 -22
  179. package/dist-client/pages/income-statement/income-statement-importer.js +0 -99
  180. package/dist-client/pages/income-statement/income-statement-importer.js.map +0 -1
  181. package/dist-client/pages/income-statement/income-statement-list-page.d.ts +0 -57
  182. package/dist-client/pages/income-statement/income-statement-list-page.js +0 -280
  183. package/dist-client/pages/income-statement/income-statement-list-page.js.map +0 -1
  184. package/dist-client/pages/payment/payment-importer.d.ts +0 -23
  185. package/dist-client/pages/payment/payment-importer.js +0 -92
  186. package/dist-client/pages/payment/payment-importer.js.map +0 -1
  187. package/dist-client/pages/payment/payment-list-page.d.ts +0 -60
  188. package/dist-client/pages/payment/payment-list-page.js +0 -317
  189. package/dist-client/pages/payment/payment-list-page.js.map +0 -1
  190. package/dist-client/pages/transaction/transaction-importer.d.ts +0 -22
  191. package/dist-client/pages/transaction/transaction-importer.js +0 -99
  192. package/dist-client/pages/transaction/transaction-importer.js.map +0 -1
  193. package/dist-client/pages/transaction/transaction-list-page.d.ts +0 -57
  194. package/dist-client/pages/transaction/transaction-list-page.js +0 -280
  195. package/dist-client/pages/transaction/transaction-list-page.js.map +0 -1
  196. package/dist-server/controllers/index.d.ts +0 -1
  197. package/dist-server/controllers/index.js +0 -5
  198. package/dist-server/controllers/index.js.map +0 -1
  199. package/dist-server/controllers/summary-statements.d.ts +0 -4
  200. package/dist-server/controllers/summary-statements.js +0 -149
  201. package/dist-server/controllers/summary-statements.js.map +0 -1
  202. package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +0 -5
  203. package/dist-server/migrations/1725201567284-seed-country-codes.js +0 -255
  204. package/dist-server/migrations/1725201567284-seed-country-codes.js.map +0 -1
  205. package/dist-server/service/financial-statement/financial-statement-line-item.d.ts +0 -19
  206. package/dist-server/service/financial-statement/financial-statement-line-item.js +0 -95
  207. package/dist-server/service/financial-statement/financial-statement-line-item.js.map +0 -1
  208. package/dist-server/service/financial-statement/financial-statement-type.d.ts +0 -20
  209. package/dist-server/service/financial-statement/financial-statement-type.js +0 -77
  210. package/dist-server/service/financial-statement/financial-statement-type.js.map +0 -1
  211. package/dist-server/service/income-statement/event-subscriber.d.ts +0 -7
  212. package/dist-server/service/income-statement/event-subscriber.js +0 -21
  213. package/dist-server/service/income-statement/event-subscriber.js.map +0 -1
  214. package/dist-server/service/income-statement/income-statement-history.d.ts +0 -28
  215. package/dist-server/service/income-statement/income-statement-history.js +0 -146
  216. package/dist-server/service/income-statement/income-statement-history.js.map +0 -1
  217. package/dist-server/service/income-statement/income-statement-line-item.d.ts +0 -19
  218. package/dist-server/service/income-statement/income-statement-line-item.js +0 -97
  219. package/dist-server/service/income-statement/income-statement-line-item.js.map +0 -1
  220. package/dist-server/service/income-statement/income-statement-mutation.d.ts +0 -10
  221. package/dist-server/service/income-statement/income-statement-mutation.js +0 -159
  222. package/dist-server/service/income-statement/income-statement-mutation.js.map +0 -1
  223. package/dist-server/service/income-statement/income-statement-query.d.ts +0 -11
  224. package/dist-server/service/income-statement/income-statement-query.js +0 -81
  225. package/dist-server/service/income-statement/income-statement-query.js.map +0 -1
  226. package/dist-server/service/income-statement/income-statement-type.d.ts +0 -20
  227. package/dist-server/service/income-statement/income-statement-type.js +0 -77
  228. package/dist-server/service/income-statement/income-statement-type.js.map +0 -1
  229. package/dist-server/service/income-statement/income-statement.d.ts +0 -28
  230. package/dist-server/service/income-statement/income-statement.js +0 -137
  231. package/dist-server/service/income-statement/income-statement.js.map +0 -1
  232. package/dist-server/service/income-statement/index.d.ts +0 -8
  233. package/dist-server/service/income-statement/index.js +0 -13
  234. package/dist-server/service/income-statement/index.js.map +0 -1
@@ -1,36 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Payment = exports.PaymentType = exports.PaymentDirection = void 0;
3
+ exports.Payment = exports.PaymentMethod = exports.PaymentPurpose = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const typeorm_1 = require("typeorm");
6
6
  const type_graphql_1 = require("type-graphql");
7
7
  const shell_1 = require("@things-factory/shell");
8
8
  const auth_base_1 = require("@things-factory/auth-base");
9
9
  const transaction_1 = require("../transaction/transaction");
10
- const bank_account_1 = require("../bank-account/bank-account");
11
- var PaymentDirection;
12
- (function (PaymentDirection) {
13
- PaymentDirection["Incoming"] = "Incoming";
14
- PaymentDirection["Outgoing"] = "Outgoing"; // 지출
15
- })(PaymentDirection || (exports.PaymentDirection = PaymentDirection = {}));
16
- (0, type_graphql_1.registerEnumType)(PaymentDirection, {
17
- name: 'PaymentDirection',
18
- description: 'Indicates whether the payment is incoming (received) or outgoing (paid)' // 결제 방향을 나타냅니다 (수금 또는 지출)
10
+ var PaymentPurpose;
11
+ (function (PaymentPurpose) {
12
+ PaymentPurpose["SETTLEMENT"] = "SETTLEMENT";
13
+ PaymentPurpose["EVIDENCE"] = "EVIDENCE";
14
+ PaymentPurpose["TRANSFER"] = "TRANSFER";
15
+ })(PaymentPurpose || (exports.PaymentPurpose = PaymentPurpose = {}));
16
+ (0, type_graphql_1.registerEnumType)(PaymentPurpose, {
17
+ name: 'PaymentPurpose',
18
+ description: 'What a payment tells of its transaction - the business document it settled, the document that evidences it, or the matching line of a move between our own accounts'
19
19
  });
20
- var PaymentType;
21
- (function (PaymentType) {
22
- PaymentType["Transfer"] = "Transfer";
23
- PaymentType["Cash"] = "Cash";
24
- PaymentType["CreditCard"] = "CreditCard";
25
- PaymentType["DebitCard"] = "DebitCard"; // 직불카드
26
- })(PaymentType || (exports.PaymentType = PaymentType = {}));
27
- (0, type_graphql_1.registerEnumType)(PaymentType, {
28
- name: 'PaymentType',
29
- description: 'Type of the payment (e.g., Transfer, Cash, CreditCard, DebitCard)' // 결제 유형을 나타냅니다
20
+ var PaymentMethod;
21
+ (function (PaymentMethod) {
22
+ PaymentMethod["RULE"] = "RULE";
23
+ PaymentMethod["PERSON"] = "PERSON";
24
+ })(PaymentMethod || (exports.PaymentMethod = PaymentMethod = {}));
25
+ (0, type_graphql_1.registerEnumType)(PaymentMethod, {
26
+ name: 'PaymentMethod',
27
+ description: 'Who made the link - a rule of the app, or a person'
30
28
  });
29
+ /**
30
+ * What a transaction paid: a part of it, put on one target - a contract round, a tax invoice, a VAT period, the other
31
+ * line of a transfer between our own accounts. One transaction may pay several targets, and one target be paid by
32
+ * several transactions.
33
+ *
34
+ * The kinds of target are registered by the apps that own them (§`registerPaymentTarget`), each with its purpose.
35
+ * Within one purpose the payments of a transaction add up to no more than the transaction; across purposes the same
36
+ * money is told twice - a deposit settles a round and is evidenced by that round's tax invoice.
37
+ */
31
38
  let Payment = class Payment {
32
39
  constructor() {
33
- this.version = 1; // 낙관적 잠금을 위한 버전 관리 필드
40
+ this.version = 1;
34
41
  }
35
42
  };
36
43
  exports.Payment = Payment;
@@ -46,111 +53,78 @@ tslib_1.__decorate([
46
53
  ], Payment.prototype, "version", void 0);
47
54
  tslib_1.__decorate([
48
55
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
49
- (0, type_graphql_1.Field)({ nullable: true, description: 'The domain to which this payment belongs' }),
50
- tslib_1.__metadata("design:type", shell_1.Domain // 결제가 속한 도메인
51
- )
56
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain to which this payment belongs' }),
57
+ tslib_1.__metadata("design:type", shell_1.Domain)
52
58
  ], Payment.prototype, "domain", void 0);
53
59
  tslib_1.__decorate([
54
60
  (0, typeorm_1.RelationId)((payment) => payment.domain),
55
61
  tslib_1.__metadata("design:type", String)
56
62
  ], Payment.prototype, "domainId", void 0);
57
63
  tslib_1.__decorate([
58
- (0, typeorm_1.ManyToOne)(type => transaction_1.Transaction, transaction => transaction.payments),
59
- (0, type_graphql_1.Field)(type => transaction_1.Transaction, { description: 'The transaction associated with this payment' }),
60
- tslib_1.__metadata("design:type", transaction_1.Transaction // 결제와 연결된 트랜잭션
61
- )
64
+ (0, typeorm_1.ManyToOne)(type => transaction_1.Transaction, transaction => transaction.payments, { nullable: false }),
65
+ (0, type_graphql_1.Field)(type => transaction_1.Transaction, { description: 'The transaction a part of which this is' }),
66
+ tslib_1.__metadata("design:type", transaction_1.Transaction)
62
67
  ], Payment.prototype, "transaction", void 0);
63
68
  tslib_1.__decorate([
64
69
  (0, typeorm_1.RelationId)((payment) => payment.transaction),
65
70
  tslib_1.__metadata("design:type", String)
66
71
  ], Payment.prototype, "transactionId", void 0);
67
72
  tslib_1.__decorate([
68
- (0, typeorm_1.Column)({ nullable: true }),
69
- (0, type_graphql_1.Field)({ nullable: true, description: 'The currency used in the payment' }),
73
+ (0, typeorm_1.Column)(),
74
+ (0, type_graphql_1.Field)({ description: 'The kind of what was paid, as registered - ContractMilestone, TaxInvoice, Transaction' }),
70
75
  tslib_1.__metadata("design:type", String)
71
- ], Payment.prototype, "currency", void 0);
76
+ ], Payment.prototype, "targetType", void 0);
72
77
  tslib_1.__decorate([
73
- (0, typeorm_1.Column)((0, shell_1.moneyColumn)({ nullable: false })),
74
- (0, type_graphql_1.Field)({ nullable: false, description: 'The amount of money involved in the payment' }),
75
- tslib_1.__metadata("design:type", Number)
76
- ], Payment.prototype, "amount", void 0);
77
- tslib_1.__decorate([
78
- (0, typeorm_1.Column)({ nullable: false }),
79
- (0, type_graphql_1.Field)(type => PaymentType, { description: 'Type of the payment' }),
78
+ (0, typeorm_1.Column)(),
79
+ (0, type_graphql_1.Field)({ description: 'The id of what was paid' }),
80
80
  tslib_1.__metadata("design:type", String)
81
- ], Payment.prototype, "paymentType", void 0);
81
+ ], Payment.prototype, "targetId", void 0);
82
82
  tslib_1.__decorate([
83
- (0, typeorm_1.ManyToOne)(type => bank_account_1.BankAccount, { nullable: true }),
84
- (0, type_graphql_1.Field)(type => bank_account_1.BankAccount, { nullable: true, description: 'Source bank account for the payment' }),
85
- tslib_1.__metadata("design:type", bank_account_1.BankAccount)
86
- ], Payment.prototype, "sourceBankAccount", void 0);
83
+ (0, typeorm_1.Column)((0, shell_1.moneyColumn)()),
84
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: "The part of the transaction put on the target, in the transaction's currency" }),
85
+ tslib_1.__metadata("design:type", Number)
86
+ ], Payment.prototype, "amount", void 0);
87
87
  tslib_1.__decorate([
88
- (0, typeorm_1.RelationId)((payment) => payment.sourceBankAccount),
88
+ (0, typeorm_1.Column)(),
89
+ (0, type_graphql_1.Field)(type => PaymentPurpose, {
90
+ description: "What the payment tells of the transaction - the target kind's purpose"
91
+ }),
89
92
  tslib_1.__metadata("design:type", String)
90
- ], Payment.prototype, "sourceBankAccountId", void 0);
93
+ ], Payment.prototype, "purpose", void 0);
91
94
  tslib_1.__decorate([
92
- (0, typeorm_1.ManyToOne)(type => bank_account_1.BankAccount, { nullable: true }),
93
- (0, type_graphql_1.Field)(type => bank_account_1.BankAccount, { nullable: true, description: 'Destination bank account for the payment' }),
94
- tslib_1.__metadata("design:type", bank_account_1.BankAccount)
95
- ], Payment.prototype, "destinationBankAccount", void 0);
96
- tslib_1.__decorate([
97
- (0, typeorm_1.RelationId)((payment) => payment.destinationBankAccount),
95
+ (0, typeorm_1.Column)({ default: PaymentMethod.PERSON }),
96
+ (0, type_graphql_1.Field)(type => PaymentMethod, { description: 'Who made the link' }),
98
97
  tslib_1.__metadata("design:type", String)
99
- ], Payment.prototype, "destinationBankAccountId", void 0);
100
- tslib_1.__decorate([
101
- (0, typeorm_1.Column)({ nullable: true }),
102
- (0, type_graphql_1.Field)({ nullable: true, description: 'Fiscal year in which the payment was made' }),
103
- tslib_1.__metadata("design:type", Number)
104
- ], Payment.prototype, "year", void 0);
105
- tslib_1.__decorate([
106
- (0, typeorm_1.Column)({ nullable: true }),
107
- (0, type_graphql_1.Field)({ nullable: true, description: 'Fiscal quarter in which the payment was made' }),
108
- tslib_1.__metadata("design:type", Number)
109
- ], Payment.prototype, "quarter", void 0);
110
- tslib_1.__decorate([
111
- (0, typeorm_1.Column)({ nullable: true }),
112
- (0, type_graphql_1.Field)({ nullable: true, description: 'Fiscal month in which the payment was made' }),
113
- tslib_1.__metadata("design:type", Number)
114
- ], Payment.prototype, "month", void 0);
115
- tslib_1.__decorate([
116
- (0, typeorm_1.Column)({ nullable: false }),
117
- (0, type_graphql_1.Field)({ nullable: false, description: 'The date and time when the payment was made' }),
118
- tslib_1.__metadata("design:type", Date // 결제가 이루어진 날짜 및 시간
119
- )
120
- ], Payment.prototype, "paidAt", void 0);
98
+ ], Payment.prototype, "method", void 0);
121
99
  tslib_1.__decorate([
122
- (0, typeorm_1.Column)({ nullable: false }),
123
- (0, type_graphql_1.Field)(type => PaymentDirection, { description: 'Direction of the payment (Incoming or Outgoing)' }),
100
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
101
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Why a rule made the link - what matched' }),
124
102
  tslib_1.__metadata("design:type", String)
125
- ], Payment.prototype, "direction", void 0);
103
+ ], Payment.prototype, "basis", void 0);
126
104
  tslib_1.__decorate([
127
- (0, typeorm_1.Column)({ nullable: true }),
128
- (0, type_graphql_1.Field)({ nullable: true, description: 'Additional notes or comments about the payment' }),
105
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
106
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
129
107
  tslib_1.__metadata("design:type", String)
130
- ], Payment.prototype, "note", void 0);
108
+ ], Payment.prototype, "notes", void 0);
131
109
  tslib_1.__decorate([
132
110
  (0, typeorm_1.CreateDateColumn)(),
133
111
  (0, type_graphql_1.Field)({ nullable: true, description: 'The date and time when the payment record was created' }),
134
- tslib_1.__metadata("design:type", Date // 결제 레코드가 생성된 날짜 및 시간
135
- )
112
+ tslib_1.__metadata("design:type", Date)
136
113
  ], Payment.prototype, "createdAt", void 0);
137
114
  tslib_1.__decorate([
138
115
  (0, typeorm_1.UpdateDateColumn)(),
139
116
  (0, type_graphql_1.Field)({ nullable: true, description: 'The date and time when the payment record was last updated' }),
140
- tslib_1.__metadata("design:type", Date // 결제 레코드가 마지막으로 업데이트된 날짜 및 시간
141
- )
117
+ tslib_1.__metadata("design:type", Date)
142
118
  ], Payment.prototype, "updatedAt", void 0);
143
119
  tslib_1.__decorate([
144
120
  (0, typeorm_1.DeleteDateColumn)(),
145
121
  (0, type_graphql_1.Field)({ nullable: true, description: 'The date and time when the payment record was deleted' }),
146
- tslib_1.__metadata("design:type", Date // 결제 레코드가 삭제된 날짜 및 시간
147
- )
122
+ tslib_1.__metadata("design:type", Date)
148
123
  ], Payment.prototype, "deletedAt", void 0);
149
124
  tslib_1.__decorate([
150
125
  (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
151
126
  (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'The user who created the payment record' }),
152
- tslib_1.__metadata("design:type", auth_base_1.User // 결제 레코드를 생성한 사용자
153
- )
127
+ tslib_1.__metadata("design:type", auth_base_1.User)
154
128
  ], Payment.prototype, "creator", void 0);
155
129
  tslib_1.__decorate([
156
130
  (0, typeorm_1.RelationId)((payment) => payment.creator),
@@ -159,8 +133,7 @@ tslib_1.__decorate([
159
133
  tslib_1.__decorate([
160
134
  (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
161
135
  (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'The user who last updated the payment record' }),
162
- tslib_1.__metadata("design:type", auth_base_1.User // 결제 레코드를 마지막으로 업데이트한 사용자
163
- )
136
+ tslib_1.__metadata("design:type", auth_base_1.User)
164
137
  ], Payment.prototype, "updater", void 0);
165
138
  tslib_1.__decorate([
166
139
  (0, typeorm_1.RelationId)((payment) => payment.updater),
@@ -168,12 +141,11 @@ tslib_1.__decorate([
168
141
  ], Payment.prototype, "updaterId", void 0);
169
142
  exports.Payment = Payment = tslib_1.__decorate([
170
143
  (0, typeorm_1.Entity)(),
171
- (0, typeorm_1.Index)('ix_payment_0', (payment) => [payment.domain, payment.transaction, payment.paidAt], {
172
- where: '"deleted_at" IS NULL'
173
- }),
174
- (0, typeorm_1.Index)('ix_payment_1', (payment) => [payment.domain, payment.year, payment.quarter, payment.month, payment.paidAt], {
144
+ (0, typeorm_1.Index)('ix_payment_0', (payment) => [payment.domain, payment.transaction, payment.targetType, payment.targetId], {
145
+ unique: true,
175
146
  where: '"deleted_at" IS NULL'
176
147
  }),
177
- (0, type_graphql_1.ObjectType)({ description: 'Entity representing a Payment record in the system' }) // 시스템 내에서 결제 기록을 나타내는 엔티티
148
+ (0, typeorm_1.Index)('ix_payment_1', (payment) => [payment.domain, payment.targetType, payment.targetId]),
149
+ (0, type_graphql_1.ObjectType)({ description: 'A part of a transaction put on what it paid' })
178
150
  ], Payment);
179
151
  //# sourceMappingURL=payment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../server/service/payment/payment.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAAsE;AAEtE,iDAA2D;AAC3D,yDAAgD;AAChD,4DAAwD;AACxD,+DAA0D;AAE1D,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;IACr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3F,gBAAI,CAAC,0BAA0B;;wCAA3B;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;kBAjGP,OAAO;IAZnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;QAClG,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,eAAK,EACJ,cAAc,EACd,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EACpG;QACE,KAAK,EAAE,sBAAsB;KAC9B,CACF;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC,CAAC,0BAA0B;GAChG,OAAO,CAkGnB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n VersionColumn,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Transaction } from '../transaction/transaction'\nimport { BankAccount } from '../bank-account/bank-account'\n\nexport enum PaymentDirection {\n Incoming = 'Incoming', // 수금\n Outgoing = 'Outgoing' // 지출\n}\n\nregisterEnumType(PaymentDirection, {\n name: 'PaymentDirection',\n description: 'Indicates whether the payment is incoming (received) or outgoing (paid)' // 결제 방향을 나타냅니다 (수금 또는 지출)\n})\n\nexport enum PaymentType {\n Transfer = 'Transfer', // 계좌 이체\n Cash = 'Cash', // 현금\n CreditCard = 'CreditCard', // 신용카드\n DebitCard = 'DebitCard' // 직불카드\n}\n\nregisterEnumType(PaymentType, {\n name: 'PaymentType',\n description: 'Type of the payment (e.g., Transfer, Cash, CreditCard, DebitCard)' // 결제 유형을 나타냅니다\n})\n\n@Entity()\n@Index('ix_payment_0', (payment: Payment) => [payment.domain, payment.transaction, payment.paidAt], {\n where: '\"deleted_at\" IS NULL'\n})\n@Index(\n 'ix_payment_1',\n (payment: Payment) => [payment.domain, payment.year, payment.quarter, payment.month, payment.paidAt],\n {\n where: '\"deleted_at\" IS NULL'\n }\n)\n@ObjectType({ description: 'Entity representing a Payment record in the system' }) // 시스템 내에서 결제 기록을 나타내는 엔티티\nexport class Payment {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the payment record' })\n readonly id: string // 고유 식별자 (UUID)\n\n @VersionColumn()\n @Field({ nullable: true, description: 'Version number used for optimistic locking' })\n version?: number = 1 // 낙관적 잠금을 위한 버전 관리 필드\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true, description: 'The domain to which this payment belongs' })\n domain?: Domain // 결제가 속한 도메인\n\n @RelationId((payment: Payment) => payment.domain)\n domainId?: string // 도메인의 ID\n\n @ManyToOne(type => Transaction, transaction => transaction.payments)\n @Field(type => Transaction, { description: 'The transaction associated with this payment' })\n transaction: Transaction // 결제와 연결된 트랜잭션\n\n @RelationId((payment: Payment) => payment.transaction)\n transactionId: string // 연결된 트랜잭션의 ID\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The currency used in the payment' })\n currency?: string // 결제에 사용된 통화\n\n @Column(moneyColumn({ nullable: false }))\n @Field({ nullable: false, description: 'The amount of money involved in the payment' })\n amount: number // 결제된 금액\n\n @Column({ nullable: false })\n @Field(type => PaymentType, { description: 'Type of the payment' })\n paymentType: PaymentType // 결제 유형\n\n @ManyToOne(type => BankAccount, { nullable: true })\n @Field(type => BankAccount, { nullable: true, description: 'Source bank account for the payment' })\n sourceBankAccount?: BankAccount\n\n @RelationId((payment: Payment) => payment.sourceBankAccount)\n sourceBankAccountId?: string\n\n @ManyToOne(type => BankAccount, { nullable: true })\n @Field(type => BankAccount, { nullable: true, description: 'Destination bank account for the payment' })\n destinationBankAccount?: BankAccount\n\n @RelationId((payment: Payment) => payment.destinationBankAccount)\n destinationBankAccountId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Fiscal year in which the payment was made' })\n year?: number // 결제가 발생한 회계 연도\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Fiscal quarter in which the payment was made' })\n quarter?: number // 결제가 발생한 회계 분기\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Fiscal month in which the payment was made' })\n month?: number // 결제가 발생한 회계 월\n\n @Column({ nullable: false })\n @Field({ nullable: false, description: 'The date and time when the payment was made' })\n paidAt: Date // 결제가 이루어진 날짜 및 시간\n\n @Column({ nullable: false })\n @Field(type => PaymentDirection, { description: 'Direction of the payment (Incoming or Outgoing)' })\n direction: PaymentDirection // 결제 방향 (수금 또는 지출)\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Additional notes or comments about the payment' })\n note?: string // 결제에 대한 추가 설명 또는 메모\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The date and time when the payment record was created' })\n createdAt?: Date // 결제 레코드가 생성된 날짜 및 시간\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The date and time when the payment record was last updated' })\n updatedAt?: Date // 결제 레코드가 마지막으로 업데이트된 날짜 및 시간\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'The date and time when the payment record was deleted' })\n deletedAt?: Date // 결제 레코드가 삭제된 날짜 및 시간\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who created the payment record' })\n creator?: User // 결제 레코드를 생성한 사용자\n\n @RelationId((payment: Payment) => payment.creator)\n creatorId?: string // 결제 레코드를 생성한 사용자의 ID\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who last updated the payment record' })\n updater?: User // 결제 레코드를 마지막으로 업데이트한 사용자\n\n @RelationId((payment: Payment) => payment.updater)\n updaterId?: string // 결제 레코드를 업데이트한 사용자의 ID\n}\n"]}
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../server/service/payment/payment.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA6E;AAE7E,iDAA2D;AAC3D,yDAAgD;AAChD,4DAAwD;AAExD,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,2CAAyB,CAAA;IACzB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;AACvB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,IAAA,+BAAgB,EAAC,cAAc,EAAE;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,qKAAqK;CACxK,CAAC,CAAA;AAEF,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAA,+BAAgB,EAAC,aAAa,EAAE;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,oDAAoD;CAClE,CAAC,CAAA;AAEF;;;;;;;;GAQG;AAYI,IAAM,OAAO,GAAb,MAAM,OAAO;IAAb;QAOL,YAAO,GAAY,CAAC,CAAA;IAuEtB,CAAC;CAAA,CAAA;AA9EY,0BAAO;AAGT;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;mCAC5D;AAInB;IAFC,IAAA,uBAAa,GAAE;IACf,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;wCACjE;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,C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,CAAC,OAAO,CAAC;;0CAChC;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;sCAC3F,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;kBA7EP,OAAO;IAXnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,cAAc,EACd,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,EACjG;QACE,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CACF;IACA,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnG,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;GAC9D,OAAO,CA8EnB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n VersionColumn,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, Float, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Transaction } from '../transaction/transaction'\n\nexport enum PaymentPurpose {\n SETTLEMENT = 'SETTLEMENT',\n EVIDENCE = 'EVIDENCE',\n TRANSFER = 'TRANSFER'\n}\n\nregisterEnumType(PaymentPurpose, {\n name: 'PaymentPurpose',\n description:\n 'What a payment tells of its transaction - the business document it settled, the document that evidences it, or the matching line of a move between our own accounts'\n})\n\nexport enum PaymentMethod {\n RULE = 'RULE',\n PERSON = 'PERSON'\n}\n\nregisterEnumType(PaymentMethod, {\n name: 'PaymentMethod',\n description: 'Who made the link - a rule of the app, or a person'\n})\n\n/**\n * What a transaction paid: a part of it, put on one target - a contract round, a tax invoice, a VAT period, the other\n * line of a transfer between our own accounts. One transaction may pay several targets, and one target be paid by\n * several transactions.\n *\n * The kinds of target are registered by the apps that own them (§`registerPaymentTarget`), each with its purpose.\n * Within one purpose the payments of a transaction add up to no more than the transaction; across purposes the same\n * money is told twice - a deposit settles a round and is evidenced by that round's tax invoice.\n */\n@Entity()\n@Index(\n 'ix_payment_0',\n (payment: Payment) => [payment.domain, payment.transaction, payment.targetType, payment.targetId],\n {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n }\n)\n@Index('ix_payment_1', (payment: Payment) => [payment.domain, payment.targetType, payment.targetId])\n@ObjectType({ description: 'A part of a transaction put on what it paid' })\nexport class Payment {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the payment record' })\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true, description: 'Version number used for optimistic locking' })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain to which this payment belongs' })\n domain?: Domain\n\n @RelationId((payment: Payment) => payment.domain)\n domainId?: string\n\n @ManyToOne(type => Transaction, transaction => transaction.payments, { nullable: false })\n @Field(type => Transaction, { description: 'The transaction a part of which this is' })\n transaction: Transaction\n\n @RelationId((payment: Payment) => payment.transaction)\n transactionId?: string\n\n @Column()\n @Field({ description: 'The kind of what was paid, as registered - ContractMilestone, TaxInvoice, Transaction' })\n targetType: string\n\n @Column()\n @Field({ description: 'The id of what was paid' })\n targetId: string\n\n @Column(moneyColumn())\n @Field(type => Float, { description: \"The part of the transaction put on the target, in the transaction's currency\" })\n amount: number\n\n @Column()\n @Field(type => PaymentPurpose, {\n description: \"What the payment tells of the transaction - the target kind's purpose\"\n })\n purpose: PaymentPurpose\n\n @Column({ default: PaymentMethod.PERSON })\n @Field(type => PaymentMethod, { description: 'Who made the link' })\n method: PaymentMethod\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Why a rule made the link - what matched' })\n basis?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The date and time when the payment record was created' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The date and time when the payment record was last updated' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'The date and time when the payment record was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who created the payment record' })\n creator?: User\n\n @RelationId((payment: Payment) => payment.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who last updated the payment record' })\n updater?: User\n\n @RelationId((payment: Payment) => payment.updater)\n updaterId?: string\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const typeorm_1 = require("typeorm");
4
+ const shell_1 = require("@things-factory/shell");
5
+ const cash_flow_type_1 = require("../cash-flow-type");
6
+ const transaction_1 = require("../transaction/transaction");
7
+ const payment_1 = require("./payment");
8
+ const payment_targets_1 = require("./payment-targets");
9
+ /**
10
+ * A move between our own accounts is two bank lines: the withdrawal pays the deposit. The payment sits on the
11
+ * withdrawal and names the deposit; a deposit takes no more than itself from the withdrawals that name it.
12
+ */
13
+ (0, payment_targets_1.registerPaymentTarget)('Transaction', {
14
+ purpose: payment_1.PaymentPurpose.TRANSFER,
15
+ async label(tx, domain, targetIds) {
16
+ const lines = await tx
17
+ .getRepository(transaction_1.Transaction)
18
+ .find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(targetIds) }, relations: ['bankAccount'] });
19
+ return new Map(lines.map(line => [line.id, [line.transactionDate, line.bankAccount?.name].filter(Boolean).join(' ')]));
20
+ },
21
+ async validate(tx, domain, { targetIds, transactionIds }) {
22
+ const repo = tx.getRepository(transaction_1.Transaction);
23
+ const deposits = await repo.find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(targetIds) } });
24
+ if (deposits.length !== new Set(targetIds).size)
25
+ throw new shell_1.Refusal('transfer-target-not-found', {}, 'the other line of the transfer was not found');
26
+ if (deposits.some(line => line.type !== cash_flow_type_1.CashFlowType.INCOME))
27
+ throw new shell_1.Refusal('transfer-target-not-deposit', {}, 'a withdrawal pays a deposit - the other line is not one');
28
+ const withdrawals = await repo.find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(transactionIds) } });
29
+ if (withdrawals.some(line => line.type !== cash_flow_type_1.CashFlowType.EXPENSE))
30
+ throw new shell_1.Refusal('transfer-from-not-withdrawal', {}, 'a transfer is put on its withdrawal');
31
+ const payments = await tx
32
+ .getRepository(payment_1.Payment)
33
+ .find({ where: { domain: { id: domain.id }, targetType: 'Transaction', targetId: (0, typeorm_1.In)(targetIds) } });
34
+ for (const deposit of deposits) {
35
+ const taken = payments
36
+ .filter(one => one.targetId === deposit.id)
37
+ .reduce((sum, one) => sum + Number(one.amount), 0);
38
+ if (taken > Math.abs(Number(deposit.amount)) + 0.005)
39
+ throw new shell_1.Refusal('transfer-over-deposit', { taken, amount: deposit.amount }, `${taken} moved into a deposit of ${deposit.amount}`);
40
+ }
41
+ }
42
+ });
43
+ //# sourceMappingURL=transfer-target.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer-target.js","sourceRoot":"","sources":["../../../server/service/payment/transfer-target.ts"],"names":[],"mappings":";;AAAA,qCAA4B;AAE5B,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,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK;gBAClD,MAAM,IAAI,eAAO,CACf,uBAAuB,EACvB,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EACjC,GAAG,KAAK,4BAA4B,OAAO,CAAC,MAAM,EAAE,CACrD,CAAA;QACL,CAAC;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { In } from 'typeorm'\n\nimport { Refusal } from '@things-factory/shell'\n\nimport { CashFlowType } from '../cash-flow-type'\nimport { Transaction } from '../transaction/transaction'\nimport { Payment, PaymentPurpose } from './payment'\nimport { registerPaymentTarget } from './payment-targets'\n\n/**\n * A move between our own accounts is two bank lines: the withdrawal pays the deposit. The payment sits on the\n * withdrawal and names the deposit; a deposit takes no more than itself from the withdrawals that name it.\n */\nregisterPaymentTarget('Transaction', {\n purpose: PaymentPurpose.TRANSFER,\n async label(tx, domain, targetIds) {\n const lines = await tx\n .getRepository(Transaction)\n .find({ where: { domain: { id: domain.id }, id: In(targetIds) }, relations: ['bankAccount'] })\n return new Map(\n lines.map(line => [line.id, [line.transactionDate, line.bankAccount?.name].filter(Boolean).join(' ')])\n )\n },\n async validate(tx, domain, { targetIds, transactionIds }) {\n const repo = tx.getRepository(Transaction)\n const deposits = await repo.find({ where: { domain: { id: domain.id }, id: In(targetIds) } })\n if (deposits.length !== new Set(targetIds).size)\n throw new Refusal('transfer-target-not-found', {}, 'the other line of the transfer was not found')\n if (deposits.some(line => line.type !== CashFlowType.INCOME))\n throw new Refusal('transfer-target-not-deposit', {}, 'a withdrawal pays a deposit - the other line is not one')\n\n const withdrawals = await repo.find({ where: { domain: { id: domain.id }, id: In(transactionIds) } })\n if (withdrawals.some(line => line.type !== CashFlowType.EXPENSE))\n throw new Refusal('transfer-from-not-withdrawal', {}, 'a transfer is put on its withdrawal')\n\n const payments = await tx\n .getRepository(Payment)\n .find({ where: { domain: { id: domain.id }, targetType: 'Transaction', targetId: In(targetIds) } })\n for (const deposit of deposits) {\n const taken = payments\n .filter(one => one.targetId === deposit.id)\n .reduce((sum, one) => sum + Number(one.amount), 0)\n if (taken > Math.abs(Number(deposit.amount)) + 0.005)\n throw new Refusal(\n 'transfer-over-deposit',\n { taken, amount: deposit.amount },\n `${taken} moved into a deposit of ${deposit.amount}`\n )\n }\n }\n})\n"]}
@@ -0,0 +1,6 @@
1
+ import { RecurringCashItem } from './recurring-cash-item';
2
+ import { RecurringCashItemQuery } from './recurring-cash-item-query';
3
+ import { RecurringCashItemMutation } from './recurring-cash-item-mutation';
4
+ export declare const entities: (typeof RecurringCashItem)[];
5
+ export declare const resolvers: (typeof RecurringCashItemQuery | typeof RecurringCashItemMutation)[];
6
+ export declare const subscribers: any[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscribers = exports.resolvers = exports.entities = void 0;
4
+ const recurring_cash_item_1 = require("./recurring-cash-item");
5
+ const recurring_cash_item_query_1 = require("./recurring-cash-item-query");
6
+ const recurring_cash_item_mutation_1 = require("./recurring-cash-item-mutation");
7
+ exports.entities = [recurring_cash_item_1.RecurringCashItem];
8
+ exports.resolvers = [recurring_cash_item_query_1.RecurringCashItemQuery, recurring_cash_item_mutation_1.RecurringCashItemMutation];
9
+ exports.subscribers = [];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/index.ts"],"names":[],"mappings":";;;AAAA,+DAAyD;AACzD,2EAAoE;AACpE,iFAA0E;AAE7D,QAAA,QAAQ,GAAG,CAAC,uCAAiB,CAAC,CAAA;AAC9B,QAAA,SAAS,GAAG,CAAC,kDAAsB,EAAE,wDAAyB,CAAC,CAAA;AAC/D,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { RecurringCashItem } from './recurring-cash-item'\nimport { RecurringCashItemQuery } from './recurring-cash-item-query'\nimport { RecurringCashItemMutation } from './recurring-cash-item-mutation'\n\nexport const entities = [RecurringCashItem]\nexport const resolvers = [RecurringCashItemQuery, RecurringCashItemMutation]\nexport const subscribers = []\n"]}
@@ -0,0 +1,7 @@
1
+ import { RecurringCashItem } from './recurring-cash-item';
2
+ import { RecurringCashItemPatch } from './recurring-cash-item-type';
3
+ export declare class RecurringCashItemMutation {
4
+ updateMultipleRecurringCashItem(patches: RecurringCashItemPatch[], context: ResolverContext): Promise<RecurringCashItem[]>;
5
+ deleteRecurringCashItems(ids: string[], context: ResolverContext): Promise<boolean>;
6
+ generateForecasts(year: number, month: number, context: ResolverContext): Promise<number>;
7
+ }
@@ -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,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CACrC,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAOK,AAAN,KAAK,CAAC,iBAAiB,CACK,IAAY,EACX,KAAa,EACjC,OAAwB;QAE/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I,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,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,uCAAiB,CAAC;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AE,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>;