feat(bookings): add transaction document uploads for bank payments
Add payment method selection (Cash/Bank) to booking details Support uploading, downloading, and deleting transaction documents Update database schema and API endpoints to handle file storage
This commit is contained in:
@@ -284,6 +284,12 @@ async function initializeDatabase() {
|
||||
person_in_charge_id text not null references users(id) on delete restrict,
|
||||
person_in_charge_name text not null,
|
||||
person_in_charge_phone_number text not null,
|
||||
payment_method text not null default 'cash',
|
||||
transaction_document_original_name text,
|
||||
transaction_document_storage_name text,
|
||||
transaction_document_mime_type text,
|
||||
transaction_document_size integer,
|
||||
transaction_document_uploaded_at timestamptz,
|
||||
remark text,
|
||||
status text not null default 'pending',
|
||||
confirmed_at timestamptz,
|
||||
@@ -328,6 +334,53 @@ async function initializeDatabase() {
|
||||
add column if not exists deleted_at timestamptz
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add column if not exists payment_method text not null default 'cash'
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add column if not exists transaction_document_original_name text
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add column if not exists transaction_document_storage_name text
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add column if not exists transaction_document_mime_type text
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add column if not exists transaction_document_size integer
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add column if not exists transaction_document_uploaded_at timestamptz
|
||||
`
|
||||
|
||||
await sql`
|
||||
update bookings
|
||||
set payment_method = 'cash'
|
||||
where payment_method is null
|
||||
or payment_method not in ('cash', 'bank')
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
alter column payment_method set not null
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
alter column payment_method set default 'cash'
|
||||
`
|
||||
|
||||
await sql`
|
||||
create unique index if not exists bookings_receipt_token_idx
|
||||
on bookings (receipt_token)
|
||||
@@ -353,6 +406,17 @@ async function initializeDatabase() {
|
||||
on bookings (deleted_at)
|
||||
`
|
||||
|
||||
await sql`
|
||||
create index if not exists bookings_payment_method_idx
|
||||
on bookings (payment_method)
|
||||
`
|
||||
|
||||
await sql`
|
||||
create unique index if not exists bookings_transaction_document_storage_name_idx
|
||||
on bookings (transaction_document_storage_name)
|
||||
where transaction_document_storage_name is not null
|
||||
`
|
||||
|
||||
await sql`
|
||||
create table if not exists booking_seats (
|
||||
id text primary key,
|
||||
@@ -444,6 +508,17 @@ async function initializeDatabase() {
|
||||
drop constraint if exists bookings_status_check
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
drop constraint if exists bookings_payment_method_check
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add constraint bookings_payment_method_check
|
||||
check (payment_method in ('cash', 'bank'))
|
||||
`
|
||||
|
||||
const [activeEvent] = await sql<{ id: string }[]>`
|
||||
select id
|
||||
from dinner_events
|
||||
|
||||
Reference in New Issue
Block a user