Skip to content

Commit 896ae1c

Browse files
Update country artifact to handle assigned tax calculation method
1 parent 4e7486b commit 896ae1c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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; }

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 currency 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)