-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VAT Rounding: Vat for Product Attributes and fixes
- Loading branch information
Markus Falk
committed
Jan 28, 2017
1 parent
e0d5381
commit 28597a8
Showing
23 changed files
with
16,540 additions
and
16,164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
316 changes: 158 additions & 158 deletions
316
src/Libraries/Nop.Services/Catalog/IPriceCalculationService.cs
Large diffs are not rendered by default.
Oops, something went wrong.
76 changes: 39 additions & 37 deletions
76
src/Libraries/Nop.Services/Catalog/IProductAttributeFormatter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
using Nop.Core.Domain.Catalog; | ||
using Nop.Core.Domain.Customers; | ||
|
||
namespace Nop.Services.Catalog | ||
{ | ||
/// <summary> | ||
/// Product attribute formatter interface | ||
/// </summary> | ||
public partial interface IProductAttributeFormatter | ||
{ | ||
/// <summary> | ||
/// Formats attributes | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <returns>Attributes</returns> | ||
string FormatAttributes(Product product, string attributesXml); | ||
|
||
/// <summary> | ||
/// Formats attributes | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="customer">Customer</param> | ||
/// <param name="serapator">Serapator</param> | ||
/// <param name="htmlEncode">A value indicating whether to encode (HTML) values</param> | ||
/// <param name="renderPrices">A value indicating whether to render prices</param> | ||
/// <param name="renderProductAttributes">A value indicating whether to render product attributes</param> | ||
/// <param name="renderGiftCardAttributes">A value indicating whether to render gift card attributes</param> | ||
/// <param name="allowHyperlinks">A value indicating whether to HTML hyperink tags could be rendered (if required)</param> | ||
/// <returns>Attributes</returns> | ||
string FormatAttributes(Product product, string attributesXml, | ||
Customer customer, string serapator = "<br />", bool htmlEncode = true, bool renderPrices = true, | ||
bool renderProductAttributes = true, bool renderGiftCardAttributes = true, | ||
bool allowHyperlinks = true); | ||
} | ||
} | ||
using Nop.Core.Domain.Catalog; | ||
using Nop.Core.Domain.Customers; | ||
|
||
namespace Nop.Services.Catalog | ||
{ | ||
/// <summary> | ||
/// Product attribute formatter interface | ||
/// </summary> | ||
public partial interface IProductAttributeFormatter | ||
{ | ||
/// <summary> | ||
/// Formats attributes | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <returns>Attributes</returns> | ||
string FormatAttributes(Product product, string attributesXml); | ||
|
||
/// <summary> | ||
/// Formats attributes | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="customer">Customer</param> | ||
/// <param name="serapator">Serapator</param> | ||
/// <param name="htmlEncode">A value indicating whether to encode (HTML) values</param> | ||
/// <param name="renderPrices">A value indicating whether to render prices</param> | ||
/// <param name="renderProductAttributes">A value indicating whether to render product attributes</param> | ||
/// <param name="renderGiftCardAttributes">A value indicating whether to render gift card attributes</param> | ||
/// <param name="allowHyperlinks">A value indicating whether to HTML hyperink tags could be rendered (if required)</param> | ||
/// <param name="subTotal">A value indicating if attribute VAT should be rendered with price. Decimal.MinusOne is default, i.e. don't render </param> | ||
/// <returns>Attributes</returns> | ||
string FormatAttributes(Product product, string attributesXml, | ||
Customer customer, string serapator = "<br />", bool htmlEncode = true, bool renderPrices = true, | ||
bool renderProductAttributes = true, bool renderGiftCardAttributes = true, | ||
bool allowHyperlinks = true, | ||
decimal subTotal = decimal.MinusOne); | ||
} | ||
} |
261 changes: 139 additions & 122 deletions
261
src/Libraries/Nop.Services/Catalog/IProductAttributeParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,139 @@ | ||
using System.Collections.Generic; | ||
using Nop.Core.Domain.Catalog; | ||
|
||
namespace Nop.Services.Catalog | ||
{ | ||
/// <summary> | ||
/// Product attribute parser interface | ||
/// </summary> | ||
public partial interface IProductAttributeParser | ||
{ | ||
#region Product attributes | ||
|
||
/// <summary> | ||
/// Gets selected product attribute mappings | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <returns>Selected product attribute mappings</returns> | ||
IList<ProductAttributeMapping> ParseProductAttributeMappings(string attributesXml); | ||
|
||
/// <summary> | ||
/// Get product attribute values | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMappingId">Product attribute mapping identifier; pass 0 to load all values</param> | ||
/// <returns>Product attribute values</returns> | ||
IList<ProductAttributeValue> ParseProductAttributeValues(string attributesXml, int productAttributeMappingId = 0); | ||
|
||
/// <summary> | ||
/// Gets selected product attribute values | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMappingId">Product attribute mapping identifier</param> | ||
/// <returns>Product attribute values</returns> | ||
IList<string> ParseValues(string attributesXml, int productAttributeMappingId); | ||
|
||
/// <summary> | ||
/// Adds an attribute | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMapping">Product attribute mapping</param> | ||
/// <param name="value">Value</param> | ||
/// <param name="quantity">Quantity (used with AttributeValueType.AssociatedToProduct to specify the quantity entered by the customer)</param> | ||
/// <returns>Updated result (XML format)</returns> | ||
string AddProductAttribute(string attributesXml, ProductAttributeMapping productAttributeMapping, string value, int? quantity = null); | ||
|
||
/// <summary> | ||
/// Remove an attribute | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMapping">Product attribute mapping</param> | ||
/// <returns>Updated result (XML format)</returns> | ||
string RemoveProductAttribute(string attributesXml, ProductAttributeMapping productAttributeMapping); | ||
|
||
/// <summary> | ||
/// Are attributes equal | ||
/// </summary> | ||
/// <param name="attributesXml1">The attributes of the first product</param> | ||
/// <param name="attributesXml2">The attributes of the second product</param> | ||
/// <param name="ignoreNonCombinableAttributes">A value indicating whether we should ignore non-combinable attributes</param> | ||
/// <param name="ignoreQuantity">A value indicating whether we should ignore the quantity of attribute value entered by the customer</param> | ||
/// <returns>Result</returns> | ||
bool AreProductAttributesEqual(string attributesXml1, string attributesXml2, bool ignoreNonCombinableAttributes, bool ignoreQuantity = true); | ||
|
||
/// <summary> | ||
/// Check whether condition of some attribute is met (if specified). Return "null" if not condition is specified | ||
/// </summary> | ||
/// <param name="pam">Product attribute</param> | ||
/// <param name="selectedAttributesXml">Selected attributes (XML format)</param> | ||
/// <returns>Result</returns> | ||
bool? IsConditionMet(ProductAttributeMapping pam, string selectedAttributesXml); | ||
|
||
/// <summary> | ||
/// Finds a product attribute combination by attributes stored in XML | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="ignoreNonCombinableAttributes">A value indicating whether we should ignore non-combinable attributes</param> | ||
/// <returns>Found product attribute combination</returns> | ||
ProductAttributeCombination FindProductAttributeCombination(Product product, | ||
string attributesXml, bool ignoreNonCombinableAttributes = true); | ||
|
||
/// <summary> | ||
/// Generate all combinations | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="ignoreNonCombinableAttributes">A value indicating whether we should ignore non-combinable attributes</param> | ||
/// <returns>Attribute combinations in XML format</returns> | ||
IList<string> GenerateAllCombinations(Product product, bool ignoreNonCombinableAttributes = false); | ||
|
||
#endregion | ||
|
||
#region Gift card attributes | ||
|
||
/// <summary> | ||
/// Add gift card attrbibutes | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="recipientName">Recipient name</param> | ||
/// <param name="recipientEmail">Recipient email</param> | ||
/// <param name="senderName">Sender name</param> | ||
/// <param name="senderEmail">Sender email</param> | ||
/// <param name="giftCardMessage">Message</param> | ||
/// <returns>Attributes</returns> | ||
string AddGiftCardAttribute(string attributesXml, string recipientName, | ||
string recipientEmail, string senderName, string senderEmail, string giftCardMessage); | ||
|
||
/// <summary> | ||
/// Get gift card attrbibutes | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="recipientName">Recipient name</param> | ||
/// <param name="recipientEmail">Recipient email</param> | ||
/// <param name="senderName">Sender name</param> | ||
/// <param name="senderEmail">Sender email</param> | ||
/// <param name="giftCardMessage">Message</param> | ||
void GetGiftCardAttribute(string attributesXml, out string recipientName, | ||
out string recipientEmail, out string senderName, | ||
out string senderEmail, out string giftCardMessage); | ||
|
||
#endregion | ||
} | ||
} | ||
using System.Collections.Generic; | ||
using Nop.Core.Domain.Catalog; | ||
using Nop.Services.Tax; | ||
|
||
namespace Nop.Services.Catalog | ||
{ | ||
/// <summary> | ||
/// Product attribute parser interface | ||
/// </summary> | ||
public partial interface IProductAttributeParser | ||
{ | ||
#region Product attributes | ||
|
||
/// <summary> | ||
/// Gets selected product attribute mappings | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <returns>Selected product attribute mappings</returns> | ||
IList<ProductAttributeMapping> ParseProductAttributeMappings(string attributesXml); | ||
|
||
/// <summary> | ||
/// Get product attribute values | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMappingId">Product attribute mapping identifier; pass 0 to load all values</param> | ||
/// <returns>Product attribute values</returns> | ||
IList<ProductAttributeValue> ParseProductAttributeValues(string attributesXml, int productAttributeMappingId = 0); | ||
|
||
/// <summary> | ||
/// Gets selected product attribute values | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMappingId">Product attribute mapping identifier</param> | ||
/// <returns>Product attribute values</returns> | ||
IList<string> ParseValues(string attributesXml, int productAttributeMappingId); | ||
|
||
/// <summary> | ||
/// Adds an attribute | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMapping">Product attribute mapping</param> | ||
/// <param name="value">Value</param> | ||
/// <param name="quantity">Quantity (used with AttributeValueType.AssociatedToProduct to specify the quantity entered by the customer)</param> | ||
/// <returns>Updated result (XML format)</returns> | ||
string AddProductAttribute(string attributesXml, ProductAttributeMapping productAttributeMapping, string value, int? quantity = null); | ||
|
||
/// <summary> | ||
/// Remove an attribute | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="productAttributeMapping">Product attribute mapping</param> | ||
/// <returns>Updated result (XML format)</returns> | ||
string RemoveProductAttribute(string attributesXml, ProductAttributeMapping productAttributeMapping); | ||
|
||
/// <summary> | ||
/// Are attributes equal | ||
/// </summary> | ||
/// <param name="attributesXml1">The attributes of the first product</param> | ||
/// <param name="attributesXml2">The attributes of the second product</param> | ||
/// <param name="ignoreNonCombinableAttributes">A value indicating whether we should ignore non-combinable attributes</param> | ||
/// <param name="ignoreQuantity">A value indicating whether we should ignore the quantity of attribute value entered by the customer</param> | ||
/// <returns>Result</returns> | ||
bool AreProductAttributesEqual(string attributesXml1, string attributesXml2, bool ignoreNonCombinableAttributes, bool ignoreQuantity = true); | ||
|
||
/// <summary> | ||
/// Check whether condition of some attribute is met (if specified). Return "null" if not condition is specified | ||
/// </summary> | ||
/// <param name="pam">Product attribute</param> | ||
/// <param name="selectedAttributesXml">Selected attributes (XML format)</param> | ||
/// <returns>Result</returns> | ||
bool? IsConditionMet(ProductAttributeMapping pam, string selectedAttributesXml); | ||
|
||
/// <summary> | ||
/// Finds a product attribute combination by attributes stored in XML | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="ignoreNonCombinableAttributes">A value indicating whether we should ignore non-combinable attributes</param> | ||
/// <returns>Found product attribute combination</returns> | ||
ProductAttributeCombination FindProductAttributeCombination(Product product, | ||
string attributesXml, bool ignoreNonCombinableAttributes = true); | ||
|
||
/// <summary> | ||
/// Generate all combinations | ||
/// </summary> | ||
/// <param name="product">Product</param> | ||
/// <param name="ignoreNonCombinableAttributes">A value indicating whether we should ignore non-combinable attributes</param> | ||
/// <returns>Attribute combinations in XML format</returns> | ||
IList<string> GenerateAllCombinations(Product product, bool ignoreNonCombinableAttributes = false); | ||
|
||
#endregion | ||
#region taxAttribute | ||
/// <summary> | ||
/// Adds tax subdivision to existing attributesXml | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="taxSummary">Set Product tax subdivision</param> | ||
/// <returns>Updated result (XML format)</returns> | ||
string AddTaxAttribute(string attributesXml, TaxSummary taxSummary); | ||
|
||
/// <summary> | ||
/// Parse ProductAttributesTax | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <returns>SortedDictionary with vatRate and vatRateWeight</returns> | ||
SortedDictionary<decimal, decimal> ParseTaxAttribute(string attributesXml); | ||
#endregion | ||
|
||
#region Gift card attributes | ||
|
||
/// <summary> | ||
/// Add gift card attrbibutes | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="recipientName">Recipient name</param> | ||
/// <param name="recipientEmail">Recipient email</param> | ||
/// <param name="senderName">Sender name</param> | ||
/// <param name="senderEmail">Sender email</param> | ||
/// <param name="giftCardMessage">Message</param> | ||
/// <returns>Attributes</returns> | ||
string AddGiftCardAttribute(string attributesXml, string recipientName, | ||
string recipientEmail, string senderName, string senderEmail, string giftCardMessage); | ||
|
||
/// <summary> | ||
/// Get gift card attrbibutes | ||
/// </summary> | ||
/// <param name="attributesXml">Attributes in XML format</param> | ||
/// <param name="recipientName">Recipient name</param> | ||
/// <param name="recipientEmail">Recipient email</param> | ||
/// <param name="senderName">Sender name</param> | ||
/// <param name="senderEmail">Sender email</param> | ||
/// <param name="giftCardMessage">Message</param> | ||
void GetGiftCardAttribute(string attributesXml, out string recipientName, | ||
out string recipientEmail, out string senderName, | ||
out string senderEmail, out string giftCardMessage); | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.