supplierOrders Collection (RF07) #151

Closed
opened 2025-12-04 17:39:43 +00:00 by GFMpt13 · 1 comment
GFMpt13 commented 2025-12-04 17:39:43 +00:00 (Migrated from github.com)

This task involves designing and implementing the supplierOrders collection in MongoDB.

This collection will serve a dual purpose:

  1. Work Order Parts: Ordering specific parts for a vehicle repair (linked to workOrder).
  2. Internal Supplies: Ordering general workshop materials (gloves, tools, cleaning supplies) which are not linked to a specific customer job.

Consequently, the workOrderId field will become optional.

Tasks

  • 1. Define Schema:

    • supplierName (String, Required): The vendor name.
    • description (String, Required): A summary of what was ordered (e.g., "5W-30 Oil & Filters" or "Safety Equipment Restock").
    • status (String, Required): Enum: Pending, Ordered, Shipped, Received, Cancelled.
    • workOrderId (ObjectId, Optional, Ref: workOrders): Only present if the order is for a specific repair job.
    • createdById (String/UUID, Required): The user placing the order.
    • createdAt, updatedAt: Standard timestamps.
  • 2. Define Schema Validation:

    • Implement JSON Schema validation in the setup script.
    • Ensure workOrderId is allowed to be null or missing (not in the required list).
    • Ensure status only accepts the defined enum values.
  • 3. Define Indexes:

    • db.supplierOrders.createIndex({ workOrderId: 1 }): To find orders linked to a job (Sparse/Partial index recommended since many will be null).
    • db.supplierOrders.createIndex({ status: 1 }): For dashboard filtering.
    • db.supplierOrders.createIndex({ createdAt: -1 }): To show the most recent orders first.
  • 4. Update Artefacts:

    • Add the creation script to database-mongodb-setup.js.
    • Update docs/database_architecture.md with the new collection definition.
This task involves designing and implementing the `supplierOrders` collection in MongoDB. This collection will serve a dual purpose: 1. **Work Order Parts:** Ordering specific parts for a vehicle repair (linked to `workOrder`). 2. **Internal Supplies:** Ordering general workshop materials (gloves, tools, cleaning supplies) which are not linked to a specific customer job. Consequently, the `workOrderId` field will become **optional**. ### Tasks - [x] 1. **Define Schema:** - [x] `supplierName` (String, Required): The vendor name. - [x] `description` (String, Required): A summary of what was ordered (e.g., "5W-30 Oil & Filters" or "Safety Equipment Restock"). - [x] `status` (String, Required): Enum: `Pending`, `Ordered`, `Shipped`, `Received`, `Cancelled`. - [x] `workOrderId` (ObjectId, **Optional**, Ref: `workOrders`): Only present if the order is for a specific repair job. - [x] `createdById` (String/UUID, Required): The user placing the order. - [x] `createdAt`, `updatedAt`: Standard timestamps. - [x] 2. **Define Schema Validation:** - [x] Implement JSON Schema validation in the setup script. - [x] Ensure `workOrderId` is allowed to be `null` or missing (not in the required list). - [x] Ensure `status` only accepts the defined enum values. - [x] 3. **Define Indexes:** - [x] `db.supplierOrders.createIndex({ workOrderId: 1 })`: To find orders linked to a job (Sparse/Partial index recommended since many will be null). - [x] `db.supplierOrders.createIndex({ status: 1 })`: For dashboard filtering. - [x] `db.supplierOrders.createIndex({ createdAt: -1 })`: To show the most recent orders first. - [ ] 4. **Update Artefacts:** - [x] Add the creation script to `database-mongodb-setup.js`. - [x] Update `docs/database_architecture.md` with the new collection definition.
AndreFerreira5 commented 2026-01-22 23:19:07 +00:00 (Migrated from github.com)

this issue has already been integrated in the maion branch, closing...

this issue has already been integrated in the maion branch, closing...
Sign in to join this conversation.
No description provided.