@things-factory/accounting 10.1.124 → 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 (257) 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 +8 -8
  12. package/dist-server/service/account/account-mutation.js.map +1 -1
  13. package/dist-server/service/account/account-query.js +2 -2
  14. package/dist-server/service/account/account-query.js.map +1 -1
  15. package/dist-server/service/account/account-type.d.ts +16 -0
  16. package/dist-server/service/account/account-type.js +71 -13
  17. package/dist-server/service/account/account-type.js.map +1 -1
  18. package/dist-server/service/account/account.d.ts +9 -3
  19. package/dist-server/service/account/account.js +34 -8
  20. package/dist-server/service/account/account.js.map +1 -1
  21. package/dist-server/service/account/index.d.ts +1 -1
  22. package/dist-server/service/accounting-category/accounting-category-mutation.js +8 -8
  23. package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -1
  24. package/dist-server/service/accounting-category/accounting-category-query.js +2 -2
  25. package/dist-server/service/accounting-category/accounting-category-query.js.map +1 -1
  26. package/dist-server/service/accounting-category/index.d.ts +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/accounting-document/index.d.ts +1 -1
  32. package/dist-server/service/bank-account/bank-account-history.d.ts +11 -14
  33. package/dist-server/service/bank-account/bank-account-history.js +46 -59
  34. package/dist-server/service/bank-account/bank-account-history.js.map +1 -1
  35. package/dist-server/service/bank-account/bank-account-mutation.d.ts +1 -2
  36. package/dist-server/service/bank-account/bank-account-mutation.js +25 -69
  37. package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -1
  38. package/dist-server/service/bank-account/bank-account-query.js +2 -0
  39. package/dist-server/service/bank-account/bank-account-query.js.map +1 -1
  40. package/dist-server/service/bank-account/bank-account-service.d.ts +5 -0
  41. package/dist-server/service/bank-account/bank-account-service.js +21 -0
  42. package/dist-server/service/bank-account/bank-account-service.js.map +1 -0
  43. package/dist-server/service/bank-account/bank-account-type.d.ts +13 -19
  44. package/dist-server/service/bank-account/bank-account-type.js +45 -69
  45. package/dist-server/service/bank-account/bank-account-type.js.map +1 -1
  46. package/dist-server/service/bank-account/bank-account.d.ts +14 -17
  47. package/dist-server/service/bank-account/bank-account.js +45 -57
  48. package/dist-server/service/bank-account/bank-account.js.map +1 -1
  49. package/dist-server/service/bank-account/index.d.ts +1 -1
  50. package/dist-server/service/bank-statement/bank-statement-query.d.ts +14 -0
  51. package/dist-server/service/bank-statement/bank-statement-query.js +92 -0
  52. package/dist-server/service/bank-statement/bank-statement-query.js.map +1 -0
  53. package/dist-server/service/bank-statement/bank-statement.d.ts +26 -0
  54. package/dist-server/service/bank-statement/bank-statement.js +109 -0
  55. package/dist-server/service/bank-statement/bank-statement.js.map +1 -0
  56. package/dist-server/service/bank-statement/index.d.ts +5 -0
  57. package/dist-server/service/bank-statement/index.js +9 -0
  58. package/dist-server/service/bank-statement/index.js.map +1 -0
  59. package/dist-server/service/cash-flow-type.d.ts +5 -0
  60. package/dist-server/service/cash-flow-type.js +15 -0
  61. package/dist-server/service/cash-flow-type.js.map +1 -0
  62. package/dist-server/service/financial-institution/financial-institution-mutation.js +10 -1
  63. package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -1
  64. package/dist-server/service/financial-institution/financial-institution-query.js +14 -6
  65. package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -1
  66. package/dist-server/service/financial-statement/financial-statement-history.d.ts +11 -9
  67. package/dist-server/service/financial-statement/financial-statement-history.js +44 -33
  68. package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
  69. package/dist-server/service/financial-statement/financial-statement-line.d.ts +24 -0
  70. package/dist-server/service/financial-statement/financial-statement-line.js +108 -0
  71. package/dist-server/service/financial-statement/financial-statement-line.js.map +1 -0
  72. package/dist-server/service/financial-statement/financial-statement-mutation.d.ts +1 -8
  73. package/dist-server/service/financial-statement/financial-statement-mutation.js +11 -136
  74. package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -1
  75. package/dist-server/service/financial-statement/financial-statement-query.d.ts +8 -7
  76. package/dist-server/service/financial-statement/financial-statement-query.js +42 -32
  77. package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
  78. package/dist-server/service/financial-statement/financial-statement-service.d.ts +33 -0
  79. package/dist-server/service/financial-statement/financial-statement-service.js +44 -0
  80. package/dist-server/service/financial-statement/financial-statement-service.js.map +1 -0
  81. package/dist-server/service/financial-statement/financial-statement.d.ts +19 -11
  82. package/dist-server/service/financial-statement/financial-statement.js +70 -62
  83. package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
  84. package/dist-server/service/financial-statement/index.d.ts +4 -3
  85. package/dist-server/service/financial-statement/index.js +2 -2
  86. package/dist-server/service/financial-statement/index.js.map +1 -1
  87. package/dist-server/service/fiscal-month/fiscal-month-mutation.js +6 -6
  88. package/dist-server/service/fiscal-month/fiscal-month-mutation.js.map +1 -1
  89. package/dist-server/service/fiscal-month/fiscal-month-query.js +2 -2
  90. package/dist-server/service/fiscal-month/fiscal-month-query.js.map +1 -1
  91. package/dist-server/service/fiscal-month/index.d.ts +1 -1
  92. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.js +6 -6
  93. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.js.map +1 -1
  94. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.js +2 -2
  95. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.js.map +1 -1
  96. package/dist-server/service/fiscal-quarter/index.d.ts +1 -1
  97. package/dist-server/service/fiscal-year/fiscal-year-mutation.js +6 -6
  98. package/dist-server/service/fiscal-year/fiscal-year-mutation.js.map +1 -1
  99. package/dist-server/service/fiscal-year/fiscal-year-query.js +2 -2
  100. package/dist-server/service/fiscal-year/fiscal-year-query.js.map +1 -1
  101. package/dist-server/service/fiscal-year/index.d.ts +1 -1
  102. package/dist-server/service/index.d.ts +15 -3
  103. package/dist-server/service/index.js +30 -13
  104. package/dist-server/service/index.js.map +1 -1
  105. package/dist-server/service/payment/index.d.ts +2 -1
  106. package/dist-server/service/payment/index.js +1 -0
  107. package/dist-server/service/payment/index.js.map +1 -1
  108. package/dist-server/service/payment/payment-history.d.ts +9 -16
  109. package/dist-server/service/payment/payment-history.js +36 -70
  110. package/dist-server/service/payment/payment-history.js.map +1 -1
  111. package/dist-server/service/payment/payment-mutation.d.ts +0 -1
  112. package/dist-server/service/payment/payment-mutation.js +19 -84
  113. package/dist-server/service/payment/payment-mutation.js.map +1 -1
  114. package/dist-server/service/payment/payment-query.d.ts +3 -0
  115. package/dist-server/service/payment/payment-query.js +32 -3
  116. package/dist-server/service/payment/payment-query.js.map +1 -1
  117. package/dist-server/service/payment/payment-service.d.ts +16 -0
  118. package/dist-server/service/payment/payment-service.js +140 -0
  119. package/dist-server/service/payment/payment-service.js.map +1 -0
  120. package/dist-server/service/payment/payment-targets.d.ts +31 -0
  121. package/dist-server/service/payment/payment-targets.js +19 -0
  122. package/dist-server/service/payment/payment-targets.js.map +1 -0
  123. package/dist-server/service/payment/payment-type.d.ts +13 -17
  124. package/dist-server/service/payment/payment-type.js +35 -51
  125. package/dist-server/service/payment/payment-type.js.map +1 -1
  126. package/dist-server/service/payment/payment.d.ts +23 -22
  127. package/dist-server/service/payment/payment.js +65 -95
  128. package/dist-server/service/payment/payment.js.map +1 -1
  129. package/dist-server/service/payment/transfer-target.d.ts +1 -0
  130. package/dist-server/service/payment/transfer-target.js +43 -0
  131. package/dist-server/service/payment/transfer-target.js.map +1 -0
  132. package/dist-server/service/recurring-cash-item/index.d.ts +6 -0
  133. package/dist-server/service/recurring-cash-item/index.js +10 -0
  134. package/dist-server/service/recurring-cash-item/index.js.map +1 -0
  135. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.d.ts +7 -0
  136. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js +63 -0
  137. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js.map +1 -0
  138. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.d.ts +15 -0
  139. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js +101 -0
  140. package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js.map +1 -0
  141. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.d.ts +23 -0
  142. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js +91 -0
  143. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js.map +1 -0
  144. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.d.ts +23 -0
  145. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js +85 -0
  146. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js.map +1 -0
  147. package/dist-server/service/recurring-cash-item/recurring-cash-item.d.ts +35 -0
  148. package/dist-server/service/recurring-cash-item/recurring-cash-item.js +142 -0
  149. package/dist-server/service/recurring-cash-item/recurring-cash-item.js.map +1 -0
  150. package/dist-server/service/recurring-cash-item/recurring-schedule.d.ts +36 -0
  151. package/dist-server/service/recurring-cash-item/recurring-schedule.js +41 -0
  152. package/dist-server/service/recurring-cash-item/recurring-schedule.js.map +1 -0
  153. package/dist-server/service/transaction/index.d.ts +2 -2
  154. package/dist-server/service/transaction/transaction-history.d.ts +42 -15
  155. package/dist-server/service/transaction/transaction-history.js +160 -54
  156. package/dist-server/service/transaction/transaction-history.js.map +1 -1
  157. package/dist-server/service/transaction/transaction-mutation.d.ts +0 -1
  158. package/dist-server/service/transaction/transaction-mutation.js +18 -83
  159. package/dist-server/service/transaction/transaction-mutation.js.map +1 -1
  160. package/dist-server/service/transaction/transaction-period.d.ts +16 -0
  161. package/dist-server/service/transaction/transaction-period.js +49 -0
  162. package/dist-server/service/transaction/transaction-period.js.map +1 -0
  163. package/dist-server/service/transaction/transaction-query.d.ts +12 -0
  164. package/dist-server/service/transaction/transaction-query.js +86 -4
  165. package/dist-server/service/transaction/transaction-query.js.map +1 -1
  166. package/dist-server/service/transaction/transaction-service.d.ts +30 -0
  167. package/dist-server/service/transaction/transaction-service.js +130 -0
  168. package/dist-server/service/transaction/transaction-service.js.map +1 -0
  169. package/dist-server/service/transaction/transaction-type.d.ts +39 -7
  170. package/dist-server/service/transaction/transaction-type.js +145 -23
  171. package/dist-server/service/transaction/transaction-type.js.map +1 -1
  172. package/dist-server/service/transaction/transaction.d.ts +58 -31
  173. package/dist-server/service/transaction/transaction.js +213 -111
  174. package/dist-server/service/transaction/transaction.js.map +1 -1
  175. package/dist-server/tsconfig.tsbuildinfo +1 -1
  176. package/package.json +8 -4
  177. package/things-factory.config.js +0 -4
  178. package/translations/en.json +34 -2
  179. package/translations/ja.json +0 -1
  180. package/translations/ko.json +34 -2
  181. package/translations/ms.json +0 -1
  182. package/translations/zh.json +0 -1
  183. package/dist-client/pages/account/account-importer.d.ts +0 -22
  184. package/dist-client/pages/account/account-importer.js +0 -99
  185. package/dist-client/pages/account/account-importer.js.map +0 -1
  186. package/dist-client/pages/account/account-list-page.d.ts +0 -57
  187. package/dist-client/pages/account/account-list-page.js +0 -306
  188. package/dist-client/pages/account/account-list-page.js.map +0 -1
  189. package/dist-client/pages/bank-account/bank-account-importer.d.ts +0 -23
  190. package/dist-client/pages/bank-account/bank-account-importer.js +0 -92
  191. package/dist-client/pages/bank-account/bank-account-importer.js.map +0 -1
  192. package/dist-client/pages/bank-account/bank-account-list-page.d.ts +0 -60
  193. package/dist-client/pages/bank-account/bank-account-list-page.js +0 -317
  194. package/dist-client/pages/bank-account/bank-account-list-page.js.map +0 -1
  195. package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +0 -22
  196. package/dist-client/pages/financial-statement/financial-statement-importer.js +0 -99
  197. package/dist-client/pages/financial-statement/financial-statement-importer.js.map +0 -1
  198. package/dist-client/pages/financial-statement/financial-statement-list-page.d.ts +0 -57
  199. package/dist-client/pages/financial-statement/financial-statement-list-page.js +0 -280
  200. package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +0 -1
  201. package/dist-client/pages/income-statement/income-statement-importer.d.ts +0 -22
  202. package/dist-client/pages/income-statement/income-statement-importer.js +0 -99
  203. package/dist-client/pages/income-statement/income-statement-importer.js.map +0 -1
  204. package/dist-client/pages/income-statement/income-statement-list-page.d.ts +0 -57
  205. package/dist-client/pages/income-statement/income-statement-list-page.js +0 -280
  206. package/dist-client/pages/income-statement/income-statement-list-page.js.map +0 -1
  207. package/dist-client/pages/payment/payment-importer.d.ts +0 -23
  208. package/dist-client/pages/payment/payment-importer.js +0 -92
  209. package/dist-client/pages/payment/payment-importer.js.map +0 -1
  210. package/dist-client/pages/payment/payment-list-page.d.ts +0 -60
  211. package/dist-client/pages/payment/payment-list-page.js +0 -317
  212. package/dist-client/pages/payment/payment-list-page.js.map +0 -1
  213. package/dist-client/pages/transaction/transaction-importer.d.ts +0 -22
  214. package/dist-client/pages/transaction/transaction-importer.js +0 -99
  215. package/dist-client/pages/transaction/transaction-importer.js.map +0 -1
  216. package/dist-client/pages/transaction/transaction-list-page.d.ts +0 -57
  217. package/dist-client/pages/transaction/transaction-list-page.js +0 -280
  218. package/dist-client/pages/transaction/transaction-list-page.js.map +0 -1
  219. package/dist-server/controllers/index.d.ts +0 -1
  220. package/dist-server/controllers/index.js +0 -5
  221. package/dist-server/controllers/index.js.map +0 -1
  222. package/dist-server/controllers/summary-statements.d.ts +0 -4
  223. package/dist-server/controllers/summary-statements.js +0 -149
  224. package/dist-server/controllers/summary-statements.js.map +0 -1
  225. package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +0 -5
  226. package/dist-server/migrations/1725201567284-seed-country-codes.js +0 -255
  227. package/dist-server/migrations/1725201567284-seed-country-codes.js.map +0 -1
  228. package/dist-server/service/financial-statement/financial-statement-line-item.d.ts +0 -19
  229. package/dist-server/service/financial-statement/financial-statement-line-item.js +0 -94
  230. package/dist-server/service/financial-statement/financial-statement-line-item.js.map +0 -1
  231. package/dist-server/service/financial-statement/financial-statement-type.d.ts +0 -20
  232. package/dist-server/service/financial-statement/financial-statement-type.js +0 -77
  233. package/dist-server/service/financial-statement/financial-statement-type.js.map +0 -1
  234. package/dist-server/service/income-statement/event-subscriber.d.ts +0 -7
  235. package/dist-server/service/income-statement/event-subscriber.js +0 -21
  236. package/dist-server/service/income-statement/event-subscriber.js.map +0 -1
  237. package/dist-server/service/income-statement/income-statement-history.d.ts +0 -28
  238. package/dist-server/service/income-statement/income-statement-history.js +0 -146
  239. package/dist-server/service/income-statement/income-statement-history.js.map +0 -1
  240. package/dist-server/service/income-statement/income-statement-line-item.d.ts +0 -19
  241. package/dist-server/service/income-statement/income-statement-line-item.js +0 -96
  242. package/dist-server/service/income-statement/income-statement-line-item.js.map +0 -1
  243. package/dist-server/service/income-statement/income-statement-mutation.d.ts +0 -10
  244. package/dist-server/service/income-statement/income-statement-mutation.js +0 -159
  245. package/dist-server/service/income-statement/income-statement-mutation.js.map +0 -1
  246. package/dist-server/service/income-statement/income-statement-query.d.ts +0 -11
  247. package/dist-server/service/income-statement/income-statement-query.js +0 -81
  248. package/dist-server/service/income-statement/income-statement-query.js.map +0 -1
  249. package/dist-server/service/income-statement/income-statement-type.d.ts +0 -20
  250. package/dist-server/service/income-statement/income-statement-type.js +0 -77
  251. package/dist-server/service/income-statement/income-statement-type.js.map +0 -1
  252. package/dist-server/service/income-statement/income-statement.d.ts +0 -28
  253. package/dist-server/service/income-statement/income-statement.js +0 -137
  254. package/dist-server/service/income-statement/income-statement.js.map +0 -1
  255. package/dist-server/service/income-statement/index.d.ts +0 -8
  256. package/dist-server/service/income-statement/index.js +0 -13
  257. package/dist-server/service/income-statement/index.js.map +0 -1
@@ -7,6 +7,7 @@ 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 accounting_category_1 = require("../accounting-category/accounting-category");
10
+ const cash_flow_type_1 = require("../cash-flow-type");
10
11
  let Account = class Account {
11
12
  constructor() {
12
13
  this.version = 1;
@@ -34,27 +35,52 @@ tslib_1.__decorate([
34
35
  ], Account.prototype, "domainId", void 0);
35
36
  tslib_1.__decorate([
36
37
  (0, typeorm_1.Column)(),
37
- (0, type_graphql_1.Field)({ nullable: true, description: 'Account code number' }),
38
+ (0, type_graphql_1.Field)({ description: 'Account code, unique in the domain' }),
38
39
  tslib_1.__metadata("design:type", String)
39
40
  ], Account.prototype, "code", void 0);
40
41
  tslib_1.__decorate([
41
42
  (0, typeorm_1.Column)(),
42
- (0, type_graphql_1.Field)({ nullable: true, description: 'Account name' }),
43
+ (0, type_graphql_1.Field)({ description: 'Account name, unique in the domain' }),
43
44
  tslib_1.__metadata("design:type", String)
44
45
  ], Account.prototype, "name", void 0);
45
46
  tslib_1.__decorate([
46
- (0, typeorm_1.Column)({ nullable: true }),
47
- (0, type_graphql_1.Field)({ nullable: true }),
47
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
48
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Description' }),
48
49
  tslib_1.__metadata("design:type", String)
49
50
  ], Account.prototype, "description", void 0);
51
+ tslib_1.__decorate([
52
+ (0, typeorm_1.Column)({ default: cash_flow_type_1.CashFlowType.EXPENSE }),
53
+ (0, type_graphql_1.Field)(type => cash_flow_type_1.CashFlowType, { description: 'Whether money booked to it comes in or goes out' }),
54
+ tslib_1.__metadata("design:type", String)
55
+ ], Account.prototype, "type", void 0);
50
56
  tslib_1.__decorate([
51
57
  (0, typeorm_1.Column)({ nullable: true }),
52
- (0, type_graphql_1.Field)({ nullable: true }),
58
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The line code of the filed financial statements its sums go to' }),
59
+ tslib_1.__metadata("design:type", String)
60
+ ], Account.prototype, "statementLine", void 0);
61
+ tslib_1.__decorate([
62
+ (0, typeorm_1.Column)({ default: true }),
63
+ (0, type_graphql_1.Field)({ description: 'Whether it counts in profit and loss - a loan or a transfer between accounts does not' }),
64
+ tslib_1.__metadata("design:type", Boolean)
65
+ ], Account.prototype, "profitAndLoss", void 0);
66
+ tslib_1.__decorate([
67
+ (0, typeorm_1.Column)({ default: false }),
68
+ (0, type_graphql_1.Field)({ description: 'Whether it is offered for expense claims' }),
69
+ tslib_1.__metadata("design:type", Boolean)
70
+ ], Account.prototype, "forExpense", void 0);
71
+ tslib_1.__decorate([
72
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
73
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Other names it appears under in old ledgers - one per line or comma' }),
74
+ tslib_1.__metadata("design:type", String)
75
+ ], Account.prototype, "aliases", void 0);
76
+ tslib_1.__decorate([
77
+ (0, typeorm_1.Column)({ default: true }),
78
+ (0, type_graphql_1.Field)({ description: 'An inactive account stays on old rows but is not offered for new ones' }),
53
79
  tslib_1.__metadata("design:type", Boolean)
54
80
  ], Account.prototype, "active", void 0);
55
81
  tslib_1.__decorate([
56
- (0, typeorm_1.ManyToOne)(type => accounting_category_1.AccountingCategory),
57
- (0, type_graphql_1.Field)(type => accounting_category_1.AccountingCategory, { nullable: true }),
82
+ (0, typeorm_1.ManyToOne)(type => accounting_category_1.AccountingCategory, { nullable: true }),
83
+ (0, type_graphql_1.Field)(type => accounting_category_1.AccountingCategory, { nullable: true, description: 'The group it belongs to' }),
58
84
  tslib_1.__metadata("design:type", accounting_category_1.AccountingCategory)
59
85
  ], Account.prototype, "category", void 0);
60
86
  tslib_1.__decorate([
@@ -108,6 +134,6 @@ exports.Account = Account = tslib_1.__decorate([
108
134
  unique: false,
109
135
  where: '"deleted_at" IS NULL'
110
136
  }),
111
- (0, type_graphql_1.ObjectType)({ description: 'Entity for Account' })
137
+ (0, type_graphql_1.ObjectType)({ description: 'An account subject - what money is booked to' })
112
138
  ], Account);
113
139
  //# sourceMappingURL=account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../server/service/account/account.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,yDAAgD;AAChD,oFAA+E;AAgBxE,IAAM,OAAO,GAAb,MAAM,OAAO;IAAb;QAOL,YAAO,GAAY,CAAC,CAAA;IAyDtB,CAAC;CAAA,CAAA;AAhEY,0BAAO;AAGT;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;mCACC;AAInB;IAFC,IAAA,uBAAa,GAAE;IACf,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACN;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,cAAM;uCAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;yCAChC;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;;qCACjD;AAIb;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;;qCAC1C;AAIb;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IA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AI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;kBA/DP,OAAO;IAdnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3E,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3E,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC/E,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;GACrC,OAAO,CAgEnB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingCategory } from '../accounting-category/accounting-category'\n\n@Entity()\n@Index('ix_account_0', (account: Account) => [account.domain, account.name], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_account_1', (account: Account) => [account.domain, account.code], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_account_2', (account: Account) => [account.domain, account.category], {\n unique: false,\n where: '\"deleted_at\" IS NULL'\n})\n@ObjectType({ description: 'Entity for Account' })\nexport class Account {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((account: Account) => account.domain)\n domainId?: string\n\n @Column()\n @Field({ nullable: true, description: 'Account code number' })\n code?: string\n\n @Column()\n @Field({ nullable: true, description: 'Account name' })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @ManyToOne(type => AccountingCategory)\n @Field(type => AccountingCategory, { nullable: true })\n category?: AccountingCategory\n\n @RelationId((account: Account) => account.category)\n categoryId?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((account: Account) => account.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((account: Account) => account.updater)\n updaterId?: string\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../server/service/account/account.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,yDAAgD;AAChD,oFAA+E;AAC/E,sDAAgD;AAgBzC,IAAM,OAAO,GAAb,M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AAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC/E,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;GAC/D,OAAO,CAoFnB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingCategory } from '../accounting-category/accounting-category'\nimport { CashFlowType } from '../cash-flow-type'\n\n@Entity()\n@Index('ix_account_0', (account: Account) => [account.domain, account.name], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_account_1', (account: Account) => [account.domain, account.code], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_account_2', (account: Account) => [account.domain, account.category], {\n unique: false,\n where: '\"deleted_at\" IS NULL'\n})\n@ObjectType({ description: 'An account subject - what money is booked to' })\nexport class Account {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((account: Account) => account.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Account code, unique in the domain' })\n code: string\n\n @Column()\n @Field({ description: 'Account name, unique in the domain' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Description' })\n description?: string\n\n @Column({ default: CashFlowType.EXPENSE })\n @Field(type => CashFlowType, { description: 'Whether money booked to it comes in or goes out' })\n type: CashFlowType\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The line code of the filed financial statements its sums go to' })\n statementLine?: string\n\n @Column({ default: true })\n @Field({ description: 'Whether it counts in profit and loss - a loan or a transfer between accounts does not' })\n profitAndLoss: boolean\n\n @Column({ default: false })\n @Field({ description: 'Whether it is offered for expense claims' })\n forExpense: boolean\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Other names it appears under in old ledgers - one per line or comma' })\n aliases?: string\n\n @Column({ default: true })\n @Field({ description: 'An inactive account stays on old rows but is not offered for new ones' })\n active: boolean\n\n @ManyToOne(type => AccountingCategory, { nullable: true })\n @Field(type => AccountingCategory, { nullable: true, description: 'The group it belongs to' })\n category?: AccountingCategory\n\n @RelationId((account: Account) => account.category)\n categoryId?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((account: Account) => account.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((account: Account) => account.updater)\n updaterId?: string\n}\n"]}
@@ -3,5 +3,5 @@ import { AccountQuery } from './account-query';
3
3
  import { AccountMutation } from './account-mutation';
4
4
  import { AccountHistoryEntitySubscriber } from './event-subscriber';
5
5
  export declare const entities: (typeof Account)[];
6
- export declare const resolvers: (typeof AccountMutation | typeof AccountQuery)[];
6
+ export declare const resolvers: (typeof AccountQuery | typeof AccountMutation)[];
7
7
  export declare const subscribers: (typeof AccountHistoryEntitySubscriber)[];
@@ -70,12 +70,12 @@ let AccountingCategoryMutation = class AccountingCategoryMutation {
70
70
  }
71
71
  async deleteAccountingCategory(id, context) {
72
72
  const { domain, tx } = context.state;
73
- await (0, shell_1.getRepository)(accounting_category_1.AccountingCategory, tx).delete({ domain: { id: domain.id }, id });
73
+ await (0, shell_1.getRepository)(accounting_category_1.AccountingCategory, tx).softDelete({ domain: { id: domain.id }, id });
74
74
  return true;
75
75
  }
76
76
  async deleteAccountingCategories(ids, context) {
77
77
  const { domain, tx } = context.state;
78
- await (0, shell_1.getRepository)(accounting_category_1.AccountingCategory, tx).delete({
78
+ await (0, shell_1.getRepository)(accounting_category_1.AccountingCategory, tx).softDelete({
79
79
  domain: { id: domain.id },
80
80
  id: (0, typeorm_1.In)(ids)
81
81
  });
@@ -94,7 +94,7 @@ let AccountingCategoryMutation = class AccountingCategoryMutation {
94
94
  exports.AccountingCategoryMutation = AccountingCategoryMutation;
95
95
  tslib_1.__decorate([
96
96
  (0, type_graphql_1.Directive)('@transaction'),
97
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
97
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
98
98
  (0, type_graphql_1.Mutation)(returns => accounting_category_1.AccountingCategory, { description: 'To create new AccountingCategory' }),
99
99
  tslib_1.__param(0, (0, type_graphql_1.Arg)('accountingCategory')),
100
100
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -104,7 +104,7 @@ tslib_1.__decorate([
104
104
  ], AccountingCategoryMutation.prototype, "createAccountingCategory", null);
105
105
  tslib_1.__decorate([
106
106
  (0, type_graphql_1.Directive)('@transaction'),
107
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
107
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
108
108
  (0, type_graphql_1.Mutation)(returns => accounting_category_1.AccountingCategory, { description: 'To modify AccountingCategory information' }),
109
109
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
110
110
  tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
@@ -115,7 +115,7 @@ tslib_1.__decorate([
115
115
  ], AccountingCategoryMutation.prototype, "updateAccountingCategory", null);
116
116
  tslib_1.__decorate([
117
117
  (0, type_graphql_1.Directive)('@transaction'),
118
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
118
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
119
119
  (0, type_graphql_1.Mutation)(returns => [accounting_category_1.AccountingCategory], { description: "To modify multiple AccountingCategories' information" }),
120
120
  tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [accounting_category_type_1.AccountingCategoryPatch])),
121
121
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -125,7 +125,7 @@ tslib_1.__decorate([
125
125
  ], AccountingCategoryMutation.prototype, "updateMultipleAccountingCategory", null);
126
126
  tslib_1.__decorate([
127
127
  (0, type_graphql_1.Directive)('@transaction'),
128
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
128
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
129
129
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete AccountingCategory' }),
130
130
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
131
131
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -135,7 +135,7 @@ tslib_1.__decorate([
135
135
  ], AccountingCategoryMutation.prototype, "deleteAccountingCategory", null);
136
136
  tslib_1.__decorate([
137
137
  (0, type_graphql_1.Directive)('@transaction'),
138
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
138
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
139
139
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple AccountingCategories' }),
140
140
  tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
141
141
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -145,7 +145,7 @@ tslib_1.__decorate([
145
145
  ], AccountingCategoryMutation.prototype, "deleteAccountingCategories", null);
146
146
  tslib_1.__decorate([
147
147
  (0, type_graphql_1.Directive)('@transaction'),
148
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
148
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
149
149
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple AccountingCategories' }),
150
150
  tslib_1.__param(0, (0, type_graphql_1.Arg)('accountingCategories', type => [accounting_category_type_1.AccountingCategoryPatch])),
151
151
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-category-mutation.js","sourceRoot":"","sources":["../../../server/service/accounting-category/accounting-category-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,+DAA0D;AAC1D,yEAA2F;AAGpF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAI/B,AAAN,KAAK,CAAC,wBAAwB,CACD,kBAAyC,EAC7D,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YAC9D,GAAG,kBAAkB;YACrB,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,wBAAwB,CACjB,EAAU,EACP,KAA8B,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAA;Q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C,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4EAUP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,2DAA2D,CAAC;IACtE,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IAEtF,mBAAA,IAAA,kBAAG,EAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,kDAAuB,CAAC,CAAC,CAAA;IAC9D,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4EAaP;qCA/IU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAgJtC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { AccountingCategory } from './accounting-category'\nimport { NewAccountingCategory, AccountingCategoryPatch } from './accounting-category-type'\n\n@Resolver(AccountingCategory)\nexport class AccountingCategoryMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => AccountingCategory, { description: 'To create new AccountingCategory' })\n async createAccountingCategory(\n @Arg('accountingCategory') accountingCategory: NewAccountingCategory,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategory> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(AccountingCategory, tx).save({\n ...accountingCategory,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => AccountingCategory, { description: 'To modify AccountingCategory information' })\n async updateAccountingCategory(\n @Arg('id') id: string,\n @Arg('patch') patch: AccountingCategoryPatch,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategory> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(AccountingCategory, tx)\n const accountingCategory = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...accountingCategory,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => [AccountingCategory], { description: \"To modify multiple AccountingCategories' information\" })\n async updateMultipleAccountingCategory(\n @Arg('patches', type => [AccountingCategoryPatch]) patches: AccountingCategoryPatch[],\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategory[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const accountingCategoryRepo = getRepository(AccountingCategory, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await accountingCategoryRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const accountingCategory = await accountingCategoryRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!accountingCategory) {\n throw new Error(`failed to find accountingCategory to update: ${updateRecord.id}`)\n }\n\n const result = await accountingCategoryRepo.save({\n ...accountingCategory,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => Boolean, { description: 'To delete AccountingCategory' })\n async deleteAccountingCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingCategory, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => Boolean, { description: 'To delete multiple AccountingCategories' })\n async deleteAccountingCategories(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingCategory, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => Boolean, { description: 'To import multiple AccountingCategories' })\n async importAccountingCategories(\n @Arg('accountingCategories', type => [AccountingCategoryPatch]) accountingCategories: AccountingCategoryPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n accountingCategories.map(async (accountingCategory: AccountingCategoryPatch) => {\n const createdAccountingCategory: AccountingCategory = await tx\n .getRepository(AccountingCategory)\n .save({ domain, ...accountingCategory })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"accounting-category-mutation.js","sourceRoot":"","sources":["../../../server/service/accounting-category/accounting-category-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,+DAA0D;AAC1D,yEAA2F;AAGpF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAI/B,AAAN,KAAK,CAAC,wBAAwB,CACD,kBAAyC,EAC7D,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YAC9D,GAAG,kBAAkB;YACrB,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,wBAA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AAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IAEtF,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4EAUP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IAEtF,mBAAA,IAAA,kBAAG,EAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,kDAAuB,CAAC,CAAC,CAAA;IAC9D,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4EAaP;qCA/IU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAgJtC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { AccountingCategory } from './accounting-category'\nimport { NewAccountingCategory, AccountingCategoryPatch } from './accounting-category-type'\n\n@Resolver(AccountingCategory)\nexport class AccountingCategoryMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => AccountingCategory, { description: 'To create new AccountingCategory' })\n async createAccountingCategory(\n @Arg('accountingCategory') accountingCategory: NewAccountingCategory,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategory> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(AccountingCategory, tx).save({\n ...accountingCategory,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => AccountingCategory, { description: 'To modify AccountingCategory information' })\n async updateAccountingCategory(\n @Arg('id') id: string,\n @Arg('patch') patch: AccountingCategoryPatch,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategory> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(AccountingCategory, tx)\n const accountingCategory = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...accountingCategory,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [AccountingCategory], { description: \"To modify multiple AccountingCategories' information\" })\n async updateMultipleAccountingCategory(\n @Arg('patches', type => [AccountingCategoryPatch]) patches: AccountingCategoryPatch[],\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategory[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const accountingCategoryRepo = getRepository(AccountingCategory, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await accountingCategoryRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const accountingCategory = await accountingCategoryRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!accountingCategory) {\n throw new Error(`failed to find accountingCategory to update: ${updateRecord.id}`)\n }\n\n const result = await accountingCategoryRepo.save({\n ...accountingCategory,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete AccountingCategory' })\n async deleteAccountingCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingCategory, tx).softDelete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple AccountingCategories' })\n async deleteAccountingCategories(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingCategory, tx).softDelete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple AccountingCategories' })\n async importAccountingCategories(\n @Arg('accountingCategories', type => [AccountingCategoryPatch]) accountingCategories: AccountingCategoryPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n accountingCategories.map(async (accountingCategory: AccountingCategoryPatch) => {\n const createdAccountingCategory: AccountingCategory = await tx\n .getRepository(AccountingCategory)\n .save({ domain, ...accountingCategory })\n })\n )\n\n return true\n }\n}\n"]}
@@ -58,7 +58,7 @@ tslib_1.__decorate([
58
58
  tslib_1.__metadata("design:returntype", Promise)
59
59
  ], AccountingCategoryQuery.prototype, "accountingCategoryRoots", null);
60
60
  tslib_1.__decorate([
61
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query")'),
61
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
62
62
  (0, type_graphql_1.Query)(returns => accounting_category_1.AccountingCategory, { nullable: true, description: 'To fetch a AccountingCategory' }),
63
63
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
64
64
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -67,7 +67,7 @@ tslib_1.__decorate([
67
67
  tslib_1.__metadata("design:returntype", Promise)
68
68
  ], AccountingCategoryQuery.prototype, "accountingCategory", null);
69
69
  tslib_1.__decorate([
70
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query")'),
70
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
71
71
  (0, type_graphql_1.Query)(returns => accounting_category_type_1.AccountingCategoryList, { description: 'To fetch multiple AccountingCategories' }),
72
72
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
73
73
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-category-query.js","sourceRoot":"","sources":["../../../server/service/accounting-category/accounting-category-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAAgC;AAChC,iDAAuG;AACvG,yDAAgD;AAChD,+DAA0D;AAC1D,yEAAmE;AAG5D,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAG5B,AAAN,KAAK,CAAC,uBAAuB,CACF,MAAiB,EACnC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC;YACnD,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;SAC7C,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAA,gBAAM,GAAE,EAAE,EAAE,CAAC,CAAA;QAEpE,MAAM,CAAC,KA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4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAE3D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAE3D;kCAhEU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CAiEnC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { IsNull } from 'typeorm'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingCategory } from './accounting-category'\nimport { AccountingCategoryList } from './accounting-category-type'\n\n@Resolver(AccountingCategory)\nexport class AccountingCategoryQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountingCategoryList, { nullable: true, description: 'To fetch a Root AccountingCategorys' })\n async accountingCategoryRoots(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategoryList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(AccountingCategory),\n searchables: ['name', 'description', 'code']\n }).andWhere({ domain: { id: domain.id }, parent: { id: IsNull() } })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\")')\n @Query(returns => AccountingCategory!, { nullable: true, description: 'To fetch a AccountingCategory' })\n async accountingCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<AccountingCategory> {\n const { domain } = context.state\n\n return await getRepository(AccountingCategory).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\")')\n @Query(returns => AccountingCategoryList, { description: 'To fetch multiple AccountingCategories' })\n async accountingCategories(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategoryList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(AccountingCategory),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() accountingCategory: AccountingCategory): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: accountingCategory.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() accountingCategory: AccountingCategory): Promise<User> {\n return await getRepository(User).findOneBy({ id: accountingCategory.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() accountingCategory: AccountingCategory): Promise<User> {\n return await getRepository(User).findOneBy({ id: accountingCategory.creatorId })\n }\n}\n"]}
1
+ {"version":3,"file":"accounting-category-query.js","sourceRoot":"","sources":["../../../server/service/accounting-category/accounting-category-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAAgC;AAChC,iDAAuG;AACvG,yDAAgD;AAChD,+DAA0D;AAC1D,yEAAmE;AAG5D,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAG5B,AAAN,KAAK,CAAC,uBAAuB,CACF,MAAiB,EACnC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC;YACnD,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;SAC7C,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,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AA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;qDAE1D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAE3D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAE3D;kCAhEU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CAiEnC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { IsNull } from 'typeorm'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingCategory } from './accounting-category'\nimport { AccountingCategoryList } from './accounting-category-type'\n\n@Resolver(AccountingCategory)\nexport class AccountingCategoryQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountingCategoryList, { nullable: true, description: 'To fetch a Root AccountingCategorys' })\n async accountingCategoryRoots(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategoryList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(AccountingCategory),\n searchables: ['name', 'description', 'code']\n }).andWhere({ domain: { id: domain.id }, parent: { id: IsNull() } })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountingCategory!, { nullable: true, description: 'To fetch a AccountingCategory' })\n async accountingCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<AccountingCategory> {\n const { domain } = context.state\n\n return await getRepository(AccountingCategory).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountingCategoryList, { description: 'To fetch multiple AccountingCategories' })\n async accountingCategories(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<AccountingCategoryList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(AccountingCategory),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() accountingCategory: AccountingCategory): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: accountingCategory.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() accountingCategory: AccountingCategory): Promise<User> {\n return await getRepository(User).findOneBy({ id: accountingCategory.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() accountingCategory: AccountingCategory): Promise<User> {\n return await getRepository(User).findOneBy({ id: accountingCategory.creatorId })\n }\n}\n"]}
@@ -3,5 +3,5 @@ import { AccountingCategoryQuery } from './accounting-category-query';
3
3
  import { AccountingCategoryMutation } from './accounting-category-mutation';
4
4
  import { AccountingCategoryHistoryEntitySubscriber } from './event-subscriber';
5
5
  export declare const entities: (typeof AccountingCategory)[];
6
- export declare const resolvers: (typeof AccountingCategoryMutation | typeof AccountingCategoryQuery)[];
6
+ export declare const resolvers: (typeof AccountingCategoryQuery | typeof AccountingCategoryMutation)[];
7
7
  export declare const subscribers: (typeof AccountingCategoryHistoryEntitySubscriber)[];
@@ -70,12 +70,12 @@ let AccountingDocumentMutation = class AccountingDocumentMutation {
70
70
  }
71
71
  async deleteAccountingDocument(id, context) {
72
72
  const { domain, tx } = context.state;
73
- await (0, shell_1.getRepository)(accounting_document_1.AccountingDocument, tx).delete({ domain: { id: domain.id }, id });
73
+ await (0, shell_1.getRepository)(accounting_document_1.AccountingDocument, tx).softDelete({ domain: { id: domain.id }, id });
74
74
  return true;
75
75
  }
76
76
  async deleteAccountingDocuments(ids, context) {
77
77
  const { domain, tx } = context.state;
78
- await (0, shell_1.getRepository)(accounting_document_1.AccountingDocument, tx).delete({
78
+ await (0, shell_1.getRepository)(accounting_document_1.AccountingDocument, tx).softDelete({
79
79
  domain: { id: domain.id },
80
80
  id: (0, typeorm_1.In)(ids)
81
81
  });
@@ -84,7 +84,10 @@ let AccountingDocumentMutation = class AccountingDocumentMutation {
84
84
  async importAccountingDocuments(accountingDocuments, context) {
85
85
  const { domain, tx } = context.state;
86
86
  await Promise.all(accountingDocuments.map(async (accountingDocument) => {
87
- const createdAccountingDocument = await (0, shell_1.getRepository)(accounting_document_1.AccountingDocument, tx).save({ domain, ...accountingDocument });
87
+ const createdAccountingDocument = await (0, shell_1.getRepository)(accounting_document_1.AccountingDocument, tx).save({
88
+ domain,
89
+ ...accountingDocument
90
+ });
88
91
  }));
89
92
  return true;
90
93
  }
@@ -92,6 +95,7 @@ let AccountingDocumentMutation = class AccountingDocumentMutation {
92
95
  exports.AccountingDocumentMutation = AccountingDocumentMutation;
93
96
  tslib_1.__decorate([
94
97
  (0, type_graphql_1.Directive)('@transaction'),
98
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
95
99
  (0, type_graphql_1.Mutation)(returns => accounting_document_1.AccountingDocument, { description: 'To create new AccountingDocument' }),
96
100
  tslib_1.__param(0, (0, type_graphql_1.Arg)('accountingDocument')),
97
101
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -101,6 +105,7 @@ tslib_1.__decorate([
101
105
  ], AccountingDocumentMutation.prototype, "createAccountingDocument", null);
102
106
  tslib_1.__decorate([
103
107
  (0, type_graphql_1.Directive)('@transaction'),
108
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
104
109
  (0, type_graphql_1.Mutation)(returns => accounting_document_1.AccountingDocument, { description: 'To modify AccountingDocument information' }),
105
110
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
106
111
  tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
@@ -111,6 +116,7 @@ tslib_1.__decorate([
111
116
  ], AccountingDocumentMutation.prototype, "updateAccountingDocument", null);
112
117
  tslib_1.__decorate([
113
118
  (0, type_graphql_1.Directive)('@transaction'),
119
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
114
120
  (0, type_graphql_1.Mutation)(returns => [accounting_document_1.AccountingDocument], { description: "To modify multiple AccountingDocuments' information" }),
115
121
  tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [accounting_document_type_1.AccountingDocumentPatch])),
116
122
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -120,6 +126,7 @@ tslib_1.__decorate([
120
126
  ], AccountingDocumentMutation.prototype, "updateMultipleAccountingDocument", null);
121
127
  tslib_1.__decorate([
122
128
  (0, type_graphql_1.Directive)('@transaction'),
129
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
123
130
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete AccountingDocument' }),
124
131
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
125
132
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -129,6 +136,7 @@ tslib_1.__decorate([
129
136
  ], AccountingDocumentMutation.prototype, "deleteAccountingDocument", null);
130
137
  tslib_1.__decorate([
131
138
  (0, type_graphql_1.Directive)('@transaction'),
139
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
132
140
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple AccountingDocuments' }),
133
141
  tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
134
142
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -138,6 +146,7 @@ tslib_1.__decorate([
138
146
  ], AccountingDocumentMutation.prototype, "deleteAccountingDocuments", null);
139
147
  tslib_1.__decorate([
140
148
  (0, type_graphql_1.Directive)('@transaction'),
149
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
141
150
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple AccountingDocuments' }),
142
151
  tslib_1.__param(0, (0, type_graphql_1.Arg)('accountingDocuments', type => [accounting_document_type_1.AccountingDocumentPatch])),
143
152
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-document-mutation.js","sourceRoot":"","sources":["../../../server/service/accounting-document/accounting-document-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,+DAA0D;AAC1D,yEAA2F;AAGpF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG/B,AAAN,KAAK,CAAC,wBAAwB,CAA4B,kBAAyC,EAAS,OAAwB;QAClI,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YAC9D,GAAG,kBAAkB;YACrB,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,wBAAwB,CACjB,EAAU,EACP,KAA8B,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAA;QACxD,MAAM,kBAAkB,GAAG,M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AA,IAAA,kBAAG,EAAC,qBAAqB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,kDAAuB,CAAC,CAAC,CAAA;IAC7D,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EAWP;qCArIU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAsItC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { AccountingDocument } from './accounting-document'\nimport { NewAccountingDocument, AccountingDocumentPatch } from './accounting-document-type'\n\n@Resolver(AccountingDocument)\nexport class AccountingDocumentMutation {\n @Directive('@transaction')\n @Mutation(returns => AccountingDocument, { description: 'To create new AccountingDocument' })\n async createAccountingDocument(@Arg('accountingDocument') accountingDocument: NewAccountingDocument, @Ctx() context: ResolverContext): Promise<AccountingDocument> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(AccountingDocument, tx).save({\n ...accountingDocument,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => AccountingDocument, { description: 'To modify AccountingDocument information' })\n async updateAccountingDocument(\n @Arg('id') id: string,\n @Arg('patch') patch: AccountingDocumentPatch,\n @Ctx() context: ResolverContext\n ): Promise<AccountingDocument> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(AccountingDocument, tx)\n const accountingDocument = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...accountingDocument,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [AccountingDocument], { description: \"To modify multiple AccountingDocuments' information\" })\n async updateMultipleAccountingDocument(\n @Arg('patches', type => [AccountingDocumentPatch]) patches: AccountingDocumentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<AccountingDocument[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const accountingDocumentRepo = getRepository(AccountingDocument, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await accountingDocumentRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const accountingDocument = await accountingDocumentRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!accountingDocument) {\n throw new Error(`failed to find accountingDocument to update: ${updateRecord.id}`)\n }\n\n const result = await accountingDocumentRepo.save({\n ...accountingDocument,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete AccountingDocument' })\n async deleteAccountingDocument(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingDocument, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple AccountingDocuments' })\n async deleteAccountingDocuments(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingDocument, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple AccountingDocuments' })\n async importAccountingDocuments(\n @Arg('accountingDocuments', type => [AccountingDocumentPatch]) accountingDocuments: AccountingDocumentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n accountingDocuments.map(async (accountingDocument: AccountingDocumentPatch) => {\n const createdAccountingDocument: AccountingDocument = await getRepository(AccountingDocument, tx).save({ domain, ...accountingDocument })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"accounting-document-mutation.js","sourceRoot":"","sources":["../../../server/service/accounting-document/accounting-document-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,+DAA0D;AAC1D,yEAA2F;AAGpF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAI/B,AAAN,KAAK,CAAC,wBAAwB,CACD,kBAAyC,EAC7D,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YAC9D,GAAG,kBAAkB;YACrB,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,wBAAwB,CACjB,EAAU,EACP,KAA8B,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAA;QACxD,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAClD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC;YACnC,GAAG,kBAAkB;YACrB,GAAG,KAAK;YACR,OAAO,EAAE,IAAI;SACd,CAAC,CAAA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AAI,CAAC,EAAE,CAAC,CAAC,kDAAuB,CAAC,CAAC,CAAA;IAC7D,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EAcP;qCAhJU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAiJtC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { AccountingDocument } from './accounting-document'\nimport { NewAccountingDocument, AccountingDocumentPatch } from './accounting-document-type'\n\n@Resolver(AccountingDocument)\nexport class AccountingDocumentMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => AccountingDocument, { description: 'To create new AccountingDocument' })\n async createAccountingDocument(\n @Arg('accountingDocument') accountingDocument: NewAccountingDocument,\n @Ctx() context: ResolverContext\n ): Promise<AccountingDocument> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(AccountingDocument, tx).save({\n ...accountingDocument,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => AccountingDocument, { description: 'To modify AccountingDocument information' })\n async updateAccountingDocument(\n @Arg('id') id: string,\n @Arg('patch') patch: AccountingDocumentPatch,\n @Ctx() context: ResolverContext\n ): Promise<AccountingDocument> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(AccountingDocument, tx)\n const accountingDocument = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...accountingDocument,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [AccountingDocument], { description: \"To modify multiple AccountingDocuments' information\" })\n async updateMultipleAccountingDocument(\n @Arg('patches', type => [AccountingDocumentPatch]) patches: AccountingDocumentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<AccountingDocument[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const accountingDocumentRepo = getRepository(AccountingDocument, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await accountingDocumentRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const accountingDocument = await accountingDocumentRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!accountingDocument) {\n throw new Error(`failed to find accountingDocument to update: ${updateRecord.id}`)\n }\n\n const result = await accountingDocumentRepo.save({\n ...accountingDocument,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete AccountingDocument' })\n async deleteAccountingDocument(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingDocument, tx).softDelete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple AccountingDocuments' })\n async deleteAccountingDocuments(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(AccountingDocument, tx).softDelete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple AccountingDocuments' })\n async importAccountingDocuments(\n @Arg('accountingDocuments', type => [AccountingDocumentPatch]) accountingDocuments: AccountingDocumentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n accountingDocuments.map(async (accountingDocument: AccountingDocumentPatch) => {\n const createdAccountingDocument: AccountingDocument = await getRepository(AccountingDocument, tx).save({\n domain,\n ...accountingDocument\n })\n })\n )\n\n return true\n }\n}\n"]}
@@ -37,6 +37,7 @@ let AccountingDocumentQuery = class AccountingDocumentQuery {
37
37
  };
38
38
  exports.AccountingDocumentQuery = AccountingDocumentQuery;
39
39
  tslib_1.__decorate([
40
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
40
41
  (0, type_graphql_1.Query)(returns => accounting_document_1.AccountingDocument, { nullable: true, description: 'To fetch a AccountingDocument' }),
41
42
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
42
43
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -45,6 +46,7 @@ tslib_1.__decorate([
45
46
  tslib_1.__metadata("design:returntype", Promise)
46
47
  ], AccountingDocumentQuery.prototype, "accountingDocument", null);
47
48
  tslib_1.__decorate([
49
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
48
50
  (0, type_graphql_1.Query)(returns => accounting_document_type_1.AccountingDocumentList, { description: 'To fetch multiple AccountingDocuments' }),
49
51
  tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
50
52
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-document-query.js","sourceRoot":"","sources":["../../../server/service/accounting-document/accounting-document-query.ts"],"names":[],"m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sDAE3D;kCAvCU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CAwCnC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingDocument } from './accounting-document'\nimport { AccountingDocumentList } from './accounting-document-type'\n\n@Resolver(AccountingDocument)\nexport class AccountingDocumentQuery {\n @Query(returns => AccountingDocument!, { nullable: true, description: 'To fetch a AccountingDocument' })\n async accountingDocument(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<AccountingDocument> {\n const { domain } = context.state\n\n return await getRepository(AccountingDocument).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => AccountingDocumentList, { description: 'To fetch multiple AccountingDocuments' })\n async accountingDocuments(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<AccountingDocumentList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(AccountingDocument),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() accountingDocument: AccountingDocument): Promise<Domain> {\n return accountingDocument.domainId && (await getRepository(Domain).findOneBy({ id: accountingDocument.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() accountingDocument: AccountingDocument): Promise<User> {\n return accountingDocument.updaterId && (await getRepository(User).findOneBy({ id: accountingDocument.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() accountingDocument: AccountingDocument): Promise<User> {\n return accountingDocument.creatorId && (await getRepository(User).findOneBy({ id: accountingDocument.creatorId }))\n }\n}\n"]}
1
+ {"version":3,"file":"accounting-document-query.js","sourceRoot":"","sources":["../../../server/service/accounting-document/accounting-document-query.ts"],"names":[],"mappings":";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AE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAE3D;kCA5CU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CA6CnC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingDocument } from './accounting-document'\nimport { AccountingDocumentList } from './accounting-document-type'\n\n@Resolver(AccountingDocument)\nexport class AccountingDocumentQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountingDocument!, { nullable: true, description: 'To fetch a AccountingDocument' })\n async accountingDocument(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<AccountingDocument> {\n const { domain } = context.state\n\n return await getRepository(AccountingDocument).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountingDocumentList, { description: 'To fetch multiple AccountingDocuments' })\n async accountingDocuments(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<AccountingDocumentList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(AccountingDocument),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() accountingDocument: AccountingDocument): Promise<Domain> {\n return accountingDocument.domainId && (await getRepository(Domain).findOneBy({ id: accountingDocument.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() accountingDocument: AccountingDocument): Promise<User> {\n return accountingDocument.updaterId && (await getRepository(User).findOneBy({ id: accountingDocument.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() accountingDocument: AccountingDocument): Promise<User> {\n return accountingDocument.creatorId && (await getRepository(User).findOneBy({ id: accountingDocument.creatorId }))\n }\n}\n"]}
@@ -3,5 +3,5 @@ import { AccountingDocumentHistoryEntitySubscriber } from './event-subscriber';
3
3
  import { AccountingDocumentQuery } from './accounting-document-query';
4
4
  import { AccountingDocumentMutation } from './accounting-document-mutation';
5
5
  export declare const entities: (typeof AccountingDocument)[];
6
- export declare const resolvers: (typeof AccountingDocumentMutation | typeof AccountingDocumentQuery)[];
6
+ export declare const resolvers: (typeof AccountingDocumentQuery | typeof AccountingDocumentMutation)[];
7
7
  export declare const subscribers: (typeof AccountingDocumentHistoryEntitySubscriber)[];
@@ -1,26 +1,24 @@
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 { AccountType, BankAccount, OwnerType } from './bank-account';
4
+ import { AccountType, BankAccount, BankAccountPurpose } from './bank-account';
5
+ /** Each version of a bank account, written when it changes. */
5
6
  export declare class BankAccountHistory implements HistoryEntityInterface<BankAccount> {
6
7
  readonly id: string;
7
8
  version?: number;
8
9
  domain?: Domain;
9
10
  domainId?: string;
10
11
  name: string;
11
- description?: string;
12
- accountHolderName?: string;
13
- accountNumber?: string;
14
- bankName?: string;
12
+ description: string;
13
+ bankName: string;
14
+ accountNumber: string;
15
15
  accountType: AccountType;
16
- currency?: string;
17
- active?: boolean;
18
- ownerType: OwnerType;
19
- ownerId: string;
20
- iban?: string;
21
- bic?: string;
22
- country?: string;
23
- image?: string;
16
+ currency: string;
17
+ timezone: string;
18
+ purpose: BankAccountPurpose;
19
+ statedBalance: number;
20
+ statedBalanceDate: string;
21
+ active: boolean;
24
22
  createdAt?: Date;
25
23
  updatedAt?: Date;
26
24
  deletedAt?: Date;
@@ -28,7 +26,6 @@ export declare class BankAccountHistory implements HistoryEntityInterface<BankAc
28
26
  creatorId?: string;
29
27
  updater?: User;
30
28
  updaterId?: string;
31
- thumbnail?: string;
32
29
  originalId: string;
33
30
  action: HistoryActionType;
34
31
  }