feat: add opportunity workflows, delete routes, company sites, algorithms, and expanded test coverage
This commit is contained in:
@@ -1351,6 +1351,35 @@ export class OpportunityController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Product
|
||||
*
|
||||
* Removes a forecast item from this opportunity in ConnectWise,
|
||||
* removes the item ID from the local productSequence, and
|
||||
* invalidates the products cache.
|
||||
*
|
||||
* @param forecastItemId - The CW forecast item ID to delete
|
||||
*/
|
||||
public async deleteProduct(forecastItemId: number): Promise<void> {
|
||||
await opportunityCw.deleteProduct(this.cwOpportunityId, forecastItemId);
|
||||
|
||||
// Remove the deleted item from the local product sequence
|
||||
if (this.productSequence.includes(forecastItemId)) {
|
||||
const updatedSequence = this.productSequence.filter(
|
||||
(id) => id !== forecastItemId,
|
||||
);
|
||||
|
||||
await prisma.opportunity.update({
|
||||
where: { id: this.id },
|
||||
data: { productSequence: updatedSequence },
|
||||
});
|
||||
|
||||
this.productSequence = updatedSequence;
|
||||
}
|
||||
|
||||
await invalidateProductsCache(this.cwOpportunityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Procurement Product By Forecast Item
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user