Endpoint
src/controllers/quotationController.js:4.
Request
This endpoint does not require any parameters or request body.Headers
Response
Success Response (200 OK)
Returns an array of all quotation objects with their complete nested structure.Empty Response
If no quotations exist in the database, an empty array is returned:Error Response (500 Internal Server Error)
Implementation Details
The controller uses Mongoose’sfind() method without any filters at src/controllers/quotationController.js:6:
This endpoint returns ALL quotations in the database without pagination or filtering. For large datasets, consider implementing pagination using the
mongoose-paginate-v2 plugin that’s already included in the model at src/models/quotation.js:36.Response Structure
Each quotation in the response array contains:Root Level Fields
Root Level Fields
| Field | Type | Description |
|---|---|---|
_id | String | MongoDB document ID (auto-generated) |
factory | String | Factory or project identifier |
fix | String | Fix reference number |
description_quotation | String | Overall quotation description |
subtotal | Number | Subtotal before additional costs |
unexpected | Number | Unexpected costs or contingency |
iva | Number | VAT/IVA tax amount |
administratitive | Number | Administrative costs |
utility | Number | Utility or profit margin |
total_price | Number | Final total price |
sections | Array | Array of section objects |
__v | Number | MongoDB version key |
Nested Section Fields
Nested Section Fields
Each section object contains:
| Field | Type | Description |
|---|---|---|
_id | String | Section ID (auto-generated) |
description_sections | String | Description of the section |
section_price | Number | Total price for this section |
items | Array | Array of item objects |
Nested Item Fields
Nested Item Fields
Each item object contains:
| Field | Type | Description |
|---|---|---|
_id | String | Item ID (auto-generated) |
item_name | String | Name of the item |
item_description | String | Detailed item description |
item_total | Number | Total cost for this item |
quantity | Number | Quantity of items |
unity | String | Unit of measurement |
item_value | Number | Unit price per item |
Usage Examples
JavaScript Fetch API
Using Axios
Using cURL
Using cURL with Pretty Print
Working with Response Data
Filtering Quotations by Factory
Calculating Total Value
Extracting All Items
Performance Considerations
The Quotation model includes
mongoose-paginate-v2 plugin. Consider implementing pagination for production use:Future Enhancements
Potential improvements to consider:Add field selection
Allow clients to specify which fields to return (e.g., exclude sections for list views)
Related Endpoints
Create Quotation
Learn how to create a new quotation
Quotations Overview
Understand the quotation data structure