The receipt service is the final step in the MRP fulfillment cycle. Once materials leave the principal warehouse via a dispatch, a receipt confirms their physical arrival at the obra (work-site) warehouse. Creating a receipt increments the obra’s inventory stock for each dispatched material, writes aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElthonJohan/Sistema-MRP/llms.txt
Use this file to discover all available pages before exploring further.
Movement(type="IN", reference_type="receipt") entry, and timestamps everything in Lima time (UTC−5, no daylight saving). Duplicate receipts for the same dispatch are rejected.
create_receipt
- Calls
get_or_create_inventoryon the obra warehouse, scoping the record to the requirement’sbudget_idwhen present. - Adds the dispatched quantity to
inventory.stock. - Inserts a
ReceiptItem(confirmed=True). - Inserts a
Movement(type="IN", reference_type="receipt").
db.commit() at the end.
Timestamp behavior: The Receipt.receipt_date and movement timestamps use Lima local time (datetime.now(UTC-5)). The timezone offset is applied in the helper _now_lima() and the tzinfo is stripped before storage so the value is stored as a naive datetime in Lima wall-clock time.
Active SQLAlchemy session. The caller opens and closes the session; this function commits internally.
ID of the dispatch being confirmed as received.
ID of the user confirming receipt. Recorded on both the
Receipt record and each Movement entry.True when the receipt was created successfully.On success:
"Recepción registrada correctamente". On failure: one of:"Despacho no existe"—dispatch_idnot found."Este despacho ya fue recibido"— a receipt already exists for this dispatch.
What gets written to the database
| Record | Action |
|---|---|
Receipt | Created with dispatch_id, receipt_date (Lima time), user_id |
ReceiptItem | One row per dispatch item with received_qty and confirmed=True |
Inventory (obra) | stock += dispatched_qty, scoped to the requirement’s project when budget_id is set |
Movement | type="IN", reference_type="receipt", warehouse_id=obra, Lima timestamp |
Project-scoped inventory at obra
When the originating requirement has abudget_id, the obra inventory is looked up and created as a project-scoped record (budget_id + budget_name). This mirrors the structure used in the principal warehouse and ensures cost tracking remains consistent per project at both ends of the supply chain.