michangarrito-backend-v2/src/modules/templates/entities/product-template.entity.ts
rckrdmrd 0019ded690 [MCH-007] feat: Implementar modulo templates con 85+ productos de 8 proveedores
- Crear entidades ProductTemplate y TemplateImport
- Implementar TemplatesService con CRUD y busqueda
- Crear TemplatesController con 9 endpoints
- Agregar soporte para giros (abarrotes, papeleria, farmacia, ferreteria)
- Agregar soporte para proveedores (Sabritas, Coca-Cola, Bimbo, etc)
- Implementar importacion masiva de templates a catalogo tenant

Sprint 5 - Inteligencia
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 04:11:35 -06:00

81 lines
1.7 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
} from 'typeorm';
export enum TemplateGiro {
ABARROTES = 'abarrotes',
PAPELERIA = 'papeleria',
FARMACIA = 'farmacia',
FERRETERIA = 'ferreteria',
GENERAL = 'general',
}
export enum TemplateProvider {
SABRITAS = 'sabritas',
COCA_COLA = 'coca-cola',
BIMBO = 'bimbo',
MARINELA = 'marinela',
GAMESA = 'gamesa',
PEPSI = 'pepsi',
NESTLE = 'nestle',
GENERIC = 'generic',
}
@Entity({ schema: 'catalog', name: 'product_templates' })
@Index(['provider', 'giro'])
@Index(['barcode'])
export class ProductTemplate {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'enum', enum: TemplateProvider })
provider: TemplateProvider;
@Column({ type: 'enum', enum: TemplateGiro })
giro: TemplateGiro;
@Column({ length: 50, nullable: true })
category: string;
@Column({ length: 50 })
sku: string;
@Column({ length: 150 })
name: string;
@Column({ type: 'text', nullable: true })
description: string;
@Column({ length: 50, nullable: true })
barcode: string;
@Column({ name: 'suggested_price', type: 'decimal', precision: 10, scale: 2 })
suggestedPrice: number;
@Column({ name: 'cost_price', type: 'decimal', precision: 10, scale: 2, nullable: true })
costPrice: number;
@Column({ name: 'image_url', type: 'text', nullable: true })
imageUrl: string;
@Column({ length: 20, default: 'pieza' })
unit: string;
@Column({ type: 'jsonb', nullable: true })
metadata: Record<string, any>;
@Column({ default: true })
active: boolean;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}