This commit is contained in:
phaichayon
2026-06-16 17:01:29 +07:00
parent 90ee59d388
commit 0a484e0b45
28 changed files with 6483 additions and 277 deletions

View File

@@ -289,6 +289,7 @@ export const crmQuotations = pgTable(
sentAt: timestamp('sent_at', { withTimezone: true }),
sentVia: text('sent_via'),
approvedAt: timestamp('approved_at', { withTimezone: true }),
approvedArtifactId: text('approved_artifact_id'),
approvedPdfUrl: text('approved_pdf_url'),
approvedSnapshot: jsonb('approved_snapshot'),
approvedTemplateVersionId: text('approved_template_version_id'),
@@ -401,6 +402,34 @@ export const crmQuotationAttachments = pgTable('crm_quotation_attachments', {
deletedAt: timestamp('deleted_at', { withTimezone: true })
});
export const crmDocumentArtifacts = pgTable('crm_document_artifacts', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
entityType: text('entity_type').notNull(),
entityId: text('entity_id').notNull(),
documentType: text('document_type').notNull(),
artifactType: text('artifact_type').notNull(),
templateVersionId: text('template_version_id'),
storageProvider: text('storage_provider').notNull(),
storageKey: text('storage_key').notNull(),
fileName: text('file_name').notNull(),
contentType: text('content_type').notNull(),
fileSize: integer('file_size'),
checksum: text('checksum'),
status: text('status').default('active').notNull(),
generatedBy: text('generated_by').notNull(),
generatedAt: timestamp('generated_at', { withTimezone: true }).defaultNow().notNull(),
lockedAt: timestamp('locked_at', { withTimezone: true }),
lockedBy: text('locked_by'),
voidedAt: timestamp('voided_at', { withTimezone: true }),
voidedBy: text('voided_by'),
voidReason: text('void_reason'),
metadata: jsonb('metadata'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true })
});
export const crmApprovalWorkflows = pgTable(
'crm_approval_workflows',
{