@stamhoofd/models 2.39.0 → 2.40.0

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 (352) hide show
  1. package/dist/src/factories/AddressFactory.d.ts +3 -4
  2. package/dist/src/factories/AddressFactory.d.ts.map +1 -1
  3. package/dist/src/factories/AddressFactory.js +13 -13
  4. package/dist/src/factories/EmergencyContactFactory.d.ts +3 -4
  5. package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -1
  6. package/dist/src/factories/EmergencyContactFactory.js +27 -27
  7. package/dist/src/factories/EmergencyContactFactory.js.map +1 -1
  8. package/dist/src/factories/GroupFactory.d.ts +4 -4
  9. package/dist/src/factories/GroupFactory.d.ts.map +1 -1
  10. package/dist/src/factories/GroupFactory.js +8 -8
  11. package/dist/src/factories/GroupFactory.js.map +1 -1
  12. package/dist/src/factories/MemberFactory.d.ts +4 -4
  13. package/dist/src/factories/MemberFactory.d.ts.map +1 -1
  14. package/dist/src/factories/MemberFactory.js +17 -17
  15. package/dist/src/factories/MemberFactory.js.map +1 -1
  16. package/dist/src/factories/OrganizationFactory.d.ts +4 -4
  17. package/dist/src/factories/OrganizationFactory.js +8 -8
  18. package/dist/src/factories/OrganizationFactory.js.map +1 -1
  19. package/dist/src/factories/ParentFactory.d.ts +1 -1
  20. package/dist/src/factories/ParentFactory.js +19 -19
  21. package/dist/src/factories/ParentFactory.js.map +1 -1
  22. package/dist/src/factories/RecordFactory.d.ts +2 -3
  23. package/dist/src/factories/RecordFactory.d.ts.map +1 -1
  24. package/dist/src/factories/RecordFactory.js +1 -1
  25. package/dist/src/factories/RecordFactory.js.map +1 -1
  26. package/dist/src/factories/RegisterCodeFactory.d.ts +2 -2
  27. package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -1
  28. package/dist/src/factories/RegisterCodeFactory.js +2 -2
  29. package/dist/src/factories/RegistrationFactory.d.ts +3 -3
  30. package/dist/src/factories/RegistrationFactory.d.ts.map +1 -1
  31. package/dist/src/factories/RegistrationFactory.js.map +1 -1
  32. package/dist/src/factories/RegistrationPeriodFactory.d.ts +2 -2
  33. package/dist/src/factories/RegistrationPeriodFactory.js.map +1 -1
  34. package/dist/src/factories/UserFactory.d.ts +3 -3
  35. package/dist/src/factories/UserFactory.d.ts.map +1 -1
  36. package/dist/src/factories/UserFactory.js +3 -3
  37. package/dist/src/factories/UserFactory.js.map +1 -1
  38. package/dist/src/factories/WebshopFactory.d.ts +4 -4
  39. package/dist/src/factories/WebshopFactory.d.ts.map +1 -1
  40. package/dist/src/factories/WebshopFactory.js +1 -1
  41. package/dist/src/factories/WebshopFactory.js.map +1 -1
  42. package/dist/src/helpers/DNSValidator.d.ts +1 -1
  43. package/dist/src/helpers/DNSValidator.d.ts.map +1 -1
  44. package/dist/src/helpers/DNSValidator.js +33 -33
  45. package/dist/src/helpers/DNSValidator.js.map +1 -1
  46. package/dist/src/helpers/EmailBuilder.d.ts +10 -10
  47. package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
  48. package/dist/src/helpers/EmailBuilder.js +34 -34
  49. package/dist/src/helpers/EmailBuilder.js.map +1 -1
  50. package/dist/src/helpers/GroupBuilder.d.ts.map +1 -1
  51. package/dist/src/helpers/GroupBuilder.js +57 -57
  52. package/dist/src/helpers/GroupBuilder.js.map +1 -1
  53. package/dist/src/helpers/Handlebars.d.ts.map +1 -1
  54. package/dist/src/helpers/Handlebars.js +29 -29
  55. package/dist/src/helpers/Handlebars.js.map +1 -1
  56. package/dist/src/helpers/MemberMerger.d.ts +1 -1
  57. package/dist/src/helpers/MemberMerger.d.ts.map +1 -1
  58. package/dist/src/helpers/MemberMerger.js +33 -33
  59. package/dist/src/helpers/MemberMerger.js.map +1 -1
  60. package/dist/src/helpers/MemberMerger.test.js +194 -194
  61. package/dist/src/helpers/MemberMerger.test.js.map +1 -1
  62. package/dist/src/helpers/RateLimiter.d.ts.map +1 -1
  63. package/dist/src/helpers/RateLimiter.js +2 -2
  64. package/dist/src/helpers/RateLimiter.js.map +1 -1
  65. package/dist/src/helpers/SetupStepsUpdater.d.ts +22 -0
  66. package/dist/src/helpers/SetupStepsUpdater.d.ts.map +1 -0
  67. package/dist/src/helpers/SetupStepsUpdater.js +255 -0
  68. package/dist/src/helpers/SetupStepsUpdater.js.map +1 -0
  69. package/dist/src/helpers/WebshopCounter.d.ts +1 -1
  70. package/dist/src/helpers/WebshopCounter.d.ts.map +1 -1
  71. package/dist/src/helpers/WebshopCounter.js +1 -1
  72. package/dist/src/helpers/WebshopCounter.js.map +1 -1
  73. package/dist/src/helpers/WebshopCounter.test.js +6 -6
  74. package/dist/src/helpers/WebshopCounter.test.js.map +1 -1
  75. package/dist/src/index.d.ts +20 -19
  76. package/dist/src/index.d.ts.map +1 -1
  77. package/dist/src/index.js +1 -0
  78. package/dist/src/index.js.map +1 -1
  79. package/dist/src/migrations/1605262045-import-postcodes.js +12 -12
  80. package/dist/src/migrations/1605262046-import-postcodes-nl.js +10 -10
  81. package/dist/src/models/BalanceItem.d.ts.map +1 -1
  82. package/dist/src/models/BalanceItem.js +37 -37
  83. package/dist/src/models/BalanceItem.js.map +1 -1
  84. package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
  85. package/dist/src/models/BalanceItemPayment.js +13 -13
  86. package/dist/src/models/BalanceItemPayment.js.map +1 -1
  87. package/dist/src/models/BuckarooPayment.d.ts +1 -1
  88. package/dist/src/models/BuckarooPayment.d.ts.map +1 -1
  89. package/dist/src/models/BuckarooPayment.js +5 -5
  90. package/dist/src/models/BuckarooPayment.js.map +1 -1
  91. package/dist/src/models/CachedOutstandingBalance.d.ts.map +1 -1
  92. package/dist/src/models/CachedOutstandingBalance.js +37 -37
  93. package/dist/src/models/CachedOutstandingBalance.js.map +1 -1
  94. package/dist/src/models/Document.d.ts +4 -4
  95. package/dist/src/models/Document.d.ts.map +1 -1
  96. package/dist/src/models/Document.js +27 -27
  97. package/dist/src/models/Document.js.map +1 -1
  98. package/dist/src/models/DocumentTemplate.d.ts +4 -4
  99. package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
  100. package/dist/src/models/DocumentTemplate.js +72 -72
  101. package/dist/src/models/DocumentTemplate.js.map +1 -1
  102. package/dist/src/models/Email.d.ts.map +1 -1
  103. package/dist/src/models/Email.js +63 -64
  104. package/dist/src/models/Email.js.map +1 -1
  105. package/dist/src/models/EmailRecipient.d.ts.map +1 -1
  106. package/dist/src/models/EmailRecipient.js +20 -20
  107. package/dist/src/models/EmailRecipient.js.map +1 -1
  108. package/dist/src/models/EmailTemplate.d.ts +3 -3
  109. package/dist/src/models/EmailTemplate.d.ts.map +1 -1
  110. package/dist/src/models/EmailTemplate.js +16 -16
  111. package/dist/src/models/EmailTemplate.js.map +1 -1
  112. package/dist/src/models/EmailVerificationCode.d.ts +2 -2
  113. package/dist/src/models/EmailVerificationCode.d.ts.map +1 -1
  114. package/dist/src/models/EmailVerificationCode.js +57 -55
  115. package/dist/src/models/EmailVerificationCode.js.map +1 -1
  116. package/dist/src/models/Event.d.ts +2 -2
  117. package/dist/src/models/Event.d.ts.map +1 -1
  118. package/dist/src/models/Event.js +15 -15
  119. package/dist/src/models/Event.js.map +1 -1
  120. package/dist/src/models/Group.d.ts +3 -1
  121. package/dist/src/models/Group.d.ts.map +1 -1
  122. package/dist/src/models/Group.js +46 -35
  123. package/dist/src/models/Group.js.map +1 -1
  124. package/dist/src/models/Image.d.ts +1 -1
  125. package/dist/src/models/Image.d.ts.map +1 -1
  126. package/dist/src/models/Image.js +26 -26
  127. package/dist/src/models/Image.js.map +1 -1
  128. package/dist/src/models/Member.d.ts +8 -8
  129. package/dist/src/models/Member.d.ts.map +1 -1
  130. package/dist/src/models/Member.js +60 -60
  131. package/dist/src/models/Member.js.map +1 -1
  132. package/dist/src/models/MemberPlatformMembership.d.ts +3 -3
  133. package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
  134. package/dist/src/models/MemberPlatformMembership.js +26 -26
  135. package/dist/src/models/MemberPlatformMembership.js.map +1 -1
  136. package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
  137. package/dist/src/models/MemberResponsibilityRecord.js +13 -13
  138. package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
  139. package/dist/src/models/MergedMember.d.ts +3 -3
  140. package/dist/src/models/MergedMember.d.ts.map +1 -1
  141. package/dist/src/models/MergedMember.js +19 -19
  142. package/dist/src/models/MergedMember.js.map +1 -1
  143. package/dist/src/models/MolliePayment.d.ts +1 -1
  144. package/dist/src/models/MolliePayment.d.ts.map +1 -1
  145. package/dist/src/models/MolliePayment.js +5 -5
  146. package/dist/src/models/MolliePayment.js.map +1 -1
  147. package/dist/src/models/MollieToken.d.ts.map +1 -1
  148. package/dist/src/models/MollieToken.js +60 -60
  149. package/dist/src/models/MollieToken.js.map +1 -1
  150. package/dist/src/models/OneTimeToken.d.ts +2 -2
  151. package/dist/src/models/OneTimeToken.d.ts.map +1 -1
  152. package/dist/src/models/OneTimeToken.js +13 -13
  153. package/dist/src/models/OneTimeToken.js.map +1 -1
  154. package/dist/src/models/Order.d.ts +1 -1
  155. package/dist/src/models/Order.d.ts.map +1 -1
  156. package/dist/src/models/Order.js +70 -70
  157. package/dist/src/models/Order.js.map +1 -1
  158. package/dist/src/models/Organization.d.ts +5 -5
  159. package/dist/src/models/Organization.d.ts.map +1 -1
  160. package/dist/src/models/Organization.js +127 -127
  161. package/dist/src/models/Organization.js.map +1 -1
  162. package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
  163. package/dist/src/models/OrganizationRegistrationPeriod.js +15 -15
  164. package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
  165. package/dist/src/models/PasswordToken.d.ts +3 -3
  166. package/dist/src/models/PasswordToken.d.ts.map +1 -1
  167. package/dist/src/models/PasswordToken.js +17 -17
  168. package/dist/src/models/PasswordToken.js.map +1 -1
  169. package/dist/src/models/PayconiqPayment.d.ts +1 -1
  170. package/dist/src/models/PayconiqPayment.d.ts.map +1 -1
  171. package/dist/src/models/PayconiqPayment.js +49 -49
  172. package/dist/src/models/PayconiqPayment.js.map +1 -1
  173. package/dist/src/models/Payment.d.ts +3 -3
  174. package/dist/src/models/Payment.d.ts.map +1 -1
  175. package/dist/src/models/Payment.js +36 -36
  176. package/dist/src/models/Payment.js.map +1 -1
  177. package/dist/src/models/Platform.d.ts +2 -2
  178. package/dist/src/models/Platform.d.ts.map +1 -1
  179. package/dist/src/models/Platform.js +8 -8
  180. package/dist/src/models/Platform.js.map +1 -1
  181. package/dist/src/models/RegisterCode.d.ts +1 -1
  182. package/dist/src/models/RegisterCode.d.ts.map +1 -1
  183. package/dist/src/models/RegisterCode.js +11 -11
  184. package/dist/src/models/RegisterCode.js.map +1 -1
  185. package/dist/src/models/Registration.d.ts +1 -1
  186. package/dist/src/models/Registration.d.ts.map +1 -1
  187. package/dist/src/models/Registration.js +88 -88
  188. package/dist/src/models/Registration.js.map +1 -1
  189. package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
  190. package/dist/src/models/RegistrationPeriod.js +12 -12
  191. package/dist/src/models/RegistrationPeriod.js.map +1 -1
  192. package/dist/src/models/STCredit.d.ts +1 -1
  193. package/dist/src/models/STCredit.d.ts.map +1 -1
  194. package/dist/src/models/STCredit.js +12 -12
  195. package/dist/src/models/STCredit.js.map +1 -1
  196. package/dist/src/models/STInvoice.d.ts +1 -1
  197. package/dist/src/models/STInvoice.d.ts.map +1 -1
  198. package/dist/src/models/STInvoice.js +16 -16
  199. package/dist/src/models/STInvoice.js.map +1 -1
  200. package/dist/src/models/STPackage.d.ts +1 -1
  201. package/dist/src/models/STPackage.d.ts.map +1 -1
  202. package/dist/src/models/STPackage.js +39 -39
  203. package/dist/src/models/STPackage.js.map +1 -1
  204. package/dist/src/models/STPendingInvoice.d.ts +1 -1
  205. package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
  206. package/dist/src/models/STPendingInvoice.js +11 -11
  207. package/dist/src/models/STPendingInvoice.js.map +1 -1
  208. package/dist/src/models/StripeAccount.d.ts.map +1 -1
  209. package/dist/src/models/StripeAccount.js +13 -13
  210. package/dist/src/models/StripeAccount.js.map +1 -1
  211. package/dist/src/models/StripeCheckoutSession.d.ts +1 -1
  212. package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -1
  213. package/dist/src/models/StripeCheckoutSession.js +7 -7
  214. package/dist/src/models/StripeCheckoutSession.js.map +1 -1
  215. package/dist/src/models/StripePaymentIntent.d.ts +1 -1
  216. package/dist/src/models/StripePaymentIntent.d.ts.map +1 -1
  217. package/dist/src/models/StripePaymentIntent.js +7 -7
  218. package/dist/src/models/StripePaymentIntent.js.map +1 -1
  219. package/dist/src/models/Ticket.d.ts +2 -2
  220. package/dist/src/models/Ticket.d.ts.map +1 -1
  221. package/dist/src/models/Ticket.js +23 -23
  222. package/dist/src/models/Ticket.js.map +1 -1
  223. package/dist/src/models/Token.d.ts +3 -3
  224. package/dist/src/models/Token.d.ts.map +1 -1
  225. package/dist/src/models/Token.js +27 -27
  226. package/dist/src/models/Token.js.map +1 -1
  227. package/dist/src/models/Token.test.js +11 -11
  228. package/dist/src/models/UsedRegisterCode.d.ts +1 -1
  229. package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
  230. package/dist/src/models/UsedRegisterCode.js +10 -10
  231. package/dist/src/models/UsedRegisterCode.js.map +1 -1
  232. package/dist/src/models/User.d.ts +4 -4
  233. package/dist/src/models/User.d.ts.map +1 -1
  234. package/dist/src/models/User.js +53 -51
  235. package/dist/src/models/User.js.map +1 -1
  236. package/dist/src/models/UserPermissions.d.ts +3 -3
  237. package/dist/src/models/UserPermissions.d.ts.map +1 -1
  238. package/dist/src/models/UserPermissions.js +12 -12
  239. package/dist/src/models/UserPermissions.js.map +1 -1
  240. package/dist/src/models/Webshop.d.ts +1 -1
  241. package/dist/src/models/Webshop.d.ts.map +1 -1
  242. package/dist/src/models/Webshop.js +23 -23
  243. package/dist/src/models/Webshop.js.map +1 -1
  244. package/dist/src/models/WebshopDiscountCode.d.ts +1 -1
  245. package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -1
  246. package/dist/src/models/WebshopDiscountCode.js +16 -16
  247. package/dist/src/models/WebshopDiscountCode.js.map +1 -1
  248. package/dist/src/models/addresses/City.d.ts.map +1 -1
  249. package/dist/src/models/addresses/City.js +9 -9
  250. package/dist/src/models/addresses/City.js.map +1 -1
  251. package/dist/src/models/addresses/PostalCode.d.ts.map +1 -1
  252. package/dist/src/models/addresses/PostalCode.js +11 -11
  253. package/dist/src/models/addresses/PostalCode.js.map +1 -1
  254. package/dist/src/models/addresses/PostalCode.test.js +22 -22
  255. package/dist/src/models/addresses/PostalCode.test.js.map +1 -1
  256. package/dist/src/models/addresses/Province.d.ts.map +1 -1
  257. package/dist/src/models/addresses/Province.js +5 -5
  258. package/dist/src/models/addresses/Province.js.map +1 -1
  259. package/dist/src/models/addresses/Street.d.ts.map +1 -1
  260. package/dist/src/models/addresses/Street.js +6 -6
  261. package/dist/src/models/addresses/Street.js.map +1 -1
  262. package/dist/src/models/index.d.ts +46 -46
  263. package/dist/src/models/index.d.ts.map +1 -1
  264. package/dist/src/models/index.js +0 -1
  265. package/dist/src/models/index.js.map +1 -1
  266. package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -1
  267. package/dist/src/structures/OrganizationServerMetaData.js +4 -4
  268. package/dist/src/structures/OrganizationServerMetaData.js.map +1 -1
  269. package/dist/tests/jest.global.setup.d.ts.map +1 -1
  270. package/dist/tests/jest.global.setup.js +15 -13
  271. package/dist/tests/jest.global.setup.js.map +1 -1
  272. package/dist/tests/jest.setup.js +3 -1
  273. package/dist/tests/jest.setup.js.map +1 -1
  274. package/dist/tsconfig.tsbuildinfo +1 -0
  275. package/package.json +3 -3
  276. package/src/factories/AddressFactory.ts +17 -17
  277. package/src/factories/EmergencyContactFactory.ts +30 -31
  278. package/src/factories/GroupFactory.ts +30 -30
  279. package/src/factories/MemberFactory.ts +41 -38
  280. package/src/factories/OrganizationFactory.ts +15 -15
  281. package/src/factories/ParentFactory.ts +24 -24
  282. package/src/factories/RecordFactory.ts +5 -4
  283. package/src/factories/RegisterCodeFactory.ts +7 -7
  284. package/src/factories/RegistrationFactory.ts +16 -16
  285. package/src/factories/RegistrationPeriodFactory.ts +5 -5
  286. package/src/factories/UserFactory.ts +20 -19
  287. package/src/factories/WebshopFactory.ts +14 -14
  288. package/src/helpers/DNSValidator.ts +89 -84
  289. package/src/helpers/EmailBuilder.ts +141 -135
  290. package/src/helpers/GroupBuilder.ts +181 -181
  291. package/src/helpers/Handlebars.ts +57 -54
  292. package/src/helpers/MemberMerger.test.ts +702 -702
  293. package/src/helpers/MemberMerger.ts +83 -77
  294. package/src/helpers/RateLimiter.ts +25 -27
  295. package/src/helpers/SetupStepsUpdater.ts +402 -0
  296. package/src/helpers/WebshopCounter.test.ts +12 -12
  297. package/src/helpers/WebshopCounter.ts +20 -19
  298. package/src/index.ts +20 -19
  299. package/src/migrations/1605262045-import-postcodes.ts +59 -63
  300. package/src/migrations/1605262046-import-postcodes-nl.ts +41 -43
  301. package/src/models/BalanceItem.ts +173 -172
  302. package/src/models/BalanceItemPayment.ts +32 -33
  303. package/src/models/BuckarooPayment.ts +7 -7
  304. package/src/models/CachedOutstandingBalance.ts +98 -99
  305. package/src/models/Document.ts +90 -87
  306. package/src/models/DocumentTemplate.ts +207 -198
  307. package/src/models/Email.ts +198 -200
  308. package/src/models/EmailRecipient.ts +38 -39
  309. package/src/models/EmailTemplate.ts +36 -37
  310. package/src/models/EmailVerificationCode.ts +146 -142
  311. package/src/models/Event.ts +53 -53
  312. package/src/models/Group.ts +136 -123
  313. package/src/models/Image.ts +48 -48
  314. package/src/models/Member.ts +277 -275
  315. package/src/models/MemberPlatformMembership.ts +71 -71
  316. package/src/models/MemberResponsibilityRecord.ts +32 -32
  317. package/src/models/MergedMember.ts +77 -77
  318. package/src/models/MolliePayment.ts +7 -7
  319. package/src/models/MollieToken.ts +131 -126
  320. package/src/models/OneTimeToken.ts +40 -39
  321. package/src/models/Order.ts +379 -372
  322. package/src/models/Organization.ts +332 -325
  323. package/src/models/OrganizationRegistrationPeriod.ts +50 -50
  324. package/src/models/PasswordToken.ts +42 -42
  325. package/src/models/PayconiqPayment.ts +80 -76
  326. package/src/models/Payment.ts +86 -86
  327. package/src/models/Platform.ts +21 -22
  328. package/src/models/RegisterCode.ts +26 -26
  329. package/src/models/Registration.ts +167 -168
  330. package/src/models/RegistrationPeriod.ts +29 -29
  331. package/src/models/STCredit.ts +24 -25
  332. package/src/models/STInvoice.ts +34 -34
  333. package/src/models/STPackage.ts +143 -136
  334. package/src/models/STPendingInvoice.ts +26 -26
  335. package/src/models/StripeAccount.ts +27 -27
  336. package/src/models/StripeCheckoutSession.ts +10 -10
  337. package/src/models/StripePaymentIntent.ts +10 -10
  338. package/src/models/Ticket.ts +51 -52
  339. package/src/models/Token.test.ts +13 -13
  340. package/src/models/Token.ts +64 -63
  341. package/src/models/UsedRegisterCode.ts +20 -21
  342. package/src/models/User.ts +148 -144
  343. package/src/models/UserPermissions.ts +25 -28
  344. package/src/models/Webshop.ts +53 -53
  345. package/src/models/WebshopDiscountCode.ts +33 -33
  346. package/src/models/addresses/City.ts +12 -12
  347. package/src/models/addresses/PostalCode.test.ts +68 -69
  348. package/src/models/addresses/PostalCode.ts +57 -57
  349. package/src/models/addresses/Province.ts +8 -8
  350. package/src/models/addresses/Street.ts +10 -12
  351. package/src/models/index.ts +54 -55
  352. package/src/structures/OrganizationServerMetaData.ts +36 -36
@@ -1,6 +1,6 @@
1
1
  import { column, ManyToOneRelation, Model } from '@simonbackx/simple-database';
2
2
  import { BalanceItemStatus } from '@stamhoofd/structures';
3
- import { v4 as uuidv4 } from "uuid";
3
+ import { v4 as uuidv4 } from 'uuid';
4
4
 
5
5
  import { BalanceItem, Organization, Payment } from './';
6
6
 
@@ -9,58 +9,58 @@ import { BalanceItem, Organization, Payment } from './';
9
9
  * It also keeps track of how much a given payment is split between multiple balance items, which makes it possible to pay a balance item partially.
10
10
  */
11
11
  export class BalanceItemPayment extends Model {
12
- static table = "balance_item_payments"
12
+ static table = 'balance_item_payments';
13
13
 
14
14
  @column({
15
- primary: true, type: "string", beforeSave(value) {
15
+ primary: true, type: 'string', beforeSave(value) {
16
16
  return value ?? uuidv4();
17
- }
17
+ },
18
18
  })
19
19
  id!: string;
20
20
 
21
- @column({ type: "string" })
22
- organizationId: string
21
+ @column({ type: 'string' })
22
+ organizationId: string;
23
23
 
24
- @column({ type: "string", foreignKey: BalanceItemPayment.payment })
24
+ @column({ type: 'string', foreignKey: BalanceItemPayment.payment })
25
25
  paymentId: string;
26
26
 
27
- @column({ type: "string", foreignKey: BalanceItemPayment.balanceItem })
27
+ @column({ type: 'string', foreignKey: BalanceItemPayment.balanceItem })
28
28
  balanceItemId: string;
29
29
 
30
30
  /**
31
31
  * Part of price of the payment that is used to 'pay' the balance item
32
32
  */
33
- @column({ type: "integer" })
34
- price = 0
33
+ @column({ type: 'integer' })
34
+ price = 0;
35
35
 
36
36
  @column({
37
- type: "datetime", beforeSave(old?: any) {
37
+ type: 'datetime', beforeSave(old?: any) {
38
38
  if (old !== undefined) {
39
39
  return old;
40
40
  }
41
- const date = new Date()
42
- date.setMilliseconds(0)
43
- return date
44
- }
41
+ const date = new Date();
42
+ date.setMilliseconds(0);
43
+ return date;
44
+ },
45
45
  })
46
- createdAt: Date
46
+ createdAt: Date;
47
47
 
48
48
  @column({
49
- type: "datetime", beforeSave() {
50
- const date = new Date()
51
- date.setMilliseconds(0)
52
- return date
49
+ type: 'datetime', beforeSave() {
50
+ const date = new Date();
51
+ date.setMilliseconds(0);
52
+ return date;
53
53
  },
54
- skipUpdate: true
54
+ skipUpdate: true,
55
55
  })
56
- updatedAt: Date
56
+ updatedAt: Date;
57
57
 
58
- static balanceItem = new ManyToOneRelation(BalanceItem, "balanceItem")
59
- static payment = new ManyToOneRelation(Payment, "payment")
58
+ static balanceItem = new ManyToOneRelation(BalanceItem, 'balanceItem');
59
+ static payment = new ManyToOneRelation(Payment, 'payment');
60
60
 
61
61
  async markPaid(this: BalanceItemPayment & Loaded<typeof BalanceItemPayment.balanceItem> & Loaded<typeof BalanceItemPayment.payment>, organization: Organization) {
62
62
  // Update cached amountPaid of the balance item (this will get overwritten later, but we need it to calculate the status)
63
- this.balanceItem.pricePaid += this.price
63
+ this.balanceItem.pricePaid += this.price;
64
64
 
65
65
  // Update status
66
66
  const old = this.balanceItem.status;
@@ -70,9 +70,10 @@ export class BalanceItemPayment extends Model {
70
70
  // Do logic of balance item
71
71
  if (this.balanceItem.status === BalanceItemStatus.Paid && old !== BalanceItemStatus.Paid) {
72
72
  // Only call markPaid once (if it wasn't (partially) paid before)
73
- await this.balanceItem.markPaid(this.payment, organization)
74
- } else {
75
- await this.balanceItem.markUpdated(this.payment, organization)
73
+ await this.balanceItem.markPaid(this.payment, organization);
74
+ }
75
+ else {
76
+ await this.balanceItem.markUpdated(this.payment, organization);
76
77
  }
77
78
  }
78
79
 
@@ -80,20 +81,18 @@ export class BalanceItemPayment extends Model {
80
81
  * Call this once a earlier succeeded payment is no longer succeeded
81
82
  */
82
83
  async undoPaid(this: BalanceItemPayment & Loaded<typeof BalanceItemPayment.balanceItem> & Loaded<typeof BalanceItemPayment.payment>, organization: Organization) {
83
- await this.balanceItem.undoPaid(this.payment, organization)
84
+ await this.balanceItem.undoPaid(this.payment, organization);
84
85
  }
85
86
 
86
87
  async markFailed(this: BalanceItemPayment & Loaded<typeof BalanceItemPayment.balanceItem> & Loaded<typeof BalanceItemPayment.payment>, organization: Organization) {
87
88
  // Do logic of balance item
88
- await this.balanceItem.markFailed(this.payment, organization)
89
+ await this.balanceItem.markFailed(this.payment, organization);
89
90
  }
90
91
 
91
92
  async undoFailed(this: BalanceItemPayment & Loaded<typeof BalanceItemPayment.balanceItem> & Loaded<typeof BalanceItemPayment.payment>, organization: Organization) {
92
93
  // Reactivate deleted items
93
- await this.balanceItem.undoFailed(this.payment, organization)
94
+ await this.balanceItem.undoFailed(this.payment, organization);
94
95
  }
95
-
96
96
  }
97
97
 
98
98
  type Loaded<T> = (T) extends ManyToOneRelation<infer Key, infer Model> ? Record<Key, Model> : never;
99
-
@@ -1,19 +1,19 @@
1
- import { column,Model } from "@simonbackx/simple-database";
2
- import { v4 as uuidv4 } from "uuid";
1
+ import { column, Model } from '@simonbackx/simple-database';
2
+ import { v4 as uuidv4 } from 'uuid';
3
3
 
4
4
  export class BuckarooPayment extends Model {
5
- static table = "buckaroo_payments";
5
+ static table = 'buckaroo_payments';
6
6
 
7
7
  @column({
8
- primary: true, type: "string", beforeSave(value) {
8
+ primary: true, type: 'string', beforeSave(value) {
9
9
  return value ?? uuidv4();
10
- }
10
+ },
11
11
  })
12
12
  id!: string;
13
13
 
14
- @column({ type: "string" })
14
+ @column({ type: 'string' })
15
15
  paymentId: string;
16
16
 
17
- @column({ type: "string" })
17
+ @column({ type: 'string' })
18
18
  transactionKey: string;
19
19
  }
@@ -1,30 +1,29 @@
1
1
  import { column, Model, SQLResultNamespacedRow } from '@simonbackx/simple-database';
2
2
  import { SQL, SQLAlias, SQLCalculation, SQLMinusSign, SQLMultiplicationSign, SQLSelect, SQLSelectAs, SQLSum, SQLWhere } from '@stamhoofd/sql';
3
3
  import { BalanceItemStatus } from '@stamhoofd/structures';
4
- import { v4 as uuidv4 } from "uuid";
4
+ import { v4 as uuidv4 } from 'uuid';
5
5
  import { BalanceItem } from './BalanceItem';
6
6
 
7
-
8
- export type CachedOutstandingBalanceType = 'organization'|'member'|'user'
7
+ export type CachedOutstandingBalanceType = 'organization' | 'member' | 'user';
9
8
 
10
9
  /**
11
10
  * Keeps track of how much a member/user owes or needs to be reimbursed.
12
11
  */
13
12
  export class CachedOutstandingBalance extends Model {
14
- static table = "cached_outstanding_balances"
13
+ static table = 'cached_outstanding_balances';
15
14
 
16
15
  @column({
17
- primary: true, type: "string", beforeSave(value) {
16
+ primary: true, type: 'string', beforeSave(value) {
18
17
  return value ?? uuidv4();
19
- }
18
+ },
20
19
  })
21
20
  id!: string;
22
21
 
23
- @column({ type: "string" })
24
- organizationId: string
22
+ @column({ type: 'string' })
23
+ organizationId: string;
25
24
 
26
- @column({ type: "string" })
27
- objectId: string
25
+ @column({ type: 'string' })
26
+ objectId: string;
28
27
 
29
28
  /**
30
29
  * Defines which field to select
@@ -32,43 +31,43 @@ export class CachedOutstandingBalance extends Model {
32
31
  * member: member id
33
32
  * user: all balance items with that user id, but without a member id
34
33
  */
35
- @column({ type: "string" })
36
- objectType: CachedOutstandingBalanceType
34
+ @column({ type: 'string' })
35
+ objectType: CachedOutstandingBalanceType;
37
36
 
38
- @column({ type: "integer" })
39
- amount = 0
37
+ @column({ type: 'integer' })
38
+ amount = 0;
40
39
 
41
- @column({ type: "integer" })
42
- amountPending = 0
40
+ @column({ type: 'integer' })
41
+ amountPending = 0;
43
42
 
44
43
  @column({
45
- type: "datetime", beforeSave(old?: any) {
44
+ type: 'datetime', beforeSave(old?: any) {
46
45
  if (old !== undefined) {
47
46
  return old;
48
47
  }
49
- const date = new Date()
50
- date.setMilliseconds(0)
51
- return date
52
- }
48
+ const date = new Date();
49
+ date.setMilliseconds(0);
50
+ return date;
51
+ },
53
52
  })
54
- createdAt: Date
53
+ createdAt: Date;
55
54
 
56
55
  @column({
57
- type: "datetime", beforeSave() {
58
- const date = new Date()
59
- date.setMilliseconds(0)
60
- return date
56
+ type: 'datetime', beforeSave() {
57
+ const date = new Date();
58
+ date.setMilliseconds(0);
59
+ return date;
61
60
  },
62
- skipUpdate: true
61
+ skipUpdate: true,
63
62
  })
64
- updatedAt: Date
63
+ updatedAt: Date;
65
64
 
66
- static async getForObjects(objectIds: string[], limitOrganizationId?: string|null): Promise<CachedOutstandingBalance[]> {
65
+ static async getForObjects(objectIds: string[], limitOrganizationId?: string | null): Promise<CachedOutstandingBalance[]> {
67
66
  const query = this.select()
68
- .where("objectId", objectIds);
67
+ .where('objectId', objectIds);
69
68
 
70
69
  if (limitOrganizationId) {
71
- query.where("organizationId", limitOrganizationId);
70
+ query.where('organizationId', limitOrganizationId);
72
71
  }
73
72
 
74
73
  return await query.fetch();
@@ -90,97 +89,97 @@ export class CachedOutstandingBalance extends Model {
90
89
 
91
90
  private static async fetchForObjects(organizationId: string, objectIds: string[], columnName: string, customWhere?: SQLWhere) {
92
91
  const query = SQL.select(
93
- SQL.column(columnName),
94
- new SQLSelectAs(
95
- new SQLCalculation(
96
- new SQLSum(
97
- new SQLCalculation(
98
- SQL.column('unitPrice'),
99
- new SQLMultiplicationSign(),
100
- SQL.column('amount')
101
- )
102
- ),
103
- new SQLMinusSign(),
104
- new SQLSum(
105
- SQL.column('pricePaid')
106
- ),
92
+ SQL.column(columnName),
93
+ new SQLSelectAs(
94
+ new SQLCalculation(
95
+ new SQLSum(
96
+ new SQLCalculation(
97
+ SQL.column('unitPrice'),
98
+ new SQLMultiplicationSign(),
99
+ SQL.column('amount'),
100
+ ),
107
101
  ),
108
- new SQLAlias('data__amount')
109
- ),
110
- new SQLSelectAs(
102
+ new SQLMinusSign(),
111
103
  new SQLSum(
112
- SQL.column('pricePending')
104
+ SQL.column('pricePaid'),
113
105
  ),
114
- new SQLAlias('data__amountPending')
115
- )
116
- )
106
+ ),
107
+ new SQLAlias('data__amount'),
108
+ ),
109
+ new SQLSelectAs(
110
+ new SQLSum(
111
+ SQL.column('pricePending'),
112
+ ),
113
+ new SQLAlias('data__amountPending'),
114
+ ),
115
+ )
117
116
  .from(BalanceItem.table)
118
- .where("organizationId", organizationId)
117
+ .where('organizationId', organizationId)
119
118
  .where(columnName, objectIds)
120
- .whereNot("status", BalanceItemStatus.Hidden)
119
+ .whereNot('status', BalanceItemStatus.Hidden)
121
120
  .groupBy(SQL.column(columnName));
122
-
121
+
123
122
  if (customWhere) {
124
123
  query.where(customWhere);
125
124
  }
126
125
 
127
126
  const result = await query.fetch();
128
127
 
129
- const results: [string, {amount: number, amountPending: number}][] = [];
128
+ const results: [string, { amount: number; amountPending: number }][] = [];
130
129
  for (const row of result) {
131
- if (!row["data"]) {
132
- throw new Error("Invalid data namespace");
130
+ if (!row['data']) {
131
+ throw new Error('Invalid data namespace');
133
132
  }
134
133
 
135
134
  if (!row[BalanceItem.table]) {
136
- throw new Error("Invalid "+ BalanceItem.table +" namespace");
135
+ throw new Error('Invalid ' + BalanceItem.table + ' namespace');
137
136
  }
138
137
 
139
138
  const objectId = row[BalanceItem.table][columnName];
140
- const amount = row["data"]["amount"];
141
- const amountPending = row["data"]["amountPending"];
139
+ const amount = row['data']['amount'];
140
+ const amountPending = row['data']['amountPending'];
142
141
 
143
- if (typeof objectId !== "string") {
144
- throw new Error("Invalid objectId");
142
+ if (typeof objectId !== 'string') {
143
+ throw new Error('Invalid objectId');
145
144
  }
146
145
 
147
- if (typeof amount !== "number") {
148
- throw new Error("Invalid amount");
146
+ if (typeof amount !== 'number') {
147
+ throw new Error('Invalid amount');
149
148
  }
150
149
 
151
- if (typeof amountPending !== "number") {
152
- throw new Error("Invalid amountPending");
150
+ if (typeof amountPending !== 'number') {
151
+ throw new Error('Invalid amountPending');
153
152
  }
154
153
 
155
- results.push([objectId, {amount, amountPending}]);
154
+ results.push([objectId, { amount, amountPending }]);
156
155
  }
157
156
 
158
157
  // Add missing object ids (with 0 amount, otherwise we don't reset the amounts back to zero when all the balance items are hidden)
159
158
  for (const objectId of objectIds) {
160
159
  if (!results.find(([id]) => id === objectId)) {
161
- results.push([objectId, {amount: 0, amountPending: 0}]);
160
+ results.push([objectId, { amount: 0, amountPending: 0 }]);
162
161
  }
163
162
  }
164
-
163
+
165
164
  return results;
166
165
  }
167
166
 
168
- private static async setForResults(organizationId: string, result: [string, {amount: number, amountPending: number}][], objectType: CachedOutstandingBalanceType) {
167
+ private static async setForResults(organizationId: string, result: [string, { amount: number; amountPending: number }][], objectType: CachedOutstandingBalanceType) {
169
168
  if (result.length === 0) {
170
169
  return;
171
170
  }
172
171
  const query = SQL.insert(this.table)
173
172
  .columns(
174
- "id",
175
- "organizationId",
176
- "objectId",
177
- "objectType",
178
- "amount",
179
- "amountPending",
180
- "createdAt",
181
- "updatedAt"
173
+ 'id',
174
+ 'organizationId',
175
+ 'objectId',
176
+ 'objectType',
177
+ 'amount',
178
+ 'amountPending',
179
+ 'createdAt',
180
+ 'updatedAt',
182
181
  )
183
- .values(...result.map(([objectId, {amount, amountPending}]) => {
182
+ .values(...result.map(([objectId, { amount, amountPending }]) => {
184
183
  return [
185
184
  uuidv4(),
186
185
  organizationId,
@@ -189,41 +188,41 @@ export class CachedOutstandingBalance extends Model {
189
188
  amount,
190
189
  amountPending,
191
190
  new Date(),
192
- new Date()
193
- ]
191
+ new Date(),
192
+ ];
194
193
  }))
195
194
  .as('v')
196
195
  .onDuplicateKeyUpdate(
197
- SQL.assignment("amount", SQL.column("v", "amount")),
198
- SQL.assignment("amountPending", SQL.column("v", "amountPending")),
199
- SQL.assignment("updatedAt", SQL.column("v", "updatedAt"))
200
- )
196
+ SQL.assignment('amount', SQL.column('v', 'amount')),
197
+ SQL.assignment('amountPending', SQL.column('v', 'amountPending')),
198
+ SQL.assignment('updatedAt', SQL.column('v', 'updatedAt')),
199
+ );
201
200
 
202
- await query.insert()
201
+ await query.insert();
203
202
  }
204
203
 
205
204
  static async updateForOrganizations(organizationId: string, organizationIds: string[]) {
206
205
  if (organizationIds.length === 0) {
207
206
  return;
208
207
  }
209
- const results = await this.fetchForObjects(organizationId, organizationIds, "payingOrganizationId");
210
- await this.setForResults(organizationId, results, "organization");
208
+ const results = await this.fetchForObjects(organizationId, organizationIds, 'payingOrganizationId');
209
+ await this.setForResults(organizationId, results, 'organization');
211
210
  }
212
211
 
213
212
  static async updateForMembers(organizationId: string, memberIds: string[]) {
214
213
  if (memberIds.length === 0) {
215
214
  return;
216
215
  }
217
- const results = await this.fetchForObjects(organizationId, memberIds, "memberId");
218
- await this.setForResults(organizationId, results, "member");
216
+ const results = await this.fetchForObjects(organizationId, memberIds, 'memberId');
217
+ await this.setForResults(organizationId, results, 'member');
219
218
  }
220
219
 
221
220
  static async updateForUsers(organizationId: string, userIds: string[]) {
222
221
  if (userIds.length === 0) {
223
222
  return;
224
223
  }
225
- const results = await this.fetchForObjects(organizationId, userIds, "userId", SQL.where("memberId", null));
226
- await this.setForResults(organizationId, results, "user");
224
+ const results = await this.fetchForObjects(organizationId, userIds, 'userId', SQL.where('memberId', null));
225
+ await this.setForResults(organizationId, results, 'user');
227
226
  }
228
227
 
229
228
  /**
@@ -231,16 +230,16 @@ export class CachedOutstandingBalance extends Model {
231
230
  */
232
231
  static select() {
233
232
  const transformer = (row: SQLResultNamespacedRow): CachedOutstandingBalance => {
234
- const d = (this as typeof CachedOutstandingBalance & typeof Model).fromRow(row[this.table] as any) as CachedOutstandingBalance|undefined
233
+ const d = (this as typeof CachedOutstandingBalance & typeof Model).fromRow(row[this.table] as any) as CachedOutstandingBalance | undefined;
235
234
 
236
235
  if (!d) {
237
- throw new Error("EmailTemplate not found")
236
+ throw new Error('EmailTemplate not found');
238
237
  }
239
238
 
240
239
  return d;
241
- }
242
-
243
- const select = new SQLSelect(transformer, SQL.wildcard())
244
- return select.from(SQL.table(this.table))
240
+ };
241
+
242
+ const select = new SQLSelect(transformer, SQL.wildcard());
243
+ return select.from(SQL.table(this.table));
245
244
  }
246
245
  }