@stamhoofd/models 2.1.1

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 (481) hide show
  1. package/dist/src/assets/Metropolis-Black.woff2 +0 -0
  2. package/dist/src/assets/Metropolis-BlackItalic.woff2 +0 -0
  3. package/dist/src/assets/Metropolis-Bold.woff2 +0 -0
  4. package/dist/src/assets/Metropolis-BoldItalic.woff2 +0 -0
  5. package/dist/src/assets/Metropolis-ExtraBold.woff2 +0 -0
  6. package/dist/src/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
  7. package/dist/src/assets/Metropolis-ExtraLight.woff2 +0 -0
  8. package/dist/src/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
  9. package/dist/src/assets/Metropolis-Light.woff2 +0 -0
  10. package/dist/src/assets/Metropolis-LightItalic.woff2 +0 -0
  11. package/dist/src/assets/Metropolis-Medium.woff2 +0 -0
  12. package/dist/src/assets/Metropolis-MediumItalic.woff2 +0 -0
  13. package/dist/src/assets/Metropolis-Regular.woff2 +0 -0
  14. package/dist/src/assets/Metropolis-RegularItalic.woff2 +0 -0
  15. package/dist/src/assets/Metropolis-SemiBold.woff2 +0 -0
  16. package/dist/src/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
  17. package/dist/src/assets/Metropolis-Thin.woff2 +0 -0
  18. package/dist/src/assets/Metropolis-ThinItalic.woff2 +0 -0
  19. package/dist/src/assets/assets/Metropolis-Black.woff2 +0 -0
  20. package/dist/src/assets/assets/Metropolis-BlackItalic.woff2 +0 -0
  21. package/dist/src/assets/assets/Metropolis-Bold.woff2 +0 -0
  22. package/dist/src/assets/assets/Metropolis-BoldItalic.woff2 +0 -0
  23. package/dist/src/assets/assets/Metropolis-ExtraBold.woff2 +0 -0
  24. package/dist/src/assets/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
  25. package/dist/src/assets/assets/Metropolis-ExtraLight.woff2 +0 -0
  26. package/dist/src/assets/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
  27. package/dist/src/assets/assets/Metropolis-Light.woff2 +0 -0
  28. package/dist/src/assets/assets/Metropolis-LightItalic.woff2 +0 -0
  29. package/dist/src/assets/assets/Metropolis-Medium.woff2 +0 -0
  30. package/dist/src/assets/assets/Metropolis-MediumItalic.woff2 +0 -0
  31. package/dist/src/assets/assets/Metropolis-Regular.woff2 +0 -0
  32. package/dist/src/assets/assets/Metropolis-RegularItalic.woff2 +0 -0
  33. package/dist/src/assets/assets/Metropolis-SemiBold.woff2 +0 -0
  34. package/dist/src/assets/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
  35. package/dist/src/assets/assets/Metropolis-Thin.woff2 +0 -0
  36. package/dist/src/assets/assets/Metropolis-ThinItalic.woff2 +0 -0
  37. package/dist/src/assets/assets/logo.png +0 -0
  38. package/dist/src/assets/logo.png +0 -0
  39. package/dist/src/factories/AddressFactory.d.ts +10 -0
  40. package/dist/src/factories/AddressFactory.d.ts.map +1 -0
  41. package/dist/src/factories/AddressFactory.js +42 -0
  42. package/dist/src/factories/AddressFactory.js.map +1 -0
  43. package/dist/src/factories/EmergencyContactFactory.d.ts +9 -0
  44. package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -0
  45. package/dist/src/factories/EmergencyContactFactory.js +42 -0
  46. package/dist/src/factories/EmergencyContactFactory.js.map +1 -0
  47. package/dist/src/factories/GroupFactory.d.ts +19 -0
  48. package/dist/src/factories/GroupFactory.d.ts.map +1 -0
  49. package/dist/src/factories/GroupFactory.js +52 -0
  50. package/dist/src/factories/GroupFactory.js.map +1 -0
  51. package/dist/src/factories/MemberFactory.d.ts +16 -0
  52. package/dist/src/factories/MemberFactory.d.ts.map +1 -0
  53. package/dist/src/factories/MemberFactory.js +98 -0
  54. package/dist/src/factories/MemberFactory.js.map +1 -0
  55. package/dist/src/factories/OrganizationFactory.d.ts +16 -0
  56. package/dist/src/factories/OrganizationFactory.d.ts.map +1 -0
  57. package/dist/src/factories/OrganizationFactory.js +40 -0
  58. package/dist/src/factories/OrganizationFactory.js.map +1 -0
  59. package/dist/src/factories/ParentFactory.d.ts +10 -0
  60. package/dist/src/factories/ParentFactory.d.ts.map +1 -0
  61. package/dist/src/factories/ParentFactory.js +44 -0
  62. package/dist/src/factories/ParentFactory.js.map +1 -0
  63. package/dist/src/factories/RecordFactory.d.ts +10 -0
  64. package/dist/src/factories/RecordFactory.d.ts.map +1 -0
  65. package/dist/src/factories/RecordFactory.js +14 -0
  66. package/dist/src/factories/RecordFactory.js.map +1 -0
  67. package/dist/src/factories/RegisterCodeFactory.d.ts +18 -0
  68. package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -0
  69. package/dist/src/factories/RegisterCodeFactory.js +19 -0
  70. package/dist/src/factories/RegisterCodeFactory.js.map +1 -0
  71. package/dist/src/factories/RegistrationFactory.d.ts +14 -0
  72. package/dist/src/factories/RegistrationFactory.d.ts.map +1 -0
  73. package/dist/src/factories/RegistrationFactory.js +26 -0
  74. package/dist/src/factories/RegistrationFactory.js.map +1 -0
  75. package/dist/src/factories/UserFactory.d.ts +21 -0
  76. package/dist/src/factories/UserFactory.d.ts.map +1 -0
  77. package/dist/src/factories/UserFactory.js +41 -0
  78. package/dist/src/factories/UserFactory.js.map +1 -0
  79. package/dist/src/factories/WebshopFactory.d.ts +16 -0
  80. package/dist/src/factories/WebshopFactory.d.ts.map +1 -0
  81. package/dist/src/factories/WebshopFactory.js +35 -0
  82. package/dist/src/factories/WebshopFactory.js.map +1 -0
  83. package/dist/src/helpers/DNSValidator.d.ts +6 -0
  84. package/dist/src/helpers/DNSValidator.d.ts.map +1 -0
  85. package/dist/src/helpers/DNSValidator.js +144 -0
  86. package/dist/src/helpers/DNSValidator.js.map +1 -0
  87. package/dist/src/helpers/EmailBuilder.d.ts +22 -0
  88. package/dist/src/helpers/EmailBuilder.d.ts.map +1 -0
  89. package/dist/src/helpers/EmailBuilder.js +100 -0
  90. package/dist/src/helpers/EmailBuilder.js.map +1 -0
  91. package/dist/src/helpers/GroupBuilder.d.ts +9 -0
  92. package/dist/src/helpers/GroupBuilder.d.ts.map +1 -0
  93. package/dist/src/helpers/GroupBuilder.js +382 -0
  94. package/dist/src/helpers/GroupBuilder.js.map +1 -0
  95. package/dist/src/helpers/Handlebars.d.ts +2 -0
  96. package/dist/src/helpers/Handlebars.d.ts.map +1 -0
  97. package/dist/src/helpers/Handlebars.js +192 -0
  98. package/dist/src/helpers/Handlebars.js.map +1 -0
  99. package/dist/src/helpers/InvoiceBuilder.d.ts +29 -0
  100. package/dist/src/helpers/InvoiceBuilder.d.ts.map +1 -0
  101. package/dist/src/helpers/InvoiceBuilder.js +406 -0
  102. package/dist/src/helpers/InvoiceBuilder.js.map +1 -0
  103. package/dist/src/helpers/InvoiceBuilder.test.d.ts +2 -0
  104. package/dist/src/helpers/InvoiceBuilder.test.d.ts.map +1 -0
  105. package/dist/src/helpers/InvoiceBuilder.test.js +52 -0
  106. package/dist/src/helpers/InvoiceBuilder.test.js.map +1 -0
  107. package/dist/src/helpers/RateLimiter.d.ts +27 -0
  108. package/dist/src/helpers/RateLimiter.d.ts.map +1 -0
  109. package/dist/src/helpers/RateLimiter.js +57 -0
  110. package/dist/src/helpers/RateLimiter.js.map +1 -0
  111. package/dist/src/helpers/WebshopCounter.d.ts +6 -0
  112. package/dist/src/helpers/WebshopCounter.d.ts.map +1 -0
  113. package/dist/src/helpers/WebshopCounter.js +36 -0
  114. package/dist/src/helpers/WebshopCounter.js.map +1 -0
  115. package/dist/src/helpers/WebshopCounter.test.d.ts +2 -0
  116. package/dist/src/helpers/WebshopCounter.test.d.ts.map +1 -0
  117. package/dist/src/helpers/WebshopCounter.test.js +17 -0
  118. package/dist/src/helpers/WebshopCounter.test.js.map +1 -0
  119. package/dist/src/index.d.ts +18 -0
  120. package/dist/src/index.d.ts.map +1 -0
  121. package/dist/src/index.js +23 -0
  122. package/dist/src/index.js.map +1 -0
  123. package/dist/src/migrations/1593773929-create-initial-tables.sql +634 -0
  124. package/dist/src/migrations/1605261999-gemeenten-tmp.sql +2820 -0
  125. package/dist/src/migrations/1605262045-import-postcodes.d.ts +16 -0
  126. package/dist/src/migrations/1605262045-import-postcodes.d.ts.map +1 -0
  127. package/dist/src/migrations/1605262045-import-postcodes.js +116 -0
  128. package/dist/src/migrations/1605262045-import-postcodes.js.map +1 -0
  129. package/dist/src/migrations/1605262046-import-postcodes-nl.d.ts +4 -0
  130. package/dist/src/migrations/1605262046-import-postcodes-nl.d.ts.map +1 -0
  131. package/dist/src/migrations/1605262046-import-postcodes-nl.js +83 -0
  132. package/dist/src/migrations/1605262046-import-postcodes-nl.js.map +1 -0
  133. package/dist/src/migrations/1605279038-drop-gemeenten-tmp.sql +1 -0
  134. package/dist/src/migrations/1648392491-default-templates.sql +9 -0
  135. package/dist/src/migrations/1651245707-default-templates-reminders.sql +6 -0
  136. package/dist/src/migrations/1708607340-tickets-deleted-at.sql +1 -0
  137. package/dist/src/migrations/1710459176-register-code-invoices.sql +3 -0
  138. package/dist/src/migrations/1712158247-discount-codes.sql +17 -0
  139. package/dist/src/migrations/1713178665-drop-invites.sql +1 -0
  140. package/dist/src/migrations/1713178666-drop-keychain.sql +1 -0
  141. package/dist/src/migrations/1713178667-drop-challenges.sql +1 -0
  142. package/dist/src/migrations/1713178668-drop-user-keys.sql +7 -0
  143. package/dist/src/migrations/1713178669-drop-organization-key.sql +2 -0
  144. package/dist/src/migrations/data/postcodes/nl/Drenthe +291 -0
  145. package/dist/src/migrations/data/postcodes/nl/Flevoland +107 -0
  146. package/dist/src/migrations/data/postcodes/nl/Friesland +518 -0
  147. package/dist/src/migrations/data/postcodes/nl/Gelderland +601 -0
  148. package/dist/src/migrations/data/postcodes/nl/Groningen +279 -0
  149. package/dist/src/migrations/data/postcodes/nl/Limburg +324 -0
  150. package/dist/src/migrations/data/postcodes/nl/Noord-Brabant +620 -0
  151. package/dist/src/migrations/data/postcodes/nl/Noord-Holland +566 -0
  152. package/dist/src/migrations/data/postcodes/nl/Overrijsel +344 -0
  153. package/dist/src/migrations/data/postcodes/nl/Utrecht +278 -0
  154. package/dist/src/migrations/data/postcodes/nl/Zeeland +179 -0
  155. package/dist/src/migrations/data/postcodes/nl/Zuid-Holland +662 -0
  156. package/dist/src/models/BalanceItem.d.ts +57 -0
  157. package/dist/src/models/BalanceItem.d.ts.map +1 -0
  158. package/dist/src/models/BalanceItem.js +346 -0
  159. package/dist/src/models/BalanceItem.js.map +1 -0
  160. package/dist/src/models/BalanceItemPayment.d.ts +31 -0
  161. package/dist/src/models/BalanceItemPayment.d.ts.map +1 -0
  162. package/dist/src/models/BalanceItemPayment.js +101 -0
  163. package/dist/src/models/BalanceItemPayment.js.map +1 -0
  164. package/dist/src/models/BuckarooPayment.d.ts +8 -0
  165. package/dist/src/models/BuckarooPayment.d.ts.map +1 -0
  166. package/dist/src/models/BuckarooPayment.js +24 -0
  167. package/dist/src/models/BuckarooPayment.js.map +1 -0
  168. package/dist/src/models/Document.d.ts +44 -0
  169. package/dist/src/models/Document.d.ts.map +1 -0
  170. package/dist/src/models/Document.js +194 -0
  171. package/dist/src/models/Document.js.map +1 -0
  172. package/dist/src/models/DocumentTemplate.d.ts +45 -0
  173. package/dist/src/models/DocumentTemplate.d.ts.map +1 -0
  174. package/dist/src/models/DocumentTemplate.js +533 -0
  175. package/dist/src/models/DocumentTemplate.js.map +1 -0
  176. package/dist/src/models/EmailTemplate.d.ts +22 -0
  177. package/dist/src/models/EmailTemplate.d.ts.map +1 -0
  178. package/dist/src/models/EmailTemplate.js +70 -0
  179. package/dist/src/models/EmailTemplate.js.map +1 -0
  180. package/dist/src/models/EmailVerificationCode.d.ts +60 -0
  181. package/dist/src/models/EmailVerificationCode.d.ts.map +1 -0
  182. package/dist/src/models/EmailVerificationCode.js +307 -0
  183. package/dist/src/models/EmailVerificationCode.js.map +1 -0
  184. package/dist/src/models/Group.d.ts +36 -0
  185. package/dist/src/models/Group.d.ts.map +1 -0
  186. package/dist/src/models/Group.js +231 -0
  187. package/dist/src/models/Group.js.map +1 -0
  188. package/dist/src/models/Image.d.ts +12 -0
  189. package/dist/src/models/Image.d.ts.map +1 -0
  190. package/dist/src/models/Image.js +137 -0
  191. package/dist/src/models/Image.js.map +1 -0
  192. package/dist/src/models/Member.d.ts +66 -0
  193. package/dist/src/models/Member.d.ts.map +1 -0
  194. package/dist/src/models/Member.js +309 -0
  195. package/dist/src/models/Member.js.map +1 -0
  196. package/dist/src/models/MemberResponsibilityRecord.d.ts +11 -0
  197. package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -0
  198. package/dist/src/models/MemberResponsibilityRecord.js +47 -0
  199. package/dist/src/models/MemberResponsibilityRecord.js.map +1 -0
  200. package/dist/src/models/MolliePayment.d.ts +8 -0
  201. package/dist/src/models/MolliePayment.d.ts.map +1 -0
  202. package/dist/src/models/MolliePayment.js +24 -0
  203. package/dist/src/models/MolliePayment.js.map +1 -0
  204. package/dist/src/models/MollieToken.d.ts +45 -0
  205. package/dist/src/models/MollieToken.d.ts.map +1 -0
  206. package/dist/src/models/MollieToken.js +333 -0
  207. package/dist/src/models/MollieToken.js.map +1 -0
  208. package/dist/src/models/OneTimeToken.d.ts +38 -0
  209. package/dist/src/models/OneTimeToken.d.ts.map +1 -0
  210. package/dist/src/models/OneTimeToken.js +126 -0
  211. package/dist/src/models/OneTimeToken.js.map +1 -0
  212. package/dist/src/models/Order.d.ts +99 -0
  213. package/dist/src/models/Order.d.ts.map +1 -0
  214. package/dist/src/models/Order.js +912 -0
  215. package/dist/src/models/Order.js.map +1 -0
  216. package/dist/src/models/Organization.d.ts +119 -0
  217. package/dist/src/models/Organization.d.ts.map +1 -0
  218. package/dist/src/models/Organization.js +900 -0
  219. package/dist/src/models/Organization.js.map +1 -0
  220. package/dist/src/models/OrganizationRegistrationPeriod.d.ts +14 -0
  221. package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -0
  222. package/dist/src/models/OrganizationRegistrationPeriod.js +62 -0
  223. package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -0
  224. package/dist/src/models/PasswordToken.d.ts +29 -0
  225. package/dist/src/models/PasswordToken.d.ts.map +1 -0
  226. package/dist/src/models/PasswordToken.js +118 -0
  227. package/dist/src/models/PasswordToken.js.map +1 -0
  228. package/dist/src/models/PayconiqPayment.d.ts +18 -0
  229. package/dist/src/models/PayconiqPayment.d.ts.map +1 -0
  230. package/dist/src/models/PayconiqPayment.js +216 -0
  231. package/dist/src/models/PayconiqPayment.js.map +1 -0
  232. package/dist/src/models/Payment.d.ts +62 -0
  233. package/dist/src/models/Payment.d.ts.map +1 -0
  234. package/dist/src/models/Payment.js +199 -0
  235. package/dist/src/models/Payment.js.map +1 -0
  236. package/dist/src/models/Platform.d.ts +15 -0
  237. package/dist/src/models/Platform.d.ts.map +1 -0
  238. package/dist/src/models/Platform.js +77 -0
  239. package/dist/src/models/Platform.js.map +1 -0
  240. package/dist/src/models/RegisterCode.d.ts +27 -0
  241. package/dist/src/models/RegisterCode.d.ts.map +1 -0
  242. package/dist/src/models/RegisterCode.js +162 -0
  243. package/dist/src/models/RegisterCode.js.map +1 -0
  244. package/dist/src/models/Registration.d.ts +47 -0
  245. package/dist/src/models/Registration.d.ts.map +1 -0
  246. package/dist/src/models/Registration.js +369 -0
  247. package/dist/src/models/Registration.js.map +1 -0
  248. package/dist/src/models/RegistrationPeriod.d.ts +15 -0
  249. package/dist/src/models/RegistrationPeriod.d.ts.map +1 -0
  250. package/dist/src/models/RegistrationPeriod.js +64 -0
  251. package/dist/src/models/RegistrationPeriod.js.map +1 -0
  252. package/dist/src/models/STCredit.d.ts +20 -0
  253. package/dist/src/models/STCredit.d.ts.map +1 -0
  254. package/dist/src/models/STCredit.js +129 -0
  255. package/dist/src/models/STCredit.js.map +1 -0
  256. package/dist/src/models/STInvoice.d.ts +51 -0
  257. package/dist/src/models/STInvoice.d.ts.map +1 -0
  258. package/dist/src/models/STInvoice.js +453 -0
  259. package/dist/src/models/STInvoice.js.map +1 -0
  260. package/dist/src/models/STPackage.d.ts +36 -0
  261. package/dist/src/models/STPackage.d.ts.map +1 -0
  262. package/dist/src/models/STPackage.js +300 -0
  263. package/dist/src/models/STPackage.js.map +1 -0
  264. package/dist/src/models/STPendingInvoice.d.ts +45 -0
  265. package/dist/src/models/STPendingInvoice.d.ts.map +1 -0
  266. package/dist/src/models/STPendingInvoice.js +284 -0
  267. package/dist/src/models/STPendingInvoice.js.map +1 -0
  268. package/dist/src/models/StripeAccount.d.ts +17 -0
  269. package/dist/src/models/StripeAccount.d.ts.map +1 -0
  270. package/dist/src/models/StripeAccount.js +81 -0
  271. package/dist/src/models/StripeAccount.js.map +1 -0
  272. package/dist/src/models/StripeCheckoutSession.d.ts +9 -0
  273. package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -0
  274. package/dist/src/models/StripeCheckoutSession.js +31 -0
  275. package/dist/src/models/StripeCheckoutSession.js.map +1 -0
  276. package/dist/src/models/StripePaymentIntent.d.ts +9 -0
  277. package/dist/src/models/StripePaymentIntent.d.ts.map +1 -0
  278. package/dist/src/models/StripePaymentIntent.js +31 -0
  279. package/dist/src/models/StripePaymentIntent.js.map +1 -0
  280. package/dist/src/models/Ticket.d.ts +61 -0
  281. package/dist/src/models/Ticket.d.ts.map +1 -0
  282. package/dist/src/models/Ticket.js +143 -0
  283. package/dist/src/models/Ticket.js.map +1 -0
  284. package/dist/src/models/Token.d.ts +49 -0
  285. package/dist/src/models/Token.d.ts.map +1 -0
  286. package/dist/src/models/Token.js +218 -0
  287. package/dist/src/models/Token.js.map +1 -0
  288. package/dist/src/models/Token.test.d.ts +2 -0
  289. package/dist/src/models/Token.test.d.ts.map +1 -0
  290. package/dist/src/models/Token.test.js +60 -0
  291. package/dist/src/models/Token.test.js.map +1 -0
  292. package/dist/src/models/UsedRegisterCode.d.ts +22 -0
  293. package/dist/src/models/UsedRegisterCode.d.ts.map +1 -0
  294. package/dist/src/models/UsedRegisterCode.js +158 -0
  295. package/dist/src/models/UsedRegisterCode.js.map +1 -0
  296. package/dist/src/models/User.d.ts +55 -0
  297. package/dist/src/models/User.d.ts.map +1 -0
  298. package/dist/src/models/User.js +314 -0
  299. package/dist/src/models/User.js.map +1 -0
  300. package/dist/src/models/UserPermissions.d.ts +15 -0
  301. package/dist/src/models/UserPermissions.d.ts.map +1 -0
  302. package/dist/src/models/UserPermissions.js +57 -0
  303. package/dist/src/models/UserPermissions.js.map +1 -0
  304. package/dist/src/models/Webshop.d.ts +44 -0
  305. package/dist/src/models/Webshop.d.ts.map +1 -0
  306. package/dist/src/models/Webshop.js +184 -0
  307. package/dist/src/models/Webshop.js.map +1 -0
  308. package/dist/src/models/WebshopDiscountCode.d.ts +18 -0
  309. package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -0
  310. package/dist/src/models/WebshopDiscountCode.js +88 -0
  311. package/dist/src/models/WebshopDiscountCode.js.map +1 -0
  312. package/dist/src/models/addresses/City.d.ts +14 -0
  313. package/dist/src/models/addresses/City.d.ts.map +1 -0
  314. package/dist/src/models/addresses/City.js +37 -0
  315. package/dist/src/models/addresses/City.js.map +1 -0
  316. package/dist/src/models/addresses/PostalCode.d.ts +20 -0
  317. package/dist/src/models/addresses/PostalCode.d.ts.map +1 -0
  318. package/dist/src/models/addresses/PostalCode.js +138 -0
  319. package/dist/src/models/addresses/PostalCode.js.map +1 -0
  320. package/dist/src/models/addresses/PostalCode.test.d.ts +2 -0
  321. package/dist/src/models/addresses/PostalCode.test.d.ts.map +1 -0
  322. package/dist/src/models/addresses/PostalCode.test.js +98 -0
  323. package/dist/src/models/addresses/PostalCode.test.js.map +1 -0
  324. package/dist/src/models/addresses/Province.d.ts +9 -0
  325. package/dist/src/models/addresses/Province.d.ts.map +1 -0
  326. package/dist/src/models/addresses/Province.js +24 -0
  327. package/dist/src/models/addresses/Province.js.map +1 -0
  328. package/dist/src/models/addresses/Street.d.ts +10 -0
  329. package/dist/src/models/addresses/Street.d.ts.map +1 -0
  330. package/dist/src/models/addresses/Street.js +26 -0
  331. package/dist/src/models/addresses/Street.js.map +1 -0
  332. package/dist/src/models/index.d.ts +37 -0
  333. package/dist/src/models/index.d.ts.map +1 -0
  334. package/dist/src/models/index.js +53 -0
  335. package/dist/src/models/index.js.map +1 -0
  336. package/dist/src/structures/OrganizationServerMetaData.d.ts +43 -0
  337. package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -0
  338. package/dist/src/structures/OrganizationServerMetaData.js +128 -0
  339. package/dist/src/structures/OrganizationServerMetaData.js.map +1 -0
  340. package/dist/tests/jest.global.setup.d.ts +3 -0
  341. package/dist/tests/jest.global.setup.d.ts.map +1 -0
  342. package/dist/tests/jest.global.setup.js +20 -0
  343. package/dist/tests/jest.global.setup.js.map +1 -0
  344. package/dist/tests/jest.setup.d.ts +2 -0
  345. package/dist/tests/jest.setup.d.ts.map +1 -0
  346. package/dist/tests/jest.setup.js +15 -0
  347. package/dist/tests/jest.setup.js.map +1 -0
  348. package/package.json +30 -0
  349. package/src/assets/Metropolis-Black.woff2 +0 -0
  350. package/src/assets/Metropolis-BlackItalic.woff2 +0 -0
  351. package/src/assets/Metropolis-Bold.woff2 +0 -0
  352. package/src/assets/Metropolis-BoldItalic.woff2 +0 -0
  353. package/src/assets/Metropolis-ExtraBold.woff2 +0 -0
  354. package/src/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
  355. package/src/assets/Metropolis-ExtraLight.woff2 +0 -0
  356. package/src/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
  357. package/src/assets/Metropolis-Light.woff2 +0 -0
  358. package/src/assets/Metropolis-LightItalic.woff2 +0 -0
  359. package/src/assets/Metropolis-Medium.woff2 +0 -0
  360. package/src/assets/Metropolis-MediumItalic.woff2 +0 -0
  361. package/src/assets/Metropolis-Regular.woff2 +0 -0
  362. package/src/assets/Metropolis-RegularItalic.woff2 +0 -0
  363. package/src/assets/Metropolis-SemiBold.woff2 +0 -0
  364. package/src/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
  365. package/src/assets/Metropolis-Thin.woff2 +0 -0
  366. package/src/assets/Metropolis-ThinItalic.woff2 +0 -0
  367. package/src/assets/logo.png +0 -0
  368. package/src/factories/AddressFactory.ts +42 -0
  369. package/src/factories/EmergencyContactFactory.ts +43 -0
  370. package/src/factories/GroupFactory.ts +66 -0
  371. package/src/factories/MemberFactory.ts +122 -0
  372. package/src/factories/OrganizationFactory.ts +45 -0
  373. package/src/factories/ParentFactory.ts +49 -0
  374. package/src/factories/RecordFactory.ts +12 -0
  375. package/src/factories/RegisterCodeFactory.ts +25 -0
  376. package/src/factories/RegistrationFactory.ts +32 -0
  377. package/src/factories/UserFactory.ts +66 -0
  378. package/src/factories/WebshopFactory.ts +43 -0
  379. package/src/helpers/DNSValidator.ts +153 -0
  380. package/src/helpers/EmailBuilder.ts +127 -0
  381. package/src/helpers/GroupBuilder.ts +438 -0
  382. package/src/helpers/Handlebars.ts +203 -0
  383. package/src/helpers/InvoiceBuilder.test.ts +57 -0
  384. package/src/helpers/InvoiceBuilder.ts +501 -0
  385. package/src/helpers/RateLimiter.ts +75 -0
  386. package/src/helpers/WebshopCounter.test.ts +16 -0
  387. package/src/helpers/WebshopCounter.ts +36 -0
  388. package/src/index.ts +21 -0
  389. package/src/migrations/1593773929-create-initial-tables.sql +634 -0
  390. package/src/migrations/1605261999-gemeenten-tmp.sql +2820 -0
  391. package/src/migrations/1605262045-import-postcodes.ts +132 -0
  392. package/src/migrations/1605262046-import-postcodes-nl.ts +97 -0
  393. package/src/migrations/1605279038-drop-gemeenten-tmp.sql +1 -0
  394. package/src/migrations/1648392491-default-templates.sql +9 -0
  395. package/src/migrations/1651245707-default-templates-reminders.sql +6 -0
  396. package/src/migrations/1708607340-tickets-deleted-at.sql +1 -0
  397. package/src/migrations/1710459176-register-code-invoices.sql +3 -0
  398. package/src/migrations/1712158247-discount-codes.sql +17 -0
  399. package/src/migrations/1713178665-drop-invites.sql +1 -0
  400. package/src/migrations/1713178666-drop-keychain.sql +1 -0
  401. package/src/migrations/1713178667-drop-challenges.sql +1 -0
  402. package/src/migrations/1713178668-drop-user-keys.sql +7 -0
  403. package/src/migrations/1713178669-drop-organization-key.sql +2 -0
  404. package/src/migrations/1714985451-user-nullable-organization-id.sql +2 -0
  405. package/src/migrations/1714985452-email-verification-code-nullable-organization-id.sql +2 -0
  406. package/src/migrations/1714985453-user-organization-permissions.sql +2 -0
  407. package/src/migrations/1714985454-user-organization-permissions.sql +2 -0
  408. package/src/migrations/1715079362-platform.sql +6 -0
  409. package/src/migrations/1715181649-registrations-organization-id.sql +2 -0
  410. package/src/migrations/1715181650-registrations-organization-id-fill.sql +1 -0
  411. package/src/migrations/1715181651-registrations-organization-id-drop-null.sql +2 -0
  412. package/src/migrations/1716117067-members-nullable-organization-id.sql +2 -0
  413. package/src/migrations/1719567581-registration-periods.sql +13 -0
  414. package/src/migrations/1719567582-organization-registration-periods.sql +13 -0
  415. package/src/migrations/1719567881-organization-periodId.sql +2 -0
  416. package/src/migrations/1719567882-groups-periodId.sql +2 -0
  417. package/src/migrations/1719567883-platform-periodId.sql +2 -0
  418. package/src/migrations/1719568079-default-period.sql +2 -0
  419. package/src/migrations/1719568080-set-default-period-platform.sql +1 -0
  420. package/src/migrations/1719568081-set-default-period-organizations.sql +1 -0
  421. package/src/migrations/1719568082-set-default-period-groups.sql +1 -0
  422. package/src/migrations/1719580828-registrations-periodId.sql +2 -0
  423. package/src/migrations/1719580829-set-default-period-registrations.sql +1 -0
  424. package/src/migrations/data/postcodes/nl/Drenthe +291 -0
  425. package/src/migrations/data/postcodes/nl/Flevoland +107 -0
  426. package/src/migrations/data/postcodes/nl/Friesland +518 -0
  427. package/src/migrations/data/postcodes/nl/Gelderland +601 -0
  428. package/src/migrations/data/postcodes/nl/Groningen +279 -0
  429. package/src/migrations/data/postcodes/nl/Limburg +324 -0
  430. package/src/migrations/data/postcodes/nl/Noord-Brabant +620 -0
  431. package/src/migrations/data/postcodes/nl/Noord-Holland +566 -0
  432. package/src/migrations/data/postcodes/nl/Overrijsel +344 -0
  433. package/src/migrations/data/postcodes/nl/Utrecht +278 -0
  434. package/src/migrations/data/postcodes/nl/Zeeland +179 -0
  435. package/src/migrations/data/postcodes/nl/Zuid-Holland +662 -0
  436. package/src/models/BalanceItem.ts +392 -0
  437. package/src/models/BalanceItemPayment.ts +106 -0
  438. package/src/models/BuckarooPayment.ts +19 -0
  439. package/src/models/Document.ts +203 -0
  440. package/src/models/DocumentTemplate.ts +583 -0
  441. package/src/models/EmailTemplate.ts +64 -0
  442. package/src/models/EmailVerificationCode.ts +352 -0
  443. package/src/models/Group.ts +293 -0
  444. package/src/models/Image.ts +147 -0
  445. package/src/models/Member.ts +386 -0
  446. package/src/models/MemberResponsibilityRecord.ts +39 -0
  447. package/src/models/MolliePayment.ts +19 -0
  448. package/src/models/MollieToken.ts +369 -0
  449. package/src/models/OneTimeToken.ts +131 -0
  450. package/src/models/Order.ts +1030 -0
  451. package/src/models/Organization.ts +1085 -0
  452. package/src/models/OrganizationRegistrationPeriod.ts +54 -0
  453. package/src/models/PasswordToken.ts +139 -0
  454. package/src/models/PayconiqPayment.ts +241 -0
  455. package/src/models/Payment.ts +216 -0
  456. package/src/models/Platform.ts +76 -0
  457. package/src/models/RegisterCode.ts +164 -0
  458. package/src/models/Registration.ts +405 -0
  459. package/src/models/RegistrationPeriod.ts +55 -0
  460. package/src/models/STCredit.ts +134 -0
  461. package/src/models/STInvoice.ts +507 -0
  462. package/src/models/STPackage.ts +324 -0
  463. package/src/models/STPendingInvoice.ts +308 -0
  464. package/src/models/StripeAccount.ts +71 -0
  465. package/src/models/StripeCheckoutSession.ts +22 -0
  466. package/src/models/StripePaymentIntent.ts +22 -0
  467. package/src/models/Ticket.ts +145 -0
  468. package/src/models/Token.test.ts +69 -0
  469. package/src/models/Token.ts +269 -0
  470. package/src/models/UsedRegisterCode.ts +166 -0
  471. package/src/models/User.ts +445 -0
  472. package/src/models/UserPermissions.ts +54 -0
  473. package/src/models/Webshop.ts +206 -0
  474. package/src/models/WebshopDiscountCode.ts +81 -0
  475. package/src/models/addresses/City.ts +31 -0
  476. package/src/models/addresses/PostalCode.test.ts +117 -0
  477. package/src/models/addresses/PostalCode.ts +164 -0
  478. package/src/models/addresses/Province.ts +20 -0
  479. package/src/models/addresses/Street.ts +25 -0
  480. package/src/models/index.ts +49 -0
  481. package/src/structures/OrganizationServerMetaData.ts +117 -0
@@ -0,0 +1,912 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Order = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const simple_database_1 = require("@simonbackx/simple-database");
6
+ const simple_errors_1 = require("@simonbackx/simple-errors");
7
+ const email_1 = require("@stamhoofd/email");
8
+ const queues_1 = require("@stamhoofd/queues");
9
+ const structures_1 = require("@stamhoofd/structures");
10
+ const utility_1 = require("@stamhoofd/utility");
11
+ const uuid_1 = require("uuid");
12
+ const EmailBuilder_1 = require("../helpers/EmailBuilder");
13
+ const WebshopCounter_1 = require("../helpers/WebshopCounter");
14
+ const _1 = require("./");
15
+ class Order extends simple_database_1.Model {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.paymentId = null;
19
+ this.userId = null;
20
+ this.number = null;
21
+ this.validAt = null;
22
+ this.status = structures_1.OrderStatus.Created;
23
+ }
24
+ getTransferReplacements() {
25
+ var _a, _b, _c, _d, _e, _f;
26
+ return {
27
+ nr: (_b = (_a = this.number) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "",
28
+ email: (_c = this.data.customer.email) !== null && _c !== void 0 ? _c : '',
29
+ phone: (_d = this.data.customer.phone) !== null && _d !== void 0 ? _d : '',
30
+ name: (_e = this.data.customer.name) !== null && _e !== void 0 ? _e : '',
31
+ naam: (_f = this.data.customer.name) !== null && _f !== void 0 ? _f : '',
32
+ };
33
+ }
34
+ getUrl() {
35
+ // Country locales are disabled on webshops (always the same country). But we need to add the language if it isn't the same as the organization default language
36
+ let locale = "";
37
+ if (this.data.consumerLanguage != this.webshop.organization.i18n.language) {
38
+ locale = "/" + this.data.consumerLanguage;
39
+ }
40
+ return "https://" + this.webshop.getHost() + locale + "/order/" + this.id;
41
+ }
42
+ generateBalanceDescription(webshop) {
43
+ if (!this.number) {
44
+ return 'Bestelling - ' + webshop.meta.name;
45
+ }
46
+ return 'Bestelling #' + this.number.toString() + ' - ' + webshop.meta.name;
47
+ }
48
+ /**
49
+ * Fetch an order
50
+ */
51
+ static async getForPayment(organizationId, paymentId) {
52
+ const order = (await this.where({ paymentId }, { limit: 1 }))[0];
53
+ if (!order) {
54
+ return;
55
+ }
56
+ if (organizationId !== null && order.organizationId !== organizationId) {
57
+ // Security check
58
+ return;
59
+ }
60
+ return order;
61
+ }
62
+ shouldIncludeStock() {
63
+ return this.status !== structures_1.OrderStatus.Canceled && this.status !== structures_1.OrderStatus.Deleted;
64
+ }
65
+ async shouldCreateTickets() {
66
+ if (this.status === structures_1.OrderStatus.Canceled || this.status === structures_1.OrderStatus.Deleted || this.id === undefined || this.id === null) {
67
+ return false;
68
+ }
69
+ if (this.data.paymentMethod === structures_1.PaymentMethod.PointOfSale || this.data.paymentMethod === structures_1.PaymentMethod.Unknown || this.data.totalPrice === 0) {
70
+ return true;
71
+ }
72
+ // Check we paid at least 1 cent
73
+ const allBalanceItems = await _1.BalanceItem.where({ orderId: this.id });
74
+ if (allBalanceItems.find(b => b.pricePaid > 0)) {
75
+ return true;
76
+ }
77
+ return false;
78
+ }
79
+ get totalToPay() {
80
+ if (this.status === structures_1.OrderStatus.Canceled || this.status === structures_1.OrderStatus.Deleted) {
81
+ return 0;
82
+ }
83
+ return this.data.totalPrice;
84
+ }
85
+ async undoPaymentFailed(_payment, _organization) {
86
+ if (this.status !== structures_1.OrderStatus.Deleted && this.status !== structures_1.OrderStatus.Canceled) {
87
+ this.markUpdated();
88
+ await this.save();
89
+ const webshop = await _1.Webshop.getByID(this.webshopId);
90
+ if (webshop) {
91
+ await this.setRelation(Order.webshop, webshop).updateTickets();
92
+ }
93
+ return;
94
+ }
95
+ console.log('Undoing payment failed for order ' + this.id);
96
+ this.markUpdated();
97
+ this.status = structures_1.OrderStatus.Created;
98
+ await this.save();
99
+ const webshop = await queues_1.QueueHandler.schedule("webshop-stock/" + this.webshopId, async () => {
100
+ // Fetch webshop inside queue to make sure the stock is up to date
101
+ const webshop = await _1.Webshop.getByID(this.webshopId);
102
+ if (!webshop) {
103
+ // ignore for now
104
+ console.error("Missing webshop with id " + this.webshopId + " in webshop stock queue for order " + this.id);
105
+ return;
106
+ }
107
+ await this.setRelation(Order.webshop, webshop).updateStock(); // readd reserved stock
108
+ return webshop;
109
+ });
110
+ if (webshop) {
111
+ await this.setRelation(Order.webshop, webshop).updateTickets();
112
+ }
113
+ }
114
+ async deleteOrderBecauseOfCreationError() {
115
+ this.status = structures_1.OrderStatus.Deleted;
116
+ await this.save();
117
+ const webshop = await queues_1.QueueHandler.schedule("webshop-stock/" + this.webshopId, async () => {
118
+ // Fetch webshop inside queue to make sure the stock is up to date
119
+ const webshop = await _1.Webshop.getByID(this.webshopId);
120
+ if (!webshop) {
121
+ // ignore for now
122
+ console.error("Missing webshop with id " + this.webshopId + " in webshop stock queue for order " + this.id);
123
+ return;
124
+ }
125
+ await this.setRelation(Order.webshop, webshop).updateStock(); // readd reserved stock
126
+ return webshop;
127
+ });
128
+ if (webshop) {
129
+ await this.setRelation(Order.webshop, webshop).updateTickets();
130
+ }
131
+ }
132
+ async onPaymentFailed(payment, organization) {
133
+ if (this.shouldIncludeStock()) {
134
+ this.markUpdated();
135
+ if (this.number === null) {
136
+ this.status = structures_1.OrderStatus.Deleted;
137
+ }
138
+ await this.save();
139
+ const webshop = await queues_1.QueueHandler.schedule("webshop-stock/" + this.webshopId, async () => {
140
+ // Fetch webshop inside queue to make sure the stock is up to date
141
+ const webshop = await _1.Webshop.getByID(this.webshopId);
142
+ if (!webshop) {
143
+ // ignore for now
144
+ console.error("Missing webshop with id " + this.webshopId + " in webshop stock queue for order " + this.id);
145
+ return;
146
+ }
147
+ await this.setRelation(Order.webshop, webshop).updateStock(); // remove reserved stock
148
+ return webshop;
149
+ });
150
+ if (webshop) {
151
+ await this.setRelation(Order.webshop, webshop).updateTickets();
152
+ }
153
+ // Send an email if the payment failed after 15 minutes being pending
154
+ // const difference = new Date().getTime() - this.createdAt.getTime()
155
+ // if (difference > 1000 * 60 * 30 && difference < 1000 * 60 * 60 * 24) {
156
+ // if (payment && payment.method !== PaymentMethod.Transfer && payment.method !== PaymentMethod.PointOfSale) {
157
+ // console.log('Marked order '+this.id+' as payment failed after ' + (difference / 1000 / 60).toFixed(1) + ' mins. Sending email.')
158
+ // const webshop = await Webshop.getByID(this.webshopId)
159
+ // if (!webshop) {
160
+ // console.error("Missing organization or webshop for order "+this.id)
161
+ // return
162
+ // }
163
+ // const { from, replyTo } = organization.getEmail(webshop.privateMeta.defaultEmailId, true)
164
+ // await this.setRelation(Order.webshop, webshop.setRelation(Order.organization, organization)).sendEmailTemplate({
165
+ // type: EmailTemplateType.OrderOnlinePaymentFailed,
166
+ // from,
167
+ // replyTo
168
+ // })
169
+ // } else {
170
+ // console.log('Marked order '+this.id+' as payment failed after ' + (difference / 1000 / 60).toFixed(1) + ' mins. Payment method not matching.')
171
+ // }
172
+ // } else {
173
+ // console.log('Marked order '+this.id+' as payment failed after ' + (difference / 1000 / 60).toFixed(1) + ' mins. Not sending email.')
174
+ // }
175
+ }
176
+ else {
177
+ this.markUpdated();
178
+ await this.save();
179
+ }
180
+ }
181
+ /**
182
+ * Adds or removes the order to the stock of the webshop (if it wasn't already included). If amounts were changed, only those
183
+ * changes will get added
184
+ * Should always happen in the webshop-stock queue to prevent multiple webshop writes at the same time
185
+ * + in combination with validation and reading the webshop
186
+ */
187
+ async updateStock(previousData = null) {
188
+ // Previous data?
189
+ var _a, _b, _c, _d, _e, _f;
190
+ // Add or delete this order from the stock?
191
+ const add = this.shouldIncludeStock();
192
+ let changed = false;
193
+ const discountCodeUsageMap = new Map();
194
+ if (previousData !== null) {
195
+ // Remove stock from old items without modifying old data
196
+ for (const item of previousData.cart.items) {
197
+ const product = this.webshop.products.find(p => p.id === item.product.id);
198
+ if (product) {
199
+ if (item.reservedAmount > 0) {
200
+ product.usedStock -= item.reservedAmount;
201
+ if (product.usedStock < 0) {
202
+ product.usedStock = 0;
203
+ }
204
+ changed = true;
205
+ }
206
+ // Product price
207
+ for (const [priceId, amount] of item.reservedPrices) {
208
+ const productPrice = product.prices.find(p => p.id === priceId);
209
+ if (productPrice) {
210
+ productPrice.usedStock -= amount;
211
+ if (productPrice.usedStock < 0) {
212
+ productPrice.usedStock = 0;
213
+ }
214
+ changed = true;
215
+ }
216
+ }
217
+ // Options
218
+ for (const [optionId, amount] of item.reservedOptions) {
219
+ const option = product.optionMenus.flatMap(om => om.options).find(o => o.id === optionId);
220
+ if (option) {
221
+ option.usedStock -= amount;
222
+ if (option.usedStock < 0) {
223
+ option.usedStock = 0;
224
+ }
225
+ changed = true;
226
+ }
227
+ }
228
+ // Seats
229
+ if (item.reservedSeats.length > 0) {
230
+ for (const seat of item.reservedSeats) {
231
+ // Only remove each seat once
232
+ const reservedIndex = product.reservedSeats.findIndex(s => s.equals(seat));
233
+ if (reservedIndex !== -1) {
234
+ product.reservedSeats.splice(reservedIndex, 1);
235
+ changed = true;
236
+ }
237
+ }
238
+ item.reservedSeats = [];
239
+ }
240
+ }
241
+ }
242
+ for (const code of previousData.discountCodes) {
243
+ if (code.reserved) {
244
+ // Remove usage
245
+ code.reserved = false;
246
+ discountCodeUsageMap.set(code.id, ((_a = discountCodeUsageMap.get(code.id)) !== null && _a !== void 0 ? _a : 0) - 1);
247
+ }
248
+ }
249
+ }
250
+ for (const item of this.data.cart.items) {
251
+ if (previousData !== null) {
252
+ // If we have previousData, we already removed the stock from the old items, so reservedAmount is always zero
253
+ item.reservedAmount = 0;
254
+ item.reservedPrices = new Map();
255
+ item.reservedOptions = new Map();
256
+ changed = true;
257
+ }
258
+ const difference = add ? (item.amount - item.reservedAmount) : -item.reservedAmount;
259
+ if (difference !== 0) {
260
+ const product = this.webshop.products.find(p => p.id === item.product.id);
261
+ if (product) {
262
+ product.usedStock += difference;
263
+ if (product.usedStock < 0) {
264
+ product.usedStock = 0;
265
+ }
266
+ // Keep track that we included this order in the stock already
267
+ item.reservedAmount += difference;
268
+ changed = true;
269
+ const productPrice = product.prices.find(p => p.id === item.productPrice.id);
270
+ if (productPrice) {
271
+ productPrice.usedStock += difference;
272
+ if (productPrice.usedStock < 0) {
273
+ productPrice.usedStock = 0;
274
+ }
275
+ // Keep track that we included this order in the stock already
276
+ item.reservedPrices.set(productPrice.id, ((_b = item.reservedPrices.get(productPrice.id)) !== null && _b !== void 0 ? _b : 0) + difference);
277
+ }
278
+ // Options
279
+ for (const cartItemOption of item.options) {
280
+ const option = (_c = product.optionMenus.find(om => om.id === cartItemOption.optionMenu.id)) === null || _c === void 0 ? void 0 : _c.options.find(o => o.id === cartItemOption.option.id);
281
+ if (option) {
282
+ option.usedStock += difference;
283
+ if (option.usedStock < 0) {
284
+ option.usedStock = 0;
285
+ }
286
+ // Keep track that we included this order in the stock already
287
+ item.reservedOptions.set(option.id, ((_d = item.reservedOptions.get(option.id)) !== null && _d !== void 0 ? _d : 0) + difference);
288
+ }
289
+ }
290
+ }
291
+ }
292
+ }
293
+ if (previousData !== null && previousData.timeSlot) {
294
+ // Changed timeslot. Remove all reserved ones
295
+ const ps = previousData.timeSlot;
296
+ const timeSlot = this.webshop.meta.checkoutMethods.flatMap(m => m.timeSlots).flatMap(t => t.timeSlots).find(t => t.id === ps.id);
297
+ if (timeSlot) {
298
+ // Remove any reserved stock
299
+ const updated = Order.updateTimeSlotStock(timeSlot, this.data, false);
300
+ changed = changed || updated;
301
+ }
302
+ else {
303
+ this.data.reservedOrder = false;
304
+ this.data.reservedPersons = 0;
305
+ changed = true;
306
+ }
307
+ }
308
+ if (this.data.timeSlot !== null) {
309
+ const s = this.data.timeSlot;
310
+ const timeSlot = this.webshop.meta.checkoutMethods.flatMap(m => m.timeSlots).flatMap(t => t.timeSlots).find(t => t.id === s.id);
311
+ if (timeSlot) {
312
+ const updated = Order.updateTimeSlotStock(timeSlot, this.data, add);
313
+ changed = changed || updated;
314
+ }
315
+ else {
316
+ console.error("Missing timeslot " + s.id + " in webshop " + this.webshopId);
317
+ }
318
+ }
319
+ // Seats
320
+ for (const item of this.data.cart.items) {
321
+ if (item.seats.length > 0) {
322
+ const product = this.webshop.products.find(p => p.id === item.product.id);
323
+ if (product) {
324
+ if (previousData !== null) {
325
+ // Already removed
326
+ item.reservedSeats = [];
327
+ changed = true;
328
+ }
329
+ // First remove all (but only once!), to avoid duplicates
330
+ for (const seat of item.reservedSeats) {
331
+ const reservedIndex = product.reservedSeats.findIndex(s => s.equals(seat));
332
+ if (reservedIndex !== -1) {
333
+ product.reservedSeats.splice(reservedIndex, 1);
334
+ }
335
+ }
336
+ // First remove all (but only once!), to avoid duplicates
337
+ if (add) {
338
+ for (const seat of item.seats) {
339
+ product.reservedSeats.push(seat);
340
+ }
341
+ }
342
+ changed = true;
343
+ item.reservedSeats = add ? item.seats : [];
344
+ }
345
+ }
346
+ }
347
+ // Discount codes
348
+ for (const code of this.data.discountCodes) {
349
+ if (previousData !== null) {
350
+ code.reserved = false;
351
+ changed = true;
352
+ }
353
+ if (code.reserved && !add) {
354
+ // Remove usage
355
+ code.reserved = false;
356
+ discountCodeUsageMap.set(code.id, ((_e = discountCodeUsageMap.get(code.id)) !== null && _e !== void 0 ? _e : 0) - 1);
357
+ changed = true;
358
+ }
359
+ else if (!code.reserved && add) {
360
+ code.reserved = true;
361
+ discountCodeUsageMap.set(code.id, ((_f = discountCodeUsageMap.get(code.id)) !== null && _f !== void 0 ? _f : 0) + 1);
362
+ changed = true;
363
+ }
364
+ }
365
+ for (const [id, amount] of discountCodeUsageMap) {
366
+ if (amount !== 0) {
367
+ const code = await _1.WebshopDiscountCode.getByID(id);
368
+ if (code) {
369
+ code.usageCount += amount;
370
+ await code.save();
371
+ changed = true;
372
+ }
373
+ }
374
+ }
375
+ if (changed) {
376
+ await this.webshop.save();
377
+ await this.save();
378
+ }
379
+ }
380
+ static updateTimeSlotStock(timeSlot, data, add) {
381
+ let changed = false;
382
+ if (data.reservedOrder !== add) {
383
+ data.reservedOrder = add;
384
+ timeSlot.usedOrders += add ? 1 : -1;
385
+ if (timeSlot.usedOrders < 0) {
386
+ timeSlot.usedOrders = 0;
387
+ }
388
+ changed = true;
389
+ }
390
+ const personDifference = (add ? data.cart.persons : 0) - data.reservedPersons;
391
+ if (personDifference !== 0) {
392
+ timeSlot.usedPersons += personDifference;
393
+ if (timeSlot.usedPersons < 0) {
394
+ timeSlot.usedPersons = 0;
395
+ }
396
+ data.reservedPersons += personDifference;
397
+ changed = true;
398
+ }
399
+ return changed;
400
+ }
401
+ async updateTickets() {
402
+ var _a;
403
+ const webshop = this.webshop;
404
+ if (webshop.meta.ticketType !== structures_1.WebshopTicketType.Tickets && webshop.meta.ticketType !== structures_1.WebshopTicketType.SingleTicket) {
405
+ return { tickets: [], didCreateTickets: false };
406
+ }
407
+ const existingTickets = !this.id ? [] : await _1.Ticket.where({ orderId: this.id });
408
+ if (!(await this.shouldCreateTickets())) {
409
+ // Delete all existing tickets
410
+ for (const ticket of existingTickets) {
411
+ if (ticket.isDeleted) {
412
+ continue;
413
+ }
414
+ console.log("Deleting ticket for order " + this.id + ", ticket id = " + ticket.id);
415
+ await ticket.softDelete();
416
+ }
417
+ return { tickets: [], didCreateTickets: false };
418
+ }
419
+ // Create tickets if needed (we might already be valid in case of transfer payments)
420
+ let tickets = [];
421
+ if (webshop.meta.ticketType === structures_1.WebshopTicketType.Tickets) {
422
+ const ticketMap = new Map();
423
+ for (const item of this.data.cart.items) {
424
+ if (item.product.type === structures_1.ProductType.Ticket || item.product.type === structures_1.ProductType.Voucher) {
425
+ const offset = (_a = ticketMap.get(item.product.id)) !== null && _a !== void 0 ? _a : 0;
426
+ // Separate ticket if multiple amounts
427
+ for (let index = 0; index < item.amount; index++) {
428
+ const ticket = new _1.Ticket();
429
+ ticket.orderId = this.id;
430
+ ticket.itemId = item.id;
431
+ ticket.organizationId = this.organizationId;
432
+ ticket.webshopId = this.webshopId;
433
+ // Relative index for items with same properties
434
+ ticket.index = offset + index + 1;
435
+ ticket.total = item.getTotalAmount(this.data.cart);
436
+ // Seat
437
+ ticket.seat = item.seats.length > 0 ? item.seats[index] : null;
438
+ ticket.originalSeat = ticket.seat;
439
+ // Do not save yet
440
+ tickets.push(ticket);
441
+ }
442
+ ticketMap.set(item.product.id, offset + item.amount);
443
+ }
444
+ }
445
+ }
446
+ else {
447
+ // Create a shared ticket for the whole order
448
+ const ticket = new _1.Ticket();
449
+ ticket.orderId = this.id;
450
+ ticket.itemId = null;
451
+ ticket.organizationId = this.organizationId;
452
+ ticket.webshopId = this.webshopId;
453
+ // Relative index for items with same properties
454
+ ticket.index = 1;
455
+ ticket.total = 1;
456
+ // Do not save yet
457
+ tickets.push(ticket);
458
+ }
459
+ let didCreateTickets = false;
460
+ if (!this.id) {
461
+ await this.save();
462
+ for (const ticket of tickets) {
463
+ ticket.orderId = this.id;
464
+ }
465
+ }
466
+ // First check if we already have tickets
467
+ const mergedTickets = [];
468
+ // First try to keep existing tickets
469
+ for (const existing of existingTickets) {
470
+ if (existing.originalSeat) {
471
+ const index = tickets.findIndex(t => t.seat && t.seat.equals(existing.originalSeat));
472
+ if (index !== -1) {
473
+ const ticket = tickets[index];
474
+ tickets.splice(index, 1);
475
+ existing.itemId = ticket.itemId;
476
+ existing.index = ticket.index;
477
+ existing.total = ticket.total;
478
+ existing.seat = ticket.seat;
479
+ existing.deletedAt = null;
480
+ mergedTickets.push(existing);
481
+ }
482
+ continue;
483
+ }
484
+ const index = tickets.findIndex(ticket => existing.itemId === ticket.itemId && ticket.index === existing.index);
485
+ if (index !== -1) {
486
+ const ticket = tickets[index];
487
+ tickets.splice(index, 1);
488
+ existing.itemId = ticket.itemId;
489
+ existing.index = ticket.index;
490
+ existing.total = ticket.total;
491
+ existing.seat = ticket.seat;
492
+ existing.deletedAt = null;
493
+ mergedTickets.push(existing);
494
+ }
495
+ }
496
+ // Try to reuse tickets instead of recreating if no match is found
497
+ for (const existing of existingTickets) {
498
+ if (mergedTickets.find(m => m.id === existing.id)) {
499
+ // Already mapped
500
+ continue;
501
+ }
502
+ const index = tickets.findIndex(ticket => existing.itemId === ticket.itemId);
503
+ if (index !== -1) {
504
+ const ticket = tickets[index];
505
+ tickets.splice(index, 1);
506
+ existing.itemId = ticket.itemId;
507
+ existing.index = ticket.index;
508
+ existing.total = ticket.total;
509
+ existing.seat = ticket.seat;
510
+ existing.deletedAt = null;
511
+ mergedTickets.push(existing);
512
+ }
513
+ }
514
+ // Remaining tickets that were not reused
515
+ for (const ticket of tickets) {
516
+ didCreateTickets = true;
517
+ mergedTickets.push(ticket);
518
+ }
519
+ tickets = mergedTickets;
520
+ // Wait to save them all
521
+ console.log("Saving merged tickets for order " + this.id);
522
+ await Promise.all(tickets.map((ticket) => ticket.save()));
523
+ // Delete others
524
+ for (const existing of existingTickets) {
525
+ if (!mergedTickets.find(m => m.id === existing.id)) {
526
+ if (existing.isDeleted) {
527
+ continue;
528
+ }
529
+ console.log("Deleting ticket for order " + this.id + ", ticket id = " + existing.id);
530
+ await existing.softDelete();
531
+ }
532
+ }
533
+ return { tickets, didCreateTickets };
534
+ }
535
+ markUpdated() {
536
+ this.updatedAt = new Date();
537
+ // Also save if this is the only saved property
538
+ this.forceSaveProperty("updatedAt");
539
+ }
540
+ /**
541
+ * A payment changed the total paid amount
542
+ */
543
+ async paymentChanged(payment, organization, knownWebshop) {
544
+ this.markUpdated();
545
+ await this.save();
546
+ }
547
+ async undoPaid(payment, organization, knownWebshop) {
548
+ var _a;
549
+ this.markUpdated();
550
+ await this.save();
551
+ const webshop = (_a = (knownWebshop !== null && knownWebshop !== void 0 ? knownWebshop : (await _1.Webshop.getByID(this.webshopId)))) === null || _a === void 0 ? void 0 : _a.setRelation(_1.Webshop.organization, organization);
552
+ if (!webshop) {
553
+ console.error("Missing webshop for order " + this.id);
554
+ return;
555
+ }
556
+ await this.setRelation(Order.webshop, webshop).updateTickets();
557
+ }
558
+ /**
559
+ * Only call this once! Make sure you use the queues correctly
560
+ */
561
+ async markPaid(payment, organization, knownWebshop) {
562
+ var _a;
563
+ console.log("Marking order " + this.id + " as paid");
564
+ this.markUpdated();
565
+ await this.save();
566
+ const webshop = (_a = (knownWebshop !== null && knownWebshop !== void 0 ? knownWebshop : (await _1.Webshop.getByID(this.webshopId)))) === null || _a === void 0 ? void 0 : _a.setRelation(_1.Webshop.organization, organization);
567
+ if (!webshop) {
568
+ console.error("Missing webshop for order " + this.id);
569
+ return;
570
+ }
571
+ if (this.status === structures_1.OrderStatus.Deleted) {
572
+ await this.undoPaymentFailed(payment, organization);
573
+ }
574
+ const { tickets, didCreateTickets } = await this.setRelation(Order.webshop, webshop).updateTickets();
575
+ // Needs to happen before validation, because we can include the tickets in the validation that way
576
+ if (this.validAt === null) {
577
+ await this.setRelation(Order.webshop, webshop).markValid(payment, tickets);
578
+ }
579
+ else {
580
+ if (!this.data.shouldSendPaymentUpdates) {
581
+ console.log("Skip sending paid email for order " + this.id);
582
+ return;
583
+ }
584
+ if (this.data.customer.email.length > 0) {
585
+ if (didCreateTickets) {
586
+ await this.setRelation(Order.webshop, webshop).sendTickets();
587
+ }
588
+ else {
589
+ if (payment && payment.method === structures_1.PaymentMethod.Transfer) {
590
+ await this.setRelation(Order.webshop, webshop).sendPaidMail();
591
+ }
592
+ }
593
+ }
594
+ }
595
+ }
596
+ async sendPaidMail() {
597
+ const organization = this.webshop.organization;
598
+ const { from, replyTo } = organization.getEmail(this.webshop.privateMeta.defaultEmailId, true);
599
+ await this.sendEmailTemplate({
600
+ type: structures_1.EmailTemplateType.OrderReceivedTransfer,
601
+ from,
602
+ replyTo
603
+ });
604
+ }
605
+ async sendTickets() {
606
+ const organization = this.webshop.organization;
607
+ const { from, replyTo } = organization.getEmail(this.webshop.privateMeta.defaultEmailId, true);
608
+ await this.sendEmailTemplate({
609
+ type: structures_1.EmailTemplateType.TicketsReceivedTransfer,
610
+ from,
611
+ replyTo
612
+ });
613
+ }
614
+ getStructureWithoutPayment() {
615
+ return structures_1.Order.create({
616
+ id: this.id,
617
+ webshopId: this.webshopId,
618
+ number: this.number,
619
+ data: this.data,
620
+ status: this.status,
621
+ balanceItems: [],
622
+ createdAt: this.createdAt,
623
+ updatedAt: this.updatedAt,
624
+ validAt: this.validAt,
625
+ });
626
+ }
627
+ static async getStructures(orders) {
628
+ var _a, _b, _c;
629
+ if (orders.length === 0) {
630
+ return [];
631
+ }
632
+ // Balance items
633
+ const allBalanceItems = await _1.BalanceItem.where({ orderId: {
634
+ sign: "IN",
635
+ value: orders.map(o => o.id)
636
+ } });
637
+ const { payments, balanceItemPayments } = await _1.BalanceItem.loadPayments(allBalanceItems);
638
+ const structures = [];
639
+ for (const order of orders) {
640
+ const balanceItems = allBalanceItems.filter(b => b.orderId === order.id);
641
+ const balanceItemStructures = balanceItems.map((balanceItem) => {
642
+ return structures_1.BalanceItemWithPayments.create({
643
+ ...balanceItem,
644
+ payments: balanceItemPayments.filter(b => b.balanceItemId === balanceItem.id).map(balanceItemPayment => {
645
+ const payment = payments.find(pp => pp.id === balanceItemPayment.paymentId);
646
+ return structures_1.MemberBalanceItemPayment.create({
647
+ ...balanceItemPayment,
648
+ payment: structures_1.Payment.create(payment)
649
+ });
650
+ })
651
+ });
652
+ });
653
+ structures.push(structures_1.Order.create({
654
+ ...order,
655
+ balanceItems: balanceItemStructures,
656
+ // Compatibility
657
+ payment: (_c = (_b = (_a = balanceItemStructures[0]) === null || _a === void 0 ? void 0 : _a.payments[0]) === null || _b === void 0 ? void 0 : _b.payment) !== null && _c !== void 0 ? _c : null
658
+ }));
659
+ }
660
+ return structures;
661
+ }
662
+ static async getPrivateStructures(orders) {
663
+ var _a, _b, _c;
664
+ if (orders.length === 0) {
665
+ return [];
666
+ }
667
+ // Balance items
668
+ const allBalanceItems = await _1.BalanceItem.where({ orderId: {
669
+ sign: "IN",
670
+ value: orders.map(o => o.id)
671
+ } });
672
+ const { payments, balanceItemPayments } = await _1.BalanceItem.loadPayments(allBalanceItems);
673
+ const structures = [];
674
+ for (const order of orders) {
675
+ const balanceItems = allBalanceItems.filter(b => b.orderId === order.id);
676
+ const balanceItemStructures = balanceItems.map((balanceItem) => {
677
+ return structures_1.BalanceItemWithPrivatePayments.create({
678
+ ...balanceItem,
679
+ payments: balanceItemPayments.filter(b => b.balanceItemId === balanceItem.id).map(balanceItemPayment => {
680
+ const payment = payments.find(pp => pp.id === balanceItemPayment.paymentId);
681
+ return structures_1.BalanceItemPaymentWithPrivatePayment.create({
682
+ ...balanceItemPayment,
683
+ payment: structures_1.PrivatePayment.create(payment)
684
+ });
685
+ })
686
+ });
687
+ });
688
+ structures.push(structures_1.PrivateOrder.create({
689
+ ...order,
690
+ balanceItems: balanceItemStructures,
691
+ // Compatibility
692
+ payment: (_c = (_b = (_a = balanceItemStructures[0]) === null || _a === void 0 ? void 0 : _a.payments[0]) === null || _b === void 0 ? void 0 : _b.payment) !== null && _c !== void 0 ? _c : null
693
+ }));
694
+ }
695
+ return structures;
696
+ }
697
+ async getStructure() {
698
+ return (await Order.getStructures([this]))[0];
699
+ }
700
+ async sendEmailTemplate(data) {
701
+ // Never send an email for archived webshops
702
+ if (this.webshop.meta.status === structures_1.WebshopStatus.Archived) {
703
+ return;
704
+ }
705
+ // First fetch template
706
+ let templates = (await _1.EmailTemplate.where({ type: data.type, webshopId: this.webshop.id }));
707
+ if (templates.length == 0) {
708
+ templates = (await _1.EmailTemplate.where({ type: data.type, organizationId: null }));
709
+ }
710
+ if (templates.length == 0) {
711
+ console.error("Could not find email template for type " + data.type);
712
+ return;
713
+ }
714
+ const template = templates[0];
715
+ let recipient = (await this.getStructure()).getRecipient(await this.webshop.organization.getStructure({ emptyGroups: true }), structures_1.WebshopPreview.create(this.webshop));
716
+ if (data.to) {
717
+ // Clear first and last name
718
+ recipient.firstName = null;
719
+ recipient.lastName = null;
720
+ recipient.replacements = recipient.replacements.filter(r => !['firstName', 'lastName'].includes(r.token));
721
+ data.to.merge(recipient);
722
+ recipient = data.to;
723
+ }
724
+ // Create e-mail builder
725
+ const builder = await (0, EmailBuilder_1.getEmailBuilder)(this.webshop.organization, {
726
+ recipients: [recipient],
727
+ subject: template.subject,
728
+ html: template.html,
729
+ // text: template.text,
730
+ from: data.from,
731
+ replyTo: data.replyTo,
732
+ type: 'transactional',
733
+ defaultReplacements: this.webshop.meta.getEmailReplacements()
734
+ });
735
+ email_1.Email.schedule(builder);
736
+ }
737
+ /**
738
+ * WARNING: this should always run inside a queue so it only runs once for the same orde
739
+ * Include any tickets that are generated and should be included in the e-mail
740
+ */
741
+ async markValid(payment, tickets) {
742
+ var _a;
743
+ const webshop = this.webshop;
744
+ const organization = webshop.organization;
745
+ console.log("Marking as valid: order " + this.id);
746
+ const wasValid = this.validAt !== null;
747
+ if (wasValid) {
748
+ console.warn("Warning: already validated an order");
749
+ return;
750
+ }
751
+ this.validAt = new Date(); // will get flattened AFTER calculations
752
+ this.validAt.setMilliseconds(0);
753
+ this.number = await WebshopCounter_1.WebshopCounter.getNextNumber(this.webshopId, this.webshop.privateMeta.numberingType);
754
+ if (payment && !Order.payment.isLoaded(this)) {
755
+ this.setRelation(Order.payment, payment);
756
+ }
757
+ // Now we have a number, update the payment
758
+ if (payment && payment.method === structures_1.PaymentMethod.Transfer) {
759
+ // Only now we can update the transfer description, since we need the order number as a reference
760
+ payment.transferSettings = webshop.meta.transferSettings.fillMissing(organization.mappedTransferSettings);
761
+ if (!payment.transferSettings.iban) {
762
+ throw new simple_errors_1.SimpleError({
763
+ code: "missing_iban",
764
+ message: "Missing IBAN",
765
+ human: "Er is geen rekeningnummer ingesteld voor overschrijvingen. Contacteer de beheerder."
766
+ });
767
+ }
768
+ payment.generateDescription(organization, this.number.toString(), this.getTransferReplacements());
769
+ await payment.save();
770
+ }
771
+ await this.save();
772
+ if (this.data.customer.email.length > 0) {
773
+ const webshop = this.webshop;
774
+ const organization = webshop.organization;
775
+ const { from, replyTo } = organization.getEmail(webshop.privateMeta.defaultEmailId, true);
776
+ if (tickets.length > 0) {
777
+ // Also send a copy
778
+ if (payment && payment.method === structures_1.PaymentMethod.PointOfSale) {
779
+ await this.sendEmailTemplate({
780
+ type: structures_1.EmailTemplateType.TicketsConfirmationPOS,
781
+ from,
782
+ replyTo
783
+ });
784
+ }
785
+ else {
786
+ await this.sendEmailTemplate({
787
+ type: structures_1.EmailTemplateType.TicketsConfirmation,
788
+ from,
789
+ replyTo
790
+ });
791
+ }
792
+ }
793
+ else {
794
+ if (this.webshop.meta.ticketType === structures_1.WebshopTicketType.None) {
795
+ if (payment && payment.method === structures_1.PaymentMethod.Transfer) {
796
+ // Also send a copy
797
+ await this.sendEmailTemplate({
798
+ type: structures_1.EmailTemplateType.OrderConfirmationTransfer,
799
+ from,
800
+ replyTo
801
+ });
802
+ }
803
+ else if (payment && payment.method === structures_1.PaymentMethod.PointOfSale) {
804
+ await this.sendEmailTemplate({
805
+ type: structures_1.EmailTemplateType.OrderConfirmationPOS,
806
+ from,
807
+ replyTo
808
+ });
809
+ }
810
+ else {
811
+ // Also send a copy
812
+ await this.sendEmailTemplate({
813
+ type: structures_1.EmailTemplateType.OrderConfirmationOnline,
814
+ from,
815
+ replyTo
816
+ });
817
+ }
818
+ }
819
+ else {
820
+ await this.sendEmailTemplate({
821
+ type: structures_1.EmailTemplateType.TicketsConfirmationTransfer,
822
+ from,
823
+ replyTo
824
+ });
825
+ }
826
+ }
827
+ }
828
+ if (this.webshop.privateMeta.notificationEmails) {
829
+ const webshop = this.webshop;
830
+ const organization = webshop.organization;
831
+ const { from, replyTo } = organization.getEmail(webshop.privateMeta.defaultEmailId, true);
832
+ const i18n = organization.i18n;
833
+ const webshopDashboardUrl = "https://" + ((_a = STAMHOOFD.domains.dashboard) !== null && _a !== void 0 ? _a : "stamhoofd.app") + "/" + i18n.locale + '/webshops/' + utility_1.Formatter.slug(webshop.meta.name) + '/orders';
834
+ // Send an email to all these notification emails
835
+ for (const email of this.webshop.privateMeta.notificationEmails) {
836
+ await this.sendEmailTemplate({
837
+ type: structures_1.EmailTemplateType.OrderNotification,
838
+ from,
839
+ replyTo,
840
+ to: structures_1.Recipient.create({
841
+ email,
842
+ replacements: [
843
+ structures_1.Replacement.create({
844
+ token: 'orderUrl',
845
+ value: webshopDashboardUrl
846
+ })
847
+ ]
848
+ })
849
+ });
850
+ }
851
+ }
852
+ }
853
+ }
854
+ exports.Order = Order;
855
+ Order.table = "webshop_orders";
856
+ Order.webshop = new simple_database_1.ManyToOneRelation(_1.Webshop, "webshop");
857
+ Order.payment = new simple_database_1.ManyToOneRelation(_1.Payment, "payment");
858
+ Order.organization = new simple_database_1.ManyToOneRelation(_1.Organization, "organization");
859
+ tslib_1.__decorate([
860
+ (0, simple_database_1.column)({
861
+ primary: true, type: "string", beforeSave(value) {
862
+ return value !== null && value !== void 0 ? value : (0, uuid_1.v4)();
863
+ }
864
+ })
865
+ ], Order.prototype, "id", void 0);
866
+ tslib_1.__decorate([
867
+ (0, simple_database_1.column)({ foreignKey: Order.organization, type: "string" })
868
+ ], Order.prototype, "organizationId", void 0);
869
+ tslib_1.__decorate([
870
+ (0, simple_database_1.column)({ foreignKey: Order.webshop, type: "string" })
871
+ ], Order.prototype, "webshopId", void 0);
872
+ tslib_1.__decorate([
873
+ (0, simple_database_1.column)({ type: "string", nullable: true, foreignKey: Order.payment })
874
+ ], Order.prototype, "paymentId", void 0);
875
+ tslib_1.__decorate([
876
+ (0, simple_database_1.column)({ type: "string", nullable: true })
877
+ ], Order.prototype, "userId", void 0);
878
+ tslib_1.__decorate([
879
+ (0, simple_database_1.column)({ type: "json", decoder: structures_1.OrderData })
880
+ ], Order.prototype, "data", void 0);
881
+ tslib_1.__decorate([
882
+ (0, simple_database_1.column)({ type: "integer", nullable: true })
883
+ ], Order.prototype, "number", void 0);
884
+ tslib_1.__decorate([
885
+ (0, simple_database_1.column)({
886
+ type: "datetime", beforeSave(old) {
887
+ if (old !== undefined) {
888
+ return old;
889
+ }
890
+ const date = new Date();
891
+ date.setMilliseconds(0);
892
+ return date;
893
+ }
894
+ })
895
+ ], Order.prototype, "createdAt", void 0);
896
+ tslib_1.__decorate([
897
+ (0, simple_database_1.column)({
898
+ type: "datetime", beforeSave() {
899
+ const date = new Date();
900
+ date.setMilliseconds(0);
901
+ return date;
902
+ },
903
+ skipUpdate: true
904
+ })
905
+ ], Order.prototype, "updatedAt", void 0);
906
+ tslib_1.__decorate([
907
+ (0, simple_database_1.column)({ type: "datetime", nullable: true })
908
+ ], Order.prototype, "validAt", void 0);
909
+ tslib_1.__decorate([
910
+ (0, simple_database_1.column)({ type: "string" })
911
+ ], Order.prototype, "status", void 0);
912
+ //# sourceMappingURL=Order.js.map