Supplier module - #342
Merged
Merged
Conversation
|
@shamoo53 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
yusuftomilola
approved these changes
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description: Implement Supplier Module with CRUD APIs
Context
Companies rely on suppliers to provide assets. Currently, our system has no structured way to store or manage supplier information. This PR introduces a Supplier module that allows the system to store supplier details, manage their lifecycle, and link assets to suppliers for traceability.
Implementation Details
Database
Created suppliers table with the following fields:
id (primary key, auto-generated)
name (string, required)
contactInfo (string, optional)
address (string, optional)
email (string, unique, required)
phone (string, optional)
createdAt & updatedAt timestamps
Entities & DTOs
Defined Supplier entity in entities/supplier.entity.ts.
Created DTOs for CreateSupplierDto and UpdateSupplierDto with validation rules (e.g., IsEmail, IsNotEmpty, etc.).
Services & Controllers
Added SupplierService with methods:
createSupplier(dto)
getAllSuppliers()
getSupplierById(id)
updateSupplier(id, dto)
deleteSupplier(id)
Added SupplierController with REST endpoints:
POST /suppliers → create supplier
GET /suppliers → list all suppliers
GET /suppliers/:id → get supplier by ID
PUT /suppliers/:id → update supplier
DELETE /suppliers/:id → delete supplier
Asset Linking
Established relationship: One Supplier → Many Assets.
Updated Asset entity to include supplierId foreign key reference.
Enabled fetching suppliers along with their associated assets.
Documentation
Updated Swagger/OpenAPI to document all supplier endpoints.
Added API usage examples.
Acceptance Criteria
Suppliers can be created, read, updated, and deleted through API endpoints.
Each supplier record must contain a name and email.
Suppliers can be linked to assets via foreign key.
Running migrations should generate a suppliers table in the database.
Test Plan
Unit Tests
Entity Validation
Ensure DTOs reject invalid emails and missing required fields.
Service Logic
Test createSupplier stores data correctly.
Test updateSupplier applies changes.
Test deleteSupplier removes entry.
Relationship
Verify assets can be queried by supplier ID.
Integration Tests
POST /suppliers
Should create a supplier and return 201 + new supplier object.
GET /suppliers
Should return a paginated list of suppliers.
GET /suppliers/:id
Should return supplier details including linked assets.
PUT /suppliers/:id
Should update supplier info and return updated record.
DELETE /suppliers/:id
Should delete supplier and return confirmation.
Manual Validation
Run migration → confirm suppliers table created.
Seed a few suppliers and link them to assets.
Use Swagger or Postman to test endpoints.
✅ With this PR, the system can now manage supplier records and link them to assets, laying the foundation for supply-chain visibility.
Close #323