Skip to content

Commit

Permalink
Fix setting stock from wholesale offer
Browse files Browse the repository at this point in the history
  • Loading branch information
mkllnk committed Jan 7, 2025
1 parent 21195c5 commit 0bd6fe6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion engines/dfc_provider/app/services/dfc_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion engines/dfc_provider/spec/services/dfc_catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0bd6fe6

Please sign in to comment.