Skip to content

Commit

Permalink
Better handle unspecified amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
bleroy committed Apr 4, 2022
1 parent 1e230ae commit e9dba99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions MoneyDataType/Amount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ namespace Money
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public struct Amount : IEquatable<Amount>, IComparable<Amount>
{
public Amount() {
Value = 0;
Currency = Money.Currency.UnspecifiedCurrency;
}

public Amount(decimal value, RegionInfo region)
{
if (region == null)
Expand Down
2 changes: 1 addition & 1 deletion OrchardCore.Commerce/Services/SimplePriceStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SimplePriceStrategy : IPriceSelectionStrategy
public Amount SelectPrice(IEnumerable<PrioritizedPrice> prices)
=> prices is null
|| !prices.Any()
? new Amount()
? new Amount(0, Currency.UnspecifiedCurrency)
: prices
.Where(pp => pp.Priority == prices.Max(pp => pp.Priority))
.Min(pp => pp.Price);
Expand Down

0 comments on commit e9dba99

Please sign in to comment.