shuup.core.taxing package¶
Submodules¶
shuup.core.taxing.utils module¶
-
shuup.core.taxing.utils.
get_tax_class_proportions
(lines)[source]¶ Generate tax class proportions from taxed lines.
Sum prices per tax class and return a list of (tax_class, factor) pairs, where factor is the proportion of total price of lines with given tax class from the total price of all lines.
Parameters: lines (list[shuup.core.order_creator.SourceLine]) – List of taxed lines to generate proportions from Return type: list[(shuup.core.models.TaxClass, decimal.Decimal)] Returns: List of tax classes with a proportion, or empty list if total price is zero. Sum of proportions is 1.
-
shuup.core.taxing.utils.
stacked_value_added_taxes
(price, taxes)[source]¶ Stack added taxes on the given price without compounding.
Note that this will not take compound taxation (Quebec) into account.
Parameters: - price (shuup.core.pricing.Price) – Taxful or taxless price to calculate taxes for
- taxes (list[shuup.core.models.Tax]) – List of Tax objects
Returns: TaxedPrice with the calculated taxes.
Return type:
-
shuup.core.taxing.utils.
calculate_compounded_added_taxes
(price, tax_groups)[source]¶ Calculate compounded and added taxes from given groups of taxes.
The
tax_groups
argument should be a list of tax groups, where each tax group is a list ofTax
objects. Taxes in each tax group will be added together and finally each added tax group will be compounded over each other.Parameters: - price (shuup.core.pricing.Price) – Taxful or taxless price to calculate taxes for
- tax_groups (list[list[shuup.core.models.Tax]]) – List of tax groups, each being a list of taxes
Returns: TaxedPrice with the calculated taxes.
Return type:
Module contents¶
-
class
shuup.core.taxing.
LineTax
¶ Bases:
object
Tax of some line.
This is an interface for specifying taxes of an
OrderLine
orSourceLine
.-
classmethod
from_tax
(tax, base_amount, **kwargs)[source]¶ Create tax line for given tax and base amount.
-
rate
¶
-
classmethod
-
class
shuup.core.taxing.
SourceLineTax
(tax, name, amount, base_amount)¶ Bases:
shuup.core.taxing.LineTax
Initialize line tax from given values.
-
class
shuup.core.taxing.
TaxModule
¶ Bases:
object
Module for calculating taxes.
-
add_taxes
(source, lines)[source]¶ Add taxes to given OrderSource lines.
Given lines are modified in-place, also new lines may be added (with
lines.extend
for example). If there is any existing taxes for thelines
, they are simply replaced.Parameters: - source (shuup.core.order_creator.OrderSource) – OrderSource of the lines
- lines (list[shuup.core.order_creator.SourceLine]) – List of lines to add taxes for
-
calculating_is_cheap
= True¶
-
get_taxed_price
(context, price, tax_class)[source]¶ Get TaxedPrice for price and tax class.
Parameters: - context (TaxingContext) – Taxing context to calculate in
- price (shuup.core.pricing.Price) – Price (taxful or taxless) to calculate taxes for
- tax_class (shuup.core.models.TaxClass) – Tax class of the item to get taxes for
Return type:
-
get_taxed_price_for
(context, item, price)[source]¶ Get TaxedPrice for taxable item.
Taxable items could be products (
Product
), services (Service
), or lines (SourceLine
).Parameters: - context (TaxingContext) – Taxing context to calculate in
- item (shuup.core.taxing.TaxableItem) – Item to get taxes for
- price (shuup.core.pricing.Price) – Price (taxful or taxless) to calculate taxes for
Return type:
-
identifier
= None¶
-
name
= None¶
-
taxing_context_class
¶ alias of
TaxingContext
-
-
class
shuup.core.taxing.
TaxSummary
¶ Bases:
list
-
classmethod
from_line_taxes
(line_taxes, untaxed)[source]¶ Create TaxSummary from LineTaxes.
Parameters: - line_taxes (list[LineTax]) – List of line taxes to summarize.
- untaxed (shuup.core.pricing.TaxlessPrice) – Sum of taxless prices that have no taxes added.
-
classmethod
-
class
shuup.core.taxing.
TaxableItem
¶ Bases:
object
-
tax_class
¶ Return type: shuup.core.models.TaxClass
-
-
class
shuup.core.taxing.
TaxedPrice
(taxful, taxless, taxes=None)¶ Bases:
object
Price with calculated taxes.
-
taxful
¶ (
TaxfulPrice
) Price including taxes.
-
taxless
¶ (
TaxlessPrice
) Pretax price.
-
taxes
¶ (
list[shuup.core.taxing.LineTax]
) List of taxes applied to the price.
Initialize from given prices and taxes.
Parameters: - taxful (shuup.core.pricing.TaxfulPrice) – Price including taxes.
- taxless (shuup.core.pricing.TaxlessPrice) – Pretax price.
- taxes (list[shuup.core.taxing.LineTax]|None) – List of taxes applied to the price.
-
tax_amount
¶ Total amount of applied taxes.
-
tax_rate
¶ Tax rate calculated from taxful and taxless amounts.
-
-
class
shuup.core.taxing.
TaxingContext
(customer_tax_group=None, customer_tax_number=None, location=None)¶ Bases:
object
-
shuup.core.taxing.
get_tax_module
()¶ Get the TaxModule specified in settings.
Return type: shuup.core.taxing.TaxModule
-
shuup.core.taxing.
should_calculate_taxes_automatically
()¶ If
settings.SHUUP_CALCULATE_TAXES_AUTOMATICALLY_IF_POSSIBLE
is False taxes shouldn’t be calculated automatically otherwise use current tax module valueTaxModule.calculating_is_cheap
to determine whether taxes should be calculated automatically.Return type: bool