Skip to content

Commit

Permalink
Calculate cart totals before promotion evaluation (#18)
Browse files Browse the repository at this point in the history
* Calculate card totals before promotion evaluation

* fix uint test
  • Loading branch information
tatarincev authored Nov 13, 2024
1 parent c273837 commit 3632362
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/VirtoCommerce.XCart.Core/CartAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ public virtual async Task<CartAggregate> RecalculateAsync()

await UpdateOrganizationName();

_cartTotalsCalculator.CalculateTotals(Cart);

var promotionEvalResult = await EvaluatePromotionsAsync();
await this.ApplyRewardsAsync(promotionEvalResult.Rewards);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ public async Task RecalculateAsync_HasPromoRewards_CalculateTotalsCalled()
var result = await cartAggregate.RecalculateAsync();

// Assert
_shoppingCartTotalsCalculatorMock.Verify(x => x.CalculateTotals(It.Is<ShoppingCart>(x => x == cartAggregate.Cart)), Times.Once);
_shoppingCartTotalsCalculatorMock.Verify(x => x.CalculateTotals(It.Is<ShoppingCart>(x => x == cartAggregate.Cart)), Times.Exactly(2));
}

#endregion RecalculateAsync
Expand Down

0 comments on commit 3632362

Please sign in to comment.