- Updated pagination-response and read-write-controllers documentation to include `orderBy` and `orderType` parameters for sorting results. - Introduced new `order-clause` module to handle ordering logic, including validation for order types and columns. - Enhanced `PaginationQueryDto` to support ordering fields in API requests. - Updated various repository and service classes to implement ordering in database queries. - Added unit tests for new ordering functionality and ensured existing tests cover the updated behavior. - Refactored related DTOs to include user and code relations for better data representation in responses.
111 lines
3.2 KiB
TypeScript
111 lines
3.2 KiB
TypeScript
import type {
|
|
CodeRelation,
|
|
DefaultRelation,
|
|
UserRelation,
|
|
} from '../../../common/http/response';
|
|
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 SalesOrderLine = {
|
|
readonly id: string;
|
|
readonly productId: string;
|
|
readonly product: DefaultRelation | null;
|
|
readonly quantity: Decimal;
|
|
readonly price: Decimal;
|
|
};
|
|
|
|
export type SalesOrderImage = {
|
|
readonly id: string;
|
|
readonly url: string;
|
|
readonly description: string | null;
|
|
};
|
|
|
|
export type SalesOrder = {
|
|
readonly id: string;
|
|
readonly code: string;
|
|
readonly salesRequestId: string | null;
|
|
readonly date: DateTime;
|
|
readonly salesPersonId: string;
|
|
readonly branchId: string;
|
|
readonly divisionId: string;
|
|
readonly customerId: string;
|
|
readonly address: string;
|
|
readonly latitude: number | null;
|
|
readonly longitude: number | null;
|
|
readonly notes: string | null;
|
|
readonly products: readonly SalesOrderLine[];
|
|
readonly images: readonly SalesOrderImage[];
|
|
readonly status: Status;
|
|
readonly createdAt: DateTime;
|
|
readonly updatedAt: DateTime;
|
|
readonly createdBy: string;
|
|
readonly updatedBy: string;
|
|
readonly salesRequest: CodeRelation | null;
|
|
readonly salesPerson: DefaultRelation | null;
|
|
readonly branch: DefaultRelation | null;
|
|
readonly division: DefaultRelation | null;
|
|
readonly customer: DefaultRelation | null;
|
|
readonly createdByUser: UserRelation;
|
|
readonly updatedByUser: UserRelation;
|
|
};
|
|
|
|
export type SalesOrderLineInput = {
|
|
readonly productId: string;
|
|
readonly quantity: Decimal;
|
|
readonly price: Decimal;
|
|
};
|
|
|
|
export type SalesOrderImageInput = {
|
|
readonly url: string;
|
|
readonly description?: string | null;
|
|
};
|
|
|
|
export type CreateSalesOrderInput = {
|
|
readonly code?: string;
|
|
readonly salesRequestId?: string | null;
|
|
readonly date: DateTime;
|
|
readonly salesPersonId: string;
|
|
readonly branchId: string;
|
|
readonly divisionId: string;
|
|
readonly customerId: string;
|
|
readonly address: string;
|
|
readonly latitude?: number | null;
|
|
readonly longitude?: number | null;
|
|
readonly notes?: string | null;
|
|
readonly products: readonly SalesOrderLineInput[];
|
|
readonly images?: readonly SalesOrderImageInput[];
|
|
readonly status?: Status;
|
|
readonly userId: string;
|
|
};
|
|
|
|
export type UpdateSalesOrderInput = {
|
|
readonly code?: string;
|
|
readonly date?: DateTime;
|
|
readonly salesPersonId?: string;
|
|
readonly branchId?: string;
|
|
readonly divisionId?: string;
|
|
readonly customerId?: string;
|
|
readonly address?: string;
|
|
readonly latitude?: number | null;
|
|
readonly longitude?: number | null;
|
|
readonly notes?: string | null;
|
|
readonly products?: readonly SalesOrderLineInput[];
|
|
readonly images?: readonly SalesOrderImageInput[];
|
|
readonly userId: string;
|
|
};
|
|
|
|
export type ListSalesOrdersFilters = {
|
|
readonly code?: string;
|
|
readonly status?: string;
|
|
readonly customerId?: string;
|
|
readonly salesPersonId?: string;
|
|
readonly branchId?: string;
|
|
readonly divisionId?: string;
|
|
readonly search?: string;
|
|
readonly orderBy?: string;
|
|
readonly orderType?: string;
|
|
readonly limit: number;
|
|
readonly offset: number;
|
|
};
|