michangarrito/apps/backend/dist/modules/sales/entities/sale.entity.js
rckrdmrd 97f407c661 [MIGRATION-V2] feat: Migrar michangarrito a estructura v2
- Prefijo v2: MCH
- TRACEABILITY-MASTER.yml creado
- Listo para integracion como submodulo

Workspace: v2.0.0 | SIMCO: v4.0.0
2026-01-10 11:28:54 -06:00

113 lines
5.0 KiB
JavaScript

"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.Sale = exports.SaleStatus = void 0;
const typeorm_1 = require("typeorm");
const sale_item_entity_1 = require("./sale-item.entity");
const payment_method_entity_1 = require("../../payments/entities/payment-method.entity");
var SaleStatus;
(function (SaleStatus) {
SaleStatus["COMPLETED"] = "completed";
SaleStatus["CANCELLED"] = "cancelled";
SaleStatus["REFUNDED"] = "refunded";
})(SaleStatus || (exports.SaleStatus = SaleStatus = {}));
let Sale = class Sale {
};
exports.Sale = Sale;
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
__metadata("design:type", String)
], Sale.prototype, "id", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tenant_id' }),
__metadata("design:type", String)
], Sale.prototype, "tenantId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'ticket_number', length: 20 }),
__metadata("design:type", String)
], Sale.prototype, "ticketNumber", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 2 }),
__metadata("design:type", Number)
], Sale.prototype, "subtotal", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tax_amount', type: 'decimal', precision: 12, scale: 2, default: 0 }),
__metadata("design:type", Number)
], Sale.prototype, "taxAmount", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'discount_amount', type: 'decimal', precision: 12, scale: 2, default: 0 }),
__metadata("design:type", Number)
], Sale.prototype, "discountAmount", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 2 }),
__metadata("design:type", Number)
], Sale.prototype, "total", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'payment_method_id', nullable: true }),
__metadata("design:type", String)
], Sale.prototype, "paymentMethodId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'amount_received', type: 'decimal', precision: 12, scale: 2 }),
__metadata("design:type", Number)
], Sale.prototype, "amountReceived", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'change_amount', type: 'decimal', precision: 12, scale: 2, default: 0 }),
__metadata("design:type", Number)
], Sale.prototype, "changeAmount", void 0);
__decorate([
(0, typeorm_1.Column)({
type: 'enum',
enum: SaleStatus,
default: SaleStatus.COMPLETED,
}),
__metadata("design:type", String)
], Sale.prototype, "status", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'cancelled_at', type: 'timestamp', nullable: true }),
__metadata("design:type", Date)
], Sale.prototype, "cancelledAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'cancel_reason', length: 255, nullable: true }),
__metadata("design:type", String)
], Sale.prototype, "cancelReason", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'customer_name', length: 200, nullable: true }),
__metadata("design:type", String)
], Sale.prototype, "customerName", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'customer_phone', length: 20, nullable: true }),
__metadata("design:type", String)
], Sale.prototype, "customerPhone", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
__metadata("design:type", String)
], Sale.prototype, "notes", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'device_info', type: 'jsonb', nullable: true }),
__metadata("design:type", Object)
], Sale.prototype, "deviceInfo", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
__metadata("design:type", Date)
], Sale.prototype, "createdAt", void 0);
__decorate([
(0, typeorm_1.OneToMany)(() => sale_item_entity_1.SaleItem, (item) => item.sale, { cascade: true }),
__metadata("design:type", Array)
], Sale.prototype, "items", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => payment_method_entity_1.PaymentMethod, { nullable: true }),
(0, typeorm_1.JoinColumn)({ name: 'payment_method_id' }),
__metadata("design:type", payment_method_entity_1.PaymentMethod)
], Sale.prototype, "paymentMethod", void 0);
exports.Sale = Sale = __decorate([
(0, typeorm_1.Entity)({ schema: 'sales', name: 'sales' })
], Sale);
//# sourceMappingURL=sale.entity.js.map