Every donation in Banco Alimentos follows a well-defined path through the system. ADocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alvarezlautaro/BancoAlimentos/llms.txt
Use this file to discover all available pages before exploring further.
Donante submits a Donacion, line items are attached as ItemDonacion records, the donation is confirmed, an invoice is generated, and goods are eventually dispatched to a beneficiary Institucion through a Remito with DetalleRemito lines. This page walks through each stage in detail.
State machine
ADonacion is always in one of three states, stored in the estado field as an EstadoDonacion enum value.
| State | Meaning | How to reach it |
|---|---|---|
PENDIENTE | Donation recorded but not yet verified | Automatically set on POST /api/donaciones |
CONFIRMADA | Donation approved; invoice generation is now possible | PUT /api/donaciones/{id}/confirmar |
CANCELADA | Donation soft-cancelled | Set estado to CANCELADA via PUT /api/donaciones/{id} |
The
confirmarDonacion service method sets estado directly to CONFIRMADA without pre-checking the current state. Confirm a donation only when all ItemDonacion line items are correct, because the attached Factura is generated from the current item set.The happy path
Register the donor
Ensure the contributing organisation exists in the system. Create one with
POST /api/donantes if needed, supplying razonSocial, cuit, telefono, email, and direccion. Note the returned numeric id — you will need it in the next step.Submit the donation
Create the
Donacion by posting to POST /api/donaciones. The request must include the donor’s id, the donation date, the supplier remito number (nroRemitoProveedor), and the initial list of ItemDonacion line items. The estado field should be set to PENDIENTE.When this request is processed, the service also automatically creates a Factura of type C and associates it with the new donation.Review and adjust line items
Additional
ItemDonacion records can be added or modified before the donation is confirmed. Each item links to a specific Producto in the catalogue and captures:cantidad— number of units being donatedvalorUnitario— unit monetary value at the time of donationfechaVencimiento— product expiry dateproductoId— foreign key into theproductoscatalogue
ItemDonacion is mapped with CascadeType.ALL and orphanRemoval = true, removing an item from the list and updating the donation will delete that row from the database.Confirm the donation
Once the item list is correct, confirm the donation. This transitions The response returns the updated
estado from PENDIENTE to CONFIRMADA.DonacionResponseDTO with estado: "CONFIRMADA". No request body is required.Create a remito for outbound distribution
When goods from the donation are to be distributed to a beneficiary institution, create a The Remito receives its own auto-generated UUID
Remito referencing the target Institucion (identified by its UUID externalId).externalId upon creation.Add DetalleRemito line items
For each A single
ItemDonacion being dispatched in this Remito, create a DetalleRemito record. Each line captures the Remito, the ItemDonacion being dispatched, and the cantidad (number of units being sent out in this specific shipment).ItemDonacion can appear across multiple DetalleRemito records (across different remitos), allowing partial dispatches of a donated lot.Key field notes
nroRemitoProveedor
ThenroRemitoProveedor field on Donacion stores the supplier’s own remito reference number. It is a plain int used to cross-reference the donation against the donor’s internal dispatch documentation. It is distinct from the system-generated Remito entity, which models the food bank’s outbound dispatch.
ItemDonacion as the central join entity
ItemDonacion is the pivot of the entire model. On the inbound side it belongs to a Donacion; on the outbound side it is referenced by DetalleRemito. This means a single donated product lot (one ItemDonacion) can be partially distributed to multiple institutions across multiple Remito records, each DetalleRemito specifying the portion dispatched.
Factura creation behaviour
Two independent paths create aFactura, and each donation can have at most one (enforced by a unique constraint on id_donacion):
- Automatic (type C):
DonacionService.save()always creates aFacturawithtipo = Cimmediately after persisting theDonacion. This is the standard path for every new donation submitted viaPOST /api/donaciones. - Explicit (type A):
FacturaService.generarFactura()creates aFacturawithtipo = Aon demand viaPOST /api/facturas/generar/{idDonacion}. Because a type-C invoice is always created automatically on save, this endpoint will throw aReglaNegocioExceptionif called for a donation that was submitted through the normal flow. It is intended for cases where a donation was persisted without the automatic invoice creation (for example, via the directPOST /api/facturasendpoint with a different type).