Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Edwin950821/BodegaX/llms.txt

Use this file to discover all available pages before exploring further.

The History page (/history), labelled Historial in the interface, provides the complete audit trail of all sales transactions recorded in BodegaX. Unlike a simple list, the page assembles a rich, joined dataset from four separate API endpoints and renders it in a scrollable table where every row can be expanded in-place to reveal the individual product line items that made up the sale. Administrators see the full transaction log across all clients; standard users see only the sales associated with their own account. An admin-only Terminar Jornada button at the bottom of the page is wired to call this.dialog.open(TerminarJornada, ...), though dialog is declared as an uninjected any-typed property in the current source and would fail at runtime.

Data Sources and Join Logic

The History component fetches data from four endpoints on initialisation, chaining each request inside the previous response’s subscription:
The component builds the joined dataset entirely in memory. Sales are linked to clients by matching venta.uuid_cliente === client.uuid. Line items are linked to products by matching productoVenta.uuid_producto === producto.uuid, and then linked back to their parent sale by matching productoVenta.uuid_venta === venta.uuid. All four datasets must resolve before the full table renders correctly.
EndpointPropertyRole in Join
GET /admin/allthis.clientProvides nombre for each sale’s uuid_cliente
GET /ventas/allthis.historyParent sale records: uuid, uuid_cliente, fecha, total_venta
GET /productos/allthis.productosProvides nombre for each line item’s uuid_producto
GET /producto-ventas/allthis.productoventasLine items: uuid_venta, uuid_producto, cantidad, total_parcial
The join sequence runs as follows:
  1. Each venta in history is enriched with a cliente property by finding the matching entry in client.
  2. Each productoVenta is enriched with a producto property (the brand name) by finding the matching entry in productos.
  3. Each venta receives a detalle array by filtering productoventas to entries where uuid_venta === venta.uuid.

Role-Based Filtering

Administrators see the Cliente column in the history table, which displays the joined client name for each sale. No additional filtering is applied — this.history contains all sales across every client. The admin can expand any row to inspect its product breakdown.

Viewing a Sale’s Product Breakdown

Each row in the history table includes a ver link. Clicking it toggles the venta.vdetalle boolean on the sale object, causing Angular’s *ngIf directives to show or hide the expandable detail rows inline — no navigation occurs.
1

Locate the Sale in the Table

Scroll through the history table to find the transaction you want to inspect. Each row shows the sale date (fecha), monetary total (total_venta), and — for admins — the client name.
2

Click 'ver' to Expand

Click the ver link in the rightmost column of the target row. The click handler executes venta.vdetalle = !venta.vdetalle, toggling the expanded state for that sale only. Other rows remain unaffected.
3

Review the Sub-Header Row

A sub-header row appears immediately below the sale row, displaying the column labels Producto, Cantidad, and Total Parcial to orient the detail view.
4

Inspect Per-Product Line Items

One detail row renders per entry in venta.detalle. Each row shows the product name (detalle.producto), crate quantity (detalle.cantidad), and the partial monetary total for that product (detalle.total_parcial).
5

Collapse the Detail

Click ver again to set venta.vdetalle back to false, collapsing the detail rows and returning the table to its compact view.

Table Column Reference

ColumnVisibilitySource Field
ClienteAdmin only (role === 'admin')venta.cliente (joined from client)
FechaAll rolesventa.fecha
TotalAll rolesventa.total_venta
verAll rolesToggles venta.vdetalle
Produto (detail)When vdetalle === truedetalle.produto (joined from productos)
Cantidad (detail)When vdetalle === truedetalle.cantidad
Total Parcial (detail)When vdetalle === truedetalle.total_parcial

Terminar Jornada

The Terminar Jornada button is rendered at the bottom of the History page only when user2.role === 'admin'. The button calls terminar(), which attempts this.dialog.open(TerminarJornada, ...) passing this.client as the client list. However, dialog is declared as dialog: any and is not injected through the constructor — MatDialog is absent from the constructor parameters — so this call would fail at runtime. See the End-of-Day Report page for the full PDF generation workflow that TerminarJornada implements.
The History component uses nested HTTP subscriptions rather than RxJS operators like forkJoin. This means the four API calls execute sequentially: clients → sales (with role filter and client join) → products → product-ventas (with product name join and sale detail grouping). The table only renders fully populated data once all four responses have resolved. In slow network environments, the table may initially appear empty or partially filled while the chain completes.

Build docs developers (and LLMs) love