Copy button text now matches the exact guest-facing template requested — "Ваше бронирование подтверждено!", Гость/Номер для связи/Объект бронирования/Количество гостей/Дополнительные пожелания/Скидка — dropping the internal-only fields (source, who booked it) since this text gets pasted straight to the client, not kept for internal records (those still show on the on-screen summary card). New checkOutDate column (nullable — null means same-day, the common case) lets a booking span multiple days; the Google Calendar link and copy text both show the date range when set. New discount column (same shape as prepayment) feeds the new "Скидка" line. Statistics page gains a money row for the selected month: total booked, prepayments collected, amount still outstanding, and total discount given. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gh2UXUQUVBWroWEnn1FLFG
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
export interface BookingSummaryInput {
|
|
bookingNumber: number;
|
|
contactName: string;
|
|
phone: string;
|
|
objectNames: string[];
|
|
date: Date;
|
|
checkOutDate: Date | null;
|
|
checkIn: string;
|
|
checkOut: string;
|
|
guestCount: number;
|
|
cost: number;
|
|
prepayment: number;
|
|
discount: number;
|
|
comment: string | null;
|
|
source: string | null;
|
|
bookedByName: string;
|
|
}
|
|
|
|
function formatDate(d: Date): string {
|
|
const dd = String(d.getDate()).padStart(2, "0");
|
|
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
return `${dd}.${mm}.${d.getFullYear()}`;
|
|
}
|
|
|
|
/**
|
|
* Guest-facing confirmation text for the "Скопировать бронирование" button
|
|
* — meant to be pasted straight to the client (WhatsApp/Telegram/SMS), so
|
|
* it deliberately excludes internal-only fields (source, who booked it).
|
|
* Field set and order match exactly what was asked for; a multi-day stay's
|
|
* date line shows both days ("дд.мм.гггг - дд.мм.гггг").
|
|
*/
|
|
export function formatBookingSummary(b: BookingSummaryInput): string {
|
|
const dateLine = b.checkOutDate ? `${formatDate(b.date)} - ${formatDate(b.checkOutDate)}` : formatDate(b.date);
|
|
const lines = [
|
|
`Ваше бронирование подтверждено! Номер бронирования: ${b.bookingNumber}`,
|
|
`Гость: ${b.contactName}`,
|
|
`Номер для связи: ${b.phone}`,
|
|
`Объект бронирования: ${b.objectNames.join("/") || "—"}`,
|
|
`Дата: ${dateLine}`,
|
|
`Время заезда/выезда: ${b.checkIn} - ${b.checkOut}`,
|
|
`Количество гостей: ${b.guestCount}`,
|
|
`Стоимость бронирования: ${b.cost}`,
|
|
`Предоплата: ${b.prepayment}`,
|
|
`Дополнительные пожелания: ${b.comment?.trim() || "-"}`,
|
|
`Скидка: ${b.discount}`,
|
|
];
|
|
return lines.join("\n");
|
|
}
|