@things-factory/accounting 8.0.0-alpha.1 → 8.0.0-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. package/client/bootstrap.ts +10 -1
  2. package/client/components/accounting-category-selector.ts +136 -0
  3. package/client/components/accounting-category-view.ts +75 -0
  4. package/client/grist-editors/grist-editor-accounting-category-object.ts +83 -0
  5. package/client/grist-editors/grist-renderer-accounting-category-object.ts +13 -0
  6. package/client/pages/account/account-list-page.ts +33 -2
  7. package/client/pages/accounting-category/accounting-category-list-page.ts +31 -1
  8. package/client/pages/accounting-category/accounting-category-tree-page.ts +338 -0
  9. package/client/pages/accounting-document/accounting-document-importer.ts +90 -0
  10. package/client/pages/accounting-document/accounting-document-list-page.ts +398 -0
  11. package/client/pages/{ledger/ledger-importer.ts → payment/payment-importer.ts} +10 -17
  12. package/client/pages/{ledger/ledger-list-page.ts → payment/payment-list-page.ts} +118 -57
  13. package/client/route.ts +0 -4
  14. package/client/types/accounting-category.ts +23 -0
  15. package/client/types/index.ts +1 -0
  16. package/dist-client/bootstrap.js +7 -1
  17. package/dist-client/bootstrap.js.map +1 -1
  18. package/dist-client/components/accounting-category-selector.d.ts +16 -0
  19. package/dist-client/components/accounting-category-selector.js +134 -0
  20. package/dist-client/components/accounting-category-selector.js.map +1 -0
  21. package/dist-client/components/accounting-category-view.d.ts +14 -0
  22. package/dist-client/components/accounting-category-view.js +81 -0
  23. package/dist-client/components/accounting-category-view.js.map +1 -0
  24. package/dist-client/grist-editors/grist-editor-accounting-category-object.d.ts +11 -0
  25. package/dist-client/grist-editors/grist-editor-accounting-category-object.js +71 -0
  26. package/dist-client/grist-editors/grist-editor-accounting-category-object.js.map +1 -0
  27. package/dist-client/grist-editors/grist-renderer-accounting-category-object.d.ts +2 -0
  28. package/dist-client/grist-editors/grist-renderer-accounting-category-object.js +9 -0
  29. package/dist-client/grist-editors/grist-renderer-accounting-category-object.js.map +1 -0
  30. package/dist-client/pages/account/account-list-page.js +33 -2
  31. package/dist-client/pages/account/account-list-page.js.map +1 -1
  32. package/dist-client/pages/accounting-category/accounting-category-list-page.js +31 -1
  33. package/dist-client/pages/accounting-category/accounting-category-list-page.js.map +1 -1
  34. package/dist-client/pages/accounting-category/accounting-category-tree-page.d.ts +46 -0
  35. package/dist-client/pages/accounting-category/accounting-category-tree-page.js +329 -0
  36. package/dist-client/pages/accounting-category/accounting-category-tree-page.js.map +1 -0
  37. package/dist-client/pages/accounting-document/accounting-document-importer.d.ts +23 -0
  38. package/dist-client/pages/accounting-document/accounting-document-importer.js +93 -0
  39. package/dist-client/pages/accounting-document/accounting-document-importer.js.map +1 -0
  40. package/dist-client/pages/accounting-document/accounting-document-list-page.d.ts +66 -0
  41. package/dist-client/pages/accounting-document/accounting-document-list-page.js +370 -0
  42. package/dist-client/pages/accounting-document/accounting-document-list-page.js.map +1 -0
  43. package/dist-client/pages/{ledger/ledger-importer.d.ts → payment/payment-importer.d.ts} +3 -2
  44. package/dist-client/pages/{ledger/ledger-importer.js → payment/payment-importer.js} +14 -21
  45. package/dist-client/pages/payment/payment-importer.js.map +1 -0
  46. package/dist-client/pages/{ledger/ledger-list-page.d.ts → payment/payment-list-page.d.ts} +12 -8
  47. package/dist-client/pages/{ledger/ledger-list-page.js → payment/payment-list-page.js} +114 -67
  48. package/dist-client/pages/payment/payment-list-page.js.map +1 -0
  49. package/dist-client/route.d.ts +1 -1
  50. package/dist-client/route.js +0 -3
  51. package/dist-client/route.js.map +1 -1
  52. package/dist-client/tsconfig.tsbuildinfo +1 -1
  53. package/dist-client/types/accounting-category.d.ts +16 -0
  54. package/dist-client/types/accounting-category.js +3 -0
  55. package/dist-client/types/accounting-category.js.map +1 -0
  56. package/dist-client/types/index.d.ts +1 -0
  57. package/dist-client/types/index.js +2 -0
  58. package/dist-client/types/index.js.map +1 -0
  59. package/dist-server/activities/activity-book.js +31 -19
  60. package/dist-server/activities/activity-book.js.map +1 -1
  61. package/dist-server/controllers/summary-statements.js +13 -7
  62. package/dist-server/controllers/summary-statements.js.map +1 -1
  63. package/dist-server/index.d.ts +1 -0
  64. package/dist-server/index.js +1 -0
  65. package/dist-server/index.js.map +1 -1
  66. package/dist-server/migrations/1725200507196-seed-fiscal-entities.js +3 -3
  67. package/dist-server/migrations/1725200507196-seed-fiscal-entities.js.map +1 -1
  68. package/dist-server/migrations/1725201467183-seed-accounts.js +31 -31
  69. package/dist-server/migrations/1725201467183-seed-accounts.js.map +1 -1
  70. package/dist-server/routes.d.ts +0 -1
  71. package/dist-server/routes.js +0 -1
  72. package/dist-server/routes.js.map +1 -1
  73. package/dist-server/service/account/account-history.d.ts +4 -1
  74. package/dist-server/service/account/account-history.js +14 -4
  75. package/dist-server/service/account/account-history.js.map +1 -1
  76. package/dist-server/service/account/account-mutation.js +13 -9
  77. package/dist-server/service/account/account-mutation.js.map +1 -1
  78. package/dist-server/service/account/account-query.js +2 -0
  79. package/dist-server/service/account/account-query.js.map +1 -1
  80. package/dist-server/service/account/account.d.ts +1 -1
  81. package/dist-server/service/account/account.js +15 -4
  82. package/dist-server/service/account/account.js.map +1 -1
  83. package/dist-server/service/account/index.d.ts +1 -2
  84. package/dist-server/service/accounting-category/accounting-category-history.d.ts +26 -0
  85. package/dist-server/service/accounting-category/accounting-category-history.js +136 -0
  86. package/dist-server/service/accounting-category/accounting-category-history.js.map +1 -0
  87. package/dist-server/service/accounting-category/accounting-category-mutation.js +12 -8
  88. package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -1
  89. package/dist-server/service/accounting-category/accounting-category-query.d.ts +1 -0
  90. package/dist-server/service/accounting-category/accounting-category-query.js +23 -0
  91. package/dist-server/service/accounting-category/accounting-category-query.js.map +1 -1
  92. package/dist-server/service/accounting-category/accounting-category.d.ts +1 -0
  93. package/dist-server/service/accounting-category/accounting-category.js +14 -3
  94. package/dist-server/service/accounting-category/accounting-category.js.map +1 -1
  95. package/dist-server/service/accounting-category/event-subscriber.d.ts +7 -0
  96. package/dist-server/service/accounting-category/event-subscriber.js +21 -0
  97. package/dist-server/service/accounting-category/event-subscriber.js.map +1 -0
  98. package/dist-server/service/accounting-category/index.d.ts +2 -1
  99. package/dist-server/service/accounting-category/index.js +4 -2
  100. package/dist-server/service/accounting-category/index.js.map +1 -1
  101. package/dist-server/service/accounting-document/accounting-document-history.d.ts +26 -0
  102. package/dist-server/service/accounting-document/accounting-document-history.js +129 -0
  103. package/dist-server/service/accounting-document/accounting-document-history.js.map +1 -0
  104. package/dist-server/service/accounting-document/accounting-document-mutation.d.ts +10 -0
  105. package/dist-server/service/accounting-document/accounting-document-mutation.js +128 -0
  106. package/dist-server/service/accounting-document/accounting-document-mutation.js.map +1 -0
  107. package/dist-server/service/accounting-document/accounting-document-query.d.ts +11 -0
  108. package/dist-server/service/accounting-document/accounting-document-query.js +79 -0
  109. package/dist-server/service/accounting-document/accounting-document-query.js.map +1 -0
  110. package/dist-server/service/accounting-document/accounting-document-type.d.ts +20 -0
  111. package/dist-server/service/accounting-document/accounting-document-type.js +74 -0
  112. package/dist-server/service/accounting-document/accounting-document-type.js.map +1 -0
  113. package/dist-server/service/accounting-document/accounting-document.d.ts +21 -0
  114. package/dist-server/service/accounting-document/accounting-document.js +104 -0
  115. package/dist-server/service/accounting-document/accounting-document.js.map +1 -0
  116. package/dist-server/service/accounting-document/event-subscriber.d.ts +7 -0
  117. package/dist-server/service/accounting-document/event-subscriber.js +21 -0
  118. package/dist-server/service/accounting-document/event-subscriber.js.map +1 -0
  119. package/dist-server/service/accounting-document/index.d.ts +7 -0
  120. package/dist-server/service/accounting-document/index.js +12 -0
  121. package/dist-server/service/accounting-document/index.js.map +1 -0
  122. package/dist-server/service/financial-statement/financial-statement-history.d.ts +9 -6
  123. package/dist-server/service/financial-statement/financial-statement-history.js +30 -20
  124. package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
  125. package/dist-server/service/financial-statement/financial-statement-line-item.d.ts +19 -0
  126. package/dist-server/service/financial-statement/financial-statement-line-item.js +94 -0
  127. package/dist-server/service/financial-statement/financial-statement-line-item.js.map +1 -0
  128. package/dist-server/service/financial-statement/financial-statement-mutation.js +12 -8
  129. package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -1
  130. package/dist-server/service/financial-statement/financial-statement-query.js +2 -0
  131. package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
  132. package/dist-server/service/financial-statement/financial-statement.d.ts +2 -0
  133. package/dist-server/service/financial-statement/financial-statement.js +45 -24
  134. package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
  135. package/dist-server/service/financial-statement/index.d.ts +2 -2
  136. package/dist-server/service/financial-statement/index.js +2 -1
  137. package/dist-server/service/financial-statement/index.js.map +1 -1
  138. package/dist-server/service/fiscal-month/fiscal-month-mutation.js +6 -0
  139. package/dist-server/service/fiscal-month/fiscal-month-mutation.js.map +1 -1
  140. package/dist-server/service/fiscal-month/fiscal-month-query.js +2 -0
  141. package/dist-server/service/fiscal-month/fiscal-month-query.js.map +1 -1
  142. package/dist-server/service/fiscal-month/fiscal-month.js +1 -1
  143. package/dist-server/service/fiscal-month/fiscal-month.js.map +1 -1
  144. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.js +6 -0
  145. package/dist-server/service/fiscal-quarter/fiscal-quarter-mutation.js.map +1 -1
  146. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.js +2 -0
  147. package/dist-server/service/fiscal-quarter/fiscal-quarter-query.js.map +1 -1
  148. package/dist-server/service/fiscal-quarter/fiscal-quarter.js +1 -1
  149. package/dist-server/service/fiscal-quarter/fiscal-quarter.js.map +1 -1
  150. package/dist-server/service/fiscal-year/fiscal-year-mutation.js +6 -0
  151. package/dist-server/service/fiscal-year/fiscal-year-mutation.js.map +1 -1
  152. package/dist-server/service/fiscal-year/fiscal-year-query.js +2 -0
  153. package/dist-server/service/fiscal-year/fiscal-year-query.js.map +1 -1
  154. package/dist-server/service/fiscal-year/fiscal-year.js +1 -1
  155. package/dist-server/service/fiscal-year/fiscal-year.js.map +1 -1
  156. package/dist-server/service/income-statement/income-statement-history.d.ts +9 -5
  157. package/dist-server/service/income-statement/income-statement-history.js +35 -20
  158. package/dist-server/service/income-statement/income-statement-history.js.map +1 -1
  159. package/dist-server/service/income-statement/income-statement-line-item.d.ts +19 -0
  160. package/dist-server/service/income-statement/income-statement-line-item.js +96 -0
  161. package/dist-server/service/income-statement/income-statement-line-item.js.map +1 -0
  162. package/dist-server/service/income-statement/income-statement-mutation.js +12 -8
  163. package/dist-server/service/income-statement/income-statement-mutation.js.map +1 -1
  164. package/dist-server/service/income-statement/income-statement-query.js +2 -0
  165. package/dist-server/service/income-statement/income-statement-query.js.map +1 -1
  166. package/dist-server/service/income-statement/income-statement.d.ts +2 -0
  167. package/dist-server/service/income-statement/income-statement.js +46 -26
  168. package/dist-server/service/income-statement/income-statement.js.map +1 -1
  169. package/dist-server/service/income-statement/index.d.ts +2 -2
  170. package/dist-server/service/income-statement/index.js +2 -1
  171. package/dist-server/service/income-statement/index.js.map +1 -1
  172. package/dist-server/service/index.d.ts +4 -2
  173. package/dist-server/service/index.js +10 -0
  174. package/dist-server/service/index.js.map +1 -1
  175. package/dist-server/service/payment/event-subscriber.d.ts +7 -0
  176. package/dist-server/service/payment/event-subscriber.js +21 -0
  177. package/dist-server/service/payment/event-subscriber.js.map +1 -0
  178. package/dist-server/service/payment/index.d.ts +8 -0
  179. package/dist-server/service/payment/index.js +12 -0
  180. package/dist-server/service/payment/index.js.map +1 -0
  181. package/dist-server/service/payment/payment-history.d.ts +30 -0
  182. package/dist-server/service/payment/payment-history.js +143 -0
  183. package/dist-server/service/payment/payment-history.js.map +1 -0
  184. package/dist-server/service/payment/payment-mutation.d.ts +10 -0
  185. package/dist-server/service/payment/payment-mutation.js +134 -0
  186. package/dist-server/service/payment/payment-mutation.js.map +1 -0
  187. package/dist-server/service/payment/payment-query.d.ts +11 -0
  188. package/dist-server/service/payment/payment-query.js +81 -0
  189. package/dist-server/service/payment/payment-query.js.map +1 -0
  190. package/dist-server/service/payment/payment-type.d.ts +24 -0
  191. package/dist-server/service/payment/payment-type.js +90 -0
  192. package/dist-server/service/payment/payment-type.js.map +1 -0
  193. package/dist-server/service/payment/payment.d.ts +30 -0
  194. package/dist-server/service/payment/payment.js +146 -0
  195. package/dist-server/service/payment/payment.js.map +1 -0
  196. package/dist-server/service/transaction/index.d.ts +2 -1
  197. package/dist-server/service/transaction/transaction-history.d.ts +6 -2
  198. package/dist-server/service/transaction/transaction-history.js +28 -9
  199. package/dist-server/service/transaction/transaction-history.js.map +1 -1
  200. package/dist-server/service/transaction/transaction-mutation.js +13 -9
  201. package/dist-server/service/transaction/transaction-mutation.js.map +1 -1
  202. package/dist-server/service/transaction/transaction-query.js +2 -0
  203. package/dist-server/service/transaction/transaction-query.js.map +1 -1
  204. package/dist-server/service/transaction/transaction.d.ts +28 -6
  205. package/dist-server/service/transaction/transaction.js +119 -31
  206. package/dist-server/service/transaction/transaction.js.map +1 -1
  207. package/dist-server/tsconfig.tsbuildinfo +1 -1
  208. package/helps/accounting/accounting-document.md +160 -0
  209. package/helps/accounting/contract.md +160 -0
  210. package/helps/accounting/payment.md +160 -0
  211. package/package.json +5 -5
  212. package/server/activities/activity-book.ts +31 -19
  213. package/server/controllers/summary-statements.ts +13 -7
  214. package/server/index.ts +1 -0
  215. package/server/migrations/1725200507196-seed-fiscal-entities.ts +3 -3
  216. package/server/migrations/1725201467183-seed-accounts.ts +31 -31
  217. package/server/routes.ts +0 -2
  218. package/server/service/account/account-history.ts +14 -6
  219. package/server/service/account/account-mutation.ts +13 -10
  220. package/server/service/account/account-query.ts +2 -0
  221. package/server/service/account/account.ts +15 -4
  222. package/server/service/accounting-category/accounting-category-history.ts +123 -0
  223. package/server/service/accounting-category/accounting-category-mutation.ts +12 -9
  224. package/server/service/accounting-category/accounting-category-query.ts +23 -0
  225. package/server/service/accounting-category/accounting-category.ts +14 -3
  226. package/server/service/accounting-category/event-subscriber.ts +20 -0
  227. package/server/service/accounting-category/index.ts +4 -2
  228. package/server/service/accounting-document/accounting-document-history.ts +117 -0
  229. package/server/service/accounting-document/accounting-document-mutation.ts +137 -0
  230. package/server/service/accounting-document/accounting-document-query.ts +48 -0
  231. package/server/service/accounting-document/accounting-document-type.ts +52 -0
  232. package/server/service/accounting-document/accounting-document.ts +93 -0
  233. package/server/service/accounting-document/event-subscriber.ts +17 -0
  234. package/server/service/accounting-document/index.ts +9 -0
  235. package/server/service/financial-statement/financial-statement-history.ts +27 -18
  236. package/server/service/financial-statement/financial-statement-line-item.ts +82 -0
  237. package/server/service/financial-statement/financial-statement-mutation.ts +12 -9
  238. package/server/service/financial-statement/financial-statement-query.ts +2 -0
  239. package/server/service/financial-statement/financial-statement.ts +52 -36
  240. package/server/service/financial-statement/index.ts +2 -1
  241. package/server/service/fiscal-month/fiscal-month-mutation.ts +10 -2
  242. package/server/service/fiscal-month/fiscal-month-query.ts +3 -1
  243. package/server/service/fiscal-month/fiscal-month.ts +1 -1
  244. package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +14 -3
  245. package/server/service/fiscal-quarter/fiscal-quarter-query.ts +2 -0
  246. package/server/service/fiscal-quarter/fiscal-quarter.ts +1 -1
  247. package/server/service/fiscal-year/fiscal-year-mutation.ts +10 -2
  248. package/server/service/fiscal-year/fiscal-year-query.ts +2 -0
  249. package/server/service/fiscal-year/fiscal-year.ts +1 -1
  250. package/server/service/income-statement/income-statement-history.ts +30 -17
  251. package/server/service/income-statement/income-statement-line-item.ts +84 -0
  252. package/server/service/income-statement/income-statement-mutation.ts +12 -10
  253. package/server/service/income-statement/income-statement-query.ts +2 -0
  254. package/server/service/income-statement/income-statement.ts +54 -39
  255. package/server/service/income-statement/index.ts +2 -1
  256. package/server/service/index.ts +18 -0
  257. package/server/service/payment/event-subscriber.ts +17 -0
  258. package/server/service/payment/index.ts +9 -0
  259. package/server/service/payment/payment-history.ts +126 -0
  260. package/server/service/payment/payment-mutation.ts +139 -0
  261. package/server/service/payment/payment-query.ts +50 -0
  262. package/server/service/payment/payment-type.ts +64 -0
  263. package/server/service/payment/payment.ts +123 -0
  264. package/server/service/transaction/transaction-history.ts +24 -8
  265. package/server/service/transaction/transaction-mutation.ts +13 -10
  266. package/server/service/transaction/transaction-query.ts +2 -0
  267. package/server/service/transaction/transaction.ts +130 -34
  268. package/things-factory.config.js +0 -1
  269. package/translations/en.json +9 -1
  270. package/translations/ja.json +9 -1
  271. package/translations/ko.json +9 -1
  272. package/translations/ms.json +9 -1
  273. package/translations/zh.json +9 -1
  274. package/client/pages/main.ts +0 -24
  275. package/dist-client/pages/ledger/ledger-importer.js.map +0 -1
  276. package/dist-client/pages/ledger/ledger-list-page.js.map +0 -1
  277. package/dist-client/pages/main.d.ts +0 -1
  278. package/dist-client/pages/main.js +0 -27
  279. package/dist-client/pages/main.js.map +0 -1
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentHistory = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const typeorm_history_1 = require("@operato/typeorm-history");
8
+ const auth_base_1 = require("@things-factory/auth-base");
9
+ const env_1 = require("@things-factory/env");
10
+ const shell_1 = require("@things-factory/shell");
11
+ const transaction_1 = require("../transaction/transaction");
12
+ const payment_1 = require("./payment");
13
+ const ORMCONFIG = env_1.config.get('ormconfig', {});
14
+ const DATABASE_TYPE = ORMCONFIG.type;
15
+ let PaymentHistory = class PaymentHistory {
16
+ constructor() {
17
+ this.version = 1;
18
+ }
19
+ };
20
+ exports.PaymentHistory = PaymentHistory;
21
+ tslib_1.__decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
23
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
24
+ tslib_1.__metadata("design:type", String)
25
+ ], PaymentHistory.prototype, "id", void 0);
26
+ tslib_1.__decorate([
27
+ (0, typeorm_1.Column)({ nullable: true, default: 1 }),
28
+ (0, type_graphql_1.Field)({ nullable: true }),
29
+ tslib_1.__metadata("design:type", Number)
30
+ ], PaymentHistory.prototype, "version", void 0);
31
+ tslib_1.__decorate([
32
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
33
+ (0, type_graphql_1.Field)({ nullable: true }),
34
+ tslib_1.__metadata("design:type", shell_1.Domain)
35
+ ], PaymentHistory.prototype, "domain", void 0);
36
+ tslib_1.__decorate([
37
+ (0, typeorm_1.RelationId)((payment) => payment.domain),
38
+ tslib_1.__metadata("design:type", String)
39
+ ], PaymentHistory.prototype, "domainId", void 0);
40
+ tslib_1.__decorate([
41
+ (0, typeorm_1.ManyToOne)(type => transaction_1.Transaction, transaction => transaction.payments),
42
+ (0, type_graphql_1.Field)(type => transaction_1.Transaction),
43
+ tslib_1.__metadata("design:type", transaction_1.Transaction)
44
+ ], PaymentHistory.prototype, "transaction", void 0);
45
+ tslib_1.__decorate([
46
+ (0, typeorm_1.RelationId)((payment) => payment.transaction),
47
+ tslib_1.__metadata("design:type", String)
48
+ ], PaymentHistory.prototype, "transactionId", void 0);
49
+ tslib_1.__decorate([
50
+ (0, typeorm_1.Column)({ nullable: false }),
51
+ (0, type_graphql_1.Field)({ nullable: false }),
52
+ tslib_1.__metadata("design:type", Number)
53
+ ], PaymentHistory.prototype, "amount", void 0);
54
+ tslib_1.__decorate([
55
+ (0, typeorm_1.Column)({ nullable: true }),
56
+ (0, type_graphql_1.Field)({ nullable: true, description: 'fiscal year' }),
57
+ tslib_1.__metadata("design:type", Number)
58
+ ], PaymentHistory.prototype, "year", void 0);
59
+ tslib_1.__decorate([
60
+ (0, typeorm_1.Column)({ nullable: true }),
61
+ (0, type_graphql_1.Field)({ nullable: true, description: 'fiscal quarter' }),
62
+ tslib_1.__metadata("design:type", Number)
63
+ ], PaymentHistory.prototype, "quarter", void 0);
64
+ tslib_1.__decorate([
65
+ (0, typeorm_1.Column)({ nullable: true }),
66
+ (0, type_graphql_1.Field)({ nullable: true, description: 'fiscal month' }),
67
+ tslib_1.__metadata("design:type", Number)
68
+ ], PaymentHistory.prototype, "month", void 0);
69
+ tslib_1.__decorate([
70
+ (0, typeorm_1.Column)({ nullable: false }),
71
+ (0, type_graphql_1.Field)({ nullable: false }),
72
+ tslib_1.__metadata("design:type", Date)
73
+ ], PaymentHistory.prototype, "paidAt", void 0);
74
+ tslib_1.__decorate([
75
+ (0, typeorm_1.Column)({ nullable: false }),
76
+ (0, type_graphql_1.Field)(type => payment_1.PaymentDirection),
77
+ tslib_1.__metadata("design:type", String)
78
+ ], PaymentHistory.prototype, "direction", void 0);
79
+ tslib_1.__decorate([
80
+ (0, typeorm_1.Column)({ nullable: true }),
81
+ (0, type_graphql_1.Field)({ nullable: true }),
82
+ tslib_1.__metadata("design:type", String)
83
+ ], PaymentHistory.prototype, "note", void 0);
84
+ tslib_1.__decorate([
85
+ (0, typeorm_1.Column)({ nullable: true }),
86
+ (0, type_graphql_1.Field)({ nullable: true }),
87
+ tslib_1.__metadata("design:type", Date)
88
+ ], PaymentHistory.prototype, "createdAt", void 0);
89
+ tslib_1.__decorate([
90
+ (0, typeorm_1.Column)({ nullable: true }),
91
+ (0, type_graphql_1.Field)({ nullable: true }),
92
+ tslib_1.__metadata("design:type", Date)
93
+ ], PaymentHistory.prototype, "updatedAt", void 0);
94
+ tslib_1.__decorate([
95
+ (0, typeorm_1.Column)({ nullable: true }),
96
+ (0, type_graphql_1.Field)({ nullable: true }),
97
+ tslib_1.__metadata("design:type", Date)
98
+ ], PaymentHistory.prototype, "deletedAt", void 0);
99
+ tslib_1.__decorate([
100
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
101
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
102
+ tslib_1.__metadata("design:type", auth_base_1.User)
103
+ ], PaymentHistory.prototype, "creator", void 0);
104
+ tslib_1.__decorate([
105
+ (0, typeorm_1.RelationId)((payment) => payment.creator),
106
+ tslib_1.__metadata("design:type", String)
107
+ ], PaymentHistory.prototype, "creatorId", void 0);
108
+ tslib_1.__decorate([
109
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
110
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
111
+ tslib_1.__metadata("design:type", auth_base_1.User)
112
+ ], PaymentHistory.prototype, "updater", void 0);
113
+ tslib_1.__decorate([
114
+ (0, typeorm_1.RelationId)((payment) => payment.updater),
115
+ tslib_1.__metadata("design:type", String)
116
+ ], PaymentHistory.prototype, "updaterId", void 0);
117
+ tslib_1.__decorate([
118
+ (0, type_graphql_1.Field)(type => String, { nullable: true }),
119
+ tslib_1.__metadata("design:type", String)
120
+ ], PaymentHistory.prototype, "thumbnail", void 0);
121
+ tslib_1.__decorate([
122
+ (0, typeorm_history_1.HistoryOriginalIdColumn)(),
123
+ tslib_1.__metadata("design:type", String)
124
+ ], PaymentHistory.prototype, "originalId", void 0);
125
+ tslib_1.__decorate([
126
+ (0, typeorm_history_1.HistoryActionColumn)({
127
+ nullable: false,
128
+ type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
129
+ ? 'enum'
130
+ : DATABASE_TYPE == 'oracle'
131
+ ? 'varchar2'
132
+ : 'smallint',
133
+ enum: typeorm_history_1.HistoryActionType
134
+ }),
135
+ tslib_1.__metadata("design:type", String)
136
+ ], PaymentHistory.prototype, "action", void 0);
137
+ exports.PaymentHistory = PaymentHistory = tslib_1.__decorate([
138
+ (0, typeorm_1.Entity)(),
139
+ (0, typeorm_1.Index)('ix_payment_history_0', (paymentHistory) => [paymentHistory.originalId, paymentHistory.version], { unique: true }),
140
+ (0, typeorm_1.Index)('ix_payment_history_1', (paymentHistory) => [paymentHistory.domain, paymentHistory.originalId, paymentHistory.version], { unique: true }),
141
+ (0, type_graphql_1.ObjectType)({ description: 'History Entity of Payment' })
142
+ ], PaymentHistory);
143
+ //# sourceMappingURL=payment-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-history.js","sourceRoot":"","sources":["../../../server/service/payment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AAC,MAAM;YACR,CAAC,CAAC,aAAa,IAAI,QAAQ;gBACzB,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU;QAClB,IAAI,EAAE,mCAAiB;KACxB,CAAC;;8CAC+B;yBA7FtB,cAAc;IAZ1B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,EACvF,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,EAC9G,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;GAC5C,cAAc,CA8F1B","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { Role, User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { Transaction } from '../transaction/transaction'\nimport { Payment, PaymentDirection } from './payment'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_payment_history_0',\n (paymentHistory: PaymentHistory) => [paymentHistory.originalId, paymentHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_payment_history_1',\n (paymentHistory: PaymentHistory) => [paymentHistory.domain, paymentHistory.originalId, paymentHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Payment' })\nexport class PaymentHistory implements HistoryEntityInterface<Payment> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((payment: Payment) => payment.domain)\n domainId?: string\n\n @ManyToOne(type => Transaction, transaction => transaction.payments)\n @Field(type => Transaction)\n transaction: Transaction\n\n @RelationId((payment: Payment) => payment.transaction)\n transactionId: string\n\n @Column({ nullable: false })\n @Field({ nullable: false })\n amount: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'fiscal year' })\n year?: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'fiscal quarter' })\n quarter?: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'fiscal month' })\n month?: number\n\n @Column({ nullable: false })\n @Field({ nullable: false })\n paidAt: Date\n\n @Column({ nullable: false })\n @Field(type => PaymentDirection)\n direction: PaymentDirection\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n note?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\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((payment: Payment) => payment.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((payment: Payment) => payment.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n thumbnail?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: HistoryActionType\n })\n public action!: HistoryActionType\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { Payment } from './payment';
2
+ import { NewPayment, PaymentPatch } from './payment-type';
3
+ export declare class PaymentMutation {
4
+ createPayment(payment: NewPayment, context: ResolverContext): Promise<Payment>;
5
+ updatePayment(id: string, patch: PaymentPatch, context: ResolverContext): Promise<Payment>;
6
+ updateMultiplePayment(patches: PaymentPatch[], context: ResolverContext): Promise<Payment[]>;
7
+ deletePayment(id: string, context: ResolverContext): Promise<boolean>;
8
+ deletePayments(ids: string[], context: ResolverContext): Promise<boolean>;
9
+ importPayments(payments: PaymentPatch[], context: ResolverContext): Promise<boolean>;
10
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const payment_1 = require("./payment");
9
+ const payment_type_1 = require("./payment-type");
10
+ let PaymentMutation = class PaymentMutation {
11
+ async createPayment(payment, context) {
12
+ const { domain, user, tx } = context.state;
13
+ const result = await (0, shell_1.getRepository)(payment_1.Payment, tx).save(Object.assign(Object.assign({}, payment), { domain, creator: user, updater: user }));
14
+ return result;
15
+ }
16
+ async updatePayment(id, patch, context) {
17
+ const { domain, user, tx } = context.state;
18
+ const repository = (0, shell_1.getRepository)(payment_1.Payment, tx);
19
+ const payment = await repository.findOne({
20
+ where: { domain: { id: domain.id }, id }
21
+ });
22
+ const result = await repository.save(Object.assign(Object.assign(Object.assign({}, payment), patch), { updater: user }));
23
+ return result;
24
+ }
25
+ async updateMultiplePayment(patches, context) {
26
+ const { domain, user, tx } = context.state;
27
+ let results = [];
28
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
29
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
30
+ const paymentRepo = (0, shell_1.getRepository)(payment_1.Payment, tx);
31
+ if (_createRecords.length > 0) {
32
+ for (let i = 0; i < _createRecords.length; i++) {
33
+ const newRecord = _createRecords[i];
34
+ const result = await paymentRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
35
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
36
+ }
37
+ }
38
+ if (_updateRecords.length > 0) {
39
+ for (let i = 0; i < _updateRecords.length; i++) {
40
+ const updateRecord = _updateRecords[i];
41
+ const payment = await paymentRepo.findOneBy({ id: updateRecord.id });
42
+ const result = await paymentRepo.save(Object.assign(Object.assign(Object.assign({}, payment), updateRecord), { updater: user }));
43
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
44
+ }
45
+ }
46
+ return results;
47
+ }
48
+ async deletePayment(id, context) {
49
+ const { domain, tx } = context.state;
50
+ await (0, shell_1.getRepository)(payment_1.Payment, tx).delete({ domain: { id: domain.id }, id });
51
+ return true;
52
+ }
53
+ async deletePayments(ids, context) {
54
+ const { domain, tx } = context.state;
55
+ await (0, shell_1.getRepository)(payment_1.Payment, tx).delete({
56
+ domain: { id: domain.id },
57
+ id: (0, typeorm_1.In)(ids)
58
+ });
59
+ return true;
60
+ }
61
+ async importPayments(payments, context) {
62
+ const { domain, tx } = context.state;
63
+ await Promise.all(payments.map(async (payment) => {
64
+ const createdPayment = await (0, shell_1.getRepository)(payment_1.Payment, tx).save(Object.assign({ domain }, payment));
65
+ }));
66
+ return true;
67
+ }
68
+ };
69
+ exports.PaymentMutation = PaymentMutation;
70
+ tslib_1.__decorate([
71
+ (0, type_graphql_1.Directive)('@transaction'),
72
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
73
+ (0, type_graphql_1.Mutation)(returns => payment_1.Payment, { description: 'To create new Payment' }),
74
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('payment')),
75
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
76
+ tslib_1.__metadata("design:type", Function),
77
+ tslib_1.__metadata("design:paramtypes", [payment_type_1.NewPayment, Object]),
78
+ tslib_1.__metadata("design:returntype", Promise)
79
+ ], PaymentMutation.prototype, "createPayment", null);
80
+ tslib_1.__decorate([
81
+ (0, type_graphql_1.Directive)('@transaction'),
82
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
83
+ (0, type_graphql_1.Mutation)(returns => payment_1.Payment, { description: 'To modify Payment information' }),
84
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
85
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
86
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
87
+ tslib_1.__metadata("design:type", Function),
88
+ tslib_1.__metadata("design:paramtypes", [String, payment_type_1.PaymentPatch, Object]),
89
+ tslib_1.__metadata("design:returntype", Promise)
90
+ ], PaymentMutation.prototype, "updatePayment", null);
91
+ tslib_1.__decorate([
92
+ (0, type_graphql_1.Directive)('@transaction'),
93
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
94
+ (0, type_graphql_1.Mutation)(returns => [payment_1.Payment], { description: "To modify multiple Payments' information" }),
95
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [payment_type_1.PaymentPatch])),
96
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
97
+ tslib_1.__metadata("design:type", Function),
98
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
99
+ tslib_1.__metadata("design:returntype", Promise)
100
+ ], PaymentMutation.prototype, "updateMultiplePayment", null);
101
+ tslib_1.__decorate([
102
+ (0, type_graphql_1.Directive)('@transaction'),
103
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
104
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Payment' }),
105
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
106
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
107
+ tslib_1.__metadata("design:type", Function),
108
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
109
+ tslib_1.__metadata("design:returntype", Promise)
110
+ ], PaymentMutation.prototype, "deletePayment", null);
111
+ tslib_1.__decorate([
112
+ (0, type_graphql_1.Directive)('@transaction'),
113
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
114
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Payments' }),
115
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
116
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
117
+ tslib_1.__metadata("design:type", Function),
118
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
119
+ tslib_1.__metadata("design:returntype", Promise)
120
+ ], PaymentMutation.prototype, "deletePayments", null);
121
+ tslib_1.__decorate([
122
+ (0, type_graphql_1.Directive)('@transaction'),
123
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation")'),
124
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Payments' }),
125
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('payments', type => [payment_type_1.PaymentPatch])),
126
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
127
+ tslib_1.__metadata("design:type", Function),
128
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
129
+ tslib_1.__metadata("design:returntype", Promise)
130
+ ], PaymentMutation.prototype, "importPayments", null);
131
+ exports.PaymentMutation = PaymentMutation = tslib_1.__decorate([
132
+ (0, type_graphql_1.Resolver)(payment_1.Payment)
133
+ ], PaymentMutation);
134
+ //# sourceMappingURL=payment-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-mutation.js","sourceRoot":"","sources":["../../../server/service/payment/payment-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,uCAAmC;AACnC,iDAAyD;AAGlD,IAAM,eAAe,GAArB,MAAM,eAAe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2D,CAAC;IACtE,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDASvE;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,6BAA6B,EAAE,CAAC;IAE1E,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,2BAAY,CAAC,CAAC,CAAA;IACvC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDAWP;0BAjIU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CAkI3B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { Payment } from './payment'\nimport { NewPayment, PaymentPatch } from './payment-type'\n\n@Resolver(Payment)\nexport class PaymentMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\")')\n @Mutation(returns => Payment, { description: 'To create new Payment' })\n async createPayment(@Arg('payment') payment: NewPayment, @Ctx() context: ResolverContext): Promise<Payment> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(Payment, tx).save({\n ...payment,\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 => Payment, { description: 'To modify Payment information' })\n async updatePayment(\n @Arg('id') id: string,\n @Arg('patch') patch: PaymentPatch,\n @Ctx() context: ResolverContext\n ): Promise<Payment> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(Payment, tx)\n const payment = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...payment,\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 => [Payment], { description: \"To modify multiple Payments' information\" })\n async updateMultiplePayment(\n @Arg('patches', type => [PaymentPatch]) patches: PaymentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Payment[]> {\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 paymentRepo = getRepository(Payment, 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 paymentRepo.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 payment = await paymentRepo.findOneBy({ id: updateRecord.id })\n\n const result = await paymentRepo.save({\n ...payment,\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 Payment' })\n async deletePayment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Payment, 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 Payments' })\n async deletePayments(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Payment, 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 Payments' })\n async importPayments(\n @Arg('payments', type => [PaymentPatch]) payments: PaymentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n payments.map(async (payment: PaymentPatch) => {\n const createdPayment: Payment = await getRepository(Payment, tx).save({ domain, ...payment })\n })\n )\n\n return true\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { Domain, ListParam } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Payment } from './payment';
4
+ import { PaymentList } from './payment-type';
5
+ export declare class PaymentQuery {
6
+ payment(id: string, context: ResolverContext): Promise<Payment>;
7
+ payments(params: ListParam, context: ResolverContext): Promise<PaymentList>;
8
+ domain(payment: Payment): Promise<Domain>;
9
+ updater(payment: Payment): Promise<User>;
10
+ creator(payment: Payment): Promise<User>;
11
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentQuery = 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 payment_1 = require("./payment");
9
+ const payment_type_1 = require("./payment-type");
10
+ let PaymentQuery = class PaymentQuery {
11
+ async payment(id, context) {
12
+ const { domain } = context.state;
13
+ return await (0, shell_1.getRepository)(payment_1.Payment).findOne({
14
+ where: { domain: { id: domain.id }, id }
15
+ });
16
+ }
17
+ async payments(params, context) {
18
+ const { domain } = context.state;
19
+ const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
20
+ domain,
21
+ params,
22
+ repository: await (0, shell_1.getRepository)(payment_1.Payment),
23
+ searchables: []
24
+ });
25
+ const [items, total] = await queryBuilder.getManyAndCount();
26
+ return { items, total };
27
+ }
28
+ async domain(payment) {
29
+ return payment.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: payment.domainId }));
30
+ }
31
+ async updater(payment) {
32
+ return payment.updaterId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: payment.updaterId }));
33
+ }
34
+ async creator(payment) {
35
+ return payment.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: payment.creatorId }));
36
+ }
37
+ };
38
+ exports.PaymentQuery = PaymentQuery;
39
+ tslib_1.__decorate([
40
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query")'),
41
+ (0, type_graphql_1.Query)(returns => payment_1.Payment, { nullable: true, description: 'To fetch a Payment' }),
42
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
43
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
44
+ tslib_1.__metadata("design:type", Function),
45
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
46
+ tslib_1.__metadata("design:returntype", Promise)
47
+ ], PaymentQuery.prototype, "payment", null);
48
+ tslib_1.__decorate([
49
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query")'),
50
+ (0, type_graphql_1.Query)(returns => payment_type_1.PaymentList, { description: 'To fetch multiple Payments' }),
51
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
52
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
53
+ tslib_1.__metadata("design:type", Function),
54
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
55
+ tslib_1.__metadata("design:returntype", Promise)
56
+ ], PaymentQuery.prototype, "payments", null);
57
+ tslib_1.__decorate([
58
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
59
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
60
+ tslib_1.__metadata("design:type", Function),
61
+ tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
62
+ tslib_1.__metadata("design:returntype", Promise)
63
+ ], PaymentQuery.prototype, "domain", null);
64
+ tslib_1.__decorate([
65
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
66
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
67
+ tslib_1.__metadata("design:type", Function),
68
+ tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
69
+ tslib_1.__metadata("design:returntype", Promise)
70
+ ], PaymentQuery.prototype, "updater", null);
71
+ tslib_1.__decorate([
72
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
73
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
74
+ tslib_1.__metadata("design:type", Function),
75
+ tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
76
+ tslib_1.__metadata("design:returntype", Promise)
77
+ ], PaymentQuery.prototype, "creator", null);
78
+ exports.PaymentQuery = PaymentQuery = tslib_1.__decorate([
79
+ (0, type_graphql_1.Resolver)(payment_1.Payment)
80
+ ], PaymentQuery);
81
+ //# sourceMappingURL=payment-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-query.js","sourceRoot":"","sources":["../../../server/service/payment/payment-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,iDAAuG;AACvG,yDAAgD;AAChD,uCAAmC;AACnC,iDAA4C;AAGrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGjB,AAAN,KAAK,CAAC,OAAO,CAAY,EAAU,EAAS,OAAwB;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAIK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I,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACnE,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2CAM1C;AAIK;IAFL,IAAA,wBAAS,EAAC,wDAAwD,CAAC;IACnE,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,0BAAW,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IAC7D,mBAAA,IAAA,mBAAI,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;4CAaxD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;uBAzCU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CA0CxB","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 { Payment } from './payment'\nimport { PaymentList } from './payment-type'\n\n@Resolver(Payment)\nexport class PaymentQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\")')\n @Query(returns => Payment!, { nullable: true, description: 'To fetch a Payment' })\n async payment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Payment> {\n const { domain } = context.state\n\n return await getRepository(Payment).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\")')\n @Query(returns => PaymentList, { description: 'To fetch multiple Payments' })\n async payments(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<PaymentList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Payment),\n searchables: []\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() payment: Payment): Promise<Domain> {\n return payment.domainId && (await getRepository(Domain).findOneBy({ id: payment.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() payment: Payment): Promise<User> {\n return payment.updaterId && (await getRepository(User).findOneBy({ id: payment.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() payment: Payment): Promise<User> {\n return payment.creatorId && (await getRepository(User).findOneBy({ id: payment.creatorId }))\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { ObjectRef } from '@things-factory/shell';
2
+ import { Payment, PaymentDirection } from './payment';
3
+ export declare class NewPayment {
4
+ transaction: ObjectRef;
5
+ currency?: string;
6
+ amount: number;
7
+ paidAt: Date;
8
+ direction: PaymentDirection;
9
+ note?: string;
10
+ }
11
+ export declare class PaymentPatch {
12
+ id?: string;
13
+ transaction: ObjectRef;
14
+ currency?: string;
15
+ amount: number;
16
+ paidAt: Date;
17
+ direction: PaymentDirection;
18
+ note?: string;
19
+ cuFlag?: string;
20
+ }
21
+ export declare class PaymentList {
22
+ items: Payment[];
23
+ total: number;
24
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentList = exports.PaymentPatch = exports.NewPayment = 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 payment_1 = require("./payment");
8
+ let NewPayment = class NewPayment {
9
+ };
10
+ exports.NewPayment = NewPayment;
11
+ tslib_1.__decorate([
12
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef),
13
+ tslib_1.__metadata("design:type", shell_1.ObjectRef)
14
+ ], NewPayment.prototype, "transaction", void 0);
15
+ tslib_1.__decorate([
16
+ (0, type_graphql_1.Field)({ nullable: true }),
17
+ tslib_1.__metadata("design:type", String)
18
+ ], NewPayment.prototype, "currency", void 0);
19
+ tslib_1.__decorate([
20
+ (0, type_graphql_1.Field)({ nullable: false }),
21
+ tslib_1.__metadata("design:type", Number)
22
+ ], NewPayment.prototype, "amount", void 0);
23
+ tslib_1.__decorate([
24
+ (0, type_graphql_1.Field)({ nullable: false }),
25
+ tslib_1.__metadata("design:type", Date)
26
+ ], NewPayment.prototype, "paidAt", void 0);
27
+ tslib_1.__decorate([
28
+ (0, type_graphql_1.Field)(type => payment_1.PaymentDirection),
29
+ tslib_1.__metadata("design:type", String)
30
+ ], NewPayment.prototype, "direction", void 0);
31
+ tslib_1.__decorate([
32
+ (0, type_graphql_1.Field)({ nullable: true }),
33
+ tslib_1.__metadata("design:type", String)
34
+ ], NewPayment.prototype, "note", void 0);
35
+ exports.NewPayment = NewPayment = tslib_1.__decorate([
36
+ (0, type_graphql_1.InputType)()
37
+ ], NewPayment);
38
+ let PaymentPatch = class PaymentPatch {
39
+ };
40
+ exports.PaymentPatch = PaymentPatch;
41
+ tslib_1.__decorate([
42
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
43
+ tslib_1.__metadata("design:type", String)
44
+ ], PaymentPatch.prototype, "id", void 0);
45
+ tslib_1.__decorate([
46
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef),
47
+ tslib_1.__metadata("design:type", shell_1.ObjectRef)
48
+ ], PaymentPatch.prototype, "transaction", void 0);
49
+ tslib_1.__decorate([
50
+ (0, type_graphql_1.Field)({ nullable: true }),
51
+ tslib_1.__metadata("design:type", String)
52
+ ], PaymentPatch.prototype, "currency", void 0);
53
+ tslib_1.__decorate([
54
+ (0, type_graphql_1.Field)({ nullable: false }),
55
+ tslib_1.__metadata("design:type", Number)
56
+ ], PaymentPatch.prototype, "amount", void 0);
57
+ tslib_1.__decorate([
58
+ (0, type_graphql_1.Field)({ nullable: false }),
59
+ tslib_1.__metadata("design:type", Date)
60
+ ], PaymentPatch.prototype, "paidAt", void 0);
61
+ tslib_1.__decorate([
62
+ (0, type_graphql_1.Field)(type => payment_1.PaymentDirection),
63
+ tslib_1.__metadata("design:type", String)
64
+ ], PaymentPatch.prototype, "direction", void 0);
65
+ tslib_1.__decorate([
66
+ (0, type_graphql_1.Field)({ nullable: true }),
67
+ tslib_1.__metadata("design:type", String)
68
+ ], PaymentPatch.prototype, "note", void 0);
69
+ tslib_1.__decorate([
70
+ (0, type_graphql_1.Field)({ nullable: true }),
71
+ tslib_1.__metadata("design:type", String)
72
+ ], PaymentPatch.prototype, "cuFlag", void 0);
73
+ exports.PaymentPatch = PaymentPatch = tslib_1.__decorate([
74
+ (0, type_graphql_1.InputType)()
75
+ ], PaymentPatch);
76
+ let PaymentList = class PaymentList {
77
+ };
78
+ exports.PaymentList = PaymentList;
79
+ tslib_1.__decorate([
80
+ (0, type_graphql_1.Field)(type => [payment_1.Payment]),
81
+ tslib_1.__metadata("design:type", Array)
82
+ ], PaymentList.prototype, "items", void 0);
83
+ tslib_1.__decorate([
84
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
85
+ tslib_1.__metadata("design:type", Number)
86
+ ], PaymentList.prototype, "total", void 0);
87
+ exports.PaymentList = PaymentList = tslib_1.__decorate([
88
+ (0, type_graphql_1.ObjectType)()
89
+ ], PaymentList);
90
+ //# sourceMappingURL=payment-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-type.js","sourceRoot":"","sources":["../../../server/service/payment/payment-type.ts"],"names":[],"mappings":";;;;AAEA,+CAAsF;AAEtF,iDAA+D;AAE/D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AC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACX;uBAvBJ,YAAY;IADxB,IAAA,wBAAS,GAAE;GACC,YAAY,CAwBxB;AAGM,IAAM,WAAW,GAAjB,MAAM,WAAW;CAMvB,CAAA;AANY,kCAAW;AAEtB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAO,CAAC,CAAC;;0CACT;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;0CACN;sBALF,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAMvB","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Payment, PaymentDirection } from './payment'\n\n@InputType()\nexport class NewPayment {\n @Field(type => ObjectRef)\n transaction: ObjectRef\n\n @Field({ nullable: true })\n currency?: string\n\n @Field({ nullable: false })\n amount: number\n\n @Field({ nullable: false })\n paidAt: Date\n\n @Field(type => PaymentDirection)\n direction: PaymentDirection\n\n @Field({ nullable: true })\n note?: string\n}\n\n@InputType()\nexport class PaymentPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field(type => ObjectRef)\n transaction: ObjectRef\n\n @Field({ nullable: true })\n currency?: string\n\n @Field({ nullable: false })\n amount: number\n\n @Field({ nullable: false })\n paidAt: Date\n\n @Field(type => PaymentDirection)\n direction: PaymentDirection\n\n @Field({ nullable: true })\n note?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class PaymentList {\n @Field(type => [Payment])\n items: Payment[]\n\n @Field(type => Int)\n total: number\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import { Domain } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Transaction } from '../transaction/transaction';
4
+ export declare enum PaymentDirection {
5
+ Incoming = "Incoming",// 수금
6
+ Outgoing = "Outgoing"
7
+ }
8
+ export declare class Payment {
9
+ readonly id: string;
10
+ version?: number;
11
+ domain?: Domain;
12
+ domainId?: string;
13
+ transaction: Transaction;
14
+ transactionId: string;
15
+ currency?: string;
16
+ amount: number;
17
+ year?: number;
18
+ quarter?: number;
19
+ month?: number;
20
+ paidAt: Date;
21
+ direction: PaymentDirection;
22
+ note?: string;
23
+ createdAt?: Date;
24
+ updatedAt?: Date;
25
+ deletedAt?: Date;
26
+ creator?: User;
27
+ creatorId?: string;
28
+ updater?: User;
29
+ updaterId?: string;
30
+ }