@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
@@ -1 +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;IAIpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,iBAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YACnD,GAAG,OAAO;YACV,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,aAAa,CACN,EAAU,EACP,KAAmB,EAC1B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,iBAAO,EAAE,EAAE,CAAC,CAAA;QAC7C,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACvC,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,OAAO;YACV,GAAG,KAAK;YACR,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC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,CAAA;;;;qDAWP;0BAvIU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CAwI3B","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.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!payment) {\n throw new Error(`failed to find payment to update: ${updateRecord.id}`)\n }\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"]}
1
+ {"version":3,"file":"payment-mutation.js","sourceRoot":"","sources":["../../../server/service/payment/payment-mutation.ts"],"names":[],"mappings":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,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,iBAAO,CAAC,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IAE5F,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,2BAAY,CAAC,CAAC,CAAA;IACtC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4DAKP;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,mBAAmB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAKhD;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,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;;;;qDAUvE;0BA5DU,eAAe;IAF3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;IACjB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,eAAe,CA6D3B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive, UseMiddleware } from 'type-graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { Payment } from './payment'\nimport { savePayments } from './payment-service'\nimport { NewPayment, PaymentPatch } from './payment-type'\n\n@Resolver(Payment)\n@UseMiddleware(SpeakRefusals)\nexport class PaymentMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Payment, { description: 'To put a part of a transaction on what it paid' })\n async createPayment(@Arg('payment') payment: NewPayment, @Ctx() context: ResolverContext): Promise<Payment> {\n const { domain, user, tx } = context.state\n const [saved] = await savePayments(tx, domain, user, [{ ...payment, cuFlag: '+' }])\n\n return saved\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\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 const [saved] = await savePayments(tx, domain, user, [{ ...patch, id, cuFlag: 'M' }])\n\n return saved\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Payment], { description: 'To add, modify and delete multiple Payments' })\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 return await savePayments(tx, domain, user, patches)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete Payment' })\n async deletePayment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n await savePayments(tx, domain, user, [{ id, cuFlag: '-' }])\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 Payments' })\n async deletePayments(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n await savePayments(\n tx,\n domain,\n user,\n ids.map(id => ({ id, cuFlag: '-' }))\n )\n\n return true\n }\n}\n"]}
@@ -1,10 +1,13 @@
1
1
  import { Domain, ListParam } from '@things-factory/shell';
2
2
  import { User } from '@things-factory/auth-base';
3
+ import { Transaction } from '../transaction/transaction';
3
4
  import { Payment } from './payment';
4
5
  import { PaymentList } from './payment-type';
5
6
  export declare class PaymentQuery {
6
7
  payment(id: string, context: ResolverContext): Promise<Payment>;
7
8
  payments(params: ListParam, context: ResolverContext): Promise<PaymentList>;
9
+ transaction(payment: Payment): Promise<Transaction>;
10
+ targetLabel(payment: Payment): Promise<string | null>;
8
11
  domain(payment: Payment): Promise<Domain>;
9
12
  updater(payment: Payment): Promise<User>;
10
13
  creator(payment: Payment): Promise<User>;
@@ -5,7 +5,9 @@ const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const shell_1 = require("@things-factory/shell");
7
7
  const auth_base_1 = require("@things-factory/auth-base");
8
+ const transaction_1 = require("../transaction/transaction");
8
9
  const payment_1 = require("./payment");
10
+ const payment_targets_1 = require("./payment-targets");
9
11
  const payment_type_1 = require("./payment-type");
10
12
  let PaymentQuery = class PaymentQuery {
11
13
  async payment(id, context) {
@@ -20,11 +22,21 @@ let PaymentQuery = class PaymentQuery {
20
22
  domain,
21
23
  params,
22
24
  repository: await (0, shell_1.getRepository)(payment_1.Payment),
23
- searchables: []
25
+ searchables: ['targetType', 'basis', 'notes']
24
26
  });
25
27
  const [items, total] = await queryBuilder.getManyAndCount();
26
28
  return { items, total };
27
29
  }
30
+ async transaction(payment) {
31
+ return payment.transaction ?? (await (0, shell_1.getRepository)(transaction_1.Transaction).findOneBy({ id: payment.transactionId }));
32
+ }
33
+ async targetLabel(payment) {
34
+ const label = (0, payment_targets_1.paymentTargetOf)(payment.targetType)?.label;
35
+ if (!label)
36
+ return null;
37
+ const labels = await label((0, shell_1.getRepository)(payment_1.Payment).manager, { id: payment.domainId }, [payment.targetId]);
38
+ return labels.get(payment.targetId) ?? null;
39
+ }
28
40
  async domain(payment) {
29
41
  return payment.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: payment.domainId }));
30
42
  }
@@ -37,7 +49,7 @@ let PaymentQuery = class PaymentQuery {
37
49
  };
38
50
  exports.PaymentQuery = PaymentQuery;
39
51
  tslib_1.__decorate([
40
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query")'),
52
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
41
53
  (0, type_graphql_1.Query)(returns => payment_1.Payment, { nullable: true, description: 'To fetch a Payment' }),
42
54
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
43
55
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -46,7 +58,7 @@ tslib_1.__decorate([
46
58
  tslib_1.__metadata("design:returntype", Promise)
47
59
  ], PaymentQuery.prototype, "payment", null);
48
60
  tslib_1.__decorate([
49
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query")'),
61
+ (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
50
62
  (0, type_graphql_1.Query)(returns => payment_type_1.PaymentList, { description: 'To fetch multiple Payments' }),
51
63
  tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
52
64
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -54,6 +66,23 @@ tslib_1.__decorate([
54
66
  tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
55
67
  tslib_1.__metadata("design:returntype", Promise)
56
68
  ], PaymentQuery.prototype, "payments", null);
69
+ tslib_1.__decorate([
70
+ (0, type_graphql_1.FieldResolver)(type => transaction_1.Transaction),
71
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
72
+ tslib_1.__metadata("design:type", Function),
73
+ tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
74
+ tslib_1.__metadata("design:returntype", Promise)
75
+ ], PaymentQuery.prototype, "transaction", null);
76
+ tslib_1.__decorate([
77
+ (0, type_graphql_1.FieldResolver)(type => String, {
78
+ nullable: true,
79
+ description: 'What people call what was paid, as its module names it'
80
+ }),
81
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
82
+ tslib_1.__metadata("design:type", Function),
83
+ tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
84
+ tslib_1.__metadata("design:returntype", Promise)
85
+ ], PaymentQuery.prototype, "targetLabel", null);
57
86
  tslib_1.__decorate([
58
87
  (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
59
88
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -1 +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,AAAN,KAAK,CAAC,QAAQ,CAA0B,MAAiB,EAAS,OAAwB;QACxF,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,iBAAO,CAAC;YACxC,WAAW,EAAE,EAAE;SAChB,CAA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A4B,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"]}
1
+ {"version":3,"file":"payment-query.js","sourceRoot":"","sources":["../../../server/service/payment/payment-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AACvG,yDAAgD;AAEhD,4DAAwD;AACxD,uCAAmC;AACnC,uDAAmD;AACnD,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,AAAN,KAAK,CAAC,QAAQ,CAA0B,MAAiB,EAAS,OAAwB;QACxF,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,iBAAO,CAAC;YACxC,WAAW,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;SAC9C,CAAC,CAA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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;uBA1DU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CA2DxB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nimport { Transaction } from '../transaction/transaction'\nimport { Payment } from './payment'\nimport { paymentTargetOf } from './payment-targets'\nimport { PaymentList } from './payment-type'\n\n@Resolver(Payment)\nexport class PaymentQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\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\", domainOwnerGranted: true)')\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: ['targetType', 'basis', 'notes']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Transaction)\n async transaction(@Root() payment: Payment): Promise<Transaction> {\n return payment.transaction ?? (await getRepository(Transaction).findOneBy({ id: payment.transactionId }))\n }\n\n @FieldResolver(type => String, {\n nullable: true,\n description: 'What people call what was paid, as its module names it'\n })\n async targetLabel(@Root() payment: Payment): Promise<string | null> {\n const label = paymentTargetOf(payment.targetType)?.label\n if (!label) return null\n const labels = await label(getRepository(Payment).manager, { id: payment.domainId }, [payment.targetId])\n\n return labels.get(payment.targetId) ?? null\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,16 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { Payment } from './payment';
3
+ import { PaymentPatch } from './payment-type';
4
+ /**
5
+ * Within one purpose a transaction pays no more than itself. Run after its payments or its amount change.
6
+ */
7
+ export declare function checkPaymentsWithin(tx: EntityManager, domain: {
8
+ id: string;
9
+ }, transactionIds: string[]): Promise<void>;
10
+ /**
11
+ * Apply rows to a domain's payments: `+` (or no id) adds, `M` changes, `-` deletes (softly). Then the general rule
12
+ * (§`checkPaymentsWithin`) and each touched kind's own rules run, in the same database transaction.
13
+ */
14
+ export declare function savePayments(tx: EntityManager, domain: {
15
+ id: string;
16
+ }, user: any, patches: PaymentPatch[]): Promise<Payment[]>;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkPaymentsWithin = checkPaymentsWithin;
4
+ exports.savePayments = savePayments;
5
+ const typeorm_1 = require("typeorm");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const transaction_1 = require("../transaction/transaction");
8
+ const payment_1 = require("./payment");
9
+ const payment_targets_1 = require("./payment-targets");
10
+ /** Amounts are decimals; a sum within half a cent of the transaction is the transaction. */
11
+ const CENT = 0.005;
12
+ /**
13
+ * Within one purpose a transaction pays no more than itself. Run after its payments or its amount change.
14
+ */
15
+ async function checkPaymentsWithin(tx, domain, transactionIds) {
16
+ const ids = [...new Set(transactionIds)];
17
+ if (!ids.length)
18
+ return;
19
+ const transactions = await tx
20
+ .getRepository(transaction_1.Transaction)
21
+ .find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(ids) }, select: ['id', 'amount'] });
22
+ const payments = await tx
23
+ .getRepository(payment_1.Payment)
24
+ .find({ where: { domain: { id: domain.id }, transaction: { id: (0, typeorm_1.In)(ids) } }, relations: ['transaction'] });
25
+ const paid = new Map();
26
+ for (const payment of payments) {
27
+ const key = `${payment.transaction.id}|${payment.purpose}`;
28
+ paid.set(key, (paid.get(key) ?? 0) + Number(payment.amount));
29
+ }
30
+ for (const transaction of transactions) {
31
+ for (const [key, sum] of paid) {
32
+ const [id, purpose] = key.split('|');
33
+ if (id !== transaction.id)
34
+ continue;
35
+ const amount = Math.abs(Number(transaction.amount));
36
+ if (sum > amount + CENT) {
37
+ throw new shell_1.Refusal('payment-over-transaction', { purpose, paid: sum, amount }, `${purpose}: ${sum} put on a transaction of ${amount}`);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ /** A patch as the row it writes: the target kind known, the amount more than zero, the purpose the kind's. */
43
+ function rowOf(patch, isNew) {
44
+ const row = {};
45
+ const transactionId = patch.transaction?.id;
46
+ if (isNew && !transactionId)
47
+ throw new shell_1.Refusal('payment-transaction-required', {}, 'a payment needs the transaction it is a part of');
48
+ if (transactionId)
49
+ row.transactionId = transactionId;
50
+ if (patch.targetType !== undefined || isNew) {
51
+ const target = (0, payment_targets_1.paymentTargetOf)(String(patch.targetType ?? ''));
52
+ if (!target)
53
+ throw new shell_1.Refusal('payment-target-unknown', { targetType: patch.targetType }, `'${patch.targetType}' is not a kind of target any module registered`);
54
+ row.targetType = patch.targetType;
55
+ row.purpose = target.purpose;
56
+ }
57
+ if (patch.targetId !== undefined || isNew) {
58
+ if (!patch.targetId)
59
+ throw new shell_1.Refusal('payment-target-required', {}, 'a payment needs what it paid');
60
+ row.targetId = patch.targetId;
61
+ }
62
+ if (patch.amount !== undefined || isNew) {
63
+ const amount = Number(patch.amount);
64
+ if (!(amount > 0))
65
+ throw new shell_1.Refusal('payment-amount-not-positive', {}, 'amount: must be more than zero');
66
+ row.amount = amount;
67
+ }
68
+ if (patch.method !== undefined)
69
+ row.method = patch.method ?? payment_1.PaymentMethod.PERSON;
70
+ if (patch.basis !== undefined)
71
+ row.basis = patch.basis || null;
72
+ if (patch.notes !== undefined)
73
+ row.notes = patch.notes || null;
74
+ return row;
75
+ }
76
+ /**
77
+ * Apply rows to a domain's payments: `+` (or no id) adds, `M` changes, `-` deletes (softly). Then the general rule
78
+ * (§`checkPaymentsWithin`) and each touched kind's own rules run, in the same database transaction.
79
+ */
80
+ async function savePayments(tx, domain, user, patches) {
81
+ const repo = tx.getRepository(payment_1.Payment);
82
+ const transactions = tx.getRepository(transaction_1.Transaction);
83
+ const touched = new Map();
84
+ const touch = (payment) => {
85
+ const kind = touched.get(payment.targetType) ?? { targetIds: new Set(), transactionIds: new Set() };
86
+ kind.targetIds.add(payment.targetId);
87
+ if (payment.transactionId)
88
+ kind.transactionIds.add(payment.transactionId);
89
+ touched.set(payment.targetType, kind);
90
+ };
91
+ const deletes = patches.filter(one => one.cuFlag === '-' && one.id).map(one => one.id);
92
+ if (deletes.length) {
93
+ const owned = await repo.find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(deletes) }, relations: ['transaction'] });
94
+ if (owned.length !== new Set(deletes).size)
95
+ throw new shell_1.Refusal('payment-not-found', {}, 'a payment was not found - reload and try again');
96
+ for (const one of owned)
97
+ touch({ ...one, transactionId: one.transaction.id });
98
+ await repo.softDelete({ id: (0, typeorm_1.In)(deletes) });
99
+ }
100
+ const saved = [];
101
+ for (const patch of patches.filter(one => one.cuFlag !== '-')) {
102
+ const isNew = !patch.id || patch.cuFlag === '+';
103
+ const { transactionId, ...row } = rowOf(patch, isNew);
104
+ const current = isNew
105
+ ? undefined
106
+ : await repo.findOne({ where: { domain: { id: domain.id }, id: patch.id }, relations: ['transaction'] });
107
+ if (!isNew && !current)
108
+ throw new shell_1.Refusal('payment-not-found', {}, 'a payment was not found - reload and try again');
109
+ const transactionOf = transactionId ?? current.transaction.id;
110
+ const transaction = await transactions.findOne({ where: { domain: { id: domain.id }, id: transactionOf } });
111
+ if (!transaction)
112
+ throw new shell_1.Refusal('payment-transaction-not-found', {}, 'the transaction was not found - reload and try again');
113
+ const targetType = row.targetType ?? current.targetType;
114
+ const targetId = row.targetId ?? current.targetId;
115
+ const twin = await repo.findOne({
116
+ where: { domain: { id: domain.id }, transaction: { id: transaction.id }, targetType, targetId }
117
+ });
118
+ if (twin && twin.id !== current?.id)
119
+ throw new shell_1.Refusal('payment-twice', { targetType, targetId }, 'the transaction already pays this - change that payment instead');
120
+ if (current)
121
+ touch({ ...current, transactionId: current.transaction.id });
122
+ const written = await repo.save({
123
+ ...(current ?? { domain, creator: user }),
124
+ ...row,
125
+ transaction,
126
+ updater: user
127
+ });
128
+ touch({ targetType: written.targetType, targetId: written.targetId, transactionId: transaction.id });
129
+ saved.push(written);
130
+ }
131
+ await checkPaymentsWithin(tx, domain, [...touched.values()].flatMap(kind => [...kind.transactionIds]));
132
+ for (const [targetType, kind] of touched) {
133
+ await (0, payment_targets_1.paymentTargetOf)(targetType)?.validate?.(tx, domain, {
134
+ targetIds: [...kind.targetIds],
135
+ transactionIds: [...kind.transactionIds]
136
+ });
137
+ }
138
+ return saved;
139
+ }
140
+ //# sourceMappingURL=payment-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-service.js","sourceRoot":"","sources":["../../../server/service/payment/payment-service.ts"],"names":[],"mappings":";;AAeA,kDAiCC;AAwCD,oCA2EC;AAnKD,qCAA2C;AAE3C,iD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KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrB,CAAC;IAED,MAAM,mBAAmB,CACvB,EAAE,EACF,MAAM,EACN,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAChE,CAAA;IACD,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QACzC,MAAM,IAAA,iCAAe,EAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE;YACxD,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;YAC9B,cAAc,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;SACzC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { EntityManager, In } from 'typeorm'\n\nimport { Refusal } from '@things-factory/shell'\n\nimport { Transaction } from '../transaction/transaction'\nimport { Payment, PaymentMethod } from './payment'\nimport { paymentTargetOf } from './payment-targets'\nimport { PaymentPatch } from './payment-type'\n\n/** Amounts are decimals; a sum within half a cent of the transaction is the transaction. */\nconst CENT = 0.005\n\n/**\n * Within one purpose a transaction pays no more than itself. Run after its payments or its amount change.\n */\nexport async function checkPaymentsWithin(\n tx: EntityManager,\n domain: { id: string },\n transactionIds: string[]\n): Promise<void> {\n const ids = [...new Set(transactionIds)]\n if (!ids.length) return\n\n const transactions = await tx\n .getRepository(Transaction)\n .find({ where: { domain: { id: domain.id }, id: In(ids) }, select: ['id', 'amount'] })\n const payments = await tx\n .getRepository(Payment)\n .find({ where: { domain: { id: domain.id }, transaction: { id: In(ids) } }, relations: ['transaction'] })\n const paid = new Map<string, number>()\n for (const payment of payments) {\n const key = `${payment.transaction.id}|${payment.purpose}`\n paid.set(key, (paid.get(key) ?? 0) + Number(payment.amount))\n }\n for (const transaction of transactions) {\n for (const [key, sum] of paid) {\n const [id, purpose] = key.split('|')\n if (id !== transaction.id) continue\n const amount = Math.abs(Number(transaction.amount))\n if (sum > amount + CENT) {\n throw new Refusal(\n 'payment-over-transaction',\n { purpose, paid: sum, amount },\n `${purpose}: ${sum} put on a transaction of ${amount}`\n )\n }\n }\n }\n}\n\n/** A patch as the row it writes: the target kind known, the amount more than zero, the purpose the kind's. */\nfunction rowOf(patch: PaymentPatch, isNew: boolean): Partial<Payment> & { transactionId?: string } {\n const row: Record<string, any> = {}\n const transactionId = patch.transaction?.id\n if (isNew && !transactionId)\n throw new Refusal('payment-transaction-required', {}, 'a payment needs the transaction it is a part of')\n if (transactionId) row.transactionId = transactionId\n\n if (patch.targetType !== undefined || isNew) {\n const target = paymentTargetOf(String(patch.targetType ?? ''))\n if (!target)\n throw new Refusal(\n 'payment-target-unknown',\n { targetType: patch.targetType },\n `'${patch.targetType}' is not a kind of target any module registered`\n )\n row.targetType = patch.targetType\n row.purpose = target.purpose\n }\n if (patch.targetId !== undefined || isNew) {\n if (!patch.targetId) throw new Refusal('payment-target-required', {}, 'a payment needs what it paid')\n row.targetId = patch.targetId\n }\n if (patch.amount !== undefined || isNew) {\n const amount = Number(patch.amount)\n if (!(amount > 0)) throw new Refusal('payment-amount-not-positive', {}, 'amount: must be more than zero')\n row.amount = amount\n }\n if (patch.method !== undefined) row.method = patch.method ?? PaymentMethod.PERSON\n if (patch.basis !== undefined) row.basis = patch.basis || null\n if (patch.notes !== undefined) row.notes = patch.notes || null\n return row\n}\n\n/**\n * Apply rows to a domain's payments: `+` (or no id) adds, `M` changes, `-` deletes (softly). Then the general rule\n * (§`checkPaymentsWithin`) and each touched kind's own rules run, in the same database transaction.\n */\nexport async function savePayments(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n patches: PaymentPatch[]\n): Promise<Payment[]> {\n const repo = tx.getRepository(Payment)\n const transactions = tx.getRepository(Transaction)\n const touched = new Map<string, { targetIds: Set<string>; transactionIds: Set<string> }>()\n const touch = (payment: { targetType: string; targetId: string; transactionId?: string }) => {\n const kind = touched.get(payment.targetType) ?? { targetIds: new Set<string>(), transactionIds: new Set<string>() }\n kind.targetIds.add(payment.targetId)\n if (payment.transactionId) kind.transactionIds.add(payment.transactionId)\n touched.set(payment.targetType, kind)\n }\n\n const deletes = patches.filter(one => one.cuFlag === '-' && one.id).map(one => one.id!)\n if (deletes.length) {\n const owned = await repo.find({ where: { domain: { id: domain.id }, id: In(deletes) }, relations: ['transaction'] })\n if (owned.length !== new Set(deletes).size)\n throw new Refusal('payment-not-found', {}, 'a payment was not found - reload and try again')\n for (const one of owned) touch({ ...one, transactionId: one.transaction.id })\n await repo.softDelete({ id: In(deletes) })\n }\n\n const saved: Payment[] = []\n for (const patch of patches.filter(one => one.cuFlag !== '-')) {\n const isNew = !patch.id || patch.cuFlag === '+'\n const { transactionId, ...row } = rowOf(patch, isNew)\n const current = isNew\n ? undefined\n : await repo.findOne({ where: { domain: { id: domain.id }, id: patch.id }, relations: ['transaction'] })\n if (!isNew && !current) throw new Refusal('payment-not-found', {}, 'a payment was not found - reload and try again')\n\n const transactionOf = transactionId ?? current!.transaction.id\n const transaction = await transactions.findOne({ where: { domain: { id: domain.id }, id: transactionOf } })\n if (!transaction)\n throw new Refusal('payment-transaction-not-found', {}, 'the transaction was not found - reload and try again')\n\n const targetType = row.targetType ?? current!.targetType\n const targetId = row.targetId ?? current!.targetId\n const twin = await repo.findOne({\n where: { domain: { id: domain.id }, transaction: { id: transaction.id }, targetType, targetId }\n })\n if (twin && twin.id !== current?.id)\n throw new Refusal(\n 'payment-twice',\n { targetType, targetId },\n 'the transaction already pays this - change that payment instead'\n )\n\n if (current) touch({ ...current, transactionId: current.transaction.id })\n const written = await repo.save({\n ...(current ?? { domain, creator: user }),\n ...row,\n transaction,\n updater: user\n } as Payment)\n touch({ targetType: written.targetType, targetId: written.targetId, transactionId: transaction.id })\n saved.push(written)\n }\n\n await checkPaymentsWithin(\n tx,\n domain,\n [...touched.values()].flatMap(kind => [...kind.transactionIds])\n )\n for (const [targetType, kind] of touched) {\n await paymentTargetOf(targetType)?.validate?.(tx, domain, {\n targetIds: [...kind.targetIds],\n transactionIds: [...kind.transactionIds]\n })\n }\n\n return saved\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { PaymentPurpose } from './payment';
3
+ /**
4
+ * The kinds of thing a transaction can pay, registered by the module that owns them.
5
+ *
6
+ * accounting keeps the general rules - the target kind is known, a transaction pays no more than itself within one
7
+ * purpose. What a target may take (a contract round's capacity, one VAT period per withdrawal) is the owner's rule,
8
+ * run in the same database transaction after the payments are written.
9
+ */
10
+ export interface PaymentTarget {
11
+ /** What a payment on this kind tells of its transaction. */
12
+ purpose: PaymentPurpose;
13
+ /** What people call each target - 「H2026021 3차」 - for the screens that list what a transaction paid. */
14
+ label?: (tx: EntityManager, domain: {
15
+ id: string;
16
+ }, targetIds: string[]) => Promise<Map<string, string>>;
17
+ /**
18
+ * The owner's rules on the payments of its targets, given the targets and transactions a save touched. Throw a
19
+ * `Refusal` to refuse the save.
20
+ */
21
+ validate?: (tx: EntityManager, domain: {
22
+ id: string;
23
+ }, touched: {
24
+ targetIds: string[];
25
+ transactionIds: string[];
26
+ }) => Promise<void>;
27
+ }
28
+ /** Register a kind of target. A kind is registered once; registering it again is a mistake in the app. */
29
+ export declare function registerPaymentTarget(targetType: string, target: PaymentTarget): void;
30
+ export declare function paymentTargetOf(targetType: string): PaymentTarget | undefined;
31
+ export declare function registeredPaymentTargets(): string[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerPaymentTarget = registerPaymentTarget;
4
+ exports.paymentTargetOf = paymentTargetOf;
5
+ exports.registeredPaymentTargets = registeredPaymentTargets;
6
+ const targets = new Map();
7
+ /** Register a kind of target. A kind is registered once; registering it again is a mistake in the app. */
8
+ function registerPaymentTarget(targetType, target) {
9
+ if (targets.has(targetType))
10
+ throw new Error(`payment target '${targetType}' is registered twice`);
11
+ targets.set(targetType, target);
12
+ }
13
+ function paymentTargetOf(targetType) {
14
+ return targets.get(targetType);
15
+ }
16
+ function registeredPaymentTargets() {
17
+ return [...targets.keys()];
18
+ }
19
+ //# sourceMappingURL=payment-targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-targets.js","sourceRoot":"","sources":["../../../server/service/payment/payment-targets.ts"],"names":[],"mappings":";;AA8BA,sDAGC;AAED,0CAEC;AAED,4DAEC;AAdD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;AAEhD,0GAA0G;AAC1G,SAAgB,qBAAqB,CAAC,UAAkB,EAAE,MAAqB;IAC7E,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,uBAAuB,CAAC,CAAA;IAClG,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AACjC,CAAC;AAED,SAAgB,eAAe,CAAC,UAAkB;IAChD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AAChC,CAAC;AAED,SAAgB,wBAAwB;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AAC5B,CAAC","sourcesContent":["import { EntityManager } from 'typeorm'\n\nimport { PaymentPurpose } from './payment'\n\n/**\n * The kinds of thing a transaction can pay, registered by the module that owns them.\n *\n * accounting keeps the general rules - the target kind is known, a transaction pays no more than itself within one\n * purpose. What a target may take (a contract round's capacity, one VAT period per withdrawal) is the owner's rule,\n * run in the same database transaction after the payments are written.\n */\nexport interface PaymentTarget {\n /** What a payment on this kind tells of its transaction. */\n purpose: PaymentPurpose\n /** What people call each target - 「H2026021 3차」 - for the screens that list what a transaction paid. */\n label?: (tx: EntityManager, domain: { id: string }, targetIds: string[]) => Promise<Map<string, string>>\n /**\n * The owner's rules on the payments of its targets, given the targets and transactions a save touched. Throw a\n * `Refusal` to refuse the save.\n */\n validate?: (\n tx: EntityManager,\n domain: { id: string },\n touched: { targetIds: string[]; transactionIds: string[] }\n ) => Promise<void>\n}\n\nconst targets = new Map<string, PaymentTarget>()\n\n/** Register a kind of target. A kind is registered once; registering it again is a mistake in the app. */\nexport function registerPaymentTarget(targetType: string, target: PaymentTarget): void {\n if (targets.has(targetType)) throw new Error(`payment target '${targetType}' is registered twice`)\n targets.set(targetType, target)\n}\n\nexport function paymentTargetOf(targetType: string): PaymentTarget | undefined {\n return targets.get(targetType)\n}\n\nexport function registeredPaymentTargets(): string[] {\n return [...targets.keys()]\n}\n"]}
@@ -1,27 +1,23 @@
1
1
  import { ObjectRef } from '@things-factory/shell';
2
- import { Payment, PaymentDirection, PaymentType } from './payment';
2
+ import { Payment, PaymentMethod } from './payment';
3
3
  export declare class NewPayment {
4
4
  transaction: ObjectRef;
5
- currency?: string;
5
+ targetType: string;
6
+ targetId: string;
6
7
  amount: number;
7
- paidAt: Date;
8
- direction: PaymentDirection;
9
- paymentType: PaymentType;
10
- sourceBankAccount?: ObjectRef;
11
- destinationBankAccount?: ObjectRef;
12
- note?: string;
8
+ method?: PaymentMethod;
9
+ basis?: string;
10
+ notes?: string;
13
11
  }
14
12
  export declare class PaymentPatch {
15
13
  id?: string;
16
- transaction: ObjectRef;
17
- currency?: string;
18
- amount: number;
19
- paidAt: Date;
20
- direction: PaymentDirection;
21
- paymentType: PaymentType;
22
- sourceBankAccount?: ObjectRef;
23
- destinationBankAccount?: ObjectRef;
24
- note?: string;
14
+ transaction?: ObjectRef;
15
+ targetType?: string;
16
+ targetId?: string;
17
+ amount?: number;
18
+ method?: PaymentMethod;
19
+ basis?: string;
20
+ notes?: string;
25
21
  cuFlag?: string;
26
22
  }
27
23
  export declare class PaymentList {
@@ -9,106 +9,90 @@ let NewPayment = class NewPayment {
9
9
  };
10
10
  exports.NewPayment = NewPayment;
11
11
  tslib_1.__decorate([
12
- (0, type_graphql_1.Field)(type => shell_1.ObjectRef),
12
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { description: 'The transaction a part of which this is' }),
13
13
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
14
14
  ], NewPayment.prototype, "transaction", void 0);
15
15
  tslib_1.__decorate([
16
- (0, type_graphql_1.Field)({ nullable: true }),
16
+ (0, type_graphql_1.Field)({ description: 'The kind of what was paid, as registered' }),
17
17
  tslib_1.__metadata("design:type", String)
18
- ], NewPayment.prototype, "currency", void 0);
18
+ ], NewPayment.prototype, "targetType", void 0);
19
19
  tslib_1.__decorate([
20
- (0, type_graphql_1.Field)({ nullable: false }),
20
+ (0, type_graphql_1.Field)({ description: 'The id of what was paid' }),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], NewPayment.prototype, "targetId", void 0);
23
+ tslib_1.__decorate([
24
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'The part of the transaction put on the target' }),
21
25
  tslib_1.__metadata("design:type", Number)
22
26
  ], NewPayment.prototype, "amount", void 0);
23
27
  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),
28
+ (0, type_graphql_1.Field)(type => payment_1.PaymentMethod, { nullable: true, description: 'Who made the link - a person when not given' }),
29
29
  tslib_1.__metadata("design:type", String)
30
- ], NewPayment.prototype, "direction", void 0);
30
+ ], NewPayment.prototype, "method", void 0);
31
31
  tslib_1.__decorate([
32
- (0, type_graphql_1.Field)(type => payment_1.PaymentType, { description: 'Type of the payment' }),
32
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Why a rule made the link' }),
33
33
  tslib_1.__metadata("design:type", String)
34
- ], NewPayment.prototype, "paymentType", void 0);
35
- tslib_1.__decorate([
36
- (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Source bank account for the payment' }),
37
- tslib_1.__metadata("design:type", shell_1.ObjectRef)
38
- ], NewPayment.prototype, "sourceBankAccount", void 0);
39
- tslib_1.__decorate([
40
- (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Destination bank account for the payment' }),
41
- tslib_1.__metadata("design:type", shell_1.ObjectRef)
42
- ], NewPayment.prototype, "destinationBankAccount", void 0);
34
+ ], NewPayment.prototype, "basis", void 0);
43
35
  tslib_1.__decorate([
44
- (0, type_graphql_1.Field)({ nullable: true }),
36
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
45
37
  tslib_1.__metadata("design:type", String)
46
- ], NewPayment.prototype, "note", void 0);
38
+ ], NewPayment.prototype, "notes", void 0);
47
39
  exports.NewPayment = NewPayment = tslib_1.__decorate([
48
- (0, type_graphql_1.InputType)()
40
+ (0, type_graphql_1.InputType)({ description: 'A new part of a transaction put on what it paid' })
49
41
  ], NewPayment);
50
42
  let PaymentPatch = class PaymentPatch {
51
43
  };
52
44
  exports.PaymentPatch = PaymentPatch;
53
45
  tslib_1.__decorate([
54
- (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
46
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'The payment to change or delete' }),
55
47
  tslib_1.__metadata("design:type", String)
56
48
  ], PaymentPatch.prototype, "id", void 0);
57
49
  tslib_1.__decorate([
58
- (0, type_graphql_1.Field)(type => shell_1.ObjectRef),
50
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'The transaction a part of which this is' }),
59
51
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
60
52
  ], PaymentPatch.prototype, "transaction", void 0);
61
53
  tslib_1.__decorate([
62
- (0, type_graphql_1.Field)({ nullable: true }),
54
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The kind of what was paid, as registered' }),
63
55
  tslib_1.__metadata("design:type", String)
64
- ], PaymentPatch.prototype, "currency", void 0);
56
+ ], PaymentPatch.prototype, "targetType", void 0);
65
57
  tslib_1.__decorate([
66
- (0, type_graphql_1.Field)({ nullable: false }),
58
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The id of what was paid' }),
59
+ tslib_1.__metadata("design:type", String)
60
+ ], PaymentPatch.prototype, "targetId", void 0);
61
+ tslib_1.__decorate([
62
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'The part of the transaction put on the target' }),
67
63
  tslib_1.__metadata("design:type", Number)
68
64
  ], PaymentPatch.prototype, "amount", void 0);
69
65
  tslib_1.__decorate([
70
- (0, type_graphql_1.Field)({ nullable: false }),
71
- tslib_1.__metadata("design:type", Date)
72
- ], PaymentPatch.prototype, "paidAt", void 0);
73
- tslib_1.__decorate([
74
- (0, type_graphql_1.Field)(type => payment_1.PaymentDirection),
66
+ (0, type_graphql_1.Field)(type => payment_1.PaymentMethod, { nullable: true, description: 'Who made the link' }),
75
67
  tslib_1.__metadata("design:type", String)
76
- ], PaymentPatch.prototype, "direction", void 0);
68
+ ], PaymentPatch.prototype, "method", void 0);
77
69
  tslib_1.__decorate([
78
- (0, type_graphql_1.Field)(type => payment_1.PaymentType, { description: 'Type of the payment' }),
70
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Why a rule made the link' }),
79
71
  tslib_1.__metadata("design:type", String)
80
- ], PaymentPatch.prototype, "paymentType", void 0);
81
- tslib_1.__decorate([
82
- (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Source bank account for the payment' }),
83
- tslib_1.__metadata("design:type", shell_1.ObjectRef)
84
- ], PaymentPatch.prototype, "sourceBankAccount", void 0);
85
- tslib_1.__decorate([
86
- (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'Destination bank account for the payment' }),
87
- tslib_1.__metadata("design:type", shell_1.ObjectRef)
88
- ], PaymentPatch.prototype, "destinationBankAccount", void 0);
72
+ ], PaymentPatch.prototype, "basis", void 0);
89
73
  tslib_1.__decorate([
90
- (0, type_graphql_1.Field)({ nullable: true }),
74
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes' }),
91
75
  tslib_1.__metadata("design:type", String)
92
- ], PaymentPatch.prototype, "note", void 0);
76
+ ], PaymentPatch.prototype, "notes", void 0);
93
77
  tslib_1.__decorate([
94
- (0, type_graphql_1.Field)({ nullable: true }),
78
+ (0, type_graphql_1.Field)({ nullable: true, description: '+ adds, M changes, - deletes' }),
95
79
  tslib_1.__metadata("design:type", String)
96
80
  ], PaymentPatch.prototype, "cuFlag", void 0);
97
81
  exports.PaymentPatch = PaymentPatch = tslib_1.__decorate([
98
- (0, type_graphql_1.InputType)()
82
+ (0, type_graphql_1.InputType)({ description: 'A change to a payment, or a grid row: cuFlag + adds, M changes, - deletes' })
99
83
  ], PaymentPatch);
100
84
  let PaymentList = class PaymentList {
101
85
  };
102
86
  exports.PaymentList = PaymentList;
103
87
  tslib_1.__decorate([
104
- (0, type_graphql_1.Field)(type => [payment_1.Payment]),
88
+ (0, type_graphql_1.Field)(type => [payment_1.Payment], { description: 'The payments on this page' }),
105
89
  tslib_1.__metadata("design:type", Array)
106
90
  ], PaymentList.prototype, "items", void 0);
107
91
  tslib_1.__decorate([
108
- (0, type_graphql_1.Field)(type => type_graphql_1.Int),
92
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'How many there are in all' }),
109
93
  tslib_1.__metadata("design:type", Number)
110
94
  ], PaymentList.prototype, "total", void 0);
111
95
  exports.PaymentList = PaymentList = tslib_1.__decorate([
112
- (0, type_graphql_1.ObjectType)()
96
+ (0, type_graphql_1.ObjectType)({ description: 'A page of payments' })
113
97
  ], PaymentList);
114
98
  //# sourceMappingURL=payment-type.js.map
@@ -1 +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,uCAAkE;AAG3D,IAAM,UAAU,GAAhB,MAAM,UAAU;CA2BtB,CAAA;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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, PaymentType } 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(type => PaymentType, { description: 'Type of the payment' })\n paymentType: PaymentType // 결제 유형\n\n @Field(type => ObjectRef, { nullable: true, description: 'Source bank account for the payment' })\n sourceBankAccount?: ObjectRef\n\n @Field(type => ObjectRef, { nullable: true, description: 'Destination bank account for the payment' })\n destinationBankAccount?: ObjectRef\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(type => PaymentType, { description: 'Type of the payment' })\n paymentType: PaymentType // 결제 유형\n\n @Field(type => ObjectRef, { nullable: true, description: 'Source bank account for the payment' })\n sourceBankAccount?: ObjectRef\n\n @Field(type => ObjectRef, { nullable: true, description: 'Destination bank account for the payment' })\n destinationBankAccount?: ObjectRef\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"]}
1
+ {"version":3,"file":"payment-type.js","sourceRoot":"","sources":["../../../server/service/payment/pay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AC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;0CACpD;sBALF,WAAW;IADvB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;GACrC,WAAW,CAMvB","sourcesContent":["import { ObjectType, Field, Float, InputType, Int, ID } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { Payment, PaymentMethod } from './payment'\n\n@InputType({ description: 'A new part of a transaction put on what it paid' })\nexport class NewPayment {\n @Field(type => ObjectRef, { description: 'The transaction a part of which this is' })\n transaction: ObjectRef\n\n @Field({ description: 'The kind of what was paid, as registered' })\n targetType: string\n\n @Field({ description: 'The id of what was paid' })\n targetId: string\n\n @Field(type => Float, { description: 'The part of the transaction put on the target' })\n amount: number\n\n @Field(type => PaymentMethod, { nullable: true, description: 'Who made the link - a person when not given' })\n method?: PaymentMethod\n\n @Field({ nullable: true, description: 'Why a rule made the link' })\n basis?: string\n\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n}\n\n@InputType({ description: 'A change to a payment, or a grid row: cuFlag + adds, M changes, - deletes' })\nexport class PaymentPatch {\n @Field(type => ID, { nullable: true, description: 'The payment to change or delete' })\n id?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'The transaction a part of which this is' })\n transaction?: ObjectRef\n\n @Field({ nullable: true, description: 'The kind of what was paid, as registered' })\n targetType?: string\n\n @Field({ nullable: true, description: 'The id of what was paid' })\n targetId?: string\n\n @Field(type => Float, { nullable: true, description: 'The part of the transaction put on the target' })\n amount?: number\n\n @Field(type => PaymentMethod, { nullable: true, description: 'Who made the link' })\n method?: PaymentMethod\n\n @Field({ nullable: true, description: 'Why a rule made the link' })\n basis?: string\n\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @Field({ nullable: true, description: '+ adds, M changes, - deletes' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A page of payments' })\nexport class PaymentList {\n @Field(type => [Payment], { description: 'The payments on this page' })\n items: Payment[]\n\n @Field(type => Int, { description: 'How many there are in all' })\n total: number\n}\n"]}