Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCST-2305: Update ApplyRewards() #24

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void ApplyRewards(this List<ProductPrice> productPrices, CatalogIt
var rewardsMap = productPrices
.Select(x => x.Currency)
.Distinct()
.ToDictionary(x => x, x => rewards);
.ToDictionary(x => x, _ => rewards);

foreach (var productPrice in productPrices)
{
Expand All @@ -45,7 +45,7 @@ public static void ApplyRewards(this List<ProductPrice> productPrices, CatalogIt

var discount = new Discount
{
DiscountAmount = reward.GetRewardAmount(priceAmount, 1),
DiscountAmount = reward.GetTotalAmount(priceAmount, 1, productPrice.Currency),
Description = reward.Promotion.Description,
Coupon = reward.Coupon,
PromotionId = reward.Promotion.Id
Expand All @@ -59,7 +59,7 @@ public static void ApplyRewards(this List<ProductPrice> productPrices, CatalogIt

foreach (var tierPrice in productPrice.TierPrices)
{
tierPrice.DiscountAmount += reward.GetRewardAmount(tierPrice.Price.Amount, 1);
tierPrice.DiscountAmount += reward.GetTotalAmount(tierPrice.Price.Amount, 1, productPrice.Currency);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/VirtoCommerce.XCatalog.Core/Models/ExpProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public virtual void ApplyRewards(CatalogItemAmountReward[] allRewards)
var rewardsMap = AllPrices
.Select(x => x.Currency)
.Distinct()
.ToDictionary(x => x, x => productRewards);
.ToDictionary(x => x, _ => productRewards);

foreach (var productPrice in AllPrices)
{
Expand All @@ -146,7 +146,7 @@ public virtual void ApplyRewards(CatalogItemAmountReward[] allRewards)

var discount = new Discount
{
DiscountAmount = reward.GetRewardAmount(priceAmount, 1),
DiscountAmount = reward.GetTotalAmount(priceAmount, 1, productPrice.Currency),
Description = reward.Promotion.Description,
Coupon = reward.Coupon,
PromotionId = reward.Promotion.Id
Expand All @@ -160,7 +160,7 @@ public virtual void ApplyRewards(CatalogItemAmountReward[] allRewards)

foreach (var tierPrice in productPrice.TierPrices)
{
tierPrice.DiscountAmount += reward.GetRewardAmount(tierPrice.ActualPrice.Amount, 1);
tierPrice.DiscountAmount += reward.GetTotalAmount(tierPrice.ActualPrice.Amount, 1, productPrice.Currency);
}
}
}
Expand All @@ -172,11 +172,11 @@ public virtual void ApplyStoreInventories(IEnumerable<InventoryInfo> inventories
ArgumentNullException.ThrowIfNull(inventories);
ArgumentNullException.ThrowIfNull(store);

var availFullfilmentCentersIds = (store.AdditionalFulfillmentCenterIds ?? Array.Empty<string>()).Concat(new[] { store.MainFulfillmentCenterId });
var availFulfilmentCentersIds = (store.AdditionalFulfillmentCenterIds ?? Array.Empty<string>()).Concat([store.MainFulfillmentCenterId]);

AllInventories.Clear();
Inventory = null;
AllInventories = inventories.Where(x => x.ProductId == Id && availFullfilmentCentersIds.Contains(x.FulfillmentCenterId)).ToList();
AllInventories = inventories.Where(x => x.ProductId == Id && availFulfilmentCentersIds.Contains(x.FulfillmentCenterId)).ToList();

Inventory = AllInventories.OrderByDescending(x => Math.Max(0, x.InStockQuantity - x.ReservedQuantity)).FirstOrDefault();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.815.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.830.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.805.0" />
<PackageReference Include="VirtoCommerce.MarketingModule.Core" Version="3.812.0" />
<PackageReference Include="VirtoCommerce.MarketingModule.Core" Version="3.815.0" />
<PackageReference Include="VirtoCommerce.PricingModule.Core" Version="3.809.0" />
<PackageReference Include="VirtoCommerce.Tools" Version="3.808.0" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/VirtoCommerce.XCatalog.Web/module.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<version>3.820.0</version>
<version-tag></version-tag>

<platformVersion>3.853.0</platformVersion>
<platformVersion>3.867.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Catalog" version="3.830.0" />
<dependency id="VirtoCommerce.Inventory" version="3.805.0" optional="true" />
<dependency id="VirtoCommerce.Marketing" version="3.812.0" optional="true" />
<dependency id="VirtoCommerce.Marketing" version="3.815.0" optional="true" />
<dependency id="VirtoCommerce.Pricing" version="3.809.0" optional="true" />
<dependency id="VirtoCommerce.Xapi" version="3.815.0" />
</dependencies>
Expand Down
Loading