Skip to content

Commit 15711a0

Browse files
committed
Implemented support for new EU ESD VAT regulation (from 2015 on)
1 parent f88b7d9 commit 15711a0

11 files changed

Lines changed: 198 additions & 85 deletions

File tree

src/Libraries/SmartStore.Core/Domain/Tax/TaxSettings.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,16 @@ public TaxSettings()
6868
/// </summary>
6969
public bool HideTaxInOrderSummary { get; set; }
7070

71-
/// codehint: sm-add
7271
/// <summary>
7372
/// Gets or sets a value indicating whether to show legal info in product list
7473
/// </summary>
7574
public bool ShowLegalHintsInProductList { get; set; }
7675

77-
/// codehint: sm-add
7876
/// <summary>
7977
/// Gets or sets a value indicating whether to show legal info in product detail
8078
/// </summary>
8179
public bool ShowLegalHintsInProductDetails { get; set; }
8280

83-
/// codehint: sm-add
8481
/// <summary>
8582
/// Gets or sets a value indicating whether to show legal info in footer
8683
/// </summary>
@@ -140,5 +137,11 @@ public TaxSettings()
140137
/// Gets or sets a value indicating whether we should notify a store owner when a new VAT number is submitted
141138
/// </summary>
142139
public bool EuVatEmailAdminWhenNewVatSubmitted { get; set; }
140+
141+
/// <summary>
142+
/// Gets or sets a value indicating the ESD tax class identifier required
143+
/// to calculate VAT for electronic services conform to EU VAT regulations (2015)
144+
/// </summary>
145+
public int? ElectronicServiceTaxClassId { get; set; }
143146
}
144147
}

src/Libraries/SmartStore.Services/Directory/GeoCountryLookup.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using SmartStore.Core;
66
using SmartStore.Core.Caching;
77
using MaxMind.GeoIP;
8+
using SmDir = SmartStore.Core.Domain.Directory;
89

910
namespace SmartStore.Services.Directory
1011
{
@@ -14,12 +15,14 @@ namespace SmartStore.Services.Directory
1415
public partial class GeoCountryLookup : IGeoCountryLookup
1516
{
1617
private readonly IWebHelper _webHelper;
18+
private readonly ICountryService _countryService;
1719
private readonly ICacheManager _cacheManager;
1820

19-
public GeoCountryLookup(IWebHelper webHelper, ICacheManager cacheManager)
21+
public GeoCountryLookup(IWebHelper webHelper, ICacheManager cacheManager, ICountryService countryService)
2022
{
2123
this._webHelper = webHelper;
2224
this._cacheManager = cacheManager;
25+
this._countryService = countryService;
2326
}
2427

2528
private MaxMind.GeoIP.LookupService GetLookupService()
@@ -97,5 +100,28 @@ public virtual string LookupCountryName(IPAddress addr)
97100
}
98101
}
99102

103+
public virtual bool IsEuIpAddress(string ipAddress, out SmDir.Country euCountry)
104+
{
105+
euCountry = null;
106+
107+
if (ipAddress.IsEmpty())
108+
return false;
109+
110+
euCountry = _cacheManager.Get("GeoCountryLookup.EuCountry.{0}".FormatInvariant(ipAddress), () =>
111+
{
112+
var countryCode = LookupCountryCode(ipAddress);
113+
if (countryCode.IsEmpty())
114+
return (SmDir.Country)null;
115+
116+
var country = _countryService.GetCountryByTwoLetterIsoCode(countryCode);
117+
return country;
118+
});
119+
120+
if (euCountry == null)
121+
return false;
122+
123+
return euCountry.SubjectToVat;
124+
}
125+
100126
}
101127
}

src/Libraries/SmartStore.Services/Directory/IGeoCountryLookup.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Net;
2+
using SmartStore.Core.Domain.Directory;
23

34
namespace SmartStore.Services.Directory
45
{
@@ -14,5 +15,15 @@ public partial interface IGeoCountryLookup
1415
string LookupCountryName(string str);
1516

1617
string LookupCountryName(IPAddress addr);
18+
19+
/// <summary>
20+
/// Gets a value indicating whether the given IP address originates from an EU country
21+
/// </summary>
22+
/// <param name="ipAddress">IP address</param>
23+
/// <param name="euCountry">An instance of <see cref="Country"/> if the IP originates from a EU country</param>
24+
/// <returns>
25+
/// <c>true</c> if the IP address originates from an EU country, <c>false</c> if not
26+
/// </returns>
27+
bool IsEuIpAddress(string ipAddress, out Country euCountry);
1728
}
1829
}

src/Libraries/SmartStore.Services/Orders/OrderTotalCalculationService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,7 @@ public virtual decimal GetTaxTotal(IList<OrganizedShoppingCartItem> cart, bool u
707707
/// <param name="taxRates">Tax rates</param>
708708
/// <param name="usePaymentMethodAdditionalFee">A value indicating whether we should use payment method additional fee when calculating tax</param>
709709
/// <returns>Tax total</returns>
710-
public virtual decimal GetTaxTotal(IList<OrganizedShoppingCartItem> cart,
711-
out SortedDictionary<decimal, decimal> taxRates, bool usePaymentMethodAdditionalFee = true)
710+
public virtual decimal GetTaxTotal(IList<OrganizedShoppingCartItem> cart, out SortedDictionary<decimal, decimal> taxRates, bool usePaymentMethodAdditionalFee = true)
712711
{
713712
if (cart == null)
714713
throw new ArgumentNullException("cart");

src/Libraries/SmartStore.Services/Tax/ITaxService.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public partial interface ITaxService
5959
/// <param name="taxCategoryId">Tax category identifier</param>
6060
/// <param name="customer">Customer</param>
6161
/// <returns>Tax rate</returns>
62-
decimal GetTaxRate(Product product, int taxCategoryId,
63-
Customer customer);
62+
decimal GetTaxRate(Product product, int taxCategoryId, Customer customer);
6463

6564

6665

@@ -72,8 +71,7 @@ decimal GetTaxRate(Product product, int taxCategoryId,
7271
/// <param name="price">Price</param>
7372
/// <param name="taxRate">Tax rate</param>
7473
/// <returns>Price</returns>
75-
decimal GetProductPrice(Product product, decimal price,
76-
out decimal taxRate);
74+
decimal GetProductPrice(Product product, decimal price, out decimal taxRate);
7775

7876
/// <summary>
7977
/// Gets price
@@ -83,8 +81,7 @@ decimal GetProductPrice(Product product, decimal price,
8381
/// <param name="customer">Customer</param>
8482
/// <param name="taxRate">Tax rate</param>
8583
/// <returns>Price</returns>
86-
decimal GetProductPrice(Product product, decimal price,
87-
Customer customer, out decimal taxRate);
84+
decimal GetProductPrice(Product product, decimal price, Customer customer, out decimal taxRate);
8885

8986
/// <summary>
9087
/// Gets price
@@ -95,8 +92,7 @@ decimal GetProductPrice(Product product, decimal price,
9592
/// <param name="customer">Customer</param>
9693
/// <param name="taxRate">Tax rate</param>
9794
/// <returns>Price</returns>
98-
decimal GetProductPrice(Product product, decimal price,
99-
bool includingTax, Customer customer, out decimal taxRate);
95+
decimal GetProductPrice(Product product, decimal price, bool includingTax, Customer customer, out decimal taxRate);
10096

10197
/// <summary>
10298
/// Gets price
@@ -270,8 +266,6 @@ VatNumberStatus DoVatCheck(string twoLetterIsoCode, string vatNumber,
270266

271267

272268

273-
274-
275269
/// <summary>
276270
/// Gets a value indicating whether tax exempt
277271
/// </summary>

0 commit comments

Comments
 (0)