mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
feat(costs): let a trip keep its costs as totals only (#1714)
Travellers who track what a trip costs but never split it saw an Unfinished warning on every expense and a settle-up they had no use for. A trip now has a costs mode (appended migration, trips.costs_mode, split by default); totals leaves payers, shares and settling up out of Costs on desktop and phone through the same gate as a trip of one, and saves new expenses without a payer. PUT /api/trips/:id and update_trip take it on budget_edit. The split chips move into their own component.
This commit is contained in:
@@ -106,6 +106,7 @@ const UNNUMBERED = [
|
||||
'Migration20200101046360_a_new_install_starts_with_more_addons_on',
|
||||
'Migration20200101046370_a_deleted_chat_message_keeps_no_text',
|
||||
'Migration20200101046380_ireland_gained_its_counties',
|
||||
'Migration20200101046390_a_trip_can_keep_its_costs_as_totals_only',
|
||||
];
|
||||
// The last step the positional runner ever had; planLegacyBaseline refuses a
|
||||
// schema_version past it.
|
||||
|
||||
@@ -560,6 +560,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task
|
||||
is_archived: 0,
|
||||
cover_image: null,
|
||||
reminder_days: 3,
|
||||
costs_mode: 'split',
|
||||
});
|
||||
// Seen INSIDE the open transaction — the write and the read share
|
||||
// one connection.
|
||||
@@ -609,6 +610,7 @@ describe('TripsRepository.insertTrip / updateTripRow / setCoverImage / deleteByI
|
||||
is_archived: 1,
|
||||
cover_image: 'c.png',
|
||||
reminder_days: 7,
|
||||
costs_mode: 'totals',
|
||||
});
|
||||
const row = await tripRow(trip.id);
|
||||
expect(row).toMatchObject({
|
||||
@@ -620,6 +622,7 @@ describe('TripsRepository.insertTrip / updateTripRow / setCoverImage / deleteByI
|
||||
is_archived: 1,
|
||||
cover_image: 'c.png',
|
||||
reminder_days: 7,
|
||||
costs_mode: 'totals',
|
||||
});
|
||||
// CURRENT_TIMESTAMP has one-second resolution — a same-second before/after
|
||||
// comparison is flaky, not a real assertion; the column being non-null and
|
||||
@@ -647,7 +650,7 @@ describe('TripsRepository.insertTrip / updateTripRow / setCoverImage / deleteByI
|
||||
// ── Plan 3c Task 8 (`TripsService.copy`, TP37) — additive ───────────────────
|
||||
|
||||
describe('TripsRepository.insertTripCopy (TP37)', () => {
|
||||
it('TRIPREPO-039: writes the 8-column copy set, is_archived hard-coded to 0 regardless of the caller', async () => {
|
||||
it('TRIPREPO-039: writes the 9-column copy set, is_archived hard-coded to 0 regardless of the caller', async () => {
|
||||
const { user: owner } = createUser(testDb);
|
||||
const { user: newOwner } = createUser(testDb);
|
||||
const newId = await trips.insertTripCopy({
|
||||
@@ -659,9 +662,20 @@ describe('TripsRepository.insertTripCopy (TP37)', () => {
|
||||
currency: 'USD',
|
||||
cover_image: 'c.png',
|
||||
reminder_days: 7,
|
||||
costs_mode: 'totals',
|
||||
});
|
||||
const { user_id, title, description, start_date, end_date, currency, cover_image, is_archived, reminder_days } =
|
||||
await tripRow(newId);
|
||||
const {
|
||||
user_id,
|
||||
title,
|
||||
description,
|
||||
start_date,
|
||||
end_date,
|
||||
currency,
|
||||
cover_image,
|
||||
is_archived,
|
||||
reminder_days,
|
||||
costs_mode,
|
||||
} = await tripRow(newId);
|
||||
const row = {
|
||||
user_id,
|
||||
title,
|
||||
@@ -672,6 +686,7 @@ describe('TripsRepository.insertTripCopy (TP37)', () => {
|
||||
cover_image,
|
||||
is_archived,
|
||||
reminder_days,
|
||||
costs_mode,
|
||||
};
|
||||
expect(row).toEqual({
|
||||
user_id: newOwner.id,
|
||||
@@ -683,6 +698,7 @@ describe('TripsRepository.insertTripCopy (TP37)', () => {
|
||||
cover_image: 'c.png',
|
||||
is_archived: 0,
|
||||
reminder_days: 7,
|
||||
costs_mode: 'totals',
|
||||
});
|
||||
// The source trip (never touched) proves is_archived: 0 is a literal, not a copied value.
|
||||
await setTrip(owner.id, { is_archived: 1 });
|
||||
@@ -701,6 +717,7 @@ describe('TripsRepository.insertTripCopy (TP37)', () => {
|
||||
currency: null,
|
||||
cover_image: null,
|
||||
reminder_days: 3,
|
||||
costs_mode: 'split',
|
||||
});
|
||||
expect((await tripRow(newId)).is_archived).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user