The History page (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.
/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.| Endpoint | Property | Role in Join |
|---|---|---|
GET /admin/all | this.client | Provides nombre for each sale’s uuid_cliente |
GET /ventas/all | this.history | Parent sale records: uuid, uuid_cliente, fecha, total_venta |
GET /productos/all | this.productos | Provides nombre for each line item’s uuid_producto |
GET /producto-ventas/all | this.productoventas | Line items: uuid_venta, uuid_producto, cantidad, total_parcial |
- Each
ventainhistoryis enriched with aclienteproperty by finding the matching entry inclient. - Each
productoVentais enriched with aproductoproperty (the brand name) by finding the matching entry inproductos. - Each
ventareceives adetallearray by filteringproductoventasto entries whereuuid_venta === venta.uuid.
Role-Based Filtering
- Admin View
- User View
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 theventa.vdetalle boolean on the sale object, causing Angular’s *ngIf directives to show or hide the expandable detail rows inline — no navigation occurs.
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.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.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.
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).Table Column Reference
| Column | Visibility | Source Field |
|---|---|---|
| Cliente | Admin only (role === 'admin') | venta.cliente (joined from client) |
| Fecha | All roles | venta.fecha |
| Total | All roles | venta.total_venta |
| ver | All roles | Toggles venta.vdetalle |
| Produto (detail) | When vdetalle === true | detalle.produto (joined from productos) |
| Cantidad (detail) | When vdetalle === true | detalle.cantidad |
| Total Parcial (detail) | When vdetalle === true | detalle.total_parcial |
Terminar Jornada
The Terminar Jornada button is rendered at the bottom of the History page only whenuser2.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.
Subscription Chain and Loading Order
Subscription Chain and Loading Order
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.