def precio_total(self): activos = Activo.objects.filter(bodega=self).aggregate( total=Sum('articulo__precio')) agg = Sum(F('articulo__precio') * F('cantidad')) agg.output_field = DecimalField(max_digits=19, decimal_places=2) nserial = ActivoNoSerial.objects.filter( bodega=self).aggregate(total=agg) if activos['total']: total = activos['total'] else: total = 0 # end if if nserial['total']: total = total + nserial['total'] # end if if total == 0: return total else: vals = str(total).split('.') money = MoneyInput() value = money.intToStringWithCommas( int(vals[0])).replace(',', '.') + ',' + vals[1] return value
def precio_insumos(self): agg = Sum(F('articulo__precio') * F('cantidad')) agg.output_field = DecimalField(max_digits=19, decimal_places=2) nserial = ActivoInsumo.objects.filter(bodega=self).aggregate(total=agg) if nserial['total']: total = nserial['total'] vals = str(total).split('.') money = MoneyInput() value = money.intToStringWithCommas(int(vals[0])).replace( ',', '.') + ',' + vals[1] return u"$ %s" % value else: return u"$ %d" % 0
def precio_insumos(self): agg = Sum(F('articulo__precio') * F('cantidad')) agg.output_field = DecimalField(max_digits=19, decimal_places=2) nserial = ActivoInsumo.objects.filter(bodega=self).aggregate(total=agg) if nserial['total']: total = nserial['total'] vals = str(total).split('.') money = MoneyInput() value = money.intToStringWithCommas( int(vals[0])).replace(',', '.') + ',' + vals[1] return u"$ %s" % value else: return u"$ %d" % 0
def precio_total(self): activos = Activo.objects.filter(bodega=self).aggregate( total=Sum('articulo__precio')) agg = Sum(F('articulo__precio') * F('cantidad')) agg.output_field = DecimalField(max_digits=19, decimal_places=2) nserial = ActivoInsumo.objects.filter(bodega=self).aggregate(total=agg) if activos['total']: total = activos['total'] else: total = 0 # end if if nserial['total']: total = total + nserial['total'] # end if if total == 0: return total else: vals = str(total).split('.') money = MoneyInput() value = money.intToStringWithCommas(int(vals[0])).replace( ',', '.') + ',' + vals[1] return value