Customer & Vendor Management
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Customer & Vendor Management module is a core component of the Outmanage outbound logistics system. It serves as the primary registry for business entities that interact with the warehouse, specifically focusing on Customers (buyers/receivers of goods) and Vendors (third-party entities involved in weighing or logistics). This module ensures that all shipments, delivery orders, and weighing operations are correctly associated with valid business profiles.
The system tracks these entities through unique identifiers, legacy system IDs (id_sl), and physical addresses. Beyond simple CRUD operations, the module integrates with an audit logging system to track all administrative changes and provides data for complex reporting, such as daily output and operational summaries.
Sources: CLAUDE.md:21-25, prisma/schema.prisma:186-200
Architecture and Data Models
Core Customer Entity
The Customer model is defined in the database schema as a central node for DeliveryOrder and CustomerLog relationships. Every customer in the system can be linked to multiple orders, which in turn contain specific product items.
The diagram shows the relationship between customers, their orders, and the audit logs that track their history.
Sources: prisma/schema.prisma:186-218
Key Data Structures
| Field | Type | Description | Constraints |
|---|---|---|---|
id | UUID | Unique internal identifier | Primary Key |
name | String | Legal or trade name of the entity | Unique |
id_sl | String | Legacy System ID for cross-platform mapping | Unique, Nullable |
address | String | Physical location for deliveries | Max 500 chars |
createdAt | DateTime | Timestamp of registration | Default: Now |
Sources: prisma/schema.prisma:186-195, comprehensive-swagger-api.json:344-360
Business Logic and Services
Customer Service Operations
The customerService.ts file handles the core database interactions using Prisma transactions. This ensures that when a customer is created or deleted, associated logs are handled atomically.
- Pagination and Search: Supports filtered retrieval by
name,id_sl, oraddresswith standard (1-based) pagination. - Timezone Management: All operations explicitly set the timezone to
Asia/Jakarta(UTC+7) before database insertion. - Soft vs. Hard Deletion: While the system supports soft deletes for users, customers undergo a hard delete in the database, but their logs are preserved by setting the
customerIdtonullinCustomerLogrecords.
Sources: src/services/customerService.ts:15-32, src/services/customerService.ts:88-95, src/services/customerService.ts:162-185
Weighing and Vendor Integration
While "Vendors" are primarily managed through the WEIGHING_METHOD enumeration, the system distinguishes between manual weighing and vendor-assisted weighing.
This flow illustrates how different weighing methods (including vendor-based) lead to the same record-keeping process.
Sources: prisma/schema.prisma:418-421, prisma/schema.prisma:484-487
API Implementation
Endpoint Overview
The system provides a RESTful API for customer management, secured via the custom x-outmanage-token header.
| Method | Endpoint | Description |
|---|---|---|
GET | /api/customers | List all customers with pagination |
POST | /api/customers | Create a new customer profile |
GET | /api/customers/{id} | Retrieve specific customer details |
PUT | /api/customers/{id} | Update customer name, address, or ID SL |
DELETE | /api/customers/{id} | Hard delete customer (preserves logs) |
Sources: comprehensive-swagger-api.json:711-850, outmanage_api_tests.postman_collection.json:1095-1250
Logic Flow for Customer Modification
Audit Logging and Reporting
Change Tracking
Every customer modification is captured by the CustomerLog entity. This includes:
- Action: CREATE, UPDATE, or DELETE.
- Snapshotting: The system stores
oldDataandnewDataas JSON blobs, allowing for granular diff tracking. - Attribution: Every log identifies the
performedById(the User who made the change).
Sources: prisma/schema.prisma:201-218, src/services/customerService.ts:133-145
Operational Reporting
Customer data is aggregated in the reportController to generate output reports. Reports can be grouped by customer to show total weight processed and volume of delivery orders over daily, monthly, or yearly periods.
Sources: src/controllers/reportController.ts:88-105, comprehensive-swagger-api.json:1200-1230
Conclusion
Customer and Vendor Management in Outmanage provides a robust foundation for logistics tracking. By enforcing strict unique identifiers and maintaining a comprehensive audit trail, the system ensures data integrity throughout the lifecycle of a delivery order—from initial customer registration to final weighing and reporting.