mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
Add a note field to expenses (#1888)
Requested in discussion #1658: an expense carries an amount and a category, and everything else about it ends up crammed into the title. The column was already there. It just was not available, because the costs UI stores an itemized receipt in it as TICKETJSON:{...}, so an expense split by receipt could never carry a note - and saving one any other way wrote note=null, which quietly wiped whatever had been typed into the budget table. The receipt gets its own column and note goes back to being text. Old clients that still send the blob as a note are routed to the right column instead of clobbering the note. On desktop the row now has fixed columns, so the amount does not drift left when one row has a note and the next does not. The category moved to the card edge as a tab like the mobile card does, which is what frees the line the note sits on. Collapsed it is one line, and the same element grows in place when opened. The dialog is two columns now: what the expense was on the left, how it is shared on the right, grouped into panels the way the trip dialog does it. On the phone the eleven category pills became a dropdown, which is where the room for the note field came from, and a note on a card unfolds when you tap it.
This commit is contained in:
@@ -3841,6 +3841,21 @@ function runMigrations(db: Database.Database): void {
|
||||
insert.run(key);
|
||||
}
|
||||
},
|
||||
|
||||
// Free the `note` column on budget items for its actual purpose (#1658).
|
||||
// The costs UI stores an itemized receipt in it as `TICKETJSON:{...}`, which
|
||||
// means an expense split by receipt can never carry a written note, and
|
||||
// saving an expense any other way wipes whatever was typed in the budget
|
||||
// table. The receipt moves to its own column and note becomes text again.
|
||||
() => {
|
||||
const hasTicket = db.prepare("SELECT 1 FROM pragma_table_info('budget_items') WHERE name = 'ticket_json'").get();
|
||||
if (!hasTicket) db.exec('ALTER TABLE budget_items ADD COLUMN ticket_json TEXT');
|
||||
db.exec(`
|
||||
UPDATE budget_items
|
||||
SET ticket_json = substr(note, 12), note = NULL
|
||||
WHERE note LIKE 'TICKETJSON:%'
|
||||
`);
|
||||
},
|
||||
];
|
||||
|
||||
if (currentVersion < migrations.length) {
|
||||
|
||||
Reference in New Issue
Block a user