126 lines
4.3 KiB
TypeScript
126 lines
4.3 KiB
TypeScript
/**
|
|
* EstimacionService - Gestión de Estimaciones de Obra
|
|
*
|
|
* Gestiona estimaciones periódicas con workflow de aprobación.
|
|
* Incluye cálculo de anticipos, retenciones e IVA.
|
|
*
|
|
* @module Estimates
|
|
*/
|
|
import { Repository, DataSource } from 'typeorm';
|
|
import { BaseService, ServiceContext, PaginatedResult } from '../../../shared/services/base.service';
|
|
import { Estimacion, EstimateStatus } from '../entities/estimacion.entity';
|
|
import { EstimacionConcepto } from '../entities/estimacion-concepto.entity';
|
|
import { Generador } from '../entities/generador.entity';
|
|
import { EstimacionWorkflow } from '../entities/estimacion-workflow.entity';
|
|
export interface CreateEstimacionDto {
|
|
contratoId: string;
|
|
fraccionamientoId: string;
|
|
periodStart: Date;
|
|
periodEnd: Date;
|
|
notes?: string;
|
|
}
|
|
export interface AddConceptoDto {
|
|
conceptoId: string;
|
|
contratoPartidaId?: string;
|
|
quantityContract?: number;
|
|
quantityPrevious?: number;
|
|
quantityCurrent: number;
|
|
unitPrice: number;
|
|
notes?: string;
|
|
}
|
|
export interface AddGeneradorDto {
|
|
generatorNumber: string;
|
|
description?: string;
|
|
loteId?: string;
|
|
departamentoId?: string;
|
|
locationDescription?: string;
|
|
quantity: number;
|
|
formula?: string;
|
|
photoUrl?: string;
|
|
sketchUrl?: string;
|
|
}
|
|
export interface EstimacionFilters {
|
|
contratoId?: string;
|
|
fraccionamientoId?: string;
|
|
status?: EstimateStatus;
|
|
periodFrom?: Date;
|
|
periodTo?: Date;
|
|
}
|
|
export declare class EstimacionService extends BaseService<Estimacion> {
|
|
private readonly conceptoRepository;
|
|
private readonly generadorRepository;
|
|
private readonly workflowRepository;
|
|
private readonly dataSource;
|
|
constructor(repository: Repository<Estimacion>, conceptoRepository: Repository<EstimacionConcepto>, generadorRepository: Repository<Generador>, workflowRepository: Repository<EstimacionWorkflow>, dataSource: DataSource);
|
|
/**
|
|
* Crear nueva estimación
|
|
*/
|
|
createEstimacion(ctx: ServiceContext, data: CreateEstimacionDto): Promise<Estimacion>;
|
|
/**
|
|
* Obtener siguiente número de secuencia
|
|
*/
|
|
private getNextSequenceNumber;
|
|
/**
|
|
* Generar número de estimación
|
|
*/
|
|
private generateEstimateNumber;
|
|
/**
|
|
* Obtener estimaciones por contrato
|
|
*/
|
|
findByContrato(ctx: ServiceContext, contratoId: string, page?: number, limit?: number): Promise<PaginatedResult<Estimacion>>;
|
|
/**
|
|
* Obtener estimaciones con filtros
|
|
*/
|
|
findWithFilters(ctx: ServiceContext, filters: EstimacionFilters, page?: number, limit?: number): Promise<PaginatedResult<Estimacion>>;
|
|
/**
|
|
* Obtener estimación con detalles completos
|
|
*/
|
|
findWithDetails(ctx: ServiceContext, id: string): Promise<Estimacion | null>;
|
|
/**
|
|
* Agregar concepto a estimación
|
|
*/
|
|
addConcepto(ctx: ServiceContext, estimacionId: string, data: AddConceptoDto): Promise<EstimacionConcepto>;
|
|
/**
|
|
* Agregar generador a concepto de estimación
|
|
*/
|
|
addGenerador(ctx: ServiceContext, estimacionConceptoId: string, data: AddGeneradorDto): Promise<Generador>;
|
|
/**
|
|
* Recalcular totales de estimación
|
|
*/
|
|
recalculateTotals(_ctx: ServiceContext, estimacionId: string): Promise<void>;
|
|
/**
|
|
* Cambiar estado de estimación
|
|
*/
|
|
changeStatus(ctx: ServiceContext, estimacionId: string, newStatus: EstimateStatus, action: string, comments?: string): Promise<Estimacion | null>;
|
|
/**
|
|
* Agregar entrada al workflow
|
|
*/
|
|
private addWorkflowEntry;
|
|
/**
|
|
* Enviar estimación para revisión
|
|
*/
|
|
submit(ctx: ServiceContext, estimacionId: string): Promise<Estimacion | null>;
|
|
/**
|
|
* Revisar estimación
|
|
*/
|
|
review(ctx: ServiceContext, estimacionId: string): Promise<Estimacion | null>;
|
|
/**
|
|
* Aprobar estimación
|
|
*/
|
|
approve(ctx: ServiceContext, estimacionId: string): Promise<Estimacion | null>;
|
|
/**
|
|
* Rechazar estimación
|
|
*/
|
|
reject(ctx: ServiceContext, estimacionId: string, reason: string): Promise<Estimacion | null>;
|
|
/**
|
|
* Obtener resumen de estimaciones por contrato
|
|
*/
|
|
getContractSummary(ctx: ServiceContext, contratoId: string): Promise<ContractEstimateSummary>;
|
|
}
|
|
interface ContractEstimateSummary {
|
|
totalEstimates: number;
|
|
totalApproved: number;
|
|
totalPaid: number;
|
|
}
|
|
export {};
|
|
//# sourceMappingURL=estimacion.service.d.ts.map
|