Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/dinogamer089/SiCom/llms.txt

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

SiCom treats every client request as a single entity — a Renta — that begins as a quotation (SOLICITADA) and progresses through a defined set of operational states until it is either completed (Finalizada) or cancelled. The same lifecycle covers both the quoting phase (handled by admin staff reviewing incoming requests) and the physical delivery, pickup, and return phases (assigned to and executed by employees). This unified model means administrators, employees, and clients all interact with the same Renta record, distinguished only by its current estado.

The Renta Entity

The Renta entity is persisted to the renta table and represents a rental agreement in any phase of its lifecycle.
FieldColumnTypeNotes
ididRentaInteger (PK, auto)Generated identity
estadoestadoString (max 45)Current lifecycle state; required
idClienteidClienteCliente (ManyToOne)Customer who placed the request
horahoraLocalTimeTime the request was created
fechaIniciofecha_inicioLocalDateDelivery start date (event date)
fechafechaLocalDateReturn/collection date
idEmpleadoidEmpleadoEmpleado (OneToOne)Employee currently assigned to the rental
entregadoEntregadoString (max 45)Name of the employee who performed delivery
recogidoRecogidoString (max 45)Name of the employee who performed collection
totaltotalBigDecimal (10,2)Calculated total of all line items
detallesRentaList<Detallerenta>Line items; ordered by ID ascending

The Detallerenta Entity

Each line item in a rental links a Renta to an Articulo with quantity and pricing captured at quote time.
FieldColumnTypeNotes
ididdetalleInteger (PK, auto)Generated identity
idrentaidrentaRenta (ManyToOne)Parent rental
idarticuloidarticuloArticulo (ManyToOne)The rented article
cantidadcantidadIntegerNumber of units
precioUnitarioprecio_unitarioBigDecimal (10,2)Unit price at time of quoting
precioTotalprecio_totalBigDecimal (10,2)cantidad × precioUnitario

Client Shopping Flow

A client request moves through three steps before creating a Renta record:
  1. Date selection — The client opens the catalog (renta_cliente.xhtml) and picks a fechaInicio (delivery) and fechaSeleccionada (return) via ArticuloCatalogoBeanUI. The catalog reloads with real-time availability calculated as articulo.unidades − SUM(cantidad_reservada) for every day in the chosen range.
  2. Cart assembly — The client clicks articles to add them to CarritoBean (@Named("carritoBean"), @SessionScoped). agregarArticulo(ArticuloCardDTO) looks up the full Articulo entity, checks stock for the date range, and adds it to the internal Carrito. Quantities are adjustable with +/ controls; the cart enforces the maximum available stock at all times.
  3. Checkout — The client fills in nombreCliente, telefono1, and direccionEntrega in the checkout dialog and accepts terms. confirmarCotizacion() calls FacadeRenta.registrarRenta() to persist the request with state SOLICITADA. A WhatsApp message with the quote summary is opened automatically in a new tab.

Rental State Machine

A Renta progresses through up to nine states. Cancelada is reachable from any active state.
SOLICITADA

    ▼ (admin approves)
 Aprobada ─────────────────────────────────────────────────────┐
    │                                                           │
    ▼ (admin confirms)                                          │
 Confirmado                                                     │
    │                                                           │
    ▼                                                           │
 Pendiente a reparto                                            │
    │                                                           │  Cancelada
    ▼ (employee assigned + "En reparto")                        │  (from any
 En reparto                                                     │   state)
    │                                                           │
    ▼ (delivery confirmed + comment)                            │
 Entregado                                                      │
    │                                                           │
    ▼                                                           │
 Pendiente a recoleccion                                        │
    │                                                           │
    ▼ (employee assigned + "En recoleccion")                    │
 En recoleccion                                                 │
    │                                                           │
    ▼ (collection confirmed + comment)                          │
 Finalizada ◄───────────────────────────────────────────────────┘
StateTriggered byEffect
SOLICITADAClient submits cartInitial state; stock not yet reserved
AprobadaAdmin approvesStored procedure reserves stock for the full date range
ConfirmadoAdmin confirmsAdditional warehouse SALIDA movement recorded
Pendiente a repartoAdmin advances stateAwaiting employee assignment
En repartoAdmin selects employeeRenta.idEmpleado set to selected employee
EntregadoEmployee or admin marks deliveredentregado field set to employee name; idEmpleado cleared; delivery comment saved
Pendiente a recoleccionAdmin advances stateAwaiting pickup employee
En recoleccionAdmin selects employeeRenta.idEmpleado set to collection employee
FinalizadaEmployee or admin marks completerecogido field set to employee name; idEmpleado cleared; stock reservations released
CanceladaAdmin cancelsStock reservations released for the full date range

The cambiar_estado_renta Stored Procedure

State transitions that affect stock are handled atomically inside the MySQL stored procedure cambiar_estado_renta(p_idRenta INT, p_nuevoEst VARCHAR).
-- Reserve stock when a SOLICITADA quote becomes Aprobada or Confirmado:
-- For every day d in [fecha_inicio, fecha], for every Detallerenta:
INSERT INTO stock_reservado_diario (idarticulo, fecha, cantidad_reservada)
VALUES (v_idarticulo, v_dia_actual, v_cantidad)
ON DUPLICATE KEY UPDATE cantidad_reservada = cantidad_reservada + v_cantidad;

-- Release stock when state changes to Cancelada or Finalizada:
UPDATE stock_reservado_diario
SET cantidad_reservada = GREATEST(cantidad_reservada - v_cantidad, 0)
WHERE idarticulo = v_idarticulo AND fecha = v_dia_actual;
The procedure is invoked by DelegateRenta.cambiarEstado(), which calls RentaDAO.cambiarEstadoRenta() and then runs registrarMovimientosAutomaticos() (SALIDA on Confirmado, ENTRADA on Finalizada) and liberarReservasCliente() (Java-side reservation cleanup on Finalizada and Cancelada).

FacadeRenta Methods

// Register a new rental/quotation from the shopping cart
public void registrarRenta(
    Cliente cliente,
    List<Detallerenta> detalles,
    LocalDate fechaInicio,   // delivery start date
    LocalDate fecha,         // return date
    LocalTime hora,          // time of submission
    String estado            // initial state, e.g. "SOLICITADA"
) { ... }
MethodDescription
obtenerCotizaciones()Returns all rentals in quotation phase (pre-Confirmado states)
obtenerRentas()Returns all active rental records
cambiarEstado(Integer, String)Calls the stored procedure and triggers warehouse movements
actualizarRentaConStock(Renta, LocalDate, LocalDate)Re-calculates stock reservations when dates or articles are changed on an existing rental
obtenerRentasDisponiblesYAsignadas(Integer)Returns rentals available for pickup or already assigned to a specific employee
guardarComentario(Comentario)Persists a delivery or collection note linked to a rental
obtenerComentarios(Integer)Returns all comments for a given rental ID

Employee Assignment

When an admin changes a rental state to En reparto or En recoleccion, RentaBeanUI.onEstadoChange() opens the employee assignment dialog and populates listaEmpleados from EmpleadoHelper.getAllEmpleados(). The admin selects one entry; idEmpleadoSeleccionado is resolved to an Empleado entity and written to Renta.idEmpleado via asignarEmpleadoYActualizarEstado(). The employee’s name is later captured in entregado or recogido when the terminal state (Entregado / Finalizada) is reached. Employees have a filtered view: EmpleadoRentaBeanUI calls obtenerRentasDisponiblesYAsignadas(idEmpleado) so employees only see rentals that are unassigned or currently assigned to them.

Delivery and Collection Comments

The Comentario entity stores free-text notes attached to a rental with a tipo field ("Entrega" or "Recoleccion"). Comments are entered via a dialog triggered when the state advances to Entregado or Finalizada. They are viewable from the rental detail screen by both admins and employees via cargarComentariosRenta().
RentaBeanUI sets minDate = LocalDate.now() at construction time, which is bound to all date-picker components in the rental edit dialogs. Administrators cannot reschedule a rental to a past date through the UI. The same minimum is enforced by ArticuloCatalogoBeanUI.onFechaCambio() on the client side, which validates that both fechaInicio and fechaSeleccionada are on or after today before loading stock.

Build docs developers (and LLMs) love