Monedero configurable por servicio y artículo
- Campo genera_monedero (default true) en servicios e items de inventario - Puntos proporcionales a las líneas elegibles al liquidar la venta - Toggle con icono Wallet en Servicios e Inventario
This commit is contained in:
@@ -87,11 +87,16 @@ class SkeenVenta(models.Model):
|
||||
'payment_state': 'paid',
|
||||
'amount_paid': venta.total,
|
||||
})
|
||||
# Acumular puntos
|
||||
# Acumular puntos (proporcional a líneas que generan monedero)
|
||||
monedero = self.env['skeen.monedero'].search([('partner_id', '=', venta.partner_id.id)], limit=1)
|
||||
if not monedero:
|
||||
monedero = self.env['skeen.monedero'].create({'partner_id': venta.partner_id.id})
|
||||
points = int(venta.total / 10)
|
||||
subtotal_total = sum(l.subtotal for l in venta.line_ids)
|
||||
elegible = sum(
|
||||
l.subtotal for l in venta.line_ids
|
||||
if (l.service_id and l.service_id.genera_monedero) or (l.item_id and l.item_id.genera_monedero)
|
||||
)
|
||||
points = int(venta.total * (elegible / subtotal_total) / 10) if subtotal_total else 0
|
||||
if points > 0:
|
||||
monedero.add_points(points, description=f'Venta {venta.name}', reference=venta.name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user