import { DineroObject } from 'dinero.js'; import { Bill, BillItem, BillItemRefer, BillSubItemRefer, VariantSelected } from '~core/modules/order/definitions'; import { Ref } from '@typegoose/typegoose'; import { OfflinePaymentType, Restaurant } from '~backend/business/business.model'; import { PaymentTransaction } from '~backend/payment/payment.interface'; import { PickupPoint } from '~backend/business/business.interface'; import { Effect } from '~core/modules/order/definitions'; import { CreditTransaction } from '~backend/marketing/credit/credit.interface'; import { Types } from 'mongoose'; import { DeliveryOption, DELIVERY_PROVIDER_TYPE, DELIVERY_STATUS } from './delivery/delivery.interface'; import { StockDeductable } from '~core/stockManager'; export * from './delivery/delivery.interface'; export declare enum PAYMENT_TYPE { cash = "cash", ePayment = "ePayment", credit = "credit", ePaymentSandbox = "ePaymentSandbox" } export declare const PayablePaymentTypes: PAYMENT_TYPE[]; export declare enum ORDER_STATUS { NEW = "NEW", ACCEPTED = "ACCEPTED", DECLINED = "DECLINED", PENDING_PAYMENT = "PENDING_PAYMENT", ALLOCATING_DELIVERY = "ALLOCATING_DELIVERY" } export declare enum ORDER_TYPE { DINE_IN = "DINE_IN", PICKUP = "PICKUP", DELIVERY = "DELIVERY" } export type RecursivePartial = { [P in keyof T]?: RecursivePartial; }; export interface SubItem extends RecursivePartial { selection: string; price: DineroObject; name: string; quantity: number; variantSelected?: VariantSelected | null; subItems?: SubItem[]; } export interface Product extends RecursivePartial { name: string; price: DineroObject; } export interface DraftItem extends RecursivePartial>, StockDeductable { id?: string; productId: string | null; subItems: SubItem[]; quantity: number; remark: string | null; product: Product; variantSelected?: VariantSelected | null; } export interface BaseOrderOption { type: ORDER_TYPE; } export interface DineInOptions extends BaseOrderOption { type: ORDER_TYPE.DINE_IN; slot: string; session?: string; pax?: number; } export interface PickupOptions extends BaseOrderOption { type: ORDER_TYPE.PICKUP; contactNumber: string; remark?: string | null; pickupAt: string; pickupPoint?: PickupPoint; } export interface QueueCalculatePayload { items: DraftItem[]; restaurantId: string; } export type OrderOptions = DineInOptions | DeliveryOption | PickupOptions; export interface OrderPayment { type: PAYMENT_TYPE; transactions?: Ref[]; credits?: Ref[]; offlinePaymentType?: OfflinePaymentType; } export interface Order { id: string; status: ORDER_STATUS; orderAt: Date; restaurant: Ref; userId: string; userName: string; option: OrderOptions; billId: string | null; bill: Bill | null; draft: DraftItem[]; payment?: OrderPayment; rejectReason?: string; effects?: Effect[]; } export interface BaseCreateOrderOption { _id?: Types.ObjectId; restaurant: string; userId: string; userName: string; draft: DraftItem[]; payment?: OrderPayment; effects?: Effect[]; } export interface CreateOrderOption extends BaseCreateOrderOption { option: OrderOptions; freeDelivery?: boolean; } export interface AcceptOrderOption { billId: string; } export interface DeclineOrderOption { reason?: string; } export interface GetRestaurantSlotOrdersDto { restaurantId: string; slot: string; status?: ORDER_STATUS[]; } export interface GetRestaurantSlotActiveBillsDto { restaurantId: string; slot: string; } export interface GetRestaurantSlotBillEffectDto { restaurantId: string; slot: string; } /** * @deprecated Use OrderDto instead */ export interface DeliveryOrderDto { skip?: number; limit?: number; deliveryType?: DELIVERY_PROVIDER_TYPE[]; userId?: string; restaurant?: string; orderStatus?: ORDER_STATUS[]; deliveryStatus?: DELIVERY_STATUS[]; excludeDeliveryStatus?: DELIVERY_STATUS[]; ascending?: number; } export interface OrderDto { skip?: number; limit?: number; orderType: ORDER_TYPE[]; deliveryType?: DELIVERY_PROVIDER_TYPE[]; userId?: string; restaurant?: string; orderStatus?: ORDER_STATUS[]; deliveryStatus?: DELIVERY_STATUS[]; excludeDeliveryStatus?: DELIVERY_STATUS[]; ascending?: number; } export interface RefundDto { orderId: string; reason?: string; } export interface NotifyPickupReadyDto { orderNumber: string; customerName: string; phoneNumber: string; pickupPoint?: PickupPoint | null; }