Credit notes in MultiSas are issued to correct or adjust previously generated invoices. A credit note references a specific sale, production order, and client, and records the adjustment amount and reason. When created, the document embeds a snapshot of the company, client, production order, and original sale — giving the note full audit context without depending on the referenced documents remaining unchanged.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/MultiSas/llms.txt
Use this file to discover all available pages before exploring further.
This endpoint requires three levels of authorization beyond a valid JWT:
Tokenmiddleware — the JWT must be a Company token (obtained viaPOST /api/user/login-company).TokenAnyis not used here.TokenAuthorize('Admin', 'Super Admin')— the caller’s role must beAdminorSuper Admin.TokenValidationPlan('Plan Basico')— the middleware callsplan.features['Plan Basico']to determine allowed plans. If this check fails, the server responds immediately with{"msj": "Tu plan no permite usar esta funcion", "status": false}.
POST /api/notes/credit/:company_id/:sale_id/:production_id/:client_id
Issues a credit note that adjusts a specific sale for a given client and production order. A sequential bill number is auto-generated using thegenerate_bill_credit helper, and today’s date is stamped automatically onto the date_credit_note field.
Auth: Token + TokenAuthorize('Admin', 'Super Admin') + TokenValidationPlan('Plan Basico')
Path Parameters
MongoDB ObjectId of the company issuing the credit note. The company must exist or the request is rejected with
404 Empresa no encontrada.MongoDB ObjectId of the sale being adjusted. Must reference an existing sale document.
MongoDB ObjectId of the production order associated with the sale. Must reference an existing production document.
MongoDB ObjectId of the client who was originally invoiced. Must reference an existing client document.
Body Parameters
A plain-text explanation for the credit note (e.g.
"Producto defectuoso devuelto", "Error en precio facturado"). Cannot be empty.The adjustment amount as a string (e.g.
"150000"). Stored as a string to preserve formatting consistency with other financial fields in the schema. Cannot be empty.Example Request
Response
Returns the persisted credit note document with all embedded snapshots.Response Fields
Confirmation message:
"Nota credito creada exitosamente".true on success.The full persisted
CreditNote document.Plan Validation
The route callsTokenValidationPlan('Plan Basico'). Inside that middleware, plan.features['Plan Basico'] is looked up in the platform’s plan.json configuration. The plan.json file defines feature keys (facturacion, inventario_basico, etc.) but does not define a key named 'Plan Basico'. As a result allowedPlans is undefined and the middleware always rejects the request before the controller runs:
Debit Notes
TheDebitNote model (debit_note collection) exists in the codebase as the structural counterpart to CreditNote. It is imported in notesController.js and shares an identical schema layout:
| Field | Type | Description |
|---|---|---|
bill_number | String | Auto-generated sequential debit note number |
date_debit_note | String | Date the debit note was issued (set automatically) |
reason | String | Plain-text reason for the debit adjustment (manual input) |
total | String | Adjustment amount as a string (manual input) |
company | Object | Snapshot: _id, name_company, name_founder, nit_company |
client | Object | Snapshot: _id, document_type_client, number_document_client, name_client, emial_client, phone_client |
production | Object | Snapshot: _id, bill_number, price_production, type_production, quantity_production |
sale | Object | Snapshot: _id, bill_number, date_sale, quantity, state, price, sub_total, total |
As of the current codebase, no HTTP route for debit note creation is registered in
notesRoutes.js. The DebitNote model is imported in the controller but its creation handler has not yet been wired to an endpoint. Do not attempt to call a debit note endpoint — no such route exists. The data model is in place for future use.Error Responses
| Status | Body | Cause |
|---|---|---|
401 | {"msj": "Sin autorizacion", "status": false} | No token provided in the request |
403 | {"msj": "Sesion finalizada", "status": false} | The JWT has expired |
403 | {"msj": "No tienes permisos", "status": false} | Caller role is not Admin or Super Admin |
403 | {"msj": "Tu plan no permite usar esta funcion", "status": false} | TokenValidationPlan('Plan Basico') check failed (see Plan Validation above) |
403 | {"msj": "Completa todos los campos", "status": false} | reason or total is missing from the request body |
404 | {"msj": "Empresa no encontrada", "status": false} | No company matches the given company_id |
404 | {"msj": "Venta no encontrada", "status": false} | No sale matches the given sale_id |
404 | {"msj": "Produccion no encontrada", "status": false} | No production order matches the given production_id |
404 | {"msj": "Cliente no encontrado", "status": false} | No client matches the given client_id |
500 | Mongoose/Node error object | Unexpected server-side error |