import { FactoryData } from "../../data/FactoryData"; import { Article } from "../../shared/entity/Article"; import { Client } from "../../shared/entity/Client"; import { Order } from "../../shared/entity/Order"; import { OrderDetail } from "../../shared/entity/OrderDetail"; import { User } from "../../shared/entity/User"; import { LogicException } from "../../shared/exceptions/logicexception"; import { ILOrder } from "../interfaces/ILOrder"; import { LArticle } from "./LArticle"; import { LUser } from "./LUser"; export class LOrder implements ILOrder { private static instancia: LOrder; private constructor() { } public static getInstance(): LOrder { if (!LOrder.instancia) { LOrder.instancia = new LOrder(); } return LOrder.instancia; } private _order: Order; public get order(): Order { return this._order; } public set order(value: Order) { this._order = value; } //*********************************** */ //VALIDATIONS private validateBarCode(barcode: string) { if (barcode.trim() === "") { throw new LogicException("The barcode cannot be empty"); } } private validateregisterItemonOrder(barcode: string,quantity:number,dataorder:Order) { this.validateBarCode(barcode) if (quantity<1) { throw new LogicException("The quantity must be greater than 0"); } if (dataorder==null) { throw new LogicException("The Order is null"); } } private validateState(state: string) { if (state!="Pending") { throw new LogicException("The state must be 'Pending'"); } } private validateArticle(article:Article) { if (article==null) { throw new LogicException("That Article does not exists in the system"); } } private validateClient(client: Client) { if (client==null) { throw new LogicException("That Client does not exists in the system"); } } private validateStockQuantity(article:Article,quantity:number) { if (article.stock