- Introduced new columns `address`, `latitude`, and `longitude` in the `sales_invoices` table to store location details. - Updated the `SalesInvoicesService` to handle the new fields, including validation for address format and geographical coordinates. - Enhanced the `SalesInvoiceDto` and related data transfer objects to include the new fields for API requests and responses. - Added unit and e2e tests to ensure proper handling of the new fields and validate their integration within the sales invoice workflow. - Created a new migration script to apply the database schema changes for the sales invoices.
113 lines
3.4 KiB
TypeScript
113 lines
3.4 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 SalesInvoiceLine = {
|
|
readonly id: string;
|
|
readonly productId: string;
|
|
readonly product: DefaultRelation | null;
|
|
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 address: string;
|
|
readonly latitude: number | null;
|
|
readonly longitude: number | null;
|
|
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;
|
|
readonly salesOrder: CodeRelation | null;
|
|
readonly packingSlip: 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 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 address: string;
|
|
readonly latitude?: number | null;
|
|
readonly longitude?: number | null;
|
|
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 address?: string;
|
|
readonly latitude?: number | null;
|
|
readonly longitude?: number | null;
|
|
readonly notes?: string | null;
|
|
readonly products?: readonly SalesInvoiceLineInput[];
|
|
readonly userId: string;
|
|
};
|
|
|
|
export type ListSalesInvoicesFilters = {
|
|
readonly code?: string;
|
|
readonly status?: string;
|
|
readonly customerId?: string;
|
|
readonly customerIds?: readonly string[];
|
|
readonly salesPersonId?: string;
|
|
readonly branchId?: string;
|
|
readonly divisionId?: string;
|
|
readonly salesOrderId?: string;
|
|
readonly packingSlipId?: string;
|
|
readonly search?: string;
|
|
readonly payable?: boolean;
|
|
readonly orderBy?: string;
|
|
readonly orderType?: string;
|
|
readonly limit: number;
|
|
readonly offset: number;
|
|
};
|