Skip to content

Commit 1670213

Browse files
authored
OCC-423: Fix broken tax rate 0 case and improve exception text. (#708)
* Add better exception text. * Fix broken tax rate 0 case.
1 parent 50c439f commit 1670213

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Modules/OrchardCore.Commerce/Abstractions/ITaxProvider.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ protected static async Task<bool> AllOrNoneAsync(
2525

2626
if (count == 0) return false;
2727
if (count == items.Count) return true;
28-
throw new InvalidOperationException("Some, but not all products have gross price. This is invalid.");
28+
throw new InvalidOperationException(
29+
"Some, but not all products have gross price. This is invalid. If you want to declare a tax-free " +
30+
"product, make sure to still include a Tax Part for the content type. Then set the Tax Rate field to 0 " +
31+
"in the products.");
2932
}
3033

3134
/// <inheritdoc cref="AllOrNoneAsync(PromotionAndTaxProviderContext, Func{IList{PromotionAndTaxProviderContextLineItem}, Task{int}})"/>

src/Modules/OrchardCore.Commerce/Services/LocalTaxProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public Task<PromotionAndTaxProviderContext> UpdateAsync(PromotionAndTaxProviderC
3939

4040
public Task<bool> IsApplicableAsync(PromotionAndTaxProviderContext model) =>
4141
ITaxProvider.AllOrNoneAsync(model, items => items
42-
.Select(item => item.Content.ContentItem.As<TaxPart>())
43-
.Count(taxPart => taxPart?.GrossPrice?.Amount.IsValid == true && taxPart.TaxRate.Value >= 0));
42+
.SelectWhere(item => item.Content.ContentItem.As<TaxPart>())
43+
.Count(taxPart => taxPart.TaxRate.Value == 0 || (taxPart.GrossPrice.Amount.IsValid && taxPart.TaxRate.Value > 0)));
4444
}

0 commit comments

Comments
 (0)