def get_taxed_price_for(self, context, item, price): taxes = [] if context.postal_code == "92602": taxes = [ # Based on data from TaxJar get_tax("CA", "California", rate="0.065"), get_tax("CA-OC", "Orange County", rate="0.01"), get_tax("CA-OC-IR", "Irvine", rate="0.00"), get_tax("CA-OC-IR-DS", "District tax", rate="0.005"), ] return stacked_value_added_taxes(price, taxes)
def get_line_taxes(self, source_line): taxes = [] if source_line.source.billing_address.postal_code == "92602": taxes = [ # Based on data from TaxJar get_tax("CA", "California", rate="0.065"), get_tax("CA-OC", "Orange County", rate="0.01"), get_tax("CA-OC-IR", "Irvine", rate="0.00"), get_tax("CA-OC-IR-DS", "District tax", rate="0.005"), ] return stacked_value_added_taxes(source_line.total_price, taxes).taxes
def get_taxed_price(self, context, price, tax_class): taxes = [] if context.postal_code == "92602": taxes = [ # Based on data from TaxJar get_tax("CA", "California", rate="0.065"), get_tax("CA-OC", "Orange County", rate="0.01"), get_tax("CA-OC-IR", "Irvine", rate="0.00"), get_tax("CA-OC-IR-DS", "District tax", rate="0.005"), ] return stacked_value_added_taxes(price, taxes)
def get_line_taxes(self, source_line): taxes = [] if source_line.source.billing_address.postal_code == "92602": taxes = [ # Based on data from TaxJar get_tax("CA", "California", rate="0.065"), get_tax("CA-OC", "Orange County", rate="0.01"), get_tax("CA-OC-IR", "Irvine", rate="0.00"), get_tax("CA-OC-IR-DS", "District tax", rate="0.005"), ] return stacked_value_added_taxes(source_line.total_price, taxes).taxes
def _calculate_taxes(price, taxing_context, tax_class): customer_tax_group = taxing_context.customer_tax_group # Check tax exempt # TODO: Should this be done in some better way? if customer_tax_group and customer_tax_group.identifier == 'tax_exempt': return taxing.TaxedPrice( TaxfulPrice(price.amount), TaxlessPrice(price.amount), [] ) tax_rules = TaxRule.objects.filter(enabled=True, tax_classes=tax_class) if customer_tax_group: tax_rules = tax_rules.filter(customer_tax_groups=customer_tax_group) tax_rules = tax_rules.order_by("-priority") # TODO: Do the Right Thing with priority taxes = [tax_rule for tax_rule in tax_rules if tax_rule.matches(taxing_context)] tax_rule = first(taxes) # TODO: Do something better than just using the first tax! tax = getattr(tax_rule, "tax", None) return stacked_value_added_taxes(price, [tax] if tax else [])
def _calculate_taxes(price, taxing_context, tax_class): customer_tax_group = taxing_context.customer_tax_group # Check tax exempt # TODO: Should this be done in some better way? if customer_tax_group and customer_tax_group.identifier == 'tax_exempt': return taxing.TaxedPrice( TaxfulPrice(price.amount), TaxlessPrice(price.amount), [] ) tax_rules = TaxRule.objects.filter(enabled=True, tax_classes=tax_class) if customer_tax_group: tax_rules = tax_rules.filter(customer_tax_groups=customer_tax_group) tax_rules = tax_rules.order_by("-priority") # TODO: Do the Right Thing with priority taxes = [tax_rule for tax_rule in tax_rules if tax_rule.matches(taxing_context)] tax_rule = first(taxes) # TODO: Do something better than just using the first tax! tax = getattr(tax_rule, "tax", None) return stacked_value_added_taxes(price, [tax] if tax else [])