def get_tax_class_proportions(lines):
 if (not lines):
  return []
 zero = lines[0].price.new(0)
 total_by_tax_class = defaultdict((lambda : zero))
 total = zero
 for line in lines:
  total_by_tax_class[line.tax_class] += line.price
  total += line.price
 if (not total):
  return []
 return [(tax_class, (tax_class_total / total)) for (tax_class, tax_class_total) in total_by_tax_class.items()]

def get_tax_class_proportions ( lines ) : if ( not lines ) : return [ ] zero = lines [ 0 ] . price . new ( 0 ) total_by_tax_class = defaultdict ( ( lambda : zero ) ) total = zero for line in lines : total_by_tax_class [ line . tax_class ] += line . price total += line . price if ( not total ) : return [ ] return [ ( tax_class , ( tax_class_total / total ) ) for ( tax_class , tax_class_total ) in total_by_tax_class . items ( ) ]
generate tax class proportions from taxed lines .