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:
Returns:

TaxedPrice with the calculated taxes.

Return type:

TaxedPrice

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 of Tax objects. Taxes in each tax group will be added together and finally each added tax group will be compounded over each other.

Parameters:
Returns:

TaxedPrice with the calculated taxes.

Return type:

TaxedPrice

Module contents

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/latest/doc/api/shuup.core.taxing.rst, line 19)

error while formatting arguments for shuup.core.taxing.TaxModule.get_context_from_order_source: name ‘OrderSource’ is not defined
class shuup.core.taxing.LineTax

Bases: object

Tax of some line.

This is an interface for specifying taxes of an OrderLine or SourceLine.

tax

(Tax) The tax that this line is about.

name

(str) Name of the tax.

amount

(Money) Tax amount.

base_amount

(Money) Amount that this tax is calculated from.

classmethod from_tax(tax, base_amount, **kwargs)[source]

Create tax line for given tax and base amount.

rate
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 the lines, they are simply replaced.

Parameters:
calculating_is_cheap = True
create_refund_lines(order, supplier, created_by, refund_data)[source]
get_context_from_data(**context_data)[source]
get_context_from_order_source()[source]
get_context_from_request(request)[source]
get_taxed_price(context, price, tax_class)[source]

Get TaxedPrice for price and tax class.

Parameters:
Return type:

shuup.core.taxing.TaxedPrice

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:
Return type:

shuup.core.taxing.TaxedPrice

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:
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:
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 value TaxModule.calculating_is_cheap to determine whether taxes should be calculated automatically.

Return type:bool