Does anybody sumarize different taxClasses in the bill?

2010/12/20 Alvaro Gomez <[email protected]>

> By the way, for the other european guys out there. Do you sumarize somehow
> your tax (VAT) amounts per taxClass somehow?. I need this and also give a
> string name to the applied rate to include it in the bill.
>
> Regards
>
> 2010/12/20 Alvaro <[email protected]>
>
> Hi
>>
>>
>> I'l developing my own VAT tax module based in teh area current one to
>> handle some territory exceptions.
>>
>> I'm creating a custom templatetag to sumarize the total tax amount and
>> base amount for products in the same taxClass (this is a legal
>> requirement), so I extended the TaxRate model by adding a tax name and
>> some extra field.
>>
>>
>> THe issue is that I'm receiving an anoying "Caught TypeError while
>> rendering: int() argument must be a string or a number, not
>> 'get_tax_details'" error and I do not understand where the problem is.
>> Do you see any obvious Type unaligment in the following code? I'm
>> calling the template tag as {% order_tax_detail order as valor %}
>>
>>
>> from django.template import
>> Library,Node,VariableDoesNotExist,TemplateSyntaxError,resolve_variable
>> from django.utils import translation
>> from decimal import Decimal
>> from satchmo_store.shop.models import OrderItem
>> from livesettings import config_value
>> from django.db.models import Sum
>> from tax.utils import get_tax_processor
>>
>>
>> import logging
>>
>> log = logging.getLogger('montapp.TAXDetails')
>>
>> register = Library()
>>
>>
>> class get_tax_details(Node):
>>    def __init__(self, order,varname):
>>        self.order,self.varname = order,varname
>>    def render(self,context):
>>        orderid = resolve_variable(self.order, context)
>>        taxer = get_tax_processor(self)
>>        valores =
>>
>> list(OrderItem.objects.filter(order=orderid).values('product__taxClass').annotate(total_tax=Sum('tax'),total_price=Sum('line_item_price')))
>>        try:
>>            for valor in valores:
>>                taxClass = valor['product__taxClass']
>>                context[taxClass]= {
>>                        'TaxName' : taxer.get_name(self,taxClass),
>>                        'TaxRate' : taxer.get_name(self,taxClass),
>>                        'TotalTax' : valor.total_tax,
>>                        'TotalPrice' : valor.total_price,
>>                        }
>>            varname = context
>>        except VariableDoesNotExist:
>>            raise TemplateSyntaxError("Invalid order %s for
>> order_tax_details",self.order)
>>        return ''
>>
>> def order_tax_detail (parser,token):
>>    """Return the Tax amount grouped by Tax class"""
>>    bits = token.contents.split()
>>    if len(bits) != 4:
>>        raise TemplateSyntaxError("Invalid number of arguments for
>> order_tax_details")
>>    if bits[2] != 'as':
>>        raise TemplateSyntaxError, "third argument to get_latest tag
>> must be 'as'"
>>
>>    return get_tax_details(bits[1],bits[3])
>>
>> register.tag('order_tax_detail',order_tax_detail)
>>
>>
>>
>>
>
>
> --
> Alvaro
> www.dorsalcero.net
>



-- 
Alvaro
www.dorsalcero.net

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to