Fix setting stock from wholesale offer

This commit is contained in:
Maikel Linke
2025-01-02 16:48:22 +11:00
parent 21195c5750
commit 0bd6fe6709
2 changed files with 13 additions and 2 deletions

View File

@@ -75,6 +75,6 @@ class DfcCatalog
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

View File

@@ -36,10 +36,21 @@ RSpec.describe DfcCatalog do
}.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