feat: checklists, minibar and deposit modules

- DB migrations 057-059: checklist_templates/items/completions, minibar_items/consumptions, hotel_deposit_settings, booking_deposits
- Backend routes: checklists (templates CRUD + task completions), minibar (items + consumptions), deposit (settings, cash/yookassa hold, release/capture)
- YooKassa service for hold/capture/cancel payments
- Frontend: ChecklistSettingsPage, MinibarSettingsPage, DepositSettingsPage
- HousekeepingPage: task cards now show checklist + minibar panel with checkboxes and quantity buttons
- BookingModal: minibar charges summary + deposit management (cash/YooKassa/release) for existing bookings
- Sidebar + App.tsx: new routes /settings/checklists, /settings/minibar, /settings/deposit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 19:24:53 +03:00
parent ed2dfd4c7f
commit 3c1a6ccebf
17 changed files with 2569 additions and 9 deletions

View File

@@ -0,0 +1,82 @@
import { randomUUID } from 'crypto'
interface YooKassaPayment {
id: string
status: string
confirmation?: { confirmation_url: string }
}
export async function createHold(params: {
shopId: string
secretKey: string
amount: number
description: string
returnUrl: string
idempotenceKey?: string
}): Promise<YooKassaPayment> {
const auth = Buffer.from(`${params.shopId}:${params.secretKey}`).toString('base64')
const res = await fetch('https://api.yookassa.ru/v3/payments', {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
'Idempotence-Key': params.idempotenceKey ?? randomUUID(),
},
body: JSON.stringify({
amount: { value: params.amount.toFixed(2), currency: 'RUB' },
capture: false,
confirmation: { type: 'redirect', return_url: params.returnUrl },
description: params.description,
}),
})
if (!res.ok) {
const err = await res.text()
throw new Error(`YooKassa error ${res.status}: ${err}`)
}
return res.json() as Promise<YooKassaPayment>
}
export async function capturePayment(params: {
shopId: string
secretKey: string
paymentId: string
amount: number
}): Promise<void> {
const auth = Buffer.from(`${params.shopId}:${params.secretKey}`).toString('base64')
const res = await fetch(`https://api.yookassa.ru/v3/payments/${params.paymentId}/capture`, {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
'Idempotence-Key': randomUUID(),
},
body: JSON.stringify({
amount: { value: params.amount.toFixed(2), currency: 'RUB' },
}),
})
if (!res.ok) {
const err = await res.text()
throw new Error(`YooKassa capture error ${res.status}: ${err}`)
}
}
export async function cancelPayment(params: {
shopId: string
secretKey: string
paymentId: string
}): Promise<void> {
const auth = Buffer.from(`${params.shopId}:${params.secretKey}`).toString('base64')
const res = await fetch(`https://api.yookassa.ru/v3/payments/${params.paymentId}/cancel`, {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
'Idempotence-Key': randomUUID(),
},
body: '{}',
})
if (!res.ok) {
const err = await res.text()
throw new Error(`YooKassa cancel error ${res.status}: ${err}`)
}
}