UNPKG

skailan-crm

Version:

Servicio de CRM y gestión de ventas para Skailan

28 lines 1.24 kB
export class UpdateOpportunity { opportunityRepository; constructor(opportunityRepository) { this.opportunityRepository = opportunityRepository; } async execute(request) { const { id, organizationId, ...updates } = request; const existingOpportunity = await this.opportunityRepository.findById(id, organizationId); if (!existingOpportunity) { throw new Error('Opportunity not found.'); } if (updates.name !== undefined) existingOpportunity.name = updates.name; if (updates.stage !== undefined) existingOpportunity.stage = updates.stage; if (updates.amount !== undefined) existingOpportunity.amount = updates.amount; if (updates.probability !== undefined) existingOpportunity.probability = updates.probability; if (updates.closeDate !== undefined) existingOpportunity.closeDate = updates.closeDate; if (updates.notes !== undefined) existingOpportunity.notes = updates.notes; existingOpportunity.updatedAt = new Date(); return this.opportunityRepository.save(existingOpportunity); } } //# sourceMappingURL=UpdateOpportunity.js.map