"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Order = exports.OrderType = exports.OrderChannel = exports.OrderStatus = void 0; const typeorm_1 = require("typeorm"); const order_item_entity_1 = require("./order-item.entity"); const customer_entity_1 = require("../../customers/entities/customer.entity"); var OrderStatus; (function (OrderStatus) { OrderStatus["PENDING"] = "pending"; OrderStatus["CONFIRMED"] = "confirmed"; OrderStatus["PREPARING"] = "preparing"; OrderStatus["READY"] = "ready"; OrderStatus["DELIVERED"] = "delivered"; OrderStatus["COMPLETED"] = "completed"; OrderStatus["CANCELLED"] = "cancelled"; })(OrderStatus || (exports.OrderStatus = OrderStatus = {})); var OrderChannel; (function (OrderChannel) { OrderChannel["WHATSAPP"] = "whatsapp"; OrderChannel["WEB"] = "web"; OrderChannel["APP"] = "app"; OrderChannel["POS"] = "pos"; })(OrderChannel || (exports.OrderChannel = OrderChannel = {})); var OrderType; (function (OrderType) { OrderType["PICKUP"] = "pickup"; OrderType["DELIVERY"] = "delivery"; OrderType["DINE_IN"] = "dine_in"; })(OrderType || (exports.OrderType = OrderType = {})); let Order = class Order { }; exports.Order = Order; __decorate([ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), __metadata("design:type", String) ], Order.prototype, "id", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'tenant_id' }), __metadata("design:type", String) ], Order.prototype, "tenantId", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'customer_id', nullable: true }), __metadata("design:type", String) ], Order.prototype, "customerId", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'order_number', length: 20 }), __metadata("design:type", String) ], Order.prototype, "orderNumber", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 20, default: OrderChannel.WHATSAPP, }), __metadata("design:type", String) ], Order.prototype, "channel", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 2 }), __metadata("design:type", Number) ], Order.prototype, "subtotal", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'delivery_fee', type: 'decimal', precision: 10, scale: 2, default: 0 }), __metadata("design:type", Number) ], Order.prototype, "deliveryFee", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'discount_amount', type: 'decimal', precision: 10, scale: 2, default: 0 }), __metadata("design:type", Number) ], Order.prototype, "discountAmount", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 2 }), __metadata("design:type", Number) ], Order.prototype, "total", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'order_type', type: 'varchar', length: 20, default: OrderType.PICKUP, }), __metadata("design:type", String) ], Order.prototype, "orderType", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'delivery_address', type: 'text', nullable: true }), __metadata("design:type", String) ], Order.prototype, "deliveryAddress", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'delivery_notes', type: 'text', nullable: true }), __metadata("design:type", String) ], Order.prototype, "deliveryNotes", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'estimated_delivery_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Order.prototype, "estimatedDeliveryAt", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 20, default: OrderStatus.PENDING, }), __metadata("design:type", String) ], Order.prototype, "status", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'payment_status', length: 20, default: 'pending' }), __metadata("design:type", String) ], Order.prototype, "paymentStatus", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'payment_method', length: 20, nullable: true }), __metadata("design:type", String) ], Order.prototype, "paymentMethod", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'confirmed_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Order.prototype, "confirmedAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'preparing_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Order.prototype, "preparingAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'ready_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Order.prototype, "readyAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'completed_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Order.prototype, "completedAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'cancelled_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Order.prototype, "cancelledAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'cancelled_reason', type: 'text', nullable: true }), __metadata("design:type", String) ], Order.prototype, "cancelledReason", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'customer_notes', type: 'text', nullable: true }), __metadata("design:type", String) ], Order.prototype, "customerNotes", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'internal_notes', type: 'text', nullable: true }), __metadata("design:type", String) ], Order.prototype, "internalNotes", void 0); __decorate([ (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }), __metadata("design:type", Date) ], Order.prototype, "createdAt", void 0); __decorate([ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }), __metadata("design:type", Date) ], Order.prototype, "updatedAt", void 0); __decorate([ (0, typeorm_1.OneToMany)(() => order_item_entity_1.OrderItem, (item) => item.order, { cascade: true }), __metadata("design:type", Array) ], Order.prototype, "items", void 0); __decorate([ (0, typeorm_1.ManyToOne)(() => customer_entity_1.Customer, { nullable: true }), (0, typeorm_1.JoinColumn)({ name: 'customer_id' }), __metadata("design:type", customer_entity_1.Customer) ], Order.prototype, "customer", void 0); exports.Order = Order = __decorate([ (0, typeorm_1.Entity)({ schema: 'orders', name: 'orders' }) ], Order); //# sourceMappingURL=order.entity.js.map