@ordergroove/offers 2.30.5 → 2.30.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordergroove/offers",
3
- "version": "2.30.5",
3
+ "version": "2.30.6",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "@ordergroove/offers-templates": "^0.5.3"
49
49
  },
50
- "gitHead": "f65f56ff0ca6dbfc2bd57a4e99cc780f5178ceb5"
50
+ "gitHead": "1845a87c8a39b7a1b1fc79c62db1d9aa37decc72"
51
51
  }
@@ -371,6 +371,56 @@ describe('Shopify productPlan Reducer', () => {
371
371
  expect(productPlanCreated).toEqual(expectedProductPlan);
372
372
  });
373
373
 
374
+ it('should create prepaid product plan that rounds subscriptionPrice to nearest decimal', () => {
375
+ const allocation = {
376
+ price_adjustments: [
377
+ {
378
+ position: 1,
379
+ price: 4798
380
+ }
381
+ ],
382
+ price: 4798,
383
+ compare_at_price: 1999,
384
+ per_delivery_price: 4798,
385
+ selling_plan_id: 688412983572
386
+ };
387
+
388
+ const sellingPlans = [
389
+ {
390
+ id: 688412983572,
391
+ name: 'Delivered every 1 month, prepaid for 3 shipments',
392
+ description: null,
393
+ options: [
394
+ {
395
+ name: 'Delivery every',
396
+ position: 1,
397
+ value: 'PREPAID-1 month'
398
+ },
399
+ {
400
+ name: 'Shipment amount',
401
+ position: 2,
402
+ value: '3 shipments'
403
+ }
404
+ ],
405
+ recurring_deliveries: true,
406
+ price_adjustments: [
407
+ {
408
+ order_count: null,
409
+ position: 1,
410
+ value_type: 'price',
411
+ value: 4798
412
+ }
413
+ ]
414
+ }
415
+ ];
416
+
417
+ const expectedsubscriptionPrice = '$15.99';
418
+
419
+ const productPlanCreated = mapSellingPlanToDiscount(allocation, sellingPlans);
420
+
421
+ expect(productPlanCreated.subscriptionPrice).toEqual(expectedsubscriptionPrice);
422
+ });
423
+
374
424
  it('should create prepaid product plan with extra discount percentage', () => {
375
425
  const allocation = {
376
426
  price_adjustments: [
@@ -27,7 +27,7 @@ export const getAllocationRegularPrice = (allocation: ShopifySellingPlanAllocati
27
27
  export const getAllocationSubscriptionPrice = (allocation: ShopifySellingPlanAllocationsEntity) => {
28
28
  if (isPrepaidAllocation(allocation)) {
29
29
  const prepaidShipmentsPerBilling = getPrepaidShipmentsNumberFromOptions(allocation.selling_plan?.options);
30
- const pricePerShipment = allocation.price / prepaidShipmentsPerBilling;
30
+ const pricePerShipment = Math.round(allocation.price / prepaidShipmentsPerBilling);
31
31
  return money(pricePerShipment);
32
32
  }
33
33