Skip to content

Commit 17e6aa5

Browse files
Merge branch 'feature/tax-calculation-methods'
# Conflicts: # Directory.Build.props
2 parents 8985187 + eb9500e commit 17e6aa5

18 files changed

+314
-95
lines changed

Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232

3333
<!-- Package validation -->
3434
<PropertyGroup>
35+
<GenerateCompatibilitySuppressionFile>false</GenerateCompatibilitySuppressionFile>
3536
<EnablePackageValidation>true</EnablePackageValidation>
36-
<PackageValidationBaselineVersion>14.0.0</PackageValidationBaselineVersion>
37+
<PackageValidationBaselineVersion>14.1.0</PackageValidationBaselineVersion>
3738
<EnableStrictModeForCompatibleFrameworksInPackage>true</EnableStrictModeForCompatibleFrameworksInPackage>
3839
<EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms>
3940
</PropertyGroup>

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<GlobalPackageReference Include="Umbraco.JsonSchema.Extensions" Version="0.3.0" PrivateAssets="all" />
1111
</ItemGroup>
1212
<ItemGroup>
13-
<PackageVersion Include="Umbraco.Commerce.Cms.Startup" Version="[14.0.0, 15)" />
13+
<PackageVersion Include="Umbraco.Commerce.Cms.Startup" Version="[14.1.0, 15)" />
1414
<PackageVersion Include="Umbraco.Deploy.Infrastructure" Version="[14.1.0, 15)" />
1515
</ItemGroup>
1616
</Project>

NuGet.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@
55
<add key="Umbraco Prereleases" value="https://www.myget.org/F/umbracoprereleases/api/v3/index.json" />
66
<add key="Umbraco Nightly" value="https://www.myget.org/F/umbraconightly/api/v3/index.json" />
77
</packageSources>
8+
<packageSourceMapping>
9+
<packageSource key="nuget.org">
10+
<package pattern="*" />
11+
<package pattern="Umbraco.Commerce.*" />
12+
</packageSource>
13+
<packageSource key="Umbraco Nightly">
14+
<package pattern="Umbraco.Commerce.*" />
15+
</packageSource>
16+
</packageSourceMapping>
817
</configuration>

src/Umbraco.Commerce.Deploy/Artifacts/CountryArtifact.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class CountryArtifact(GuidUdi? udi, GuidUdi storeUdi, IEnumerable<Artifac
1414
get => Code;
1515
}
1616

17+
18+
public GuidUdi? TaxCalculationMethodUdi { get; set; }
1719
public GuidUdi? DefaultCurrencyUdi { get; set; }
1820
public GuidUdi? DefaultPaymentMethodUdi { get; set; }
1921
public GuidUdi? DefaultShippingMethodUdi { get; set; }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
using Umbraco.Cms.Core;
3+
using Umbraco.Cms.Core.Deploy;
4+
using Umbraco.Deploy.Infrastructure.Serialization;
5+
6+
namespace Umbraco.Commerce.Deploy.Artifacts
7+
{
8+
public class TaxCalculationMethodArtifact(GuidUdi? udi, GuidUdi storeUdi, IEnumerable<ArtifactDependency> dependencies = null)
9+
: StoreEntityArtifactBase(udi, storeUdi, dependencies)
10+
{
11+
public string SalesTaxProviderAlias { get; set; }
12+
public SortedDictionary<string, string> SalesTaxProviderSettings { get; set; }
13+
public int SortOrder { get; set; }
14+
}
15+
}

src/Umbraco.Commerce.Deploy/Artifacts/TaxClassArtifact.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ public class TaxClassArtifact(GuidUdi? udi, GuidUdi storeUdi, IEnumerable<Artifa
1111
[RoundingDecimalConverter(3)]
1212
public decimal DefaultTaxRate { get; set; }
1313

14-
public IEnumerable<CountryRegionTaxRateArtifact>? CountryRegionTaxRates { get; set; }
14+
public string DefaultTaxCode { get; set; }
15+
16+
public IEnumerable<CountryRegionTaxClassArtifact>? CountryRegionTaxClasses { get; set; }
1517

1618
public int SortOrder { get; set; }
1719
}
1820

19-
public class CountryRegionTaxRateArtifact
21+
public class CountryRegionTaxClassArtifact
2022
{
2123
public GuidUdi CountryUdi { get; set; }
2224

2325
public GuidUdi? RegionUdi { get; set; }
2426

2527
[RoundingDecimalConverter(3)]
2628
public decimal TaxRate { get; set; }
29+
30+
public string TaxCode { get; set; }
2731
}
2832
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
3+
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
4+
<Suppression>
5+
<DiagnosticId>CP0001</DiagnosticId>
6+
<Target>T:Umbraco.Commerce.Deploy.Artifacts.CountryRegionTaxRateArtifact</Target>
7+
<Left>lib/net8.0/Umbraco.Commerce.Deploy.dll</Left>
8+
<Right>lib/net8.0/Umbraco.Commerce.Deploy.dll</Right>
9+
<IsBaselineSuppression>true</IsBaselineSuppression>
10+
</Suppression>
11+
<Suppression>
12+
<DiagnosticId>CP0002</DiagnosticId>
13+
<Target>M:Umbraco.Commerce.Deploy.Artifacts.TaxClassArtifact.get_CountryRegionTaxRates</Target>
14+
<Left>lib/net8.0/Umbraco.Commerce.Deploy.dll</Left>
15+
<Right>lib/net8.0/Umbraco.Commerce.Deploy.dll</Right>
16+
<IsBaselineSuppression>true</IsBaselineSuppression>
17+
</Suppression>
18+
<Suppression>
19+
<DiagnosticId>CP0002</DiagnosticId>
20+
<Target>M:Umbraco.Commerce.Deploy.Artifacts.TaxClassArtifact.set_CountryRegionTaxRates(System.Collections.Generic.IEnumerable{Umbraco.Commerce.Deploy.Artifacts.CountryRegionTaxRateArtifact})</Target>
21+
<Left>lib/net8.0/Umbraco.Commerce.Deploy.dll</Left>
22+
<Right>lib/net8.0/Umbraco.Commerce.Deploy.dll</Right>
23+
<IsBaselineSuppression>true</IsBaselineSuppression>
24+
</Suppression>
25+
</Suppressions>

src/Umbraco.Commerce.Deploy/Composing/UmbracoCommerceDeployComponent.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private static void RegisterUdiTypes()
4444
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.Region, UdiType.GuidUdi);
4545
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.Currency, UdiType.GuidUdi);
4646
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.TaxClass, UdiType.GuidUdi);
47+
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.TaxCalculationMethod, UdiType.GuidUdi);
4748
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.EmailTemplate, UdiType.GuidUdi);
4849
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.PrintTemplate, UdiType.GuidUdi);
4950
UdiParser.RegisterUdiType(UmbracoCommerceConstants.UdiEntityType.ExportTemplate, UdiType.GuidUdi);
@@ -172,6 +173,7 @@ private void InitializeDiskRefreshers()
172173
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.Region);
173174
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.Currency);
174175
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.TaxClass);
176+
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.TaxCalculationMethod);
175177
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.EmailTemplate);
176178
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.PrintTemplate);
177179
diskEntityService.RegisterDiskEntityType(UmbracoCommerceConstants.UdiEntityType.ExportTemplate);
@@ -214,6 +216,10 @@ private void InitializeDiskRefreshers()
214216
EventHub.NotificationEvents.OnTaxClassSaved((e) => WriteEntityArtifact(e.TaxClass));
215217
EventHub.NotificationEvents.OnTaxClassDeleted((e) => DeleteEntityArtifact(e.TaxClass));
216218

219+
// TaxCalculationMethod
220+
EventHub.NotificationEvents.OnTaxCalculationMethodSaved((e) => WriteEntityArtifact(e.TaxCalculationMethod));
221+
EventHub.NotificationEvents.OnTaxCalculationMethodDeleted((e) => DeleteEntityArtifact(e.TaxCalculationMethod));
222+
217223
// EmailTemplate
218224
EventHub.NotificationEvents.OnEmailTemplateSaved((e) => WriteEntityArtifact(e.EmailTemplate));
219225
EventHub.NotificationEvents.OnEmailTemplateDeleted((e) => DeleteEntityArtifact(e.EmailTemplate));

src/Umbraco.Commerce.Deploy/Configuration/UmbracoCommerceDeploySettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Umbraco.Commerce.Deploy.Configuration
22
{
33
public class UmbracoCommerceDeploySettings
44
{
5+
public UmbracoCommerceDeployTaxCalculationMethodSettings TaxCalculationMethods { get; set; } = new();
56
public UmbracoCommerceDeployPaymentMethodSettings PaymentMethods { get; set; } = new();
67
public UmbracoCommerceDeployShippingMethodSettings ShippingMethods { get; set; } = new();
78
}
@@ -15,4 +16,9 @@ public class UmbracoCommerceDeployShippingMethodSettings
1516
{
1617
public string[] IgnoreSettings { get; set; } = [];
1718
}
19+
20+
public class UmbracoCommerceDeployTaxCalculationMethodSettings
21+
{
22+
public string[] IgnoreSettings { get; set; } = [];
23+
}
1824
}

src/Umbraco.Commerce.Deploy/Connectors/ServiceConnectors/UmbracoCommerceCountryServiceConnector.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ public override IAsyncEnumerable<CountryReadOnly> GetEntitiesAsync(
6767
SortOrder = entity.SortOrder
6868
};
6969

70+
// Tax calculation method
71+
if (entity.TaxCalculationMethodId != null)
72+
{
73+
var taxCalculationMethodDepUdi = new GuidUdi(UmbracoCommerceConstants.UdiEntityType.TaxCalculationMethod, entity.TaxCalculationMethodId.Value);
74+
var taxCalculationMethodDep = new UmbracoCommerceArtifactDependency(taxCalculationMethodDepUdi);
75+
76+
dependencies.Add(taxCalculationMethodDep);
77+
78+
artifact.TaxCalculationMethodUdi = taxCalculationMethodDepUdi;
79+
}
80+
7081
// Default currency
7182
if (entity.DefaultCurrencyId != null)
7283
{
@@ -164,6 +175,14 @@ private Task Pass4Async(ArtifactDeployState<CountryArtifact, CountryReadOnly> st
164175
{
165176
Country? entity = _umbracoCommerceApi.GetCountry(state.Entity.Id).AsWritable(uow);
166177

178+
if (artifact.TaxCalculationMethodUdi != null)
179+
{
180+
artifact.TaxCalculationMethodUdi.EnsureType(UmbracoCommerceConstants.UdiEntityType.TaxCalculationMethod);
181+
// TODO: Check the tax calculation method exists?
182+
}
183+
184+
entity.SetTaxCalculationMethod(artifact.TaxCalculationMethodUdi?.Guid);
185+
167186
if (artifact.DefaultCurrencyUdi != null)
168187
{
169188
artifact.DefaultCurrencyUdi.EnsureType(UmbracoCommerceConstants.UdiEntityType.Currency);

0 commit comments

Comments
 (0)