Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ChrisCore1/inventario_sud/llms.txt

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

The loans (préstamos) module lets you record when a fixed asset leaves your facility in someone else’s care. Each loan entry tracks the asset, how many units were taken, who authorized the loan, the external recipient, and the expected return date. Registering a loan automatically updates the asset’s availability status so the rest of the inventory reflects the correct state.

Loan fields

Each record in the Movimiento_Prestamos table stores the following fields:
FieldTypeDescription
id_articulointegerThe asset being loaned (FK to Articulo)
cantidad_prestadaintegerNumber of units being loaned out (default: 1)
autorizado_porvarchar(100)Name of the person who authorized the loan
destinovarchar(150)Destination or purpose of the loan
fecha_iniciotimestampDate the loan starts
fecha_retornotimestampExpected return date
responsable_externovarchar(100)Name of the external person responsible for the asset
id_usuariointegerThe logged-in user who registered the loan (FK to Usuario)
The full server action input type is:
export type RegisterLoanInput = {
  id_articulo: number;
  cantidad_prestada: number;
  autorizado_por: string;
  destino: string;
  fecha_inicio: Date;
  fecha_retorno: Date;
  responsable_externo: string;
  id_usuario: number;
};
cantidad_prestada cannot exceed the asset’s recorded cantidad. If you attempt to loan more units than are registered, the registrarPrestamo action returns an error and the loan is not saved.

Register a new loan

1

Open the loans page

Navigate to Préstamos from the sidebar. The table lists all active (non-deleted) loan records.
2

Click Register

Click Registrar préstamo to open RegisterLoanModal. The asset selector only shows assets whose estado_disponibilidad is "Disponible".
3

Select the asset

Choose the asset from the dropdown. The list is pre-filtered to available assets only.
4

Fill in loan details

Enter the quantity being loaned, the authorizing person, the destination, the external responsible person, the loan start date, and the expected return date.
5

Submit the form

Click Guardar. The registrarPrestamo server action:
  1. Validates that cantidad_prestada does not exceed the asset’s cantidad.
  2. Inserts a new row into Movimiento_Prestamos.
  3. Sets the asset’s estado_disponibilidad to "Prestado".
  4. Logs the action to the audit trail.

Close or cancel a loan

When an asset is returned or a loan is cancelled, use the delete/close action on the loan row. The eliminarPrestamo server action:
  1. Sets is_deleted = true on the Movimiento_Prestamos record (soft-delete).
  2. Sets the associated asset’s estado_disponibilidad back to "Disponible".
  3. Logs the closure to the audit trail.
  4. Revalidates both /prestamos and /activos so both pages reflect the updated state immediately.
The loan record is preserved in the database for audit purposes even after it is closed.

Build docs developers (and LLMs) love