Saltar a contenido

PDF-010I - B2B Pricing Engine Local Prototype

Fecha: 2026-06-23

Estado: PROTOTIPO TECNICO LOCAL + TESTS / SIN RUNTIME / SIN WRITES

portal_visible = yes

Scope: tenant

tenant_id: alpuntodeventa

Destino funcional: SOURCE-001 Clientes + SOURCE-002 Productos -> WooCommerce La Directa

Owner: Gabi / Carlos Canu

A. SAFE POINT inicial

Control Resultado
git status -sb ## main...origin/main
git rev-parse HEAD a6536f2159c5f8ceaa775fbea801d7c2e77f06e4
git rev-parse origin/main a6536f2159c5f8ceaa775fbea801d7c2e77f06e4
git log -3 --oneline a6536f2 docs: add pdf-010h b2b runtime dry-run design; d17fb94 docs: add pdf-010g b2b commercial price rules approval; 979c919 docs: add pdf-010f b2b commercial pricing design
git diff --check inicial PASS

Safe point esperado confirmado:

  • HEAD coincide con a6536f2159c5f8ceaa775fbea801d7c2e77f06e4.
  • origin/main coincide con a6536f2159c5f8ceaa775fbea801d7c2e77f06e4.
  • repo limpio al inicio.
  • ultimo commit esperado confirmado.

B. Documentacion leida

Documentacion base revisada:

  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010A-B2B-PRICE-LISTS-CUSTOMER-SYNC-CONTRACT.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010D-SOURCE-001-VCLIENTES-READ-ONLY-SNAPSHOT.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010E-B2B-CUSTOMER-PRICE-DRY-RUN.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010F-B2B-COMMERCIAL-PRICE-RULES-SERVER-SIDE-PRICING-DESIGN.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010G-B2B-COMMERCIAL-PRICE-RULES-APPROVAL.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010H-B2B-RUNTIME-DRY-RUN-DESIGN.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-009M-WOOCOMMERCE-PRODUCT-DRAFT-PILOT-WRITE.md

C. Prototipo creado

Paquete local creado:

  • infra/business-observer/production/b2b-pricing/PDF-010I/b2b_pricing_engine.py
  • infra/business-observer/production/b2b-pricing/PDF-010I/run_b2b_pricing_dry_run.py
  • infra/business-observer/production/b2b-pricing/PDF-010I/test_b2b_pricing_engine.py
  • infra/business-observer/production/b2b-pricing/PDF-010I/README.md

Impacto:

  • agrega motor local puro para calcular precios B2B con snapshots locales;
  • no agrega dependencias nuevas;
  • no se conecta a WooCommerce, PostgreSQL, SGC runtime ni .env;
  • no ejecuta writes.

D. Logica implementada

Reglas implementadas:

Caso Resultado
visitante no logueado PUBLIC_DEFAULT, usa PrecioListaFinal
cliente logueado activo con lista 1..9 B2B_PRICE_OK, usa PrecioL{Lista_Precio}
cliente suspendido/de baja BLOCKED_CUSTOMER_STATUS
cliente activo sin mapping/lista BLOCKED_CUSTOMER_MAPPING
lista fuera de 1..9 BLOCKED_PRICE_LIST
SKU inexistente, precio faltante o precio <= 0 BLOCKED_PRICE_MISSING

Salida metadata:

  • sku
  • customer_ref
  • price_list_code
  • applied_price
  • regular_price_reference
  • source_hash
  • pricing_status

source_hash se calcula localmente desde SKU, PrecioListaFinal y PrecioL1..PrecioL9, sin incluir costos, margenes, cliente, CUIT, email ni telefono.

E. Tests creados

Tests locales:

  • visitante ve PrecioListaFinal.
  • cliente Lista_Precio = 1 usa PrecioL1.
  • cliente Lista_Precio = 5 usa PrecioL5.
  • cliente suspendido bloqueado.
  • cliente de baja bloqueado.
  • SKU 3995 bloqueado por precio 0.000.
  • SKU 4010 bloqueado por precio 0.000.
  • lista invalida bloqueada.
  • cliente sin mapping/lista bloqueado.

F. Tests ejecutados

Comando:

powershell pytest infra/business-observer/production/b2b-pricing/PDF-010I

Resultado:

  • 9 passed in 0.27s

G. Dry-run ejecutado

Comando:

powershell python infra/business-observer/production/b2b-pricing/PDF-010I/run_b2b_pricing_dry_run.py

Resumen no sensible:

pricing_status Casos
PUBLIC_DEFAULT 1
B2B_PRICE_OK 2
BLOCKED_CUSTOMER_STATUS 2
BLOCKED_PRICE_MISSING 2
BLOCKED_PRICE_LIST 1
BLOCKED_CUSTOMER_MAPPING 1

El dry-run imprime solo referencias sinteticas:

  • PUBLIC_VISITOR
  • SOURCE-001-L1-ACTIVE-CANDIDATE
  • SOURCE-001-L5-ACTIVE-CANDIDATE
  • SOURCE-001-SUSPENDED-CANDIDATE
  • SOURCE-001-INACTIVE-CANDIDATE
  • UNMAPPED_CUSTOMER

No imprime CUIT, email, telefono ni datos personales completos.

H. Snapshots usados

Entradas locales read-only:

Source Path Uso
SOURCE-001 Clientes snapshots/source-001/SOURCE-001-VCLIENTES-READ-ONLY-SANITIZED-20260623.json contexto documental y referencias sanitizadas
SOURCE-002 Productos snapshots/source-002/SOURCE-002-PRODUCTS-RUNTIME-PREFLIGHT-20260620-173614.csv SKU, PrecioListaFinal, PrecioL1..PrecioL9

Los snapshots estan ignorados por Git mediante .gitignore.

I. Archivos creados/modificados

Creado:

  • infra/business-observer/production/b2b-pricing/PDF-010I/b2b_pricing_engine.py
  • infra/business-observer/production/b2b-pricing/PDF-010I/run_b2b_pricing_dry_run.py
  • infra/business-observer/production/b2b-pricing/PDF-010I/test_b2b_pricing_engine.py
  • infra/business-observer/production/b2b-pricing/PDF-010I/README.md
  • docs/tenants/alpuntodeventa/business-observer/production/PDF-010I-B2B-PRICING-ENGINE-LOCAL-PROTOTYPE.md

Actualizados:

  • docs/tenants/alpuntodeventa/business-observer/production/README.md
  • docs/PROJECT-STATE.md
  • docs/ROADMAP.md
  • docs/governance/ACTIVE-CONTEXT.md
  • mkdocs.yml

J. Validaciones requeridas

Validaciones de cierre:

  • git diff --check
  • .\.venv-portal\Scripts\mkdocs.exe build --strict
  • pytest infra/business-observer/production/b2b-pricing/PDF-010I
  • python infra/business-observer/production/b2b-pricing/PDF-010I/run_b2b_pricing_dry_run.py

K. Estado final esperado

  • commit local creado;
  • sin push;
  • sin deploy;
  • sin runtime WooCommerce;
  • sin PostgreSQL;
  • sin sync, scheduler, cron ni pipelines.

L. Proximo paso recomendado

Abrir gate separado para integrar este motor con un store real de mapping wc_customer_id -> sgc_customer_id y preparar dry-run de catalogo, carrito, checkout y metadata de orden, manteniendo bloqueados API WooCommerce, PostgreSQL writes, sync, scheduler, cron y pipelines hasta autorizacion posterior explicita.

M. Restricciones preservadas

Durante este gate:

  • no se toco WooCommerce API;
  • no se toco .env;
  • no se imprimieron secretos;
  • no se toco PostgreSQL;
  • no se ejecuto SQL;
  • no se modifico runtime WooCommerce;
  • no se instalo plugin;
  • no se modifico theme;
  • no se ejecuto sync;
  • no se activo scheduler, cron ni pipelines;
  • no se hizo push;
  • no se hizo deploy;
  • no se crearon clientes;
  • no se crearon productos;
  • no se modificaron productos.