Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Handle taxes where not handled

Anna Siwik36817fa93200
diff --git a/docs/architecture/stock.rst b/docs/architecture/stock.rst
index 339453ca95..08bf2d98b3 100644
--- a/docs/architecture/stock.rst
+++ b/docs/architecture/stock.rst
@@ -29,6 +29,6 @@ Once an order is placed, quantity needed to fulfil each order line is immediatel
Decreasing Stock After Shipment
-------------------------------
-Once a delivery group is marked as shipped, each stock record used to fulfil its lines will have both its quantity at hand and quantity allocated decreased by the number of items shipped.
+Once order lines are marked as shipped, each corresponding stock record will have both its quantity at hand and quantity allocated decreased by the number of items shipped.
**Example:** Two boxes of shoes from warehouse A are shipped to a customer. The stock records **quantity** is now **3**, **quantity allocated** becomes **2** and **quantity available** stays at **1**.
diff --git a/saleor/checkout/core.py b/saleor/checkout/core.py
index 011401bb75..9b47ce6795 100644
--- a/saleor/checkout/core.py
+++ b/saleor/checkout/core.py
@@ -104,6 +104,11 @@ class Checkout:
"""Return `True` if this checkout session needs shipping."""
return self.cart.is_shipping_required()
+ @property
+ def are_taxes_handled(self):
+ """Return `True` if taxes are handled in the delivery country."""
+ return bool(self.get_taxes())
+
@property
def shipping_address(self):
"""Return a shipping address if any."""
diff --git a/saleor/product/utils/variants_picker.py b/saleor/product/utils/variants_picker.py
index 6f3662b7e0..82488ba8f3 100644
--- a/saleor/product/utils/variants_picker.py
+++ b/saleor/product/utils/variants_picker.py
@@ -63,7 +63,9 @@ def get_variant_picker_data(
availability.price_range_undiscounted),
'priceRangeLocalCurrency': price_range_as_dict(
availability.price_range_local_currency)}
- data['displayGrossPrices'] = display_gross_prices()
+ data['priceDisplay'] = {
+ 'displayGross': display_gross_prices(),
+ 'handleTaxes': bool(taxes)}
return data
diff --git a/saleor/product/views.py b/saleor/product/views.py
index 0cbe285c4d..8912a0c4ee 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -68,19 +68,19 @@ def product_details(request, slug, product_id, form=None):
# show_variant_picker determines if variant picker is used or select input
show_variant_picker = all([v.attributes for v in product.variants.all()])
json_ld_data = product_json_ld(product, product_attributes)
- return TemplateResponse(
- request, 'product/details.html', {
- 'is_visible': is_visible,
- 'form': form,
- 'availability': availability,
- 'product': product,
- 'product_attributes': product_attributes,
- 'product_images': product_images,
- 'show_variant_picker': show_variant_picker,
- 'variant_picker_data': json.dumps(
- variant_picker_data, default=serialize_decimal),
- 'json_ld_product_data': json.dumps(
- json_ld_data, default=serialize_decimal)})
+ ctx = {
+ 'is_visible': is_visible,
+ 'form': form,
+ 'availability': availability,
+ 'product': product,
+ 'product_attributes': product_attributes,
+ 'product_images': product_images,
+ 'show_variant_picker': show_variant_picker,
+ 'variant_picker_data': json.dumps(
+ variant_picker_data, default=serialize_decimal),
+ 'json_ld_product_data': json.dumps(
+ json_ld_data, default=serialize_decimal)}
+ return TemplateResponse(request, 'product/details.html', ctx)
def product_add_to_cart(request, slug, product_id):
diff --git a/saleor/settings.py b/saleor/settings.py
index 3778af54e4..8160cf5d26 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -272,7 +272,7 @@ AUTH_USER_MODEL = 'account.User'
LOGIN_URL = '/account/login/'
-DEFAULT_COUNTRY = 'DE'
+DEFAULT_COUNTRY = 'US'
DEFAULT_CURRENCY = 'USD'
DEFAULT_DECIMAL_PLACES = get_currency_fraction(DEFAULT_CURRENCY)
AVAILABLE_CURRENCIES = [DEFAULT_CURRENCY]
diff --git a/saleor/static/js/components/variant-picker.js b/saleor/static/js/components/variant-picker.js
index 82300d360a..1f47aeeafd 100644
--- a/saleor/static/js/components/variant-picker.js
+++ b/saleor/static/js/components/variant-picker.js
@@ -29,8 +29,8 @@ export default $(document).ready((e) => {
ReactDOM.render(
<VariantPrice
availability={variantPickerData.availability}
+ priceDisplay={variantPickerData.priceDisplay}
store={variantPickerStore}
- displayGrossPrices={variantPickerData.displayGrossPrices}
/>,
variantPriceContainer
);
diff --git a/saleor/static/js/components/variantPicker/VariantPrice.js b/saleor/static/js/components/variantPicker/VariantPrice.js
index 6ad794ea7d..958109ef35 100644
--- a/saleor/static/js/components/variantPicker/VariantPrice.js
+++ b/saleor/static/js/components/variantPicker/VariantPrice.js
@@ -4,19 +4,20 @@ import React, { Component, PropTypes } from 'react';
export default observer(class VariantPrice extends Component {
static propTypes = {
availability: PropTypes.object.isRequired,
- store: PropTypes.object,
- displayGrossPrices: PropTypes.bool
+ priceDisplay: PropTypes.object.isRequired,
+ store: PropTypes.object
}
render() {
let priceText, priceUndiscountedText, priceLocalCurrency, isDiscount;
- const { availability, store, displayGrossPrices } = this.props;
+ const { availability, priceDisplay, store } = this.props;
+ const { displayGross, handleTaxes } = priceDisplay;
const variant = store.variant;
const taxRate = availability.taxRate;
if (!store.isEmpty) {
// variant price
isDiscount = variant.price.gross !== variant.priceUndiscounted.gross;
- if (displayGrossPrices) {
+ if (displayGross) {
priceText = `${variant.price.grossLocalized}`;
priceUndiscountedText = `${variant.priceUndiscounted.grossLocalized}`;
if (variant.priceLocalCurrency) {
@@ -33,7 +34,7 @@ export default observer(class VariantPrice extends Component {
// if there's no variant, fall back to product price
const { discount, priceRange, priceRangeUndiscounted } = availability;
isDiscount = discount && !!Object.keys(discount).length;
- if (displayGrossPrices) {
+ if (displayGross) {
priceText = `${priceRange.minPrice.grossLocalized}`;
priceUndiscountedText = `${priceRangeUndiscounted.minPrice.grossLocalized}`;
if (availability.priceRangeLocalCurrency) {
@@ -56,12 +57,13 @@ export default observer(class VariantPrice extends Component {
{priceLocalCurrency && (
<p><small className="text-info">&asymp; {priceLocalCurrency}</small></p>
)}
- {displayGrossPrices && (
- <small>including {taxRate}% VAT</small>
- )}
- {!displayGrossPrices && (
- <small>excluding {taxRate}% VAT</small>
- )}
+ {handleTaxes && [
+ displayGross ? (
+ <small>including {taxRate}% VAT</small>
+ ) : (
+ <small>excluding {taxRate}% VAT</small>
+ )
+ ]}
</h2>
);
}
diff --git a/templates/checkout/details.html b/templates/checkout/details.html
index af9d3d2247..79a5719f7c 100644
--- a/templates/checkout/details.html
+++ b/templates/checkout/details.html
@@ -80,6 +80,13 @@
<div class="col-4">
<p class="float-right">{% price total.tax %}</p>
</div>
+ <div class="col-12">
+ {% if not checkout.are_taxes_handled %}
+ <small class="form-text text-muted">
+ <p>{% trans "Calculating tax rates in delivery country is not supported" context "Order review section title" %}</p>
+ </small>
+ {% endif %}
+ </div>
</div>
<div class="row checkout__review__section">
<div class="col-12">
diff --git a/templates/product/details.html b/templates/product/details.html
index a190a3fb53..5f70b6c829 100644
--- a/templates/product/details.html
+++ b/templates/product/details.html
@@ -140,18 +140,20 @@
{% price availability.price_range_local_currency %}
</small>
{% endif %}
- <small>
- {% tax_rate request.taxes product.tax_rate as tax_rate %}
- {% if site.settings.display_gross_prices %}
- {% blocktrans trimmed with tax_rate=tax_rate context "Product details page vat rate value" %}
- including {{ tax_rate }}% VAT
- {% endblocktrans %}
- {% else %}
- {% blocktrans trimmed with tax_rate=tax_rate context "Product details page vat rate value" %}
- excluding {{ tax_rate }}% VAT
- {% endblocktrans %}
- {% endif %}
- </small>
+ {% if request.taxes %}
+ <small>
+ {% tax_rate request.taxes product.tax_rate as tax_rate %}
+ {% if site.settings.display_gross_prices %}
+ {% blocktrans trimmed with tax_rate=tax_rate context "Product details page vat rate value" %}
+ including {{ tax_rate }}% VAT
+ {% endblocktrans %}
+ {% else %}
+ {% blocktrans trimmed with tax_rate=tax_rate context "Product details page vat rate value" %}
+ excluding {{ tax_rate }}% VAT
+ {% endblocktrans %}
+ {% endif %}
+ </small>
+ {% endif %}
</h2>
{% endif %}
{% endif %}
@@ -159,8 +161,7 @@
{% block orderform %}
{% if show_variant_picker %}
{% csrf_token %}
- <div id="variant-picker" data-variant-picker-data="{{ variant_picker_data }}"
- data-action="{% url 'product:add-to-cart' product_id=product.pk slug=product.get_slug %}" data-display-gross-price="{{ site.settings.display_gross_prices }}"></div>
+ <div id="variant-picker" data-variant-picker-data="{{ variant_picker_data }}" data-action="{% url 'product:add-to-cart' product_id=product.pk slug=product.get_slug %}"></div>
{% else %}
<form id="product-form" role="form" class="product-form clearfix" method="post" action="{% url 'product:add-to-cart' product_id=product.pk slug=product.get_slug %}" novalidate>
{% csrf_token %}