This commit is contained in:
phaichayon
2026-06-16 13:42:38 +07:00
parent 56683ee7b9
commit edee45375e
29 changed files with 4240 additions and 51 deletions

View File

@@ -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));
}