Add products and sales management modules with database schema and validation

- Introduced `ProductsModule` to manage product data, including read and write controllers.
- Created database migrations for the `products`, `sales_requests`, `sales_orders`, `sales_invoices`, and related tables, including constraints and unique indexes.
- Implemented validation for product fields such as code, name, unit, and brand with corresponding utility functions.
- Developed service and repository layers for handling product and sales data operations.
- Added unit tests for the products and sales services, repositories, and controllers to ensure functionality and correctness.
- Updated application module to include the new `ProductsModule` and related sales modules for better organization.
This commit is contained in:
shancheas
2026-08-25 09:54:16 +07:00
parent ddbe8a9ef8
commit 34d4f2c120
82 changed files with 12609 additions and 2 deletions
@@ -0,0 +1,85 @@
import { DateTime } from '../../../common/value-objects/date-time/date-time';
import { Decimal } from '../../../common/value-objects/decimal/decimal';
import { Status } from '../../../common/value-objects/status/status';
export type SalesInvoiceLine = {
readonly id: string;
readonly productId: string;
readonly quantity: Decimal;
readonly price: Decimal;
};
export type SalesInvoice = {
readonly id: string;
readonly code: string;
readonly salesOrderId: string | null;
readonly salesOrderCode: string | null;
readonly packingSlipId: string | null;
readonly packingSlipCode: string | null;
readonly date: DateTime;
readonly salesPersonId: string;
readonly branchId: string;
readonly divisionId: string;
readonly customerId: string;
readonly notes: string | null;
readonly balance: Decimal;
readonly products: readonly SalesInvoiceLine[];
readonly status: Status;
readonly createdAt: DateTime;
readonly updatedAt: DateTime;
readonly createdBy: string;
readonly updatedBy: string;
};
export type SalesInvoiceLineInput = {
readonly productId: string;
readonly quantity: Decimal;
readonly price: Decimal;
};
export type CreateSalesInvoiceInput = {
readonly code?: string;
readonly salesOrderId?: string | null;
readonly salesOrderCode?: string | null;
readonly packingSlipId?: string | null;
readonly packingSlipCode?: string | null;
readonly date: DateTime;
readonly salesPersonId: string;
readonly branchId: string;
readonly divisionId: string;
readonly customerId: string;
readonly notes?: string | null;
readonly products: readonly SalesInvoiceLineInput[];
readonly status?: Status;
readonly userId: string;
};
export type UpdateSalesInvoiceInput = {
readonly code?: string;
readonly salesOrderId?: string | null;
readonly salesOrderCode?: string | null;
readonly packingSlipId?: string | null;
readonly packingSlipCode?: string | null;
readonly date?: DateTime;
readonly salesPersonId?: string;
readonly branchId?: string;
readonly divisionId?: string;
readonly customerId?: string;
readonly notes?: string | null;
readonly products?: readonly SalesInvoiceLineInput[];
readonly userId: string;
};
export type ListSalesInvoicesFilters = {
readonly code?: string;
readonly status?: string;
readonly customerId?: string;
readonly salesPersonId?: string;
readonly branchId?: string;
readonly divisionId?: string;
readonly salesOrderId?: string;
readonly packingSlipId?: string;
readonly search?: string;
readonly limit: number;
readonly offset: number;
};