task-d complate

This commit is contained in:
phaichayon
2026-06-15 13:46:33 +07:00
parent 8148850fda
commit 1d2406483e
32 changed files with 4812 additions and 39 deletions

View File

@@ -188,3 +188,61 @@ export const crmCustomerContacts = pgTable('crm_customer_contacts', {
createdBy: text('created_by').notNull(),
updatedBy: text('updated_by').notNull()
});
export const crmEnquiries = pgTable(
'crm_enquiries',
{
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
branchId: text('branch_id'),
code: text('code').notNull(),
customerId: text('customer_id').notNull(),
contactId: text('contact_id'),
title: text('title').notNull(),
description: text('description'),
requirement: text('requirement'),
projectName: text('project_name'),
projectLocation: text('project_location'),
productType: text('product_type').notNull(),
status: text('status').notNull(),
priority: text('priority').notNull(),
leadChannel: text('lead_channel'),
estimatedValue: doublePrecision('estimated_value'),
chancePercent: integer('chance_percent'),
expectedCloseDate: timestamp('expected_close_date', { withTimezone: true }),
competitor: text('competitor'),
source: text('source'),
notes: text('notes'),
isHotProject: boolean('is_hot_project').default(false).notNull(),
isActive: boolean('is_active').default(true).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true }),
createdBy: text('created_by').notNull(),
updatedBy: text('updated_by').notNull()
},
(table) => ({
organizationCodeIdx: uniqueIndex('crm_enquiries_org_code_idx').on(
table.organizationId,
table.code
)
})
);
export const crmEnquiryFollowups = pgTable('crm_enquiry_followups', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
enquiryId: text('enquiry_id').notNull(),
followupDate: timestamp('followup_date', { withTimezone: true }).notNull(),
followupType: text('followup_type').notNull(),
contactId: text('contact_id'),
outcome: text('outcome'),
notes: text('notes'),
nextFollowupDate: timestamp('next_followup_date', { withTimezone: true }),
nextAction: text('next_action'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true }),
createdBy: text('created_by').notNull(),
updatedBy: text('updated_by').notNull()
});

View File

@@ -142,6 +142,13 @@ const FOUNDATION_OPTIONS = {
{ code: 'high', label: 'High', value: 'high', sortOrder: 3 },
{ code: 'urgent', label: 'Urgent', value: 'urgent', sortOrder: 4 }
],
crm_followup_type: [
{ code: 'call', label: 'Call', value: 'call', sortOrder: 1 },
{ code: 'meeting', label: 'Meeting', value: 'meeting', sortOrder: 2 },
{ code: 'site_visit', label: 'Site Visit', value: 'site_visit', sortOrder: 3 },
{ code: 'email', label: 'Email', value: 'email', sortOrder: 4 },
{ code: 'line', label: 'LINE', value: 'line', sortOrder: 5 }
],
crm_lead_channel: [
{ code: 'website', label: 'Website', value: 'website', sortOrder: 1 },
{ code: 'referral', label: 'Referral', value: 'referral', sortOrder: 2 },