compleate
This commit is contained in:
phaichayon
2026-06-15 13:20:39 +07:00
parent b8cd39eaa4
commit 8148850fda
33 changed files with 4800 additions and 35 deletions

View File

@@ -128,3 +128,63 @@ export const trAuditLogs = pgTable('tr_audit_logs', {
requestId: text('request_id'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull()
});
export const crmCustomers = pgTable(
'crm_customers',
{
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
branchId: text('branch_id'),
code: text('code').notNull(),
name: text('name').notNull(),
abbr: text('abbr'),
taxId: text('tax_id'),
customerType: text('customer_type').notNull(),
customerStatus: text('customer_status').notNull(),
address: text('address'),
province: text('province'),
district: text('district'),
subDistrict: text('sub_district'),
postalCode: text('postal_code'),
country: text('country'),
phone: text('phone'),
fax: text('fax'),
email: text('email'),
website: text('website'),
leadChannel: text('lead_channel'),
customerGroup: text('customer_group'),
notes: text('notes'),
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_customers_org_code_idx').on(
table.organizationId,
table.code
)
})
);
export const crmCustomerContacts = pgTable('crm_customer_contacts', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
customerId: text('customer_id').notNull(),
name: text('name').notNull(),
position: text('position'),
department: text('department'),
phone: text('phone'),
mobile: text('mobile'),
email: text('email'),
isPrimary: boolean('is_primary').default(false).notNull(),
notes: text('notes'),
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()
});