def create_assigned_tax_class(name, rates_to_assign):
 tax_class = TaxClass.objects.create(name=(u'TC-%s' % name))
 for (n, tax_rate) in enumerate(rates_to_assign, 1):
  tax_name = ((u'Tax-%s' % name) if (len(rates_to_assign) == 1) else (u'Tax-%s-%d' % (name, n)))
  tax = Tax.objects.create(rate=tax_rate, name=tax_name)
  TaxRule.objects.create(tax=tax).tax_classes.add(tax_class)
 return tax_class

def create_assigned_tax_class ( name , rates_to_assign ) : tax_class = TaxClass . objects . create ( name = ( u'TC-%s' % name ) ) for ( n , tax_rate ) in enumerate ( rates_to_assign , 1 ) : tax_name = ( ( u'Tax-%s' % name ) if ( len ( rates_to_assign ) == 1 ) else ( u'Tax-%s-%d' % ( name , n ) ) ) tax = Tax . objects . create ( rate = tax_rate , name = tax_name ) TaxRule . objects . create ( tax = tax ) . tax_classes . add ( tax_class ) return tax_class
create a tax class and assign taxes for it with tax rules .