@curless/hotel-storefront 0.84.0 → 0.84.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/addon-pages.d.ts.map +1 -1
- package/dist/account/addon-pages.js +23 -7
- package/dist/account/addon-pages.js.map +1 -1
- package/dist/account/cancel-pages.d.ts +118 -0
- package/dist/account/cancel-pages.d.ts.map +1 -0
- package/dist/account/cancel-pages.js +313 -0
- package/dist/account/cancel-pages.js.map +1 -0
- package/dist/account/index.d.ts +50 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +389 -34
- package/dist/account/index.js.map +1 -1
- package/dist/account/pages.d.ts +31 -3
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +98 -19
- package/dist/account/pages.js.map +1 -1
- package/dist/account/requests.d.ts +11 -1
- package/dist/account/requests.d.ts.map +1 -1
- package/dist/account/requests.js +2 -1
- package/dist/account/requests.js.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/config.d.ts +14 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/legal.d.ts.map +1 -1
- package/dist/legal.js +4 -3
- package/dist/legal.js.map +1 -1
- package/dist/otaless/addons-answers.d.ts +2 -0
- package/dist/otaless/addons-answers.d.ts.map +1 -1
- package/dist/otaless/addons-answers.js +32 -12
- package/dist/otaless/addons-answers.js.map +1 -1
- package/dist/otaless/addons.d.ts +16 -4
- package/dist/otaless/addons.d.ts.map +1 -1
- package/dist/otaless/addons.js +25 -12
- package/dist/otaless/addons.js.map +1 -1
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +55 -1
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +39 -4
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +406 -61
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +3 -1
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +14 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +18 -8
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +19 -3
- package/dist/otaless/make.js.map +1 -1
- package/dist/otaless/shop-answers.d.ts +100 -3
- package/dist/otaless/shop-answers.d.ts.map +1 -1
- package/dist/otaless/shop-answers.js +271 -26
- package/dist/otaless/shop-answers.js.map +1 -1
- package/dist/otaless/shop-client.d.ts +7 -0
- package/dist/otaless/shop-client.d.ts.map +1 -1
- package/dist/otaless/shop-client.js +5 -0
- package/dist/otaless/shop-client.js.map +1 -1
- package/dist/otaless/shop-fake.d.ts +5 -0
- package/dist/otaless/shop-fake.d.ts.map +1 -1
- package/dist/otaless/shop-fake.js +2 -0
- package/dist/otaless/shop-fake.js.map +1 -1
- package/dist/otaless/shop-record.d.ts +24 -0
- package/dist/otaless/shop-record.d.ts.map +1 -0
- package/dist/otaless/shop-record.js +128 -0
- package/dist/otaless/shop-record.js.map +1 -0
- package/dist/otaless/shop-service.d.ts +60 -3
- package/dist/otaless/shop-service.d.ts.map +1 -1
- package/dist/otaless/shop-service.js +169 -8
- package/dist/otaless/shop-service.js.map +1 -1
- package/dist/otaless/shop.d.ts +44 -0
- package/dist/otaless/shop.d.ts.map +1 -1
- package/dist/otaless/shop.js +97 -0
- package/dist/otaless/shop.js.map +1 -1
- package/dist/otaless/wallet.d.ts.map +1 -1
- package/dist/otaless/wallet.js +27 -6
- package/dist/otaless/wallet.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +153 -8
- package/dist/server.js.map +1 -1
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +5 -1
- package/dist/surface.js.map +1 -1
- package/dist/tools.d.ts +79 -19
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +452 -42
- package/dist/tools.js.map +1 -1
- package/dist/trip-ids.d.ts +39 -2
- package/dist/trip-ids.d.ts.map +1 -1
- package/dist/trip-ids.js +80 -3
- package/dist/trip-ids.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -10,8 +10,8 @@ import { clockOf, minutesOf, startProblem, stayWords, windowWords } from './hour
|
|
|
10
10
|
import { amountsIn, formatMoney, inFullCurrency, keepingAmounts, money, multiplyMoney, toMinor, } from './money.js';
|
|
11
11
|
import { namedExactly, roomNamesOf, roomTypeNamed, withTraditional } from './names.js';
|
|
12
12
|
import { cardAnswer, hotelListAnswer, prepareRefusal, preparedAnswer, statusAnswer, } from './otaless/addons-answers.js';
|
|
13
|
-
import { buyAnswer, finishAnswer, itemAnswer, listAnswer, ordersPart, previewAnswer, shopSignInAnswer, } from './otaless/shop-answers.js';
|
|
14
|
-
import { looksLikeShopOrder, unitCentsOf } from './otaless/shop-service.js';
|
|
13
|
+
import { addOnsCancelPreview, addOnsCancelResult, buyAnswer, finishAnswer, itemAnswer, listAnswer, ordersPart, previewAnswer, shopOrdersAnswer, shopSignInAnswer, } from './otaless/shop-answers.js';
|
|
14
|
+
import { BOOKING_ENDED, looksLikeShopOrder, unitCentsOf } from './otaless/shop-service.js';
|
|
15
15
|
import { overlapsOf } from './overlap.js';
|
|
16
16
|
import { MAX_COMPARED, MAX_CONS, MAX_DAYS, MAX_ITEMS_PER_DAY, MAX_MOMENTS, MAX_PROS, buildItinerary, candidatesFor, compareHotels, namesMoreThanOne, nightlyIncludesTaxes, } from './present.js';
|
|
17
17
|
import { withReference } from './reference.js';
|
|
@@ -197,6 +197,8 @@ export const withheldTools = (n, caps) => new Set([
|
|
|
197
197
|
// its buy tool only where buying is open too. The names exist only with `data.otaless.shop`.
|
|
198
198
|
...(n.listShopItems && !(caps.shop && !caps.readOnly) ? [n.listShopItems] : []),
|
|
199
199
|
...(n.buyShopItem && !(caps.shop && caps.shopBuy && !caps.readOnly) ? [n.buyShopItem] : []),
|
|
200
|
+
// The account's value-added service orders (0.84.1): where the shop's listing is.
|
|
201
|
+
...(n.listShopOrders && !(caps.shop && !caps.readOnly) ? [n.listShopOrders] : []),
|
|
200
202
|
// The card's own add-ons tool (0.82.0): only where the hotel's add-ons or the shop are on.
|
|
201
203
|
...(n.cardAddons && !((caps.addons || caps.shop) && !caps.readOnly) ? [n.cardAddons] : []),
|
|
202
204
|
// Nothing can be booked here yet (`readOnly`, Otaless 2026-11-03): no tool
|
|
@@ -493,6 +495,14 @@ const forCapabilities = (tools, n, v, caps) => {
|
|
|
493
495
|
inputSchema: without(out.inputSchema, 'requests', 'arrivingAt', 'notes'),
|
|
494
496
|
};
|
|
495
497
|
}
|
|
498
|
+
// ⚠️ A VALUE-ADDED SERVICE ORDER IS NOT A HOTEL BOOKING (0.84.1, robin 11-25: asked for "my shop
|
|
499
|
+
// orders", the model read the hotel bookings first and had no times). Only where the shop is on:
|
|
500
|
+
// every other deployment's description is word for word as it was (the frozen root listing).
|
|
501
|
+
if (t.name === n.listBookings && n.listShopOrders && caps.shop && !caps.readOnly)
|
|
502
|
+
out = {
|
|
503
|
+
...out,
|
|
504
|
+
description: `${out.description} ${SHOP_ORDERS_IN_BOOKINGS}`,
|
|
505
|
+
};
|
|
496
506
|
// ⚠️ ONE CANCEL, WHICH ASKS THE REFUND TOO (0.74.2, robin 11-17): said by the tool
|
|
497
507
|
// itself, for the model in every client - there is no refund tool to reach for.
|
|
498
508
|
if (t.name === n.cancelBooking && caps.refunds && !caps.readOnly)
|
|
@@ -1343,6 +1353,18 @@ const allTools = (n, v) => {
|
|
|
1343
1353
|
},
|
|
1344
1354
|
]
|
|
1345
1355
|
: []),
|
|
1356
|
+
// ⚠️ THE ACCOUNT'S VALUE-ADDED SERVICE ORDERS ON THEIR OWN (0.84.1, robin 11-25: 「首选把我酒店预订订单先
|
|
1357
|
+
// 出来,然后没有时间」): asked for its shop orders, the model read the hotel bookings first. Read only.
|
|
1358
|
+
...(n.listShopOrders
|
|
1359
|
+
? [
|
|
1360
|
+
{
|
|
1361
|
+
name: n.listShopOrders,
|
|
1362
|
+
description: SHOP_ORDERS_DESCRIPTION,
|
|
1363
|
+
annotations: reads('Value-added service orders', open),
|
|
1364
|
+
inputSchema: { type: 'object', properties: {} },
|
|
1365
|
+
},
|
|
1366
|
+
]
|
|
1367
|
+
: []),
|
|
1346
1368
|
...(n.buyShopItem
|
|
1347
1369
|
? [
|
|
1348
1370
|
{
|
|
@@ -1436,6 +1458,14 @@ const allTools = (n, v) => {
|
|
|
1436
1458
|
: []),
|
|
1437
1459
|
];
|
|
1438
1460
|
};
|
|
1461
|
+
/**
|
|
1462
|
+
* The value-added service orders tool (0.84.1). ⚠️ Says what it reads, in the words a guest uses for it
|
|
1463
|
+
* (增值服务订单, 商城订单, shop orders, add-on orders - one thing), and that they are not hotel bookings;
|
|
1464
|
+
* names no other tool and tells the model nothing to do (listing.ts).
|
|
1465
|
+
*/
|
|
1466
|
+
export const SHOP_ORDERS_DESCRIPTION = 'The value-added service orders (增值服务订单) of the Otaless account signed in here: goods bought from the Otaless shop to go with a stay - not hotel bookings. 增值服务订单, 商城订单, shop orders and add-on orders are all the same thing. Each order comes with its item, total and currency, status, order id, the hotel booking it was bought with where that is known, and when it was ordered and paid where that is known (in UTC); cancelled ones are listed as the shop has them. It only reads: nothing is ordered, paid or cancelled. Nothing is listed when no account is signed in.';
|
|
1467
|
+
/** Said by the bookings list where the shop is on (0.84.1). */
|
|
1468
|
+
export const SHOP_ORDERS_IN_BOOKINGS = "Value-added service orders (增值服务订单 - the same as shop orders or add-on orders) are not hotel bookings: here each one shows under the hotel booking it was bought with, and one that matches none under other value-added service orders; the account's value-added service orders tool lists them all on their own, with their times.";
|
|
1439
1469
|
/** A guest's reason for a refund, as the group's staff are sent it (`otaless/booking.ts`). */
|
|
1440
1470
|
const REFUND_REASON_MAX = 200;
|
|
1441
1471
|
// The shape of each tool's `structuredContent`, so a reader knows what it is
|
|
@@ -1881,6 +1911,26 @@ const shopSchemas = (n) => ({
|
|
|
1881
1911
|
},
|
|
1882
1912
|
}
|
|
1883
1913
|
: {}),
|
|
1914
|
+
...(n.listShopOrders
|
|
1915
|
+
? {
|
|
1916
|
+
[n.listShopOrders]: {
|
|
1917
|
+
type: 'object',
|
|
1918
|
+
properties: {
|
|
1919
|
+
view: { enum: ['shop-orders', 'error'] },
|
|
1920
|
+
brand: STR,
|
|
1921
|
+
toolNames: OBJ,
|
|
1922
|
+
bookingMode: STR,
|
|
1923
|
+
shopOrders: ARR,
|
|
1924
|
+
count: { type: 'number' },
|
|
1925
|
+
counts: OBJ,
|
|
1926
|
+
timesNote: STR,
|
|
1927
|
+
error: STR,
|
|
1928
|
+
detail: STR,
|
|
1929
|
+
},
|
|
1930
|
+
required: ['view'],
|
|
1931
|
+
},
|
|
1932
|
+
}
|
|
1933
|
+
: {}),
|
|
1884
1934
|
...(n.buyShopItem
|
|
1885
1935
|
? {
|
|
1886
1936
|
[n.buyShopItem]: {
|
|
@@ -2556,10 +2606,174 @@ const bookingForCard = (b) => ({
|
|
|
2556
2606
|
...(b.payment.refundAmount
|
|
2557
2607
|
? { refundAmountText: formatMoney(b.payment.refundAmount) }
|
|
2558
2608
|
: {}),
|
|
2609
|
+
// The price shown, where what is paid or asked is not it (Otaless 0.84.2), as text.
|
|
2610
|
+
...(b.payment.quotedAs ? { quotedAs: formatMoney(b.payment.quotedAs) } : {}),
|
|
2559
2611
|
},
|
|
2560
2612
|
}
|
|
2561
2613
|
: {}),
|
|
2562
2614
|
});
|
|
2615
|
+
/**
|
|
2616
|
+
* What was paid here in advance on a booking being cancelled, and what
|
|
2617
|
+
* cancelling it now gives back - as facts for the card to say in the guest's
|
|
2618
|
+
* language (2026-10-21 re-audit, T2-2).
|
|
2619
|
+
*
|
|
2620
|
+
* ⚠️ WHY THE CARD NEEDS THEM. For a booking with terms as facts the card does
|
|
2621
|
+
* not show `rule`, and "paid ¥300, all of it goes back to the card" / "nothing
|
|
2622
|
+
* goes back, the fee is the whole stay" is only in `rule`: a guest who had
|
|
2623
|
+
* paid ¥300 saw "Cancelling would cost ¥300" on the screen where they decide,
|
|
2624
|
+
* and could read it as a second payment. `rule` stays for the model, word for
|
|
2625
|
+
* word; these are the same facts, as data. The shape is the booking's own
|
|
2626
|
+
* payment (`method`, `amount` as text) with what cancelling now does to it:
|
|
2627
|
+
* `refund` is `all`, `part` (and `refundAmount` says how much) or `none`.
|
|
2628
|
+
*
|
|
2629
|
+
* Only where money was paid HERE and the booking can be cancelled now: paid in
|
|
2630
|
+
* advance by card, or paid with UnionPay - which the hotel charged, and gives
|
|
2631
|
+
* back to that card, not through this connector. A booking paid at the hotel,
|
|
2632
|
+
* a demonstration's hold, a page not paid yet and a booking that cannot be
|
|
2633
|
+
* cancelled have none, and the card says nothing of money for them.
|
|
2634
|
+
*/
|
|
2635
|
+
/**
|
|
2636
|
+
* A cancellation preview as a string the guest's press must find again (0.84.2, P1-8 - the cancel page):
|
|
2637
|
+
* the fee and whether it is known, the terms, the reason, what was paid and what goes back. Anything of it
|
|
2638
|
+
* different at the press - a fee moved, the terms changed, the booking paid meanwhile - and nothing is
|
|
2639
|
+
* sent. In memory only, never shown.
|
|
2640
|
+
*/
|
|
2641
|
+
const cancelShapeOf = (preview, refundAsked, paid, booked) => JSON.stringify([
|
|
2642
|
+
preview.bookingId,
|
|
2643
|
+
preview.fee.minor,
|
|
2644
|
+
preview.fee.currency,
|
|
2645
|
+
preview.feeUnknown === true,
|
|
2646
|
+
preview.feeIsCap === true,
|
|
2647
|
+
preview.termsNew === true,
|
|
2648
|
+
preview.reason ?? '',
|
|
2649
|
+
preview.rule,
|
|
2650
|
+
preview.freeUntil ?? '',
|
|
2651
|
+
refundAsked?.amount ?? '',
|
|
2652
|
+
paid?.refund ?? '',
|
|
2653
|
+
paid?.refundAmount ?? '',
|
|
2654
|
+
booked?.payment?.status ?? '',
|
|
2655
|
+
]);
|
|
2656
|
+
/** What the cancel page shows (0.84.2, P1-8): the preview the tool made, as facts - `until` is the account's to set. */
|
|
2657
|
+
const cancelFactsOf = (deps, preview, booked, which, refundAsked, paid, shown, shape) => {
|
|
2658
|
+
const unpaid = preview.reason === 'unpaid';
|
|
2659
|
+
const stay = which.stay;
|
|
2660
|
+
return {
|
|
2661
|
+
booking: { id: preview.bookingId, code: preview.confirmationCode },
|
|
2662
|
+
...(which.hotelName ? { hotelName: which.hotelName } : {}),
|
|
2663
|
+
...(which.hotelNames && typeof which.hotelNames === 'object'
|
|
2664
|
+
? { hotelNames: which.hotelNames }
|
|
2665
|
+
: {}),
|
|
2666
|
+
...(stay ? { stay } : {}),
|
|
2667
|
+
group: holderOf(deps, preview.supplier).name,
|
|
2668
|
+
...(unpaid
|
|
2669
|
+
? { unpaid: true }
|
|
2670
|
+
: preview.feeUnknown
|
|
2671
|
+
? { feeUnknown: true }
|
|
2672
|
+
: {
|
|
2673
|
+
fee: formatMoney(preview.fee),
|
|
2674
|
+
...(preview.feeIsCap ? { feeIsCap: true } : {}),
|
|
2675
|
+
}),
|
|
2676
|
+
// ⚠️ THE GROUP'S OWN TERMS, AS IT GAVE THEM, only where `rule` is that (Otaless: a fee not known
|
|
2677
|
+
// before the group cancels, under terms it sent) - never our words for the model.
|
|
2678
|
+
...(preview.feeUnknown && !preview.termsNew && preview.rule
|
|
2679
|
+
? { groupTerms: preview.rule }
|
|
2680
|
+
: {}),
|
|
2681
|
+
...(preview.termsNew ? { termsNew: true } : {}),
|
|
2682
|
+
...(refundAsked ? { refundWithCancel: { amount: refundAsked.amount } } : {}),
|
|
2683
|
+
...(paid
|
|
2684
|
+
? {
|
|
2685
|
+
payment: {
|
|
2686
|
+
amount: paid.amount,
|
|
2687
|
+
refund: paid.refund,
|
|
2688
|
+
...(paid.refundAmount ? { refundAmount: paid.refundAmount } : {}),
|
|
2689
|
+
},
|
|
2690
|
+
}
|
|
2691
|
+
: {}),
|
|
2692
|
+
...(booked ? { bookingTotal: formatMoney(booked.quote.total) } : {}),
|
|
2693
|
+
...addOnRowsOf(shown),
|
|
2694
|
+
shape,
|
|
2695
|
+
until: '',
|
|
2696
|
+
};
|
|
2697
|
+
};
|
|
2698
|
+
/** The value-added service orders an answer carries (shop-answers.ts `addOnRow`), as the cancel page lists them. */
|
|
2699
|
+
const addOnRowsOf = (s) => {
|
|
2700
|
+
const rows = Array.isArray(s.addOnOrders)
|
|
2701
|
+
? s.addOnOrders.map((o) => ({
|
|
2702
|
+
name: String(o.name ?? ''),
|
|
2703
|
+
total: String(o.total ?? ''),
|
|
2704
|
+
fate: String(o.fate ?? ''),
|
|
2705
|
+
}))
|
|
2706
|
+
: [];
|
|
2707
|
+
return {
|
|
2708
|
+
...(rows.length ? { addOns: rows } : {}),
|
|
2709
|
+
...(s.addOnOrdersUnavailable === true ? { addOnsUnread: true } : {}),
|
|
2710
|
+
};
|
|
2711
|
+
};
|
|
2712
|
+
/** The refusals that leave a booking as it was - anything else the cancel answers with is not known. */
|
|
2713
|
+
const NOT_CANCELLED = new Set([
|
|
2714
|
+
'not-cancelled',
|
|
2715
|
+
'unconfirmed',
|
|
2716
|
+
'sign-in',
|
|
2717
|
+
'link-redo',
|
|
2718
|
+
'signed-out',
|
|
2719
|
+
'session-expired',
|
|
2720
|
+
]);
|
|
2721
|
+
/** How the cancel tool's answer came out, for the cancel page (0.84.2, P1-8). Anything not read is "not known". */
|
|
2722
|
+
const cancelOutcomeOf = (s) => {
|
|
2723
|
+
const view = s.view;
|
|
2724
|
+
if (view === 'cancellation-preview')
|
|
2725
|
+
return { outcome: 'changed' };
|
|
2726
|
+
if (view === 'booking-not-found')
|
|
2727
|
+
return { outcome: 'gone' };
|
|
2728
|
+
if (view === 'error')
|
|
2729
|
+
return NOT_CANCELLED.has(String(s.error)) ? { outcome: 'refused' } : { outcome: 'unknown' };
|
|
2730
|
+
if (view !== 'cancelled')
|
|
2731
|
+
return { outcome: 'unknown' };
|
|
2732
|
+
const b = (s.booking ?? {});
|
|
2733
|
+
const p = b.payment;
|
|
2734
|
+
const back = p?.refundAmountText ?? p?.amount ?? '';
|
|
2735
|
+
// ⚠️ NEVER "REFUNDED" OR "NOTHING CHARGED" ON A GUESS: a payment state not read here is "being checked".
|
|
2736
|
+
const money = !p
|
|
2737
|
+
? b.paymentUnknown
|
|
2738
|
+
? { kind: 'payment-unknown' }
|
|
2739
|
+
: undefined
|
|
2740
|
+
: p.status === 'refunding'
|
|
2741
|
+
? p.refundUnsure
|
|
2742
|
+
? { kind: 'refund-unsure' }
|
|
2743
|
+
: p.refundStuck
|
|
2744
|
+
? { kind: 'refund-stuck' }
|
|
2745
|
+
: p.groupReviews
|
|
2746
|
+
? { kind: 'refund-submitted', back }
|
|
2747
|
+
: { kind: 'refunding', back }
|
|
2748
|
+
: p.status === 'refunded'
|
|
2749
|
+
? { kind: 'refunded', back }
|
|
2750
|
+
: p.status === 'awaiting' || p.status === 'lapsed'
|
|
2751
|
+
? { kind: 'not-paid' }
|
|
2752
|
+
: p.status === 'paid'
|
|
2753
|
+
? { kind: 'paid-settling', amount: p.amount ?? '' }
|
|
2754
|
+
: { kind: 'payment-unknown' };
|
|
2755
|
+
return {
|
|
2756
|
+
outcome: 'cancelled',
|
|
2757
|
+
code: String(b.confirmationCode ?? ''),
|
|
2758
|
+
...(money ? { money } : {}),
|
|
2759
|
+
...(s.feeUnknown === true
|
|
2760
|
+
? { feeUnknown: true }
|
|
2761
|
+
: typeof s.fee === 'string'
|
|
2762
|
+
? { fee: s.fee }
|
|
2763
|
+
: {}),
|
|
2764
|
+
...addOnRowsOf(s),
|
|
2765
|
+
};
|
|
2766
|
+
};
|
|
2767
|
+
/**
|
|
2768
|
+
* ⚠️ THE GUEST'S PRESS ON THE ONE-TIME CANCEL PAGE (0.84.2, the 11-25 code audit's P1-8 - account/index.ts
|
|
2769
|
+
* `cancels`): the cancel tool's own confirmed cancel - the same 9, 9.1 and value-added service orders as
|
|
2770
|
+
* a card's button - for the conversation the link was made in, and only if the preview is still the one
|
|
2771
|
+
* the page showed (`facts.shape`). How it came out, for the page. Throws only what the tool throws.
|
|
2772
|
+
*/
|
|
2773
|
+
export const cancelOnPage = async (deps, key, facts) => {
|
|
2774
|
+
const said = await handleTool(deps, deps.tools.cancelBooking, { booking: facts.booking.id, confirmed: true }, { ...contextFor(deps, key), cancelPressed: facts.shape });
|
|
2775
|
+
return cancelOutcomeOf(said.structured);
|
|
2776
|
+
};
|
|
2563
2777
|
const paidFactsOf = (booked, preview) => {
|
|
2564
2778
|
const p = booked?.payment;
|
|
2565
2779
|
if (!p || p.status !== 'paid' || !preview.cancellable)
|
|
@@ -2685,11 +2899,21 @@ const paidLine = (deps, b, fee) => {
|
|
|
2685
2899
|
return b.status === 'confirmed'
|
|
2686
2900
|
? `${amount} paid with UnionPay, and booked with ${h.name}, who charges the one-time card UnionPay issued: nothing more is paid at the hotel.`
|
|
2687
2901
|
: `${amount} confirmed on UnionPay. ${h.name} has not confirmed the booking yet - ${deps.tools.listBookings} shows when it has; if it does not take it, the one-time card is not charged.`;
|
|
2902
|
+
// ⚠️ CHARGED WHEN IT WAS BOOKED, NO PAGE (Otaless 0.84.2, the 11-25 code audit's P0-1):
|
|
2903
|
+
// the group took it itself - from a wallet the guest has with it (questions #102) - and
|
|
2904
|
+
// that is said, never "nothing has been charged".
|
|
2905
|
+
if (p.chargedWhenBooked)
|
|
2906
|
+
return p.amountUnsaid
|
|
2907
|
+
? // ⚠️ NO AMOUNT SAID IS NOT ¥0, NOR THE PRICE (总线程's review of 0.84.2, 3).
|
|
2908
|
+
`${h.name} charged it when it was booked - there was no payment page - without saying how much; the price shown before booking was ${amount}, and a person here is checking what was charged. It is booked: nothing more is paid at the hotel.`
|
|
2909
|
+
: `${h.name} charged ${amount} for it when it was booked - there was no payment page to go through - and it is booked: nothing more is paid at the hotel.`;
|
|
2688
2910
|
return b.status === 'confirmed'
|
|
2689
2911
|
? `${amount} paid in advance by card, and booked with ${h.name}: nothing more is paid at the hotel.`
|
|
2690
2912
|
: `${amount} paid in advance by card. ${h.name} has not confirmed the booking yet - ${deps.tools.listBookings} shows when it has; if it does not take it, all ${amount} goes back.`;
|
|
2691
2913
|
case 'lapsed':
|
|
2692
|
-
return
|
|
2914
|
+
return p.cancelledUnpaid
|
|
2915
|
+
? 'Cancelled before it was paid: nothing was booked and nothing was charged.'
|
|
2916
|
+
: 'Not paid in time: nothing was booked and nothing was charged.';
|
|
2693
2917
|
case 'refunding':
|
|
2694
2918
|
return (groupRefundWords(p, h.name, back, whole, amount) ??
|
|
2695
2919
|
(p.refundStuck
|
|
@@ -2701,7 +2925,20 @@ const paidLine = (deps, b, fee) => {
|
|
|
2701
2925
|
return `The money is with ${h.name}, who returns what its terms give back to the card it charged - nothing is refunded from here.`;
|
|
2702
2926
|
}
|
|
2703
2927
|
})();
|
|
2704
|
-
return `${said}${test}`;
|
|
2928
|
+
return `${said}${shownPriceSaid(p, h.name, ended)}${test}`;
|
|
2929
|
+
};
|
|
2930
|
+
/**
|
|
2931
|
+
* ⚠️ WHAT IS CHARGED, WHERE IT IS NOT THE PRICE SHOWN (Otaless 0.84.2, the 11-25 code audit's P0-2
|
|
2932
|
+
* and P1-4): the group's USD figure - or its own amount, its prices not checked - beside the price
|
|
2933
|
+
* the guest agreed to, so the guest is always told what was charged, or is to be, in its currency.
|
|
2934
|
+
*/
|
|
2935
|
+
const shownPriceSaid = (p, group, ended) => {
|
|
2936
|
+
const shown = p.quotedAs;
|
|
2937
|
+
if (!shown || ended || (p.status !== 'paid' && p.status !== 'awaiting'))
|
|
2938
|
+
return '';
|
|
2939
|
+
const other = shown.currency !== p.amount.currency;
|
|
2940
|
+
const what = p.status === 'paid' ? 'was charged' : 'is what the payment page asks';
|
|
2941
|
+
return ` ${formatMoney(p.amount)} ${what} - ${other ? `${group}'s own figure in ${p.amount.currency}` : `${group}'s own amount`}; the price shown before booking was ${formatMoney(shown)}.`;
|
|
2705
2942
|
};
|
|
2706
2943
|
/**
|
|
2707
2944
|
* A stay sent to the hotel's own system whose answer is not in yet: being
|
|
@@ -2718,8 +2955,30 @@ const madeForCard = (deps, b) => {
|
|
|
2718
2955
|
const { confirmationCode: _unconfirmed, ...rest } = card;
|
|
2719
2956
|
return { ...rest, pending: true };
|
|
2720
2957
|
};
|
|
2958
|
+
/**
|
|
2959
|
+
* ⚠️ WHAT IS NOT AS THE GUEST CHOSE, SAID (Otaless 0.84.2, 总线程's re-review): 8 answered PAID or
|
|
2960
|
+
* CONFIRMED (no page) for an order whose guests, terms or amount are not the ones chosen - kept, a
|
|
2961
|
+
* person checking it with the group. Never a plain "confirmed".
|
|
2962
|
+
*/
|
|
2963
|
+
export const differsSaid = (deps, b) => {
|
|
2964
|
+
const d = b.differs;
|
|
2965
|
+
if (!d?.length)
|
|
2966
|
+
return '';
|
|
2967
|
+
const words = {
|
|
2968
|
+
guests: 'the number of guests',
|
|
2969
|
+
terms: 'the cancellation terms',
|
|
2970
|
+
amount: 'the amount',
|
|
2971
|
+
'amount-unsaid': 'the amount (it did not say one)',
|
|
2972
|
+
step: 'a further step it asks for',
|
|
2973
|
+
};
|
|
2974
|
+
const items = d.map((x) => words[x] ?? x);
|
|
2975
|
+
const list = items.length > 1 ? `${items.slice(0, -1).join(', ')} and ${items.at(-1)}` : (items[0] ?? '');
|
|
2976
|
+
const g = holderOf(deps, b.supplier).name;
|
|
2977
|
+
return `${g} confirmed this booking, but ${list} ${items.length > 1 ? 'are' : 'is'} not what the guest chose: a person here is checking it with ${g}. If the guest does not want it as it is, it can be cancelled.`;
|
|
2978
|
+
};
|
|
2721
2979
|
const bookedLine = (deps, b) => [
|
|
2722
2980
|
unconfirmedSaid(deps, b),
|
|
2981
|
+
differsSaid(deps, b),
|
|
2723
2982
|
heldLine(deps, b),
|
|
2724
2983
|
// The group's own number, where the booking has one (0.77.6).
|
|
2725
2984
|
b.orderNumber ? `Order number ${b.orderNumber}.` : '',
|
|
@@ -2766,9 +3025,20 @@ const heldLine = (deps, b) => {
|
|
|
2766
3025
|
? `${total} all in, to be paid at the hotel. ${h.name} has not confirmed this booking yet - that takes up to eight minutes, and ${deps.tools.listBookings} shows when it has. Nothing has been charged.`
|
|
2767
3026
|
: `${total} all in, paid at the hotel. **Nothing has been charged here** - this is ${h.name}'s own reservation, kept until it is cancelled, and the guest pays at check-in.`;
|
|
2768
3027
|
}
|
|
3028
|
+
// ⚠️ CONFIRMED WITH NO PAYMENT PAGE, ITS PAYMENT NOT KNOWN (Otaless 0.84.2, P0-1): never
|
|
3029
|
+
// "nothing has been charged" - the group may have charged a wallet the guest has with it.
|
|
3030
|
+
if (b.paymentUnknown)
|
|
3031
|
+
return paymentUnknownWords(deps, b, h.name);
|
|
2769
3032
|
const lapses = b.holdUntilLocal
|
|
2770
3033
|
? `${b.holdUntilLocal} hotel time`
|
|
2771
3034
|
: `${b.holdUntil?.slice(0, 16).replace('T', ' ')} UTC`;
|
|
3035
|
+
// ⚠️ NO TIME IS NO "UNTIL undefined UTC" (0.84.2, P0-1): said without one. ⚠️ "HAS THE BOOKING"
|
|
3036
|
+
// ONLY WHEN IT IS CONFIRMED (总线程's review of 0.84.2, 1): one 8 did not answer for - or answered a
|
|
3037
|
+
// server error - is not known to be made; said as that, never as made and never "nothing charged".
|
|
3038
|
+
if (!b.holdUntilLocal && !b.holdUntil)
|
|
3039
|
+
return b.status === 'confirmed'
|
|
3040
|
+
? `${total} all in. ${h.name} has the booking; ${deps.tools.listBookings} shows where its payment stands.`
|
|
3041
|
+
: `${total} all in. Whether ${h.name} took it - and whether anything was charged for it - is not known yet: ${deps.tools.listBookings} shows once it is. Do not book it again meanwhile, and do not say nothing was charged.`;
|
|
2772
3042
|
// ⚠️ NOT "PRESENTS A CARD AT CHECK-IN" (2026-10-05 audit, P2): a demo
|
|
2773
3043
|
// booking has no check-in, and saying so sent a guest towards a real desk.
|
|
2774
3044
|
//
|
|
@@ -2781,6 +3051,16 @@ const heldLine = (deps, b) => {
|
|
|
2781
3051
|
return `${total} all in. **${demoBookingWords(h)}** Nothing has been charged and no card is needed. ${demoHoldWords(b, deps.trips.now())} ${notSentSaid(h.name)}`;
|
|
2782
3052
|
return `${total} all in. **Nothing has been charged** - the rooms are held until ${lapses}, and the guest presents a card at check-in.`;
|
|
2783
3053
|
};
|
|
3054
|
+
/**
|
|
3055
|
+
* A booking the group confirmed with no payment page, whether it was charged not known yet
|
|
3056
|
+
* (Otaless 0.84.2, the 11-25 code audit's P0-1) - made, listed or cancelled.
|
|
3057
|
+
*/
|
|
3058
|
+
export const paymentUnknownWords = (deps, b, group) => {
|
|
3059
|
+
const total = formatMoney(b.quote.total);
|
|
3060
|
+
return b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed'
|
|
3061
|
+
? `${group} had confirmed it without a payment page, and whether it charged it (to a wallet or card the guest has with ${group}) is still not known - if it did, a person here takes up its refund with ${group}. Do not say nothing was charged.`
|
|
3062
|
+
: `${total} all in. ${group} confirmed it without a payment page, and whether it has charged it already (to a wallet or card the guest has with ${group}) is being checked - there is nothing to pay here now, and ${deps.tools.listBookings} shows once it is known. Do not say nothing was charged.`;
|
|
3063
|
+
};
|
|
2784
3064
|
/**
|
|
2785
3065
|
* How long a demonstration hold lasts, as "in N minutes" from now - the hold
|
|
2786
3066
|
* lapses by itself, and says nothing about the stay (T2, `heldLine`).
|
|
@@ -4121,6 +4401,9 @@ const paymentWords = (b) => {
|
|
|
4121
4401
|
p.refundAmount &&
|
|
4122
4402
|
p.refundAmount.minor !== p.amount.minor)
|
|
4123
4403
|
return `${formatMoney(p.refundAmount)} of ${formatMoney(p.amount)} ${p.status === 'refunded' ? 'refunded' : 'going back'} - the rest was the fee`;
|
|
4404
|
+
// ⚠️ CANCELLED BEFORE IT WAS PAID IS NOT "NOT PAID IN TIME" (Otaless 0.84.2, the UI review's P2-2).
|
|
4405
|
+
if (p.status === 'lapsed' && p.cancelledUnpaid)
|
|
4406
|
+
return 'cancelled before it was paid - nothing booked or charged';
|
|
4124
4407
|
return ((p.method === 'unionpay' ? UNIONPAY_WORDS[p.status] : undefined) ?? PAYMENT_WORDS[p.status]);
|
|
4125
4408
|
};
|
|
4126
4409
|
/**
|
|
@@ -4254,8 +4537,9 @@ const notPaidWords = (b) => !b.paymentNotConnected
|
|
|
4254
4537
|
/**
|
|
4255
4538
|
* ⚠️ VALUE-ADDED SERVICES (增值服务), SAID WHERE A BOOKING IS DONE (0.84.0, robin 11-24: 「应该在订单完成的
|
|
4256
4539
|
* 时候就可以购买,而不是要去我的预订买」). Only where the deployment sells them (`/claude`: the shop with
|
|
4257
|
-
* buying open), only for a booking of this account that can still take them
|
|
4258
|
-
*
|
|
4540
|
+
* buying open), only for a booking of this account that can still take them - confirmed: a booking still
|
|
4541
|
+
* waiting for its room payment is paid first, in the bookings list too (0.84.2, the 11-25 UI review's
|
|
4542
|
+
* P2-1 - `canAdd` takes confirmed bookings alone; it had offered them for one awaiting payment). The next
|
|
4259
4543
|
* step in words, tool names and what each takes, so a client that draws no card can go on; a card
|
|
4260
4544
|
* client is told the card shows them under the booking. ⚠️ NOTHING IS BOUGHT BY THE ASSISTANT: the buy
|
|
4261
4545
|
* tool prepares a page the guest confirms on.
|
|
@@ -4572,6 +4856,8 @@ const termsAnswer = (deps, ctx, key, terms) => {
|
|
|
4572
4856
|
rooms: x.rooms,
|
|
4573
4857
|
total: formatMoney(x.total),
|
|
4574
4858
|
totalMoney: x.total,
|
|
4859
|
+
// What the payment may be taken in, as the backend gave it (0.84.2, P1-4).
|
|
4860
|
+
...(x.payAs ? { payAs: formatMoney(x.payAs) } : {}),
|
|
4575
4861
|
// ⚠️ THE MOMENT ONLY (0.63.0 screenshots): the card writes it in the viewer's own
|
|
4576
4862
|
// language and time zone. "10:05 UTC, 10 Nov" here was drawn as is in a
|
|
4577
4863
|
// Chinese card - and it is not the hotel's clock anyway (no zone is sent).
|
|
@@ -4599,6 +4885,11 @@ const termsAnswer = (deps, ctx, key, terms) => {
|
|
|
4599
4885
|
return [
|
|
4600
4886
|
`${withZh(x.hotelName, x.hotelNames, ctx.noCards)} · ${x.roomName} · ${stayWords(x.stay)} · ${x.rooms} ${x.rooms === 1 ? 'room' : 'rooms'} · ${formatMoney(x.total)} · ${x.groupName}${code ? ` · order ${code}` : ''}`,
|
|
4601
4887
|
x.source === 'none' ? `${x.groupName} gave no cancellation terms for this room.` : '',
|
|
4888
|
+
// ⚠️ SAID BEFORE THE GUEST AGREES (0.84.2, the 11-25 code audit's P1-4; 总线程 11-25): the
|
|
4889
|
+
// group's page may ask its own USD figure for this price - as the backend gave it.
|
|
4890
|
+
x.payAs
|
|
4891
|
+
? `${x.groupName}'s payment page may ask ${formatMoney(x.payAs)} for it - ${x.groupName}'s own figure in ${x.payAs.currency} for this price, not converted here; tell the guest before they agree.`
|
|
4892
|
+
: '',
|
|
4602
4893
|
x.changed
|
|
4603
4894
|
? `They can be agreed to until ${until}; not agreed by then, the order is cancelled.`
|
|
4604
4895
|
: heldOrder
|
|
@@ -4643,6 +4934,7 @@ const termsAnswer = (deps, ctx, key, terms) => {
|
|
|
4643
4934
|
rooms: x.rooms,
|
|
4644
4935
|
total: formatMoney(x.total),
|
|
4645
4936
|
totalMoney: x.total,
|
|
4937
|
+
...(x.payAs ? { payAs: formatMoney(x.payAs) } : {}),
|
|
4646
4938
|
text: x.text,
|
|
4647
4939
|
until: x.until,
|
|
4648
4940
|
})),
|
|
@@ -4686,9 +4978,14 @@ const bookingLine = (deps, b, noCards) => {
|
|
|
4686
4978
|
b.payment.method === 'card' &&
|
|
4687
4979
|
deps.backend.otalessBooking
|
|
4688
4980
|
? ` · ${b.termsChanged || b.confirmAsked ? termsHeldWords(deps, b) : LINK_CLOSED_WORDS}`
|
|
4689
|
-
: ` · ${paymentWords(b)}`
|
|
4690
|
-
:
|
|
4981
|
+
: ` · ${paymentWords(b)}${shownPriceSaid(b.payment, holderOf(deps, b.supplier).name, b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed').replace(/^ /, ' - ')}`
|
|
4982
|
+
: // ⚠️ CONFIRMED WITH NO PAGE, ITS PAYMENT NOT KNOWN (Otaless 0.84.2, P0-1).
|
|
4983
|
+
b.paymentUnknown
|
|
4984
|
+
? ` · ${b.status === 'cancelled' ? 'cancelled - whether it had been charged is still not known; a person here follows it up' : 'whether it has been charged (to a wallet or card at the group) is being checked - nothing to pay here now'}`
|
|
4985
|
+
: '',
|
|
4691
4986
|
bookingNotes(deps, b) ? ` · ${bookingNotes(deps, b)}` : '',
|
|
4987
|
+
// 0.84.2 (总线程's re-review): what is not as chosen.
|
|
4988
|
+
differsSaid(deps, b) ? ` · ${differsSaid(deps, b)}` : '',
|
|
4692
4989
|
].join('');
|
|
4693
4990
|
};
|
|
4694
4991
|
/**
|
|
@@ -5905,19 +6202,14 @@ export const tripRenewed = (deps, o = {
|
|
|
5905
6202
|
signedIn: false,
|
|
5906
6203
|
}) => {
|
|
5907
6204
|
const t = deps.tools;
|
|
5908
|
-
const again = t.listHotels
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
: o.pressed === 'book'
|
|
5917
|
-
? `This card was drawn before the guest signed in. ${older} Nothing was booked. To go on booking, draw the trip or the hotels again on a new card${[t.viewTrip, t.listHotels].filter(Boolean).length
|
|
5918
|
-
? ` (${[t.viewTrip, t.listHotels].filter(Boolean).join(', ')})`
|
|
5919
|
-
: ''}.`
|
|
5920
|
-
: `This card was drawn before the guest signed in. ${older} Tell the guest to use the newest card${again}.`;
|
|
6205
|
+
const again = t.listHotels ? ` or draw the hotels again (${t.listHotels})` : '';
|
|
6206
|
+
// ⚠️ WHAT HAPPENED, AS IT HAPPENED (总线程 11-25): never "signed in somewhere else", never "already
|
|
6207
|
+
// signed in" unchecked. The way on is the card's own sign-in (the same account goes back to this
|
|
6208
|
+
// conversation - server.ts `rejoins`).
|
|
6209
|
+
const happened = o.why === 'sign-out'
|
|
6210
|
+
? 'This card was drawn before this conversation signed out, so it can no longer act on its trip'
|
|
6211
|
+
: 'This card was drawn before this conversation signed in, and its trip moved on with the sign-in, so this card can no longer act on it';
|
|
6212
|
+
const detail = `${happened} - nothing was lost, booked or changed by the press.${o.pressed === 'book' ? ' Nothing was booked.' : ''} The guest can sign in on this card to carry on with it (signed in as the same account, it is back on this conversation)${again}.`;
|
|
5921
6213
|
return {
|
|
5922
6214
|
structured: {
|
|
5923
6215
|
view: 'error',
|
|
@@ -5925,7 +6217,7 @@ export const tripRenewed = (deps, o = {
|
|
|
5925
6217
|
error: 'trip-gone',
|
|
5926
6218
|
renewed: true,
|
|
5927
6219
|
renewedFor: o.pressed,
|
|
5928
|
-
|
|
6220
|
+
renewedWhy: o.why ?? 'sign-in',
|
|
5929
6221
|
detail,
|
|
5930
6222
|
},
|
|
5931
6223
|
text: detail,
|
|
@@ -9062,6 +9354,24 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9062
9354
|
});
|
|
9063
9355
|
return listAnswer(base, found, { ...(query ? { query } : {}), ...(category ? { category } : {}), maxPrice }, shop.buyOpen, deps.shopLink);
|
|
9064
9356
|
}
|
|
9357
|
+
// ⚠️ THE ACCOUNT'S VALUE-ADDED SERVICE ORDERS ON THEIR OWN (0.84.1, robin 11-25: 「首选把我酒店预订订单先
|
|
9358
|
+
// 出来,然后没有时间」). A read: every order as the shop lists it, with what is known of its booking
|
|
9359
|
+
// and times (shop-service.ts adds this server's own note of an order bought here) - and the card's page.
|
|
9360
|
+
if (t.listShopOrders && name === t.listShopOrders) {
|
|
9361
|
+
const shop = deps.backend.otalessShop;
|
|
9362
|
+
const base = common(deps, key);
|
|
9363
|
+
if (!shop)
|
|
9364
|
+
return {
|
|
9365
|
+
structured: { view: 'error', ...base, error: 'not-offered' },
|
|
9366
|
+
text: `There is no shop through ${deps.vocab.brand}.`,
|
|
9367
|
+
isError: true,
|
|
9368
|
+
};
|
|
9369
|
+
const who = identity(deps, ctx, key, args);
|
|
9370
|
+
return shopOrdersAnswer(base, await shop.orders(who, deps.lang === 'zh' ? 'zh' : 'en'), {
|
|
9371
|
+
...(deps.groupSignIn?.signInTool ? { signIn: deps.groupSignIn.signInTool } : {}),
|
|
9372
|
+
...(deps.shopLink ? { shopLink: deps.shopLink } : {}),
|
|
9373
|
+
});
|
|
9374
|
+
}
|
|
9065
9375
|
// ⚠️ NEVER BUYS (0.82.0): it checks the item, the booking and the price the guest was shown, and
|
|
9066
9376
|
// PREPARES a one-time confirm page. The purchase is the guest's press on that page.
|
|
9067
9377
|
if (t.buyShopItem && name === t.buyShopItem) {
|
|
@@ -9253,8 +9563,12 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9253
9563
|
// ⚠️ ADD-ONS (0.82.0): only where `addons` or the shop is on, and only for a live booking of this account.
|
|
9254
9564
|
const addonsApi = deps.backend.otalessAddons;
|
|
9255
9565
|
const addable = addonsApi ? bookings.filter((b) => addonsApi.canAdd(b)) : [];
|
|
9566
|
+
// 0.84.1 (robin 11-25): each value-added service order under the booking it was bought with; one
|
|
9567
|
+
// that matches none of these under "other" - never forced under a booking.
|
|
9568
|
+
// 0.84.2 (P1-1): an open order whose booking has ended is said so, its payment page held back - the
|
|
9569
|
+
// bookings read here are not looked up again.
|
|
9256
9570
|
const shopPart = shopApi && !code
|
|
9257
|
-
? ordersPart(await shopApi.orders(who, deps.lang === 'zh' ? 'zh' : 'en'), deps.shopLink)
|
|
9571
|
+
? ordersPart(await shopApi.orders(who, deps.lang === 'zh' ? 'zh' : 'en', bookings), deps.shopLink, bookings.map((b) => b.confirmationCode))
|
|
9258
9572
|
: undefined;
|
|
9259
9573
|
return {
|
|
9260
9574
|
structured: {
|
|
@@ -9276,7 +9590,11 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9276
9590
|
text: [
|
|
9277
9591
|
missed ? missLine : '',
|
|
9278
9592
|
bookings.length
|
|
9279
|
-
? bookings
|
|
9593
|
+
? bookings
|
|
9594
|
+
.map((b) => [bookingLine(deps, b, ctx.noCards), shopPart?.under.get(b.confirmationCode) ?? '']
|
|
9595
|
+
.filter(Boolean)
|
|
9596
|
+
.join('\n'))
|
|
9597
|
+
.join('\n')
|
|
9280
9598
|
: code
|
|
9281
9599
|
? ''
|
|
9282
9600
|
: // ⚠️ NOT "NO BOOKINGS" when a group did not answer: it may hold them.
|
|
@@ -9626,6 +9944,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9626
9944
|
// whole amount, nothing comes back" - and confirmed, 9.1 was sent. Then `refundWithCancel`
|
|
9627
9945
|
// says the money, and the facts of a fee kept are not sent.
|
|
9628
9946
|
const paid = preview.feeUnknown || refundAsked ? undefined : paidFactsOf(booked, preview);
|
|
9947
|
+
const sayTheWord = `Say the word and it is cancelled (${t.cancelBooking} with \`confirmed\`).`;
|
|
9629
9948
|
const asPreview = {
|
|
9630
9949
|
structured: {
|
|
9631
9950
|
view: 'cancellation-preview',
|
|
@@ -9637,7 +9956,13 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9637
9956
|
// Each room's terms as they stand now: free while its own free
|
|
9638
9957
|
// time lasts (the backend's \`freeUntil\` is the earliest of those
|
|
9639
9958
|
// still running), non-refundable, or past it and charged.
|
|
9640
|
-
|
|
9959
|
+
// ⚠️ NO GUESS WHERE THE FEE IS NOT KNOWN (0.84.2, the 11-25 UI review's P1-2): a paid
|
|
9960
|
+
// Otaless booking (`feeUnknown`, no `freeUntil`) fell to "charged" - 「已过免费取消时间」 -
|
|
9961
|
+
// for a stay months away, under "what cancelling costs is what the group says". Only a
|
|
9962
|
+
// rate that is non-refundable says so; the others say nothing of a free time here.
|
|
9963
|
+
terms: rooms
|
|
9964
|
+
.filter((l) => !preview.feeUnknown || l.refundable === false)
|
|
9965
|
+
.map((l) => ({
|
|
9641
9966
|
room: l.title,
|
|
9642
9967
|
...(l.titleNames ? { roomNames: l.titleNames } : {}),
|
|
9643
9968
|
state: l.refundable === false
|
|
@@ -9715,9 +10040,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9715
10040
|
refundAsked
|
|
9716
10041
|
? `It was paid (${refundAsked.amount}): cancelling it also asks ${holderOf(deps, preview.supplier).name} for all of that back, in the same step - ${holderOf(deps, preview.supplier).name} reviews it and returns it to the card it was paid with.`
|
|
9717
10042
|
: '',
|
|
9718
|
-
preview.cancellable
|
|
9719
|
-
? `Say the word and it is cancelled (${t.cancelBooking} with \`confirmed\`).`
|
|
9720
|
-
: '',
|
|
10043
|
+
preview.cancellable ? sayTheWord : '',
|
|
9721
10044
|
demoBookingNote(deps, preview.supplier),
|
|
9722
10045
|
]
|
|
9723
10046
|
.filter(Boolean)
|
|
@@ -9730,12 +10053,67 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9730
10053
|
const shownKey = `${key}|cancel|${preview.bookingId}`;
|
|
9731
10054
|
const wasShown = previewsOf(deps).get(shownKey);
|
|
9732
10055
|
remember(deps, shownKey, preview.fee.minor);
|
|
10056
|
+
// ⚠️ THE VALUE-ADDED SERVICE ORDERS BOUGHT WITH IT (0.84.2, the 11-25 UI review's P1-1), where the shop
|
|
10057
|
+
// is on (never root): read fresh and said beside the preview - one awaiting payment is cancelled with
|
|
10058
|
+
// the booking, one paid is NOT refunded by it (its refund is offered), and orders not read are said
|
|
10059
|
+
// as that. A booking that cannot be cancelled yet says nothing of them; one no longer active does.
|
|
10060
|
+
const addOnsOf = { confirmationCode: preview.confirmationCode, id: preview.bookingId };
|
|
10061
|
+
const withAddOns = async (said) => {
|
|
10062
|
+
if (!shopApi || !(preview.cancellable || preview.reason === 'not-active'))
|
|
10063
|
+
return said;
|
|
10064
|
+
const part = addOnsCancelPreview(await shopApi.withBooking(who, addOnsOf, shopLang), preview.confirmationCode, preview.cancellable, { preview: t.previewCancellation }, deps.shopLink);
|
|
10065
|
+
return part
|
|
10066
|
+
? {
|
|
10067
|
+
...said,
|
|
10068
|
+
structured: { ...said.structured, ...part.structured },
|
|
10069
|
+
text: [said.text, part.text].join('\n'),
|
|
10070
|
+
}
|
|
10071
|
+
: said;
|
|
10072
|
+
};
|
|
9733
10073
|
if (name === t.previewCancellation || args.confirmed !== true)
|
|
9734
|
-
return asPreview;
|
|
10074
|
+
return withAddOns(asPreview);
|
|
9735
10075
|
if (!preview.cancellable)
|
|
9736
|
-
return asPreview;
|
|
9737
|
-
|
|
10076
|
+
return withAddOns(asPreview);
|
|
10077
|
+
// ⚠️ ON A CLIENT THAT DRAWS NO CARD, THE GUEST'S OWN PRESS IN THEIR SIGNED-IN BROWSER (0.84.2, the 11-25
|
|
10078
|
+
// code audit's P1-8, option C ④ - `account.cancelOnPage`, `deps.cancelLink`): the model's `confirmed`
|
|
10079
|
+
// cancels nothing there - whoever holds the conversation's trip id can say it. It answers with a
|
|
10080
|
+
// one-time page that shows this preview and one button; the press there comes back here
|
|
10081
|
+
// (`ctx.cancelPressed`: the preview the page showed) and cancels only if the preview is still that.
|
|
10082
|
+
// A card's own button is the guest's press, as before; with the switch off none of this exists.
|
|
10083
|
+
const shape = cancelShapeOf(preview, refundAsked, paid, booked);
|
|
10084
|
+
if (ctx.cancelPressed !== undefined) {
|
|
10085
|
+
if (ctx.cancelPressed !== shape)
|
|
10086
|
+
return withAddOns({
|
|
10087
|
+
...asPreview,
|
|
10088
|
+
structured: { ...asPreview.structured, changedSincePage: true },
|
|
10089
|
+
text: `Nothing was cancelled: what cancelling ${preview.confirmationCode} does has changed since the page showed it. ${asPreview.text}`,
|
|
10090
|
+
});
|
|
10091
|
+
}
|
|
10092
|
+
else if (deps.cancelLink && ctx.noCards) {
|
|
10093
|
+
const shown = await withAddOns(asPreview);
|
|
10094
|
+
const link = deps.cancelLink(key, cancelFactsOf(deps, preview, booked, which, refundAsked, paid, shown.structured, shape));
|
|
10095
|
+
if (!link)
|
|
10096
|
+
return {
|
|
10097
|
+
structured: { view: 'error', ...common(deps, key), error: 'no-cancel-page' },
|
|
10098
|
+
text: `Nothing was cancelled: a one-time page for the guest to cancel ${preview.confirmationCode} on could not be made (they must be signed in to their account here, and not have asked for too many links at once). On this app a booking is cancelled only by the guest's own press on that page - never by your word.`,
|
|
10099
|
+
isError: true,
|
|
10100
|
+
};
|
|
10101
|
+
const { toolToConfirm: _byWord, ...facts } = shown.structured;
|
|
10102
|
+
const until = clockWords(link.expiresAt) ?? link.expiresAt;
|
|
9738
10103
|
return {
|
|
10104
|
+
structured: {
|
|
10105
|
+
...facts,
|
|
10106
|
+
cancelPage: { url: link.url, host: hostOf(link.url), expiresAt: link.expiresAt },
|
|
10107
|
+
},
|
|
10108
|
+
text: [
|
|
10109
|
+
`Nothing is cancelled yet: here a booking is cancelled by the guest's own press, on a one-time page in their own browser - not by your word. Give the guest this page to cancel ${preview.confirmationCode} on: ${link.url} - ${inBrowserWords(deps, ctx) ? `it works once, and is good until ${until}. ${OPENS_SIGNED_IN} ${GUEST_ALONE}` : `it opens only in the browser signed in to their account, works once, and is good until ${until}.`}`,
|
|
10110
|
+
`The page shows what cancelling does - what follows - and one button; ${preview.confirmationCode} is cancelled only when the guest presses it there, and the page shows how it came out. Never say it is cancelled until ${t.listBookings} shows it.`,
|
|
10111
|
+
shown.text.replace(` ${sayTheWord}`, '').replace(sayTheWord, ''),
|
|
10112
|
+
].join(' '),
|
|
10113
|
+
};
|
|
10114
|
+
}
|
|
10115
|
+
else if (wasShown === undefined || wasShown !== preview.fee.minor) {
|
|
10116
|
+
return withAddOns({
|
|
9739
10117
|
...asPreview,
|
|
9740
10118
|
text: [
|
|
9741
10119
|
wasShown === undefined
|
|
@@ -9743,11 +10121,39 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9743
10121
|
: `The fee has changed since it was shown - it is now ${formatMoney(preview.fee)}. Nothing is cancelled yet.`,
|
|
9744
10122
|
asPreview.text,
|
|
9745
10123
|
].join(' '),
|
|
9746
|
-
};
|
|
10124
|
+
});
|
|
9747
10125
|
}
|
|
9748
10126
|
const cancelled = await deps.backend.cancelBooking(ref, who, str(args.reason) || undefined);
|
|
9749
10127
|
if (!cancelled)
|
|
9750
10128
|
return asPreview;
|
|
10129
|
+
// ⚠️ …AND ONCE IT IS CANCELLED (0.84.2, P1-1): each of its orders still awaiting payment is cancelled
|
|
10130
|
+
// at the shop - read fresh, its payment asked again: one paid meanwhile is NOT refunded and nothing is
|
|
10131
|
+
// sent for it (shop-service.ts `cancelWithBooking`). A paid one's refund is offered, never asked: it
|
|
10132
|
+
// is the guest's own yes on its own preview. No money moves back on the booking's yes. Only for a
|
|
10133
|
+
// booking the backend answered as ended: one it did not is not "cancelled" here, and nothing is sent.
|
|
10134
|
+
let addOnsDone;
|
|
10135
|
+
if (shopApi && BOOKING_ENDED.has(cancelled.status)) {
|
|
10136
|
+
const open = await shopApi.withBooking(who, addOnsOf, shopLang);
|
|
10137
|
+
const done = [];
|
|
10138
|
+
if (open.ok)
|
|
10139
|
+
for (const ord of open.orders) {
|
|
10140
|
+
if (ord.status !== 'awaiting-payment') {
|
|
10141
|
+
done.push({ order: ord, fate: 'refund-offered' });
|
|
10142
|
+
continue;
|
|
10143
|
+
}
|
|
10144
|
+
const c = await shopApi.cancelWithBooking(who, ord.id, shopLang);
|
|
10145
|
+
done.push(c.outcome === 'cancelled'
|
|
10146
|
+
? { order: c.order, fate: 'cancelled' }
|
|
10147
|
+
: c.outcome === 'paid'
|
|
10148
|
+
? { order: c.order, fate: 'refund-offered' }
|
|
10149
|
+
: c.outcome === 'unknown'
|
|
10150
|
+
? { order: c.order ?? ord, fate: 'not-known' }
|
|
10151
|
+
: c.order?.status === 'cancelled'
|
|
10152
|
+
? { order: c.order, fate: 'cancelled' }
|
|
10153
|
+
: { order: c.order ?? ord, fate: 'not-cancelled' });
|
|
10154
|
+
}
|
|
10155
|
+
addOnsDone = addOnsCancelResult(open, done, cancelled.confirmationCode || preview.confirmationCode, { preview: t.previewCancellation }, deps.shopLink);
|
|
10156
|
+
}
|
|
9751
10157
|
// A coupon handed back is back on the member's badge.
|
|
9752
10158
|
await refreshMember(deps, key);
|
|
9753
10159
|
// ⚠️ WHAT THE HOTEL SAYS IT CHARGED, once it has said. A group's own system
|
|
@@ -9791,25 +10197,29 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9791
10197
|
rule: preview.rule,
|
|
9792
10198
|
cancellable: false,
|
|
9793
10199
|
...(couponNow ? { coupon: couponNow } : {}),
|
|
10200
|
+
...(addOnsDone?.structured ?? {}),
|
|
9794
10201
|
},
|
|
9795
10202
|
text: [
|
|
9796
10203
|
cancelled.payment
|
|
9797
10204
|
? // Paid here in advance: what becomes of the money is the answer.
|
|
9798
10205
|
`${cancelled.confirmationCode} is ${cancelled.status === 'expired' ? 'called off before it was paid' : 'cancelled'}. ${paidLine(deps, cancelled, feeUnsaid ? undefined : charged)}`
|
|
9799
|
-
:
|
|
9800
|
-
? `${cancelled.confirmationCode} is cancelled. ${h.name}
|
|
9801
|
-
:
|
|
9802
|
-
?
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
:
|
|
10206
|
+
: cancelled.paymentUnknown
|
|
10207
|
+
? `${cancelled.confirmationCode} is cancelled. ${paymentUnknownWords(deps, cancelled, h.name)}`
|
|
10208
|
+
: feeUnsaid
|
|
10209
|
+
? `${cancelled.confirmationCode} is cancelled. ${h.name} charges whatever its own terms say; the amount is not known here.`
|
|
10210
|
+
: h.notReal
|
|
10211
|
+
? // The fact, in no environment's word (robin, 2026-11-03); nobody charges
|
|
10212
|
+
// a booking that was never sent anything (2026-10-05 audit, P2).
|
|
10213
|
+
`${cancelled.confirmationCode} is cancelled. ${charged.minor === 0 ? 'No fee.' : `A real booking on this rate would be charged ${formatMoney(charged)}; this booking was never sent to ${h.name}, and nothing is charged.`}`
|
|
10214
|
+
: h.test
|
|
10215
|
+
? `${cancelled.confirmationCode} is cancelled. ${charged.minor === 0 ? 'No fee.' : `A real booking on this rate would be charged ${formatMoney(charged)}; this booking held no room for anyone, and nothing is charged.`}`
|
|
10216
|
+
: `${cancelled.confirmationCode} is cancelled. ${charged.minor === 0 ? 'No fee.' : `The hotel charges ${formatMoney(charged)}.`}${cancelled.paymentNotConnected ? ` ${notPaidWords(cancelled)}` : ''}`,
|
|
9808
10217
|
couponNow?.said ?? '',
|
|
9809
10218
|
demoBookingNote(deps, cancelled.supplier),
|
|
9810
10219
|
]
|
|
9811
10220
|
.filter(Boolean)
|
|
9812
|
-
.join(' ')
|
|
10221
|
+
.join(' ')
|
|
10222
|
+
.concat(addOnsDone ? `\n${addOnsDone.text}` : ''),
|
|
9813
10223
|
};
|
|
9814
10224
|
}
|
|
9815
10225
|
if (name === t.compare) {
|