El POS muestra el precio de la lista de su sucursal en la tarjeta

Encontrado al probar el POS de punta a punta: la caja cobraba bien el precio
de la sucursal, pero la tarjeta seguía pintando list_price. Con precios por
sucursal (ADR-009) eso es un número que la caja no cobra — el cajero leía
$400 y la línea salía en $450.

La tarjeta ahora pregunta el mismo precio que usará la orden: la lista de la
orden abierta si hay cliente con lista propia, y si no la del punto de venta.
El tema ya dejaba anotado que esto quedaba pendiente "para Fase 2 con un
getter propio"; es exactamente esto.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jorem JuárezandClaude Opus 5 committed 2026-08-18 18:16:33 -06:00
1 parent f4f026ba74
commit 72290c42f0
4 files changed
+58 -5

No files matched your search

+1
View File
@@ -25,6 +25,7 @@ El veredicto del spike está en docs/adr/ADR-001-spike-pos.md.
'assets': {
'point_of_sale._assets_pos': [
'beyond_pos_theme/static/src/scss/beyond_pos.scss',
'beyond_pos_theme/static/src/product_card/product_card.js',
'beyond_pos_theme/static/src/xml/product_card.xml',
'beyond_pos_theme/static/src/empleados_linea/empleados_linea.js',
'beyond_pos_theme/static/src/receipt/beyond_receipt.js',
@@ -0,0 +1,33 @@
/* Part of Beyond. Collina Systems proprietary module. */
import { patch } from "@web/core/utils/patch";
import { ProductCard } from "@point_of_sale/app/components/product_card/product_card";
/**
* Price shown on the product card (template in static/src/xml/product_card.xml).
*
* It used to print list_price, which was right while the whole network sold
* at one price. Since ADR-009 each branch prices from its own list, and the
* base price on the card would be a number the register never charges: the
* cashier reads 400 and the line rings up 450. This asks the POS for the
* same price the order will use.
*
* The pricelist is the order's when there is one open — a customer with a
* pricelist of their own changes it — and the register's default otherwise.
*/
patch(ProductCard.prototype, {
get beyondPrice() {
const template = this.props.product;
if (!template) {
return false;
}
const pos = this.env.services.pos;
const pricelist = pos?.getOrder()?.pricelist_id || pos?.config?.pricelist_id;
const variant = template.product_variant_ids?.[0];
if (!pricelist || !variant || typeof template.getPrice !== "function") {
// Nothing to price against: fall back to the base price rather
// than leaving the card blank.
return template.list_price;
}
return template.getPrice(pricelist, 1, 0, false, variant);
},
});
@@ -3,17 +3,20 @@
<!--
Extensión de la tarjeta de producto del POS: precio visible sobre la
imagen (patrón app de consumo, BRIEF §3). Herencia OWL pura: el core
no se toca. Nota spike: list_price es el precio de lista con IVA
incluido; la lógica de listas de precios por cliente se resolvería en
Fase 2 con un getter propio.
no se toca.
El precio sale del getter beyondPrice (product_card/product_card.js),
que aplica la lista de precios de la sucursal (ADR-009). Antes se
pintaba list_price, que desde que cada sucursal tiene su lista es un
número que la caja no cobra.
-->
<t t-name="beyond_pos_theme.ProductCard"
t-inherit="point_of_sale.ProductCard"
t-inherit-mode="extension">
<xpath expr="//article" position="inside">
<span t-if="props.product and props.product.list_price"
<span t-if="beyondPrice"
class="beyond-price position-absolute"
t-esc="env.utils.formatCurrency(props.product.list_price)"/>
t-esc="env.utils.formatCurrency(beyondPrice)"/>
</xpath>
</t>
</templates>
@@ -24,6 +24,22 @@ class TestBeyondPosThemeAssets(TransactionCase):
with file_open(path) as handle:
self.assertTrue(handle.read().strip(), f"{path} está vacío")
def test_la_tarjeta_no_pinta_el_precio_base(self):
"""ADR-009: con lista de precios por sucursal, list_price en la
tarjeta es un número que la caja no cobra. El precio sale del getter
beyondPrice, que aplica la lista de la sucursal."""
with file_open('beyond_pos_theme/static/src/xml/product_card.xml') as handle:
plantilla = handle.read()
self.assertIn('beyondPrice', plantilla)
self.assertNotIn('props.product.list_price', plantilla)
manifest = get_manifest('beyond_pos_theme')
bundle = manifest['assets'].get('point_of_sale._assets_pos', [])
self.assertIn(
'beyond_pos_theme/static/src/product_card/product_card.js', bundle,
'el getter tiene que viajar en el bundle del POS')
with file_open('beyond_pos_theme/static/src/product_card/product_card.js') as handle:
self.assertIn('getPrice', handle.read())
def test_herencia_extiende_product_card(self):
with file_open('beyond_pos_theme/static/src/xml/product_card.xml') as handle:
contenido = handle.read()