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:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user