addio-admin-sdk 1.7.102 → 1.7.104

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 (325) hide show
  1. package/dist/Interfaces/Algolia/index.d.ts +1 -0
  2. package/dist/Interfaces/Attribute/index.d.ts +1 -0
  3. package/dist/Interfaces/CMS/index.d.ts +3 -0
  4. package/dist/Interfaces/CMS/index.js +3 -0
  5. package/dist/Interfaces/CMS/index.js.map +1 -1
  6. package/dist/Interfaces/Cart/index.d.ts +1 -0
  7. package/dist/Interfaces/Cart/index.js +6 -2
  8. package/dist/Interfaces/Cart/index.js.map +1 -1
  9. package/dist/Interfaces/CartReservedQuantities/index.d.ts +2 -0
  10. package/dist/Interfaces/Customer/IStoreCredit.d.ts +1 -0
  11. package/dist/Interfaces/Customer/index.d.ts +7 -0
  12. package/dist/Interfaces/Customer/index.js +7 -0
  13. package/dist/Interfaces/Customer/index.js.map +1 -1
  14. package/dist/Interfaces/Declination/index.js +8 -2
  15. package/dist/Interfaces/Declination/index.js.map +1 -1
  16. package/dist/Interfaces/Email/IEmail.js +7 -3
  17. package/dist/Interfaces/Email/IEmail.js.map +1 -1
  18. package/dist/Interfaces/G2/index.js +2 -0
  19. package/dist/Interfaces/G2/index.js.map +1 -1
  20. package/dist/Interfaces/Indexed/Product/index.d.ts +3 -0
  21. package/dist/Interfaces/Indexed/Product/index.js +43 -2
  22. package/dist/Interfaces/Indexed/Product/index.js.map +1 -1
  23. package/dist/Interfaces/Menu/index.d.ts +11 -0
  24. package/dist/Interfaces/Product/IImportProduct.js +94 -3
  25. package/dist/Interfaces/Product/IImportProduct.js.map +1 -1
  26. package/dist/Interfaces/Product/IInventoryItem.d.ts +11 -27
  27. package/dist/Interfaces/Product/IInventoryItem.js +13 -4
  28. package/dist/Interfaces/Product/IInventoryItem.js.map +1 -1
  29. package/dist/Interfaces/Product/IPricing.js +6 -0
  30. package/dist/Interfaces/Product/IPricing.js.map +1 -1
  31. package/dist/Interfaces/Product/index.d.ts +8 -0
  32. package/dist/Interfaces/Product/index.js +8 -0
  33. package/dist/Interfaces/Product/index.js.map +1 -1
  34. package/dist/Interfaces/PromiseToPurchase/IIndexedBankUsed.js +1 -1
  35. package/dist/Interfaces/PromiseToPurchase/IIndexedBankUsed.js.map +1 -1
  36. package/dist/Interfaces/Rules/IDiscountRule.d.ts +18 -0
  37. package/dist/Interfaces/Rules/IDiscountRule.js +19 -0
  38. package/dist/Interfaces/Rules/IDiscountRule.js.map +1 -1
  39. package/dist/Interfaces/Services/IService.d.ts +4 -0
  40. package/dist/Interfaces/Shipping/Shiptime/order.js +23 -0
  41. package/dist/Interfaces/Shipping/Shiptime/order.js.map +1 -1
  42. package/dist/Interfaces/Space/index.d.ts +8 -0
  43. package/dist/Interfaces/Space/index.js +9 -0
  44. package/dist/Interfaces/Space/index.js.map +1 -1
  45. package/dist/Interfaces/TCG/index.d.ts +12 -1
  46. package/dist/Interfaces/TCG/index.js +11 -0
  47. package/dist/Interfaces/TCG/index.js.map +1 -1
  48. package/dist/Interfaces/TransferRequest/index.js +3 -0
  49. package/dist/Interfaces/TransferRequest/index.js.map +1 -1
  50. package/dist/constants/services.js +1 -0
  51. package/dist/constants/services.js.map +1 -1
  52. package/dist/index.d.ts +18 -0
  53. package/dist/index.js +24 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/lib/Attribute/index.js +43 -0
  56. package/dist/lib/Attribute/index.js.map +1 -1
  57. package/dist/lib/BGJob/index.js +5 -1
  58. package/dist/lib/BGJob/index.js.map +1 -1
  59. package/dist/lib/Booking/index.d.ts +15 -0
  60. package/dist/lib/Booking/index.js +20 -0
  61. package/dist/lib/Booking/index.js.map +1 -1
  62. package/dist/lib/Brand/index.d.ts +9 -0
  63. package/dist/lib/Brand/index.js +18 -0
  64. package/dist/lib/Brand/index.js.map +1 -1
  65. package/dist/lib/Cart/index.d.ts +99 -0
  66. package/dist/lib/Cart/index.js +498 -9
  67. package/dist/lib/Cart/index.js.map +1 -1
  68. package/dist/lib/CartReservedQuantities/index.d.ts +29 -0
  69. package/dist/lib/CartReservedQuantities/index.js +41 -0
  70. package/dist/lib/CartReservedQuantities/index.js.map +1 -1
  71. package/dist/lib/Catalogue/index.d.ts +6 -0
  72. package/dist/lib/Catalogue/index.js +9 -0
  73. package/dist/lib/Catalogue/index.js.map +1 -1
  74. package/dist/lib/Category/index.d.ts +6 -0
  75. package/dist/lib/Category/index.js +15 -0
  76. package/dist/lib/Category/index.js.map +1 -1
  77. package/dist/lib/Class/index.d.ts +4 -0
  78. package/dist/lib/Class/index.js +8 -0
  79. package/dist/lib/Class/index.js.map +1 -1
  80. package/dist/lib/Customer/index.d.ts +12 -0
  81. package/dist/lib/Customer/index.js +13 -0
  82. package/dist/lib/Customer/index.js.map +1 -1
  83. package/dist/lib/Declination/index.js +2 -0
  84. package/dist/lib/Declination/index.js.map +1 -1
  85. package/dist/lib/Discount/index.d.ts +9 -0
  86. package/dist/lib/Discount/index.js +23 -0
  87. package/dist/lib/Discount/index.js.map +1 -1
  88. package/dist/lib/ElasticSearch/index.d.ts +5 -0
  89. package/dist/lib/ElasticSearch/index.js +5 -0
  90. package/dist/lib/ElasticSearch/index.js.map +1 -1
  91. package/dist/lib/Elavon/index.js +5 -0
  92. package/dist/lib/Elavon/index.js.map +1 -1
  93. package/dist/lib/Email/AbandonedCartEmail.d.ts +8 -0
  94. package/dist/lib/Email/AbandonedCartEmail.js +8 -0
  95. package/dist/lib/Email/AbandonedCartEmail.js.map +1 -1
  96. package/dist/lib/Email/AccountConfirmationEmail.d.ts +8 -0
  97. package/dist/lib/Email/AccountConfirmationEmail.js +8 -0
  98. package/dist/lib/Email/AccountConfirmationEmail.js.map +1 -1
  99. package/dist/lib/Email/AdminOrderConfirmationEmail.d.ts +8 -0
  100. package/dist/lib/Email/AdminOrderConfirmationEmail.js +8 -0
  101. package/dist/lib/Email/AdminOrderConfirmationEmail.js.map +1 -1
  102. package/dist/lib/Email/ApplicationEmail.d.ts +8 -0
  103. package/dist/lib/Email/ApplicationEmail.js +8 -0
  104. package/dist/lib/Email/ApplicationEmail.js.map +1 -1
  105. package/dist/lib/Email/BackInStockEmail.d.ts +8 -0
  106. package/dist/lib/Email/BackInStockEmail.js +8 -0
  107. package/dist/lib/Email/BackInStockEmail.js.map +1 -1
  108. package/dist/lib/Email/ContactEmail.d.ts +8 -0
  109. package/dist/lib/Email/ContactEmail.js +8 -0
  110. package/dist/lib/Email/ContactEmail.js.map +1 -1
  111. package/dist/lib/Email/CustomerBookingAdminEmail.d.ts +8 -0
  112. package/dist/lib/Email/CustomerBookingAdminEmail.js +8 -0
  113. package/dist/lib/Email/CustomerBookingAdminEmail.js.map +1 -1
  114. package/dist/lib/Email/CustomerBookingEmail.d.ts +8 -0
  115. package/dist/lib/Email/CustomerBookingEmail.js +8 -0
  116. package/dist/lib/Email/CustomerBookingEmail.js.map +1 -1
  117. package/dist/lib/Email/OrderConfirmationEmail.d.ts +8 -0
  118. package/dist/lib/Email/OrderConfirmationEmail.js +8 -0
  119. package/dist/lib/Email/OrderConfirmationEmail.js.map +1 -1
  120. package/dist/lib/Email/OrderDenounciationEmail.d.ts +8 -0
  121. package/dist/lib/Email/OrderDenounciationEmail.js +8 -0
  122. package/dist/lib/Email/OrderDenounciationEmail.js.map +1 -1
  123. package/dist/lib/Email/OrderSampleEmail.d.ts +8 -0
  124. package/dist/lib/Email/OrderSampleEmail.js +8 -0
  125. package/dist/lib/Email/OrderSampleEmail.js.map +1 -1
  126. package/dist/lib/Email/OtherTypeEmails.d.ts +8 -0
  127. package/dist/lib/Email/OtherTypeEmails.js +8 -0
  128. package/dist/lib/Email/OtherTypeEmails.js.map +1 -1
  129. package/dist/lib/Email/PasswordResetEmail.d.ts +8 -0
  130. package/dist/lib/Email/PasswordResetEmail.js +8 -0
  131. package/dist/lib/Email/PasswordResetEmail.js.map +1 -1
  132. package/dist/lib/Email/PhotoShootEmail.d.ts +8 -0
  133. package/dist/lib/Email/PhotoShootEmail.js +8 -0
  134. package/dist/lib/Email/PhotoShootEmail.js.map +1 -1
  135. package/dist/lib/Email/PickUpConfirmation.d.ts +8 -0
  136. package/dist/lib/Email/PickUpConfirmation.js +8 -0
  137. package/dist/lib/Email/PickUpConfirmation.js.map +1 -1
  138. package/dist/lib/Email/ShippingConfirmation.d.ts +8 -0
  139. package/dist/lib/Email/ShippingConfirmation.js +8 -0
  140. package/dist/lib/Email/ShippingConfirmation.js.map +1 -1
  141. package/dist/lib/Email/WelcomeEmail.d.ts +8 -0
  142. package/dist/lib/Email/WelcomeEmail.js +8 -0
  143. package/dist/lib/Email/WelcomeEmail.js.map +1 -1
  144. package/dist/lib/Email/index.d.ts +8 -0
  145. package/dist/lib/Email/index.js +8 -0
  146. package/dist/lib/Email/index.js.map +1 -1
  147. package/dist/lib/ExternalService/Ebay.d.ts +12 -0
  148. package/dist/lib/ExternalService/Ebay.js +22 -0
  149. package/dist/lib/ExternalService/Ebay.js.map +1 -1
  150. package/dist/lib/Indexed/IndexedCart.js +5 -0
  151. package/dist/lib/Indexed/IndexedCart.js.map +1 -1
  152. package/dist/lib/Indexed/Product.js +50 -0
  153. package/dist/lib/Indexed/Product.js.map +1 -1
  154. package/dist/lib/Inventory/index.d.ts +59 -0
  155. package/dist/lib/Inventory/index.js +157 -9
  156. package/dist/lib/Inventory/index.js.map +1 -1
  157. package/dist/lib/Invoice/index.d.ts +11 -0
  158. package/dist/lib/Invoice/index.js +11 -0
  159. package/dist/lib/Invoice/index.js.map +1 -1
  160. package/dist/lib/MarketplacePublication/index.js +308 -0
  161. package/dist/lib/MarketplacePublication/index.js.map +1 -1
  162. package/dist/lib/Menu/index.js +2 -0
  163. package/dist/lib/Menu/index.js.map +1 -1
  164. package/dist/lib/Order/index.d.ts +20 -0
  165. package/dist/lib/Order/index.js +23 -0
  166. package/dist/lib/Order/index.js.map +1 -1
  167. package/dist/lib/Org/index.d.ts +41 -0
  168. package/dist/lib/Org/index.js +41 -0
  169. package/dist/lib/Org/index.js.map +1 -1
  170. package/dist/lib/PandaPay/index.js +6 -0
  171. package/dist/lib/PandaPay/index.js.map +1 -1
  172. package/dist/lib/Paysafe/index.js +1 -0
  173. package/dist/lib/Paysafe/index.js.map +1 -1
  174. package/dist/lib/Product/index.d.ts +25 -0
  175. package/dist/lib/Product/index.js +55 -1
  176. package/dist/lib/Product/index.js.map +1 -1
  177. package/dist/lib/PromiseToPurchase/index.d.ts +72 -0
  178. package/dist/lib/PromiseToPurchase/index.js +79 -0
  179. package/dist/lib/PromiseToPurchase/index.js.map +1 -1
  180. package/dist/lib/PurchaseOrder/index.d.ts +11 -0
  181. package/dist/lib/PurchaseOrder/index.js +12 -0
  182. package/dist/lib/PurchaseOrder/index.js.map +1 -1
  183. package/dist/lib/Service/index.d.ts +8 -0
  184. package/dist/lib/Service/index.js +8 -0
  185. package/dist/lib/Service/index.js.map +1 -1
  186. package/dist/lib/Shipment/index.js +13 -0
  187. package/dist/lib/Shipment/index.js.map +1 -1
  188. package/dist/lib/Slider/index.d.ts +6 -0
  189. package/dist/lib/Slider/index.js +6 -0
  190. package/dist/lib/Slider/index.js.map +1 -1
  191. package/dist/lib/Space/index.d.ts +178 -0
  192. package/dist/lib/Space/index.js +495 -6
  193. package/dist/lib/Space/index.js.map +1 -1
  194. package/dist/lib/Supplier/index.js +5 -0
  195. package/dist/lib/Supplier/index.js.map +1 -1
  196. package/dist/lib/Tags/index.js +5 -0
  197. package/dist/lib/Tags/index.js.map +1 -1
  198. package/dist/lib/TransferRequest/index.d.ts +178 -0
  199. package/dist/lib/TransferRequest/index.js +236 -4
  200. package/dist/lib/TransferRequest/index.js.map +1 -1
  201. package/dist/lib/User/index.d.ts +54 -0
  202. package/dist/lib/User/index.js +101 -21
  203. package/dist/lib/User/index.js.map +1 -1
  204. package/dist/lib/baseService.js +26 -0
  205. package/dist/lib/baseService.js.map +1 -1
  206. package/dist/rules/GR/constants/data.js +22 -0
  207. package/dist/rules/GR/constants/data.js.map +1 -1
  208. package/dist/rules/GR/constants/products.d.ts +3 -0
  209. package/dist/rules/GR/constants/products.js +16 -0
  210. package/dist/rules/GR/constants/products.js.map +1 -1
  211. package/dist/rules/GR/interfaces/data.js +7 -1
  212. package/dist/rules/GR/interfaces/data.js.map +1 -1
  213. package/dist/rules/GR/utils/cart.d.ts +41 -0
  214. package/dist/rules/GR/utils/cart.js +107 -1
  215. package/dist/rules/GR/utils/cart.js.map +1 -1
  216. package/dist/rules/GR/utils/data.js +4 -1
  217. package/dist/rules/GR/utils/data.js.map +1 -1
  218. package/dist/rules/GR/utils/expedition.d.ts +69 -0
  219. package/dist/rules/GR/utils/expedition.js +399 -11
  220. package/dist/rules/GR/utils/expedition.js.map +1 -1
  221. package/dist/rules/GR/utils/g2.d.ts +33 -0
  222. package/dist/rules/GR/utils/g2.js +135 -3
  223. package/dist/rules/GR/utils/g2.js.map +1 -1
  224. package/dist/rules/GR/utils/invoices.d.ts +27 -0
  225. package/dist/rules/GR/utils/invoices.js +41 -0
  226. package/dist/rules/GR/utils/invoices.js.map +1 -1
  227. package/dist/rules/GR/utils/products.d.ts +161 -0
  228. package/dist/rules/GR/utils/products.js +272 -1
  229. package/dist/rules/GR/utils/products.js.map +1 -1
  230. package/dist/rules/GR/utils/upsells.d.ts +32 -0
  231. package/dist/rules/GR/utils/upsells.js +32 -0
  232. package/dist/rules/GR/utils/upsells.js.map +1 -1
  233. package/dist/services/database/DatabaseService.d.ts +84 -0
  234. package/dist/services/database/DatabaseService.js +85 -0
  235. package/dist/services/database/DatabaseService.js.map +1 -1
  236. package/dist/services/database/FirebaseProvider.js +17 -0
  237. package/dist/services/database/FirebaseProvider.js.map +1 -1
  238. package/dist/services/database/NotFirebaseProvider.d.ts +14 -0
  239. package/dist/services/database/NotFirebaseProvider.js +19 -0
  240. package/dist/services/database/NotFirebaseProvider.js.map +1 -1
  241. package/dist/services/g2/G2OrderSlip.d.ts +7 -0
  242. package/dist/services/g2/G2OrderSlip.js +18 -0
  243. package/dist/services/g2/G2OrderSlip.js.map +1 -1
  244. package/dist/services/g2/utils.d.ts +10 -0
  245. package/dist/services/g2/utils.js +189 -3
  246. package/dist/services/g2/utils.js.map +1 -1
  247. package/dist/services/logs/index.d.ts +3 -0
  248. package/dist/services/logs/index.js +6 -1
  249. package/dist/services/logs/index.js.map +1 -1
  250. package/dist/services/products/BaseClass.js +2 -0
  251. package/dist/services/products/BaseClass.js.map +1 -1
  252. package/dist/services/products/TCGService.js +17 -1
  253. package/dist/services/products/TCGService.js.map +1 -1
  254. package/dist/services/products/utils.d.ts +22 -0
  255. package/dist/services/products/utils.js +50 -0
  256. package/dist/services/products/utils.js.map +1 -1
  257. package/dist/utils/anonymisation.d.ts +24 -0
  258. package/dist/utils/anonymisation.js +30 -0
  259. package/dist/utils/anonymisation.js.map +1 -1
  260. package/dist/utils/aws.d.ts +22 -0
  261. package/dist/utils/aws.js +28 -0
  262. package/dist/utils/aws.js.map +1 -1
  263. package/dist/utils/booking.d.ts +8 -0
  264. package/dist/utils/booking.js +9 -0
  265. package/dist/utils/booking.js.map +1 -1
  266. package/dist/utils/cart.d.ts +81 -0
  267. package/dist/utils/cart.js +175 -10
  268. package/dist/utils/cart.js.map +1 -1
  269. package/dist/utils/context.js +2 -2
  270. package/dist/utils/context.js.map +1 -1
  271. package/dist/utils/currency.js +31 -1
  272. package/dist/utils/currency.js.map +1 -1
  273. package/dist/utils/data.js +2 -0
  274. package/dist/utils/data.js.map +1 -1
  275. package/dist/utils/discount.d.ts +118 -0
  276. package/dist/utils/discount.js +178 -1
  277. package/dist/utils/discount.js.map +1 -1
  278. package/dist/utils/file-admin.js +1 -0
  279. package/dist/utils/file-admin.js.map +1 -1
  280. package/dist/utils/file.js +9 -1
  281. package/dist/utils/file.js.map +1 -1
  282. package/dist/utils/firebase-admin.d.ts +9 -0
  283. package/dist/utils/firebase-admin.js +12 -0
  284. package/dist/utils/firebase-admin.js.map +1 -1
  285. package/dist/utils/firebase.d.ts +17 -0
  286. package/dist/utils/firebase.js +17 -0
  287. package/dist/utils/firebase.js.map +1 -1
  288. package/dist/utils/inventories.d.ts +52 -0
  289. package/dist/utils/inventories.js +77 -2
  290. package/dist/utils/inventories.js.map +1 -1
  291. package/dist/utils/locale.d.ts +9 -0
  292. package/dist/utils/locale.js +9 -0
  293. package/dist/utils/locale.js.map +1 -1
  294. package/dist/utils/mailchimp.js +36 -0
  295. package/dist/utils/mailchimp.js.map +1 -1
  296. package/dist/utils/mathUtils.js +9 -0
  297. package/dist/utils/mathUtils.js.map +1 -1
  298. package/dist/utils/object.d.ts +19 -0
  299. package/dist/utils/object.js +21 -3
  300. package/dist/utils/object.js.map +1 -1
  301. package/dist/utils/products.d.ts +7 -0
  302. package/dist/utils/products.js +9 -0
  303. package/dist/utils/products.js.map +1 -1
  304. package/dist/utils/promiseToPurchase.d.ts +32 -0
  305. package/dist/utils/promiseToPurchase.js +34 -0
  306. package/dist/utils/promiseToPurchase.js.map +1 -1
  307. package/dist/utils/prosprsearch.d.ts +16 -0
  308. package/dist/utils/prosprsearch.js +34 -0
  309. package/dist/utils/prosprsearch.js.map +1 -1
  310. package/dist/utils/sdc.js +7 -0
  311. package/dist/utils/sdc.js.map +1 -1
  312. package/dist/utils/searchIndexes.d.ts +37 -0
  313. package/dist/utils/searchIndexes.js +37 -0
  314. package/dist/utils/searchIndexes.js.map +1 -1
  315. package/dist/utils/string.js +7 -6
  316. package/dist/utils/string.js.map +1 -1
  317. package/dist/utils/tools.d.ts +4 -0
  318. package/dist/utils/tools.js +4 -0
  319. package/dist/utils/tools.js.map +1 -1
  320. package/dist/utils/transferRequests.d.ts +24 -0
  321. package/dist/utils/transferRequests.js +24 -0
  322. package/dist/utils/transferRequests.js.map +1 -1
  323. package/dist/utils/update.js +12 -0
  324. package/dist/utils/update.js.map +1 -1
  325. package/package.json +1 -1
@@ -27,19 +27,24 @@ const floor_1 = __importDefault(require("lodash/floor"));
27
27
  const Cart_1 = require("../../../Interfaces/Cart");
28
28
  const G2_1 = require("../../../Interfaces/G2");
29
29
  const IDiscountRule_1 = require("../../../Interfaces/Rules/IDiscountRule");
30
+ // General utils
30
31
  const string_1 = require("../../../utils/string");
31
32
  const locale_1 = require("../../../utils/locale");
32
33
  const inventories_1 = require("../../../utils/inventories");
33
34
  const products_1 = require("../../../utils/products");
35
+ // Specitic utils
34
36
  const expedition_1 = require("./expedition");
35
37
  const products_2 = require("../constants/products");
36
38
  const g2_1 = require("./g2");
37
39
  const cart_1 = require("./cart");
40
+ // Specific interfaces
38
41
  const products_3 = require("../interfaces/products");
39
42
  const data_1 = require("../interfaces/data");
40
43
  const cart_2 = require("../interfaces/cart");
41
44
  const upsells_1 = require("./upsells");
42
45
  const object_1 = require("../../../utils/object");
46
+ // ----------------------------------------------------------------------------------------------------------
47
+ // #region PRODUCT UNITS
43
48
  const pluralSellUnits = {
44
49
  p2: { fr: 'pi²', en: 'sqft' },
45
50
  sac: { fr: 'sacs', en: 'bags' },
@@ -85,6 +90,14 @@ const sellUnitsBySlug = {
85
90
  pqt: { fr: 'paquet', en: 'bundle' },
86
91
  '': { fr: 'unité', en: 'unit' }
87
92
  };
93
+ /**
94
+ * @description Returns sell unit label in correct language for a specific product's other_units
95
+ * @param {IFilledDimensionUnits[] | undefined} otherUnits The unit array we have to check to get the sell unit
96
+ * @param {string | undefined} locale The language in which we want to return the label
97
+ * @param {string[]} returnUnitForSlugs An array of the slugs we want to return the unit label for
98
+ * @param {boolean} options.returnPlural If plural version should be returned
99
+ * @param {boolean} options.returnShortByDefault If short version should be prioritized
100
+ */
88
101
  const getProductSellUnitLabel = (otherUnits, locale = 'fr', returnUnitForSlugs, options = {}) => {
89
102
  if (!!!otherUnits)
90
103
  return '';
@@ -94,6 +107,15 @@ const getProductSellUnitLabel = (otherUnits, locale = 'fr', returnUnitForSlugs,
94
107
  return (0, exports.getUnitLabelWithSlug)(sellingUnit.unit_slug, locale, options.returnPlural, returnUnitForSlugs, options.returnShortByDefault);
95
108
  };
96
109
  exports.getProductSellUnitLabel = getProductSellUnitLabel;
110
+ /**
111
+ * @description Returns unit label in correct language for a specific product's other_units
112
+ * @param {IFilledDimensionUnits[] | undefined} otherUnits The unit array we have to check to get the sell unit
113
+ * @param {string} type The unit type to check
114
+ * @param {string | undefined} locale The language in which we want to return the label
115
+ * @param {string[]} returnUnitForSlugs An array of the slugs we want to return the unit label for
116
+ * @param {boolean} options.returnPlural If plural version should be returned
117
+ * @param {boolean} options.returnShortByDefault If short version should be prioritized
118
+ */
97
119
  const getProductUnitLabel = (otherUnits, type, locale = 'fr', returnUnitForSlugs, options = {}) => {
98
120
  if (!!!otherUnits)
99
121
  return '';
@@ -103,6 +125,14 @@ const getProductUnitLabel = (otherUnits, type, locale = 'fr', returnUnitForSlugs
103
125
  return (0, exports.getUnitLabelWithSlug)(unitToUse.unit_slug, locale, options.returnPlural, returnUnitForSlugs, options.returnShortByDefault);
104
126
  };
105
127
  exports.getProductUnitLabel = getProductUnitLabel;
128
+ /**
129
+ * Returns the unit label for a specific slug
130
+ * @param {string} unitSlug The slug of the unit for which we want to get the label
131
+ * @param {string | undefined} locale The language in which we want to get the label
132
+ * @param {boolean} getPluralVersion Optionnal - If the plural version should be returned instead.
133
+ * @param {string[]} returnUnitForSlugs The slugs for which we want to return a default value, in this case the unit slug for unit
134
+ * @param {boolean} returnShortByDefault Optionnal - If the short version should be prioritized
135
+ */
106
136
  const getUnitLabelWithSlug = (unitSlug, locale = 'fr', getPluralVersion = false, returnUnitForSlugs, returnShortByDefault) => {
107
137
  if (!!returnUnitForSlugs && !!returnUnitForSlugs.includes(unitSlug)) {
108
138
  return (0, exports.getUnitLabelWithSlug)('unite', locale, getPluralVersion);
@@ -116,6 +146,13 @@ const getUnitLabelWithSlug = (unitSlug, locale = 'fr', getPluralVersion = false,
116
146
  return longVersion || shortVersion || unitSlug;
117
147
  };
118
148
  exports.getUnitLabelWithSlug = getUnitLabelWithSlug;
149
+ /**
150
+ * Returns the plural unit label for a specific slug
151
+ * @deprecated Should use getUnitLabelWithSlug instead (with props getPluralVersion=true)
152
+ * @param {string} unitSlug The slug of the unit for which we want to get the label
153
+ * @param {string | undefined} locale The language in which we want to get the label
154
+ * @param {string[]} returnUnitForSlugs The slugs for which we want to return a default value, in this case the unit slug for unit
155
+ */
119
156
  const getPluralUnitLabelWithSlug = (unitSlug, locale = 'fr', returnUnitForSlugs, useShortIfDifferent) => {
120
157
  if (!!returnUnitForSlugs && !!returnUnitForSlugs.includes(unitSlug)) {
121
158
  return (0, locale_1.translateILang)(pluralSellUnitsBySlug['unite'], locale);
@@ -123,6 +160,7 @@ const getPluralUnitLabelWithSlug = (unitSlug, locale = 'fr', returnUnitForSlugs,
123
160
  const shortVersion = !!(0, inventories_1.getUnitShortDict)(unitSlug) ? (0, locale_1.translateILang)((0, inventories_1.getUnitShortDict)(unitSlug), locale) : '';
124
161
  const normalVersion = !!sellUnitsBySlug[unitSlug] ? (0, locale_1.translateILang)(sellUnitsBySlug[unitSlug], locale) : '';
125
162
  const pluralVersion = !!pluralSellUnitsBySlug[unitSlug] ? (0, locale_1.translateILang)(pluralSellUnitsBySlug[unitSlug], locale) : '';
163
+ // If useShowIfDifferent is defined, and short version is different from the "normal" version, return short value
126
164
  if (useShortIfDifferent && shortVersion != normalVersion)
127
165
  return shortVersion;
128
166
  return pluralVersion || shortVersion || unitSlug;
@@ -141,6 +179,10 @@ const productUnitSupportsDecimals = (unitSlug, isService) => {
141
179
  return !!isService || !!['p2', 'pl', 'vg3', 'tonne'].includes(unitSlug);
142
180
  };
143
181
  exports.productUnitSupportsDecimals = productUnitSupportsDecimals;
182
+ // #endregion
183
+ // ----------------------------------------------------------------------------------------------------------
184
+ // ----------------------------------------------------------------------------------------------------------
185
+ // #region GENERAL
144
186
  const getProductAttributes = (product) => {
145
187
  const arrColor = !!product.attributes[data_1.AttributesIdEnumGR.SUBCOLOR]
146
188
  ? product.attributes[data_1.AttributesIdEnumGR.SUBCOLOR]
@@ -169,6 +211,13 @@ const getDescriptionString = (showFullDesc, maxLength, description, locale = 'fr
169
211
  return truncated.join(' ') + ' [...]';
170
212
  };
171
213
  exports.getDescriptionString = getDescriptionString;
214
+ /**
215
+ * Returns rounded product sell_unit quantities depending on current value, value of secondary input if existant and sale unit per command step ratio found in product.
216
+ * @param value {number} - Current quantity as entered by user in first input
217
+ * @param otherUnits {IFilledDimensionUnits[] | undefined} - FilledDimensionUnits found in product (possibly undefined)
218
+ * @param value2 {number | undefined} - Current quantity as entered by user in second input (possibly undefined)
219
+ * @param targetIsSecondaryInput {boolean} - If action was triggered from secondary input (defaults to false)
220
+ */
172
221
  const getRoundedSellUnitProductQuantities = (value, otherUnits = [], value2, targetIsSecondaryInput = false) => {
173
222
  var _a;
174
223
  const saleUnit = otherUnits.find((unit) => unit.is_sale_unit);
@@ -178,14 +227,18 @@ const getRoundedSellUnitProductQuantities = (value, otherUnits = [], value2, tar
178
227
  qte1: value,
179
228
  qte2: value2
180
229
  };
230
+ // Now rounds quantities in calculations to 2 or 0 decimals (depending on what the unit supports)
181
231
  if (!!targetIsSecondaryInput && typeof value2 === 'number') {
182
232
  if (!!commandStep && !!commandStep.fitting_unit && !!commandUnit && !!commandUnit.fitting_unit && !!saleUnit) {
183
233
  const nbCmdUnitPerCmdStep = (0, round_1.default)(commandStep.fitting_unit / commandUnit.fitting_unit, 5);
184
234
  const nbSaleUnitPerCmdStep = (0, round_1.default)(commandStep.fitting_unit / ((_a = saleUnit.fitting_unit) !== null && _a !== void 0 ? _a : 1), (0, exports.productUnitSupportsDecimals)(saleUnit.unit_slug) ? 5 : 0);
235
+ // Round value2 to command step
185
236
  const roundedValue = value2 === 0
186
237
  ? 0
187
238
  : _roundNbUnitPerCmdStep(value2, nbCmdUnitPerCmdStep, (0, exports.productUnitSupportsDecimals)(saleUnit.unit_slug) ? 2 : 0);
239
+ // Calculate amount of current command units by dividing roundedValue with nbCmdUnitPerCmdStep
188
240
  const nbOfRoundedCmdUnits = roundedValue / nbCmdUnitPerCmdStep;
241
+ // Then multiply result by amount of sale units in one command step
189
242
  const nbOfRoundedSaleUnits = nbOfRoundedCmdUnits * nbSaleUnitPerCmdStep;
190
243
  roundedQuantities = {
191
244
  qte1: value2 === 0
@@ -207,8 +260,20 @@ const getRoundedSellUnitProductQuantities = (value, otherUnits = [], value2, tar
207
260
  if (value === 0) {
208
261
  commandUnitQty = 0;
209
262
  }
263
+ // ** NOTE - Commented section here to fix rounding bug - Commented on 10-09-2025, in relation to bug GR-I540
264
+ // if sell_unit has a fitting unit of 1, we can simply divide the command_unit from roundedValue to get result
265
+ // else if (saleFittingUnit == 1) {
266
+ // console.log('YO YO YO are we HERE&&????')
267
+ // commandUnitQty = round(
268
+ // roundedValue / commandUnit.fitting_unit,
269
+ // productUnitSupportsDecimals(commandUnit.unit_slug) ? 2 : 0
270
+ // )
271
+ // }
210
272
  else {
273
+ // Calculate amount of current command steps by dividing roundedValue with saleUnitsPerCommandStep
274
+ // ** NOTE - Added round here on 10-09-2025 in relation to bug GR-I540
211
275
  const nbOfCmdSteps = (0, round_1.default)(roundedValue / nbSaleUnitPerCmdStep, (0, exports.productUnitSupportsDecimals)(saleUnit.unit_slug) ? 5 : 0);
276
+ // Then multiply result by amount of command unit in one command step
212
277
  commandUnitQty =
213
278
  nbOfCmdSteps *
214
279
  (0, round_1.default)(cmdStepFittingUnit / commandUnit.fitting_unit, (0, exports.productUnitSupportsDecimals)(commandUnit.unit_slug) ? 5 : 0);
@@ -223,6 +288,12 @@ const getRoundedSellUnitProductQuantities = (value, otherUnits = [], value2, tar
223
288
  return roundedQuantities;
224
289
  };
225
290
  exports.getRoundedSellUnitProductQuantities = getRoundedSellUnitProductQuantities;
291
+ /**
292
+ * Returns rounded product quantities depending on current value per command step ratio found in product.
293
+ * @param value {number} - Current quantity as entered by user in first input
294
+ * @param otherUnits {IFilledDimensionUnits[] | undefined} - FilledDimensionUnits found in product (possibly undefined)
295
+ * @param type {'sale_unit' | 'inventory_unit'} - Quantity type for computing
296
+ */
226
297
  const getRoundedUnitProductQuantities = (value, otherUnits = [], type) => {
227
298
  const unitToTest = type == 'sale_unit'
228
299
  ? otherUnits.find((unit) => unit.is_sale_unit)
@@ -242,8 +313,9 @@ const getRoundedUnitProductQuantities = (value, otherUnits = [], type) => {
242
313
  };
243
314
  exports.getRoundedUnitProductQuantities = getRoundedUnitProductQuantities;
244
315
  const _roundNbUnitPerCmdStepV2 = (value, nbUnitPerCmdStep, decimalsToCheck = 0) => {
245
- const currentFittingValue = (0, floor_1.default)(value / nbUnitPerCmdStep, 5);
316
+ const currentFittingValue = (0, floor_1.default)(value / nbUnitPerCmdStep, 5); // Rounds unsignificant quantities to lower value (ex. if result is 0.000007, we don't want it to round up to 1)
246
317
  const roundedUp = (0, round_1.default)((0, ceil_1.default)(currentFittingValue) * nbUnitPerCmdStep, decimalsToCheck);
318
+ // retrun roundedUp as default value.
247
319
  return roundedUp;
248
320
  };
249
321
  const _roundNbUnitPerCmdStep = (value, nbUnitPerCmdStep, decimalsToCheck = 0) => {
@@ -255,16 +327,29 @@ const _roundNbUnitPerCmdStep = (value, nbUnitPerCmdStep, decimalsToCheck = 0) =>
255
327
  }
256
328
  const rounded = (0, round_1.default)(value / nbUnitPerCmdStep, decimalsToCheck) * nbUnitPerCmdStep;
257
329
  const roundedUp = Math.ceil(value / nbUnitPerCmdStep) * nbUnitPerCmdStep;
330
+ // if rounded value is 0, but roundedUp is > 0, return roundedUp
258
331
  if (rounded == 0 && roundedUp > 0)
259
332
  return roundedUp;
333
+ // ** NEW - Added on 10-09-2025 in relation to bug GR-I540
334
+ // if provided value is already a multiple of cmdStep, return value
260
335
  if ((0, round_1.default)(value % nbUnitPerCmdStep, decimalsToCheck) == 0)
261
336
  return rounded;
337
+ // if provided value is larger than rounded, and roundedUp is an exact multiple of rounded, return roundedUp
262
338
  if ((0, round_1.default)(value, decimalsToCheck) > rounded + numberBuffer)
263
339
  return roundedUp;
340
+ // if rounded value is an exact multiple of cmdStep, return rounded
264
341
  if ((0, round_1.default)(rounded, decimalsToCheck) % nbUnitPerCmdStep <= numberBuffer)
265
342
  return rounded;
343
+ // retrun roundedUp as default value.
266
344
  return roundedUp;
267
345
  };
346
+ /**
347
+ *
348
+ * @param {string} stringToSplit
349
+ * @param {string} dummyStringToReplace.currentValue, optionnal, default : '%%-%%'. Used to provide general replace values for a specific string. Is applied to both sections of the splitted string.
350
+ * @param {string} dummyStringToReplace.newValue, optionnal, default : ' - '. Used to provide general replace values for a specific string. Is applied to both sections of the splitted string.
351
+ * @returns {string[]}
352
+ */
268
353
  const splitOnDashes = (stringToSplit, dummyStringToReplace = { currentValue: '%%-%%', newValue: ' - ' }) => {
269
354
  let splited = stringToSplit.split(' - ');
270
355
  if (splited.length === 1)
@@ -279,6 +364,12 @@ const splitOnDashes = (stringToSplit, dummyStringToReplace = { currentValue: '%%
279
364
  ];
280
365
  };
281
366
  exports.splitOnDashes = splitOnDashes;
367
+ /**
368
+ * Get product name as array. Array created mostly by splitting name on dash symbol (and variations).
369
+ * @param {IIndexedVariationAlgolia | IIndexedProduct} product
370
+ * @param {string | undefined} locale
371
+ * @returns {string[]} - Position 0 is the "commum section" of the name, and position 1 should contain all specifics (ex. color, size, etc...)
372
+ */
282
373
  const getProdName = (product, locale) => {
283
374
  let name;
284
375
  if (!!product.full_name) {
@@ -294,23 +385,33 @@ const getProdName = (product, locale) => {
294
385
  }
295
386
  let newNameArray = [];
296
387
  const dashesToFind = [' - ', '- ', ' -'];
388
+ // If name includes parenthesis...
297
389
  if (name.includes('(')) {
298
390
  let newStr = '';
299
391
  let strWithParenthesisToCheck = name;
392
+ // a. Replace all occurences of dashesToFind found between parenthesis with '-'
300
393
  while (strWithParenthesisToCheck.includes('(')) {
301
394
  let positionStart = strWithParenthesisToCheck.indexOf('(');
302
395
  let positionEnd = strWithParenthesisToCheck.indexOf(')');
396
+ // When first string between paranthesis found, replace dashesToFind
303
397
  let substrToCheck = strWithParenthesisToCheck.substring(positionStart, positionEnd + 1);
304
398
  for (let dash of dashesToFind) {
305
399
  substrToCheck = substrToCheck.replace(dash, '-');
306
400
  }
401
+ // Add updated string to newStr from the beginning to the end of section with parenthesis
307
402
  newStr += strWithParenthesisToCheck.substring(0, positionStart) + substrToCheck;
403
+ // Strip checked string to remove section added to newStr.
404
+ // This will mean next time we go through the loop, logic will check for next section with parenthesis. If not found, loop ends.
308
405
  strWithParenthesisToCheck =
309
406
  positionEnd === strWithParenthesisToCheck.length - 1 ? '' : strWithParenthesisToCheck.substring(positionEnd + 1);
310
407
  }
408
+ // Add ending of string to newly formatted string after loop done (in case last parenthesis found was not at the end of the string)
311
409
  newStr += strWithParenthesisToCheck;
410
+ // b. Isolate "first part" of string
312
411
  const positionOfFirst = newStr.indexOf(')');
313
412
  let firstPart = newStr.substring(0, positionOfFirst);
413
+ // If first closing parenthesis is not at end of string and firstPart contains dashesToFind, it means the ' - ' should be keep intact.
414
+ // Replace ' - ' found with uncommon string so we can put it back later, then call splitOnDashes function
314
415
  if (positionOfFirst !== newStr.length - 1 && dashesToFind.some((str) => firstPart.includes(str))) {
315
416
  const secondPart = newStr.substring(positionOfFirst);
316
417
  for (let str of dashesToFind) {
@@ -318,16 +419,22 @@ const getProdName = (product, locale) => {
318
419
  }
319
420
  newNameArray = (0, exports.splitOnDashes)(`${firstPart}${secondPart}`);
320
421
  }
422
+ // Else, simply call splitOnDashes function
321
423
  else {
322
424
  newNameArray = (0, exports.splitOnDashes)(newStr);
323
425
  }
324
426
  }
427
+ // Else, no parenthesis found, call splitOnDashes function
325
428
  else {
326
429
  newNameArray = (0, exports.splitOnDashes)(name);
327
430
  }
328
431
  return newNameArray;
329
432
  };
330
433
  exports.getProdName = getProdName;
434
+ /**
435
+ * Function getParentProductCategoryGroup
436
+ * @param prod - Product to check
437
+ */
331
438
  const getParentProductCategoryGroup = (prod) => {
332
439
  let type = 'other';
333
440
  if (!!prod.categories && !!prod.categories['lvl0']) {
@@ -353,11 +460,18 @@ const getParentProductCategoryGroup = (prod) => {
353
460
  return type;
354
461
  };
355
462
  exports.getParentProductCategoryGroup = getParentProductCategoryGroup;
463
+ /**
464
+ * Function getProductFormOptions - Returns all AttributeValues for product to construct options in add to cart form
465
+ * @param product - Product to check
466
+ * @param attributes - Array of IAttributes to fetch info from
467
+ */
356
468
  const getProductFormOptions = (product, attributes) => {
357
469
  let allColorOptions = [];
358
470
  let allDimensionOptions = [];
359
471
  let allFormatOptions = [];
472
+ //Product Attributes
360
473
  const product_attributes = (0, exports.getProductAttributes)(product);
474
+ //Overridden attr
361
475
  let overridenAttributes = product.declinations
362
476
  .map((declination) => declination.overriden_attributes)
363
477
  .filter((ova) => !!ova);
@@ -387,6 +501,8 @@ const getProductFormOptions = (product, attributes) => {
387
501
  }
388
502
  return finalOptions;
389
503
  };
504
+ // ----------------------------------------------------------
505
+ // #region colors
390
506
  const subColorsAttr = attributes.find((attr) => attr.id === data_1.AttributesIdEnumGR.SUBCOLOR);
391
507
  if (!!subColorsAttr) {
392
508
  const subColors = subColorsAttr.values;
@@ -394,6 +510,10 @@ const getProductFormOptions = (product, attributes) => {
394
510
  const finalColors = getOverriddenValues(colorsAttributes, data_1.AttributesIdEnumGR.SUBCOLOR);
395
511
  allColorOptions = (0, orderBy_1.default)(finalColors, (color) => product.declinations.findIndex((d) => d.attributes[data_1.AttributesIdEnumGR.SUBCOLOR].includes(color.slug)));
396
512
  }
513
+ // #endregion
514
+ // ----------------------------------------------------------
515
+ // ----------------------------------------------------------
516
+ // #region dimensions
397
517
  const dimensionsAttr = attributes.find((attr) => attr.id === data_1.AttributesIdEnumGR.DIMENSIONS);
398
518
  if (!!dimensionsAttr) {
399
519
  const dimensions = dimensionsAttr.values;
@@ -401,11 +521,17 @@ const getProductFormOptions = (product, attributes) => {
401
521
  const finalDimensions = getOverriddenValues(dimensionsAttributes, data_1.AttributesIdEnumGR.DIMENSIONS);
402
522
  allDimensionOptions = finalDimensions;
403
523
  }
524
+ // #endregion
525
+ // ----------------------------------------------------------
526
+ // ----------------------------------------------------------
527
+ // #region formats
404
528
  const formatsAttr = attributes.find((attr) => attr.id === data_1.AttributesIdEnumGR.FORMATS);
405
529
  if (!!formatsAttr) {
406
530
  const formats = formatsAttr.values;
407
531
  allFormatOptions = formats.filter((f) => product_attributes.formats.includes(f.slug));
408
532
  }
533
+ // #endregion
534
+ // ----------------------------------------------------------
409
535
  return {
410
536
  allColors: allColorOptions,
411
537
  allDimensions: allDimensionOptions,
@@ -413,6 +539,13 @@ const getProductFormOptions = (product, attributes) => {
413
539
  };
414
540
  };
415
541
  exports.getProductFormOptions = getProductFormOptions;
542
+ /**
543
+ * @description Checks if product is of type by checking TYPE attribute value. Works with indexed product or cart item.
544
+ * @param product
545
+ * @param type
546
+ * @param excludeUndefined If excludeUndefined is true, products without the "type" attribute will return true
547
+ * @returns boolean
548
+ */
416
549
  const checkIfProductIsOfType = (product, type, excludeUndefined) => {
417
550
  const attr = !!product && !!product.attributes ? product.attributes : {};
418
551
  if (!!!attr[data_1.AttributesIdEnumGR.TYPE] && !!excludeUndefined)
@@ -422,15 +555,29 @@ const checkIfProductIsOfType = (product, type, excludeUndefined) => {
422
555
  attr[data_1.AttributesIdEnumGR.TYPE].includes(type));
423
556
  };
424
557
  exports.checkIfProductIsOfType = checkIfProductIsOfType;
558
+ // #endregion
559
+ // ----------------------------------------------------------------------------------------------------------
560
+ // ----------------------------------------------------------------------------------------------------------
561
+ // #region GRASS
425
562
  const checkIfProductIsInstallation = (item) => {
426
563
  return !!item.is_service && !!item.parent_slug && !!item.parent_slug.includes('installation');
427
564
  };
428
565
  exports.checkIfProductIsInstallation = checkIfProductIsInstallation;
566
+ /**
567
+ * Returns array of installation items found in provided array
568
+ * @param items - Array of cart items or IIndexedDeclinations to check
569
+ */
429
570
  const getAllInstallFromItems = (items) => {
430
571
  return items.filter((i) => (!!i.parent_slug && products_2.installationProductsSlugs.includes(i.parent_slug)) ||
431
572
  Object.values(products_2.installationProSpecSkus).includes(i.sku));
432
573
  };
433
574
  exports.getAllInstallFromItems = getAllInstallFromItems;
575
+ /**
576
+ * Function fuseGrassProducts
577
+ * @description - Returns items with only one apparent grass product (used for detail customers).
578
+ * ** FOR DISPLAY PURPOSES ONLY - Always save grass products separatly in ICart **
579
+ * @param recursiveItems - ICartItems with subitems (object created for display purposes)
580
+ */
434
581
  const fuseGrassProducts = (recursiveItems, isPro) => {
435
582
  const specialityGrass = recursiveItems[0];
436
583
  const kentuckyGrass = (specialityGrass.sub_items || []).find((sub) => sub.sku === products_2.kentucky);
@@ -490,6 +637,7 @@ const getMinQtyFeeText = (parent_slug = '', grassProduct, isPro, locale = 'fr',
490
637
  fr: ` Ce frais correspond au prix du gazon choisi multiplié par la différence entre la quantité choisie et le minimum.`,
491
638
  en: ` Ce frais correspond au prix du gazon choisi multiplié par la différence entre la quantité choisie et le minimum.`
492
639
  }, locale);
640
+ // If expedition method not chosen yet, and pickup & shipping quantities are different, show both
493
641
  if (!!!expeditionMethod && type === 'order' && minQuantities.pickup !== minQuantities.shipping) {
494
642
  const strMinShipping = `${minQuantities.shipping}${localeSellUnit} (${minQuantities.shipping / 740} ${localeMinUnit})`;
495
643
  const strMinPickup = !!minQuantities.pickup
@@ -504,6 +652,7 @@ const getMinQtyFeeText = (parent_slug = '', grassProduct, isPro, locale = 'fr',
504
652
  }
505
653
  return str;
506
654
  }
655
+ // Show specific quantity for expedition type
507
656
  const minBillableQty = type === 'install'
508
657
  ? minQuantities.install
509
658
  : expeditionMethod === 'pickup'
@@ -586,6 +735,12 @@ const getGrassSubQuestionsByType = (type) => {
586
735
  return products_2.otherGrassSubQuestions.filter((sub) => 'installation-gazon' === sub.associatedProductSlug || (!!sub.installOnly && !!!sub.proOnly));
587
736
  };
588
737
  exports.getGrassSubQuestionsByType = getGrassSubQuestionsByType;
738
+ /**
739
+ * @description For grass products. Over 1480pi2, if installation, quantities are rounded to rolls (10pi2) if pickup, and to half pal. if shipping
740
+ * @param grassProduct
741
+ * @param cartData
742
+ * @returns quantity rounded to rolls with items to change or undefined
743
+ */
589
744
  const handleGrassProductQtyRoundForShipping = (cartData, grassProduct) => {
590
745
  if (!!!cartData || !!!grassProduct)
591
746
  return;
@@ -595,10 +750,12 @@ const handleGrassProductQtyRoundForShipping = (cartData, grassProduct) => {
595
750
  const productOtherUnits = product.other_units;
596
751
  if (!!!productOtherUnits)
597
752
  return;
753
+ // get new rounded qte
598
754
  const palUnit = productOtherUnits.find((u) => u.unit_slug === 'pal');
599
755
  const rounded = (0, exports.roundGrassQte)(product.qte, !!!cartData.is_pickup, palUnit);
600
756
  if (!!!rounded || rounded === grassProduct.qte)
601
757
  return;
758
+ // ajust items with new quantity
602
759
  let itemsToChange = [];
603
760
  const recursiveGrassItem = (0, cart_1.getRecursiveItems)(cartData.items).find((item) => item.sku === grassProduct.sku);
604
761
  const getItemsToChange = (item) => {
@@ -647,6 +804,13 @@ const handleGrassProductQtyRoundForShipping = (cartData, grassProduct) => {
647
804
  return { rounded, itemsToChange };
648
805
  };
649
806
  exports.handleGrassProductQtyRoundForShipping = handleGrassProductQtyRoundForShipping;
807
+ /**
808
+ * Function roundGrassQte
809
+ * @description Returns rounded grass quantity depending on current qty, if customer selected installation and pallet unit (if defined)
810
+ * @param currentQte {number} - Current quantity as entered by user in input
811
+ * @param isShipping {boolean} - Whether customer has selected installation option
812
+ * @param palUnit {IFilledDimensionUnits | undefined} - Pallet FilledDimensionUnit (possibly undefined)
813
+ */
650
814
  const roundGrassQte = (currentQte, isShipping, palUnit) => {
651
815
  let newQte = currentQte;
652
816
  switch (true) {
@@ -680,6 +844,11 @@ const roundGrassQte = (currentQte, isShipping, palUnit) => {
680
844
  return newQte;
681
845
  };
682
846
  exports.roundGrassQte = roundGrassQte;
847
+ /**
848
+ * Detects if customer has "Installation tout inclus".
849
+ * @param customPriceList - Customer custom price list
850
+ * @return All inclusive installation if exists, undefined otherwise
851
+ */
683
852
  const getInstallationAllInclusiveFromPriceList = (customPriceList) => {
684
853
  if (!!!customPriceList || !!!customPriceList.length)
685
854
  return;
@@ -690,10 +859,22 @@ const getInstallationAllInclusiveFromPriceList = (customPriceList) => {
690
859
  return item;
691
860
  };
692
861
  exports.getInstallationAllInclusiveFromPriceList = getInstallationAllInclusiveFromPriceList;
862
+ /**
863
+ * Checks if all-inclusive installation is active.
864
+ * @param hasInstallation - Whether the cart/form contains an installation
865
+ * @param isPro - Whether the customer is a pro
866
+ * @param customPriceList - Customer custom price list
867
+ * @returns true if all-inclusive installation is active
868
+ */
693
869
  const isInstallAllInclusiveActive = (hasInstallation, isPro, customPriceList) => {
694
870
  return !!hasInstallation && !!isPro && !!(0, exports.getInstallationAllInclusiveFromPriceList)(customPriceList);
695
871
  };
696
872
  exports.isInstallAllInclusiveActive = isInstallAllInclusiveActive;
873
+ /**
874
+ * Force )$ to kentucky base grass and sod delivery fee if install all-inclusive.
875
+ * @param item - The cart item to potentially override
876
+ * @returns The item with zeroed price if applicable, or the original item
877
+ */
697
878
  const applyAllInclusiveOverrides = (item) => {
698
879
  const isKentucky = item.parent_slug === 'kentucky' || item.sku === products_2.kentucky;
699
880
  const isSodDelivery = item.parent_slug === 'livraison-gazon' && products_2.sodDeliverySkus.includes(item.sku);
@@ -703,17 +884,21 @@ const applyAllInclusiveOverrides = (item) => {
703
884
  return item;
704
885
  };
705
886
  exports.applyAllInclusiveOverrides = applyAllInclusiveOverrides;
887
+ // Determines if a cart item should be hidden from checkout display. Used for all-inclusive installation
706
888
  const shouldHideItemInCheckout = (item, allItems) => {
707
889
  const hasAllInclusive = allItems.some((i) => i.sku === products_2.installationAllInclusiveSku);
708
890
  if (!hasAllInclusive)
709
891
  return false;
710
892
  if (item.regular_price.amount !== 0)
711
893
  return false;
894
+ // Hide installation upsells at $0 (mobilisation, fertilisation, roulage, etc.)
712
895
  const installationSkus = allItems.filter((i) => i.parent_slug === 'installation-gazon').map((i) => i.sku);
713
896
  if (!!item.is_upsell_of_sku && installationSkus.includes(item.is_upsell_of_sku))
714
897
  return true;
898
+ // Hide sod delivery at $0
715
899
  if (item.parent_slug === 'livraison-gazon')
716
900
  return true;
901
+ // Hide installation surcharges at $0 (e.g. surcharge mobilisation île de Montréal)
717
902
  if (item.parent_slug === 'surcharges-installation-gazon')
718
903
  return true;
719
904
  return false;
@@ -728,6 +913,8 @@ const getInstallationArray = async (qte, baseGrassUpsells, fetchProduct, locale,
728
913
  const installation_parent = await fetchProduct('installation-gazon', locale, true, true);
729
914
  let installation_decli;
730
915
  const minQteInstall = (0, expedition_1.getMinQteInstall)(isPro);
916
+ // Variable pour vérifier si une déclinaison d'installation existe déjà dans le cart
917
+ // ** Utile pour la modification des items du cart, vu que la props is_upsell_of_sku ne peut pas se modifier on update
731
918
  let arrayFinal = [];
732
919
  if (!!installation_parent && !!installation_upsell && !!installation_upsell.length) {
733
920
  let installation_array = [];
@@ -745,8 +932,11 @@ const getInstallationArray = async (qte, baseGrassUpsells, fetchProduct, locale,
745
932
  const closestQte = (0, maxBy_1.default)(installation_qte_array.filter((upsell) => {
746
933
  return upsell.actual_qty <= qte;
747
934
  }), 'actual_qty');
935
+ // MODIFS. FRAIS 2024 - On n'ajoute pas les frais au panier si leur prix régulier est de 0.00$
936
+ // Vérification faite à chaque ajout de déclinaison au arrayFinal
748
937
  if (!!closestQte) {
749
938
  installation_decli = installation_parent.declinations.find((decli) => decli.sku === closestQte.recommendation_sku);
939
+ // Check if customer has installation all-inclusive
750
940
  const allInclusivePriceItem = !!isPro && !!customPriceList ? (0, exports.getInstallationAllInclusiveFromPriceList)(customPriceList) : undefined;
751
941
  if (!!installation_decli) {
752
942
  const allInclusiveDecli = !!allInclusivePriceItem && !!installation_parent
@@ -761,10 +951,12 @@ const getInstallationArray = async (qte, baseGrassUpsells, fetchProduct, locale,
761
951
  installation_decli = (0, g2_1.checkForCustomPriceEquivalent)(installation_decli, customPriceList);
762
952
  }
763
953
  }
954
+ // Add the correct installation option depending on whether the customer has "Installation tout inclus"
764
955
  if (!(0, exports.shouldHideItemIfRegPriceIs0)(installation_decli, installation_parent.slug)) {
765
956
  arrayFinal.push(Object.assign(Object.assign({}, installation_decli), { parent_slug: 'installation-gazon', qte: qte, is_upsell_of_sku: chosenSku, product_upsells: installation_parent.product_upsells }));
766
957
  }
767
958
  }
959
+ // Frais minimum d'installation
768
960
  if (qte < minQteInstall) {
769
961
  const minimum_installation_fee = await fetchProduct('frais-minimum-gazon-pour-installation', locale, true, true);
770
962
  if (!!minimum_installation_fee) {
@@ -778,6 +970,7 @@ const getInstallationArray = async (qte, baseGrassUpsells, fetchProduct, locale,
778
970
  }
779
971
  }
780
972
  }
973
+ // Frais de mobilisation (pour l'installation)
781
974
  const mobilisation_fee = await fetchProduct('frais-de-mobilisation', locale, true, true);
782
975
  if (!!mobilisation_fee && !!isPro) {
783
976
  let mobilisationDecli = mobilisation_fee.declinations[0];
@@ -790,8 +983,11 @@ const getInstallationArray = async (qte, baseGrassUpsells, fetchProduct, locale,
790
983
  : minQteInstall / (740 * expedition_1.installationFeePalletTier)), is_upsell_of_sku: installation_decli.sku, product_upsells: mobilisation_fee.product_upsells }));
791
984
  }
792
985
  }
986
+ // -----------------------------------------------------------------------
987
+ // AUTRES FRAIS CONNEXES
793
988
  if (!!returnOtherFees) {
794
989
  if (!!returnOtherFees.engrais) {
990
+ // fertilisation
795
991
  const fertilisation = await fetchProduct('installation-fertilisation', locale, true, true);
796
992
  if (!!fertilisation) {
797
993
  let minFertilisationDecli = fertilisation.declinations[0];
@@ -804,6 +1000,7 @@ const getInstallationArray = async (qte, baseGrassUpsells, fetchProduct, locale,
804
1000
  }
805
1001
  }
806
1002
  if (returnOtherFees.roulage) {
1003
+ // roullage
807
1004
  const roullage = await fetchProduct('installation-roulage', locale, true, true);
808
1005
  if (!!roullage) {
809
1006
  let minRoulageDecli = roullage.declinations[0];
@@ -840,6 +1037,10 @@ const getInstallItemPrice = (parentSlug, servicesFees) => {
840
1037
  return price;
841
1038
  };
842
1039
  exports.getInstallItemPrice = getInstallItemPrice;
1040
+ // #endregion
1041
+ // ----------------------------------------------------------------------------------------------------------
1042
+ // ----------------------------------------------------------------------------------------------------------
1043
+ // #region CONCRETE
843
1044
  const getConcreteQteText = (declination, locale = 'fr') => {
844
1045
  let txt = '';
845
1046
  if (!!!declination)
@@ -868,6 +1069,7 @@ const getConcreteQteText = (declination, locale = 'fr') => {
868
1069
  nbSaleUnitsPerCmdStep = !!cmdSameAsSale
869
1070
  ? commandStep.fitting_unit / commandUnit.fitting_unit
870
1071
  : commandStep.fitting_unit / saleUnit.fitting_unit;
1072
+ // Round at correct decimals for products where commandStep.fitting_unit is 1 (meaning value calculated before is correct sell units per step)
871
1073
  nbUnitsPerPal =
872
1074
  commandStep.fitting_unit == 1 && !!!commandStep.is_sale_unit
873
1075
  ? unitsPerPal.fitting_unit *
@@ -894,6 +1096,11 @@ const getConcreteQteText = (declination, locale = 'fr') => {
894
1096
  return txt;
895
1097
  };
896
1098
  exports.getConcreteQteText = getConcreteQteText;
1099
+ /**
1100
+ * @description returns all items in cart where attribute AVAILABILITY contains wanted type.
1101
+ * @param cartData
1102
+ * @param availabilityType
1103
+ */
897
1104
  const getConcreteItemsByAvailability = (cartData, availabilityType, returnTrueIfUndefined) => {
898
1105
  return cartData.items.filter((i) => {
899
1106
  return ((i.attributes[data_1.AttributesIdEnumGR.AVAILABILITY] &&
@@ -902,8 +1109,21 @@ const getConcreteItemsByAvailability = (cartData, availabilityType, returnTrueIf
902
1109
  });
903
1110
  };
904
1111
  exports.getConcreteItemsByAvailability = getConcreteItemsByAvailability;
1112
+ // #endregion
1113
+ // ----------------------------------------------------------------------------------------------------------
1114
+ // ----------------------------------------------------------------------------------------------------------
1115
+ // #region VRAC
1116
+ /**
1117
+ * Function getVracType - constructs vrac helper object is cart contains vrac or vrac associated items.
1118
+ * @param stores
1119
+ * @param cartData
1120
+ * @param getInventoryItemCallback
1121
+ * @param inventoryItemArray
1122
+ * @returns IVracType object containing vrac_type enum value and vrac_store_ids where vrac items are available
1123
+ */
905
1124
  const getVracType = async (stores, cartData, getInventoryItemCallback, inventoyItemArray) => {
906
1125
  const items = cartData.items;
1126
+ // If cart does not contain vrac or vrac-agacent accessories (.is_other_type==='vrac)), return
907
1127
  if (!!!items ||
908
1128
  !!!items.length ||
909
1129
  (!!!(0, cart_1.checkIfCartContainsType)(cart_2.CartGeneralTypeEnum.VRAC, cartData) &&
@@ -944,6 +1164,31 @@ const getVracType = async (stores, cartData, getInventoryItemCallback, inventoyI
944
1164
  }
945
1165
  };
946
1166
  exports.getVracType = getVracType;
1167
+ // #endregion
1168
+ // ----------------------------------------------------------------------------------------------------------
1169
+ // ----------------------------------------------------------------------------------------------------------
1170
+ // #region FEES
1171
+ /**
1172
+ * Get all possible fees for a cart with basic info, to show approx. fee total before all data is saved in cart
1173
+ *
1174
+ * @param useFees If local fee array should be used, to save database calls
1175
+ * @param newCart Current cart data
1176
+ * @param deliveryType If fees should be checked for a pick-up or shipping order
1177
+ * @param fetchProduct Callback function for product fetch
1178
+ * @param getIfAddressIsInsideZones Callback function for zone check
1179
+ * @param getDistanceFromAddress Callback function to check distance with provided address
1180
+ * @param locale User's locale (fr or en)
1181
+ * @param allStores Full store array for space
1182
+ * @param isPro If customer associated with cart is a pro customer
1183
+ * @param grassProduct Constructed grass product from cart (with extra data for checks)
1184
+ * @param concreteOrder Constructed concrete products from cart (with extra data for checks)
1185
+ * @param settings.addOnePalletToPickup Optionnal - If additionnal pal. should be added for order
1186
+ * @param settings.saveToShippingPayload Optional - If data collected should be saved to cart's shipping_payload
1187
+ * @param settings.useStoreAddress Optionnal - Provided store ID for which the address should be used for check
1188
+ * @param settings.useDeliveryAddress Optionnal - If current carts shipping address should be used for check
1189
+ * @param settings.useAvailableVracStores Optionnal - Provided array of store IDs available for vrac order
1190
+ * @param customPriceList Optionnal - If pro customer with G2 custom price list and custom prices should be checked
1191
+ */
947
1192
  const fetchFeesBeforeCart = async (useFees, newCart, deliveryType, fetchProduct, getIfAddressIsInsideZones, getDistanceFromAddress, locale, allStores, isPro, grassProduct, concreteOrder, settings, customPriceList) => {
948
1193
  const cartContainsVrac = (0, cart_1.checkIfCartContainsType)(cart_2.CartGeneralTypeEnum.VRAC, newCart);
949
1194
  const cartContainsInstallation = (0, cart_1.checkIfCartContainsType)(cart_2.CartGeneralTypeEnum.INSTALLATION, newCart);
@@ -960,14 +1205,27 @@ const fetchFeesBeforeCart = async (useFees, newCart, deliveryType, fetchProduct,
960
1205
  : undefined, locale, undefined, false, cartContainsAccessoriesOnly, undefined, allStores, customPriceList, !!useFees);
961
1206
  };
962
1207
  exports.fetchFeesBeforeCart = fetchFeesBeforeCart;
1208
+ // #endregion
1209
+ // ----------------------------------------------------------------------------------------------------------
1210
+ // ----------------------------------------------------------------------------------------------------------
1211
+ // #region PRO SPECIFICITIES
1212
+ /**
1213
+ * Check if pro custom promo info should be shown for customer for a specific product.
1214
+ * @param userData
1215
+ * @param isPro
1216
+ * @param product
1217
+ * @param customMinPrice
1218
+ */
963
1219
  const shouldShowProCustomPromo = (userData, isPro, product, customMinPrice) => {
964
1220
  if (!!!product || !!!isPro || !!!userData)
965
1221
  return false;
1222
+ // If customMinPrice is defined (meaning customer has custom price list), and the price type is not REG or has type NET, always return true
966
1223
  if (!!customMinPrice) {
967
1224
  if (customMinPrice.type === G2_1.CustomPriceItemTypeEnum.REG && customMinPrice.code2 !== 'NET')
968
1225
  return false;
969
1226
  return true;
970
1227
  }
1228
+ // Check customer group. If promo exists and should apply for customer group, return true
971
1229
  const customerGroup = (0, object_1.recursiveCheckObject)(userData, 'userData.basic_info.customer_professionnal_info.external_customer_group');
972
1230
  const customerType = !!customerGroup ? (0, g2_1.getG2CustomerTypeFromCode)(customerGroup) : undefined;
973
1231
  const prodPriceClass = !!product.price_classes_range
@@ -1014,22 +1272,35 @@ const applyProCustomPromo = (decli, userData) => {
1014
1272
  };
1015
1273
  };
1016
1274
  exports.applyProCustomPromo = applyProCustomPromo;
1275
+ // Indexed products - Custom prices if pro
1017
1276
  const getFormattedProdGR = (decli, productSlug, isPro) => {
1018
1277
  const { promo_price, discount_price, tier_pricing } = decli, rest = __rest(decli, ["promo_price", "discount_price", "tier_pricing"]);
1019
1278
  return !!isPro ? Object.assign(Object.assign({}, rest), (productSlug !== 'kentucky' ? { tier_pricing } : {})) : decli;
1020
1279
  };
1021
1280
  exports.getFormattedProdGR = getFormattedProdGR;
1281
+ /**
1282
+ * Checks if a 0.00$ reg_price item should be considered "hidden" or not.
1283
+ * @param item - The indexedDecli or cartItem to check
1284
+ * @param productSlug - The parent product's slug (in case it is not found in item)
1285
+ * @param isUpsellOfInstallProd - Optionnal. If item is upsell of install product (additionnal fee for installation)
1286
+ */
1022
1287
  const shouldHideItemIfRegPriceIs0 = (item, productSlug, isUpsellOfInstallProd) => {
1288
+ // A. Check if reg price is 0. If not, should not hide item
1023
1289
  const regPriceIs0 = item.regular_price.amount == 0;
1024
1290
  if (!regPriceIs0)
1025
1291
  return false;
1292
+ // B. Check if item is fee or service. If not, should not hide item
1026
1293
  if (!item.is_service)
1027
1294
  return false;
1295
+ // C. Check if item is an upsell of an installation product (additionnal install fees). If so, should not hide item
1028
1296
  if (!!isUpsellOfInstallProd)
1029
1297
  return false;
1298
+ // D. Check if item is a shipping fee. If so, should not hide item
1030
1299
  if (expedition_1.slugsToCheckFromExpeditionFees.shipping.includes(productSlug))
1031
1300
  return false;
1032
1301
  return true;
1033
1302
  };
1034
1303
  exports.shouldHideItemIfRegPriceIs0 = shouldHideItemIfRegPriceIs0;
1304
+ // #endregion
1305
+ // ----------------------------------------------------------------------------------------------------------
1035
1306
  //# sourceMappingURL=products.js.map