task-h
This commit is contained in:
@@ -314,13 +314,22 @@ async function syncQuotationStatusFromApproval(
|
||||
throw new AuthError(`Quotation status ${nextStatusCode} is not configured`, 400);
|
||||
}
|
||||
|
||||
const nextValues: Partial<typeof crmQuotations.$inferInsert> = {
|
||||
status: statusId,
|
||||
approvedAt: nextStatusCode === 'approved' ? new Date() : null,
|
||||
updatedAt: new Date(),
|
||||
updatedBy: userId
|
||||
};
|
||||
|
||||
if (nextStatusCode !== 'approved') {
|
||||
nextValues.approvedPdfUrl = null;
|
||||
nextValues.approvedSnapshot = null;
|
||||
nextValues.approvedTemplateVersionId = null;
|
||||
}
|
||||
|
||||
await db
|
||||
.update(crmQuotations)
|
||||
.set({
|
||||
status: statusId,
|
||||
updatedAt: new Date(),
|
||||
updatedBy: userId
|
||||
})
|
||||
.set(nextValues)
|
||||
.where(eq(crmQuotations.id, quotationId));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user