shoop.core.taxing package¶
Submodules¶
shoop.core.taxing.utils module¶
-
shoop.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[shoop.core.order_creator.SourceLine]) – List of taxed lines to generate proportions from Return type: list[(shoop.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.
-
shoop.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 (shoop.core.pricing.Price) – Taxful or taxless price to calculate taxes for
- taxes (list[shoop.core.models.Tax]) – List of Tax objects
Returns: TaxedPrice with the calculated taxes.
Return type:
-
shoop.core.taxing.utils.calculate_compounded_added_taxes(price, tax_groups)[source]¶ Calculate compounded and added taxes from given groups of taxes.
The
tax_groupsargument should be a list of tax groups, where each tax group is a list ofTaxobjects. Taxes in each tax group will be added together and finally each added tax group will be compounded over each other.Parameters: - price (shoop.core.pricing.Price) – Taxful or taxless price to calculate taxes for
- tax_groups (list[list[shoop.core.models.Tax]]) – List of tax groups, each being a list of taxes
Returns: TaxedPrice with the calculated taxes.
Return type:
Module contents¶
-
class
shoop.core.taxing.LineTax¶ Bases:
objectTax of some line.
This is an interface for specifying taxes of an
OrderLineorSourceLine.-
classmethod
from_tax(tax, base_amount, **kwargs)[source]¶ Create tax line for given tax and base amount.
-
rate¶
-
classmethod
-
class
shoop.core.taxing.SourceLineTax(tax, name, amount, base_amount)¶ Bases:
shoop.core.taxing.LineTaxInitialize line tax from given values.
-
class
shoop.core.taxing.TaxModule¶ Bases:
objectModule 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.extendfor example). If there is any existing taxes for thelines, they are simply replaced.Parameters: - source (shoop.core.order_creator.OrderSource) – OrderSource of the lines
- lines (list[shoop.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 (shoop.core.pricing.Price) – Price (taxful or taxless) to calculate taxes for
- tax_class (shoop.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 (shoop.core.taxing.TaxableItem) – Item to get taxes for
- price (shoop.core.pricing.Price) – Price (taxful or taxless) to calculate taxes for
Return type:
-
identifier= None¶
-
name= None¶
-
taxing_context_class¶ alias of
TaxingContext
-
-
class
shoop.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 (shoop.core.pricing.TaxlessPrice) – Sum of taxless prices that have no taxes added
-
classmethod
-
class
shoop.core.taxing.TaxableItem¶ Bases:
object-
tax_class¶ Return type: shoop.core.models.TaxClass
-
-
class
shoop.core.taxing.TaxedPrice(taxful, taxless, taxes=None)¶ Bases:
objectPrice with calculated taxes.
-
taxful¶ (
TaxfulPrice) Price including taxes.
-
taxless¶ (
TaxlessPrice) Pretax price.
-
taxes¶ (
list[shoop.core.taxing.LineTax]) List of taxes applied to the price.
Initialize from given prices and taxes.
Parameters: - taxful (shoop.core.pricing.TaxfulPrice) – Price including taxes.
- taxless (shoop.core.pricing.TaxlessPrice) – Pretax price.
- taxes (list[shoop.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
shoop.core.taxing.TaxingContext(customer_tax_group=None, customer_tax_number=None, location=None)¶ Bases:
object
-
shoop.core.taxing.get_tax_module()¶ Get the TaxModule specified in settings.
Return type: shoop.core.taxing.TaxModule
-
shoop.core.taxing.should_calculate_taxes_automatically()¶ If
settings.SHOOP_CALCULATE_TAXES_AUTOMATICALLY_IF_POSSIBLEis False taxes shouldn’t be calculated automatically otherwise use current tax module valueTaxModule.calculating_is_cheapto determine whether taxes should be calculated automatically.Return type: bool