Skip to main content

POST /api/quotation/register/quotation

Creates a new quotation in the system with complete pricing breakdown, sections, and itemized construction details. All required fields are validated before storage.

Headers

Content-Type
string
required
Must be application/json

Request Body

factory
string
required
Factory or construction site name/identifier.
fix
string
required
Fix or property identifier associated with the quotation.
description_quotation
string
required
General description of the entire quotation.
subtotal
number
required
Subtotal amount before taxes and additional costs.
unexpected
number
required
Unexpected costs or contingency amount.
iva
number
required
IVA (Value Added Tax) amount to be applied.
administratitive
number
required
Administrative costs.
utility
number
required
Utility or profit margin amount.
total_price
number
required
Total price including all costs, taxes, and additional charges.
sections
array
required
Array of construction sections. Each section contains description, price, and items.
sections[].description_sections
string
required
Description of the construction section.
sections[].section_price
number
required
Total price for this section.
sections[].items
array
required
Array of construction items within the section.
sections[].items[].item_name
string
required
Name of the construction item.
sections[].items[].item_description
string
required
Detailed description of the item.
sections[].items[].item_total
number
required
Total cost for this item (typically quantity × unit value).
sections[].items[].quantity
number
required
Quantity of items needed.
sections[].items[].unity
string
required
Unit of measurement (e.g., “m2”, “units”, “kg”, “m3”).
sections[].items[].item_value
number
required
Unit value/price per individual item.

Request Example

curl -X POST http://localhost:3000/api/quotation/register/quotation \
  -H "Content-Type: application/json" \
  -d '{
    "factory": "Construction Site A",
    "fix": "Building 1",
    "description_quotation": "Complete construction quotation for residential building",
    "subtotal": 50000000,
    "unexpected": 2500000,
    "iva": 9500000,
    "administratitive": 3000000,
    "utility": 5000000,
    "total_price": 70000000,
    "sections": [
      {
        "description_sections": "Foundation and Structure",
        "section_price": 25000000,
        "items": [
          {
            "item_name": "Concrete",
            "item_description": "High-strength concrete for foundation",
            "item_total": 15000000,
            "quantity": 100,
            "unity": "m3",
            "item_value": 150000
          },
          {
            "item_name": "Steel Rebar",
            "item_description": "Reinforcement steel bars",
            "item_total": 10000000,
            "quantity": 5000,
            "unity": "kg",
            "item_value": 2000
          }
        ]
      },
      {
        "description_sections": "Walls and Finishes",
        "section_price": 25000000,
        "items": [
          {
            "item_name": "Brick",
            "item_description": "Standard construction brick",
            "item_total": 12000000,
            "quantity": 20000,
            "unity": "units",
            "item_value": 600
          }
        ]
      }
    ]
  }'

Response

message
string
Success message confirming quotation storage.
quotation
object
The newly created quotation object including MongoDB generated ID.
quotation._id
string
MongoDB generated quotation ID.
quotation.factory
string
Factory or construction site name.
quotation.fix
string
Fix or property identifier.
quotation.description_quotation
string
General description of the quotation.
quotation.subtotal
number
Subtotal amount.
quotation.unexpected
number
Unexpected costs.
quotation.iva
number
IVA amount.
quotation.administratitive
number
Administrative costs.
quotation.utility
number
Utility amount.
quotation.total_price
number
Total price.
quotation.sections
array
Array of sections with items.
Example Response
{
  "message": "Cotización almacenada correctamente",
  "quotation": {
    "_id": "507f1f77bcf86cd799439011",
    "factory": "Construction Site A",
    "fix": "Building 1",
    "description_quotation": "Complete construction quotation for residential building",
    "subtotal": 50000000,
    "unexpected": 2500000,
    "iva": 9500000,
    "administratitive": 3000000,
    "utility": 5000000,
    "total_price": 70000000,
    "sections": [
      {
        "description_sections": "Foundation and Structure",
        "section_price": 25000000,
        "items": [
          {
            "item_name": "Concrete",
            "item_description": "High-strength concrete for foundation",
            "item_total": 15000000,
            "quantity": 100,
            "unity": "m3",
            "item_value": 150000
          },
          {
            "item_name": "Steel Rebar",
            "item_description": "Reinforcement steel bars",
            "item_total": 10000000,
            "quantity": 5000,
            "unity": "kg",
            "item_value": 2000
          }
        ]
      },
      {
        "description_sections": "Walls and Finishes",
        "section_price": 25000000,
        "items": [
          {
            "item_name": "Brick",
            "item_description": "Standard construction brick",
            "item_total": 12000000,
            "quantity": 20000,
            "unity": "units",
            "item_value": 600
          }
        ]
      }
    ]
  }
}
Returned when the request body is missing required fields or has invalid format.
error
string
Error message describing the validation failure.
Invalid JSON Format
{
  "error": "Formato de JSON inválido"
}
This error is returned when any of the following conditions are not met:
  • factory field is missing or empty
  • fix field is missing or empty
  • description_quotation field is missing or empty
  • subtotal is undefined
  • unexpected is undefined
  • iva is undefined
  • administratitive is undefined
  • utility is undefined
  • total_price is undefined
  • sections is not an array or is missing
Returned when an unexpected server error occurs during quotation storage.
message
string
Error message.
error
object
Error details object.
Example Response
{
  "message": "Error al almacenar la cotización",
  "error": {}
}

Validation Rules

The endpoint performs strict validation on the request body:
  1. Required String Fields: factory, fix, description_quotation must be present and non-empty
  2. Required Number Fields: All pricing fields must be defined (can be 0, but not undefined):
    • subtotal
    • unexpected
    • iva
    • administratitive
    • utility
    • total_price
  3. Sections Array: Must be a valid array (can be empty, but must be an array)
  4. Section Structure: Each section must contain:
    • description_sections (string, required)
    • section_price (number, required)
    • items (array, required)
  5. Item Structure: Each item must contain:
    • item_name (string, required)
    • item_description (string, required)
    • item_total (number, required)
    • quantity (number, required)
    • unity (string, required)
    • item_value (number, required)

Pricing Structure

The quotation follows this pricing hierarchy:
Subtotal (sum of all section prices)
+ Unexpected costs
+ Administrative costs
+ Utility/Profit margin
+ IVA (tax)
= Total Price
Each section contains multiple items, where:
Item Total = Quantity × Item Value
Section Price = Sum of all item totals in that section

Implementation Reference

The create quotation endpoint is implemented in:
  • Route: /home/daytona/workspace/source/src/routes/quotationRoutes.js:9
  • Controller: /home/daytona/workspace/source/src/controllers/quotationController.js:14

Build docs developers (and LLMs) love