77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
/**
|
|
* Fleet Entity
|
|
* Mecánicas Diesel - ERP Suite
|
|
*
|
|
* Represents vehicle fleets for commercial customers.
|
|
*/
|
|
|
|
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
OneToMany,
|
|
Index,
|
|
} from 'typeorm';
|
|
import { Vehicle } from './vehicle.entity';
|
|
|
|
@Entity({ name: 'fleets', schema: 'vehicle_management' })
|
|
@Index('idx_fleets_tenant', ['tenantId'])
|
|
@Index('idx_fleets_name', ['name'])
|
|
export class Fleet {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Column({ type: 'varchar', length: 200 })
|
|
name: string;
|
|
|
|
@Column({ type: 'varchar', length: 20, nullable: true })
|
|
code?: string;
|
|
|
|
// Contact
|
|
@Column({ name: 'contact_name', type: 'varchar', length: 200, nullable: true })
|
|
contactName?: string;
|
|
|
|
@Column({ name: 'contact_email', type: 'varchar', length: 200, nullable: true })
|
|
contactEmail?: string;
|
|
|
|
@Column({ name: 'contact_phone', type: 'varchar', length: 20, nullable: true })
|
|
contactPhone?: string;
|
|
|
|
// Commercial terms
|
|
@Column({ name: 'discount_labor_pct', type: 'decimal', precision: 5, scale: 2, default: 0 })
|
|
discountLaborPct: number;
|
|
|
|
@Column({ name: 'discount_parts_pct', type: 'decimal', precision: 5, scale: 2, default: 0 })
|
|
discountPartsPct: number;
|
|
|
|
@Column({ name: 'credit_days', type: 'integer', default: 0 })
|
|
creditDays: number;
|
|
|
|
@Column({ name: 'credit_limit', type: 'decimal', precision: 12, scale: 2, default: 0 })
|
|
creditLimit: number;
|
|
|
|
@Column({ name: 'vehicle_count', type: 'integer', default: 0 })
|
|
vehicleCount: number;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
notes?: string;
|
|
|
|
@Column({ name: 'is_active', type: 'boolean', default: true })
|
|
isActive: boolean;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
// Relations
|
|
@OneToMany(() => Vehicle, vehicle => vehicle.fleet)
|
|
vehicles: Vehicle[];
|
|
}
|