From 0bd6fe670995fc83b4073bcb988625581bda52ac Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 2 Jan 2025 16:48:22 +1100 Subject: [PATCH] Fix setting stock from wholesale offer --- engines/dfc_provider/app/services/dfc_catalog.rb | 2 +- .../dfc_provider/spec/services/dfc_catalog_spec.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/engines/dfc_provider/app/services/dfc_catalog.rb b/engines/dfc_provider/app/services/dfc_catalog.rb index f068bdc3cf8..08649494c7e 100644 --- a/engines/dfc_provider/app/services/dfc_catalog.rb +++ b/engines/dfc_provider/app/services/dfc_catalog.rb @@ -75,6 +75,6 @@ def adjust_offer_stock(product, transformation) return unless offer && wholesale_offer&.stockLimitation.present? - offer.stockLimiation = wholesale_offer.stockLimitation.to_i * transformation.factor + offer.stockLimitation = wholesale_offer.stockLimitation.to_i * transformation.factor end end diff --git a/engines/dfc_provider/spec/services/dfc_catalog_spec.rb b/engines/dfc_provider/spec/services/dfc_catalog_spec.rb index 15e59f1d2ec..282f345fe71 100644 --- a/engines/dfc_provider/spec/services/dfc_catalog_spec.rb +++ b/engines/dfc_provider/spec/services/dfc_catalog_spec.rb @@ -36,10 +36,21 @@ }.from(2.09).to(1.57) # 18.85 wholesale price divided by 12 end - it "changes stock level of retail variants" do + it "changes stock level of retail variant's catalog item" do expect { catalog.apply_wholesale_values! }.to change { catalog_item.stockLimitation }.from("-1").to(-12) end + + it "changes stock level of retail variant's offer" do + wholesale_offer = catalog.item( + "https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts/44519466500403/Offer" + ) + wholesale_offer.stockLimitation = 2 + + expect { catalog.apply_wholesale_values! }.to change { + offer.stockLimitation + }.from(nil).to(24) + end end end