shuup.default_tax package

Submodules

shuup.default_tax.models module

class shuup.default_tax.models.TaxRuleQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: django.db.models.query.QuerySet

may_match_postal_code(postalcode)[source]
class shuup.default_tax.models.TaxRule(id, enabled, country_codes_pattern, region_codes_pattern, postal_codes_pattern, _postal_codes_min, _postal_codes_max, priority, override_group, tax)[source]

Bases: django.db.models.base.Model

Parameters:
  • id (AutoField) – Id
  • enabled (BooleanField) – Enable this if this tax rule is active.
  • country_codes_pattern (CharField) – Country codes pattern
  • region_codes_pattern (CharField) – Region codes pattern
  • postal_codes_pattern (TextField) – Postal codes pattern
  • _postal_codes_min (CharField) – postal codes min
  • _postal_codes_max (CharField) – postal codes max
  • priority (IntegerField) – Rules with same priority define added taxes (e.g. US taxes) and rules with different priority define compound taxes (e.g. Canada Quebec PST case)
  • override_group (IntegerField) – If several rules match, only the rules with the highest override group number will be effective. This can be used, for example, to implement tax exemption by adding a rule with very high override group that sets a zero tax.
  • tax (ForeignKey to shuup.core.models.Tax) – The tax to apply when this rule is applied.
  • tax_classes (ManyToManyField to shuup.core.models.TaxClass) – Tax classes of the items to be taxed
  • customer_tax_groups (ManyToManyField to shuup.core.models.CustomerTaxGroup) – The customer tax groups for which this tax rule is limited.
enabled

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tax_classes

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

customer_tax_groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

country_codes_pattern

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

region_codes_pattern

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

postal_codes_pattern

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

priority

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

override_group

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tax

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

objects = <django.db.models.manager.ManagerFromTaxRuleQuerySet object>
matches(taxing_context)[source]

Check if this tax rule matches given taxing context.

save(*args, **kwargs)[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tax_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

shuup.default_tax.module module

class shuup.default_tax.module.DefaultTaxModule[source]

Bases: shuup.core.taxing.TaxModule

identifier = 'default_tax'
name = 'Default Taxation'
get_taxed_price(context, price, tax_class)[source]
shuup.default_tax.module.get_taxes_of_effective_rules(taxing_context, tax_rules)[source]

Get taxes grouped by priority from effective tax rules.

Effective tax rules is determined by first limiting the scope to the rules that match the given taxing context (see TaxRule.match) and then further limiting the matching rules by selecting only the rules in the highest numbered override group.

The Tax objects in the effective rules will be grouped by the priority of the rules. The tax groups are returned as list of tax lists.

Parameters:tax_rules (Iterable[TaxRule]) – Tax rules to filter from. These should be ordered desceding by override group and then ascending by priority.
Return type:list[list[shuup.core.models.Tax]]

Module contents

class shuup.default_tax.AppConfig(*args, **kwargs)[source]

Bases: shuup.apps.AppConfig

name = 'shuup.default_tax'
verbose_name = 'Shuup Default Tax'
label = 'default_tax'
provides = {'tax_module': ['shuup.default_tax.module:DefaultTaxModule'], 'admin_module': ['shuup.default_tax.admin_module:TaxRulesAdminModule']}