fix(mcp): file a transit fare under the transport cost category

transit is not one of the fixed Costs categories, so typeToCostCategory
would put an uncategorised fare under other. Default to transport, the
category every rail and bus booking maps to.
This commit is contained in:
bear
2026-10-26 04:19:24 +08:00
committed by Maurice
parent 8d10bff616
commit 547f0b84b0
3 changed files with 7 additions and 5 deletions
+5 -3
View File
@@ -198,7 +198,7 @@ export class TransitMcp {
price: bookingPriceSchema.optional().describe('Fare — shown on the journey and linked in the Budget tab'),
budget_category: bookingBudgetCategorySchema
.optional()
.describe('Budget category for the fare entry (defaults to transit)'),
.describe('Budget category for the fare entry (defaults to transport)'),
},
annotations: TOOL_ANNOTATIONS_OPEN_WORLD_NON_IDEMPOTENT,
access: { group: 'reservations', mode: 'write' },
@@ -283,9 +283,11 @@ export class TransitMcp {
};
}
// The fare files the linked expense in the booking's own transaction and
// rides along in the metadata, as create_transport's price does.
// rides along in the metadata, as create_transport's price does. `transit`
// is no Costs category (typeToCostCategory would file it under other), so a
// fare defaults to the one every rail and bus booking maps to.
const linkedCost =
price != null && price > 0 ? { total_price: price, category: budget_category || 'transit' } : undefined;
price != null && price > 0 ? { total_price: price, category: budget_category || 'transport' } : undefined;
const { reservation } = await this.writes.createBooking(
String(tripId),
{
+1 -1
View File
@@ -273,7 +273,7 @@ describe('MCP transit tools', () => {
}),
) as { reservation: { id: number; metadata: string } };
const item = await findRow(orm, BudgetItems, { reservation: result.reservation.id });
expect(item).toMatchObject({ name: 'Namba → Umeda', category: 'transit', total_price: 240 });
expect(item).toMatchObject({ name: 'Namba → Umeda', category: 'transport', total_price: 240 });
expect(JSON.parse(result.reservation.metadata).price).toBe('240');
expect(broadcastMock.mock.calls.some((c) => c[1] === 'budget:created')).toBe(true);
expect(broadcastMock.mock.calls.some((c) => c[1] === 'reservation:created')).toBe(true);
+1 -1
View File
@@ -134,7 +134,7 @@ Transit search is powered by the configured transit provider (Transitous by defa
|---|---|---|
| `search_transit_stops` | `geo:read` | Search real public-transit stops and stations, optionally biased around coordinates. |
| `search_transit_routes` | `geo:read` | Search scheduled routes between two coordinates with time, mode, and transfer filters. Also returns `provider` (`transitous` or `google`, the backend that answered) and `dropped`, the number of provider itineraries that failed validation and are absent from the results. |
| `create_transit_journey` | `reservations:write` | Save a selected route as a first-class automated transit journey on a trip day. Pass `provider` from `search_transit_routes` to preserve the actual source, including fallback results. Older callers that omit it retain the configured-provider behavior. `price` records the fare as an expense linked to the journey (`budget_category`, `transit` by default). |
| `create_transit_journey` | `reservations:write` | Save a selected route as a first-class automated transit journey on a trip day. Pass `provider` from `search_transit_routes` to preserve the actual source, including fallback results. Older callers that omit it retain the configured-provider behavior. `price` records the fare as an expense linked to the journey (`budget_category`, `transport` by default). |
### Reservations