Commit Graph

8 Commits (0eb0618fd281ea1e2282a9ee3fa5435bb13627fe)

Author SHA1 Message Date
Dustin 0eb0618fd2 add_receipt: Fix editing Firefly xact notes
dustin/receipts/pipeline/head This commit looks good Details
If a new receipt is being attached to an existing Firefly transaction,
we need to update the notes field of the transaction to match what's
specified with the receipt.  This was happening correctly for
transactions that already had value in its notes field, but not for
transactions without any notes at all.  The reason for this is because
we were only updating the field inside a conditional that checked if the
existing value was not equal to the new value, but it did not account
for the case where there was no existing value at all.
2025-05-07 18:24:04 -05:00
Dustin da3d3e4c8e receipts/list: Generate thumbnails for receipts
Instead of sending the whole image file for every receipt shown on the
list page, we now generate thumbnails for them on the fly.  This
dramatically reduces the amount of bytes sent for each image, especially
very large, high-quality photographs.  It also improves support for
non-image attachments like PDFs, by rendering image previews in the
grid view instead of a broken image placeholder.

We use GraphicsMagic to do the conversion.  Its `MagickWand` API is
pretty straightforward and convenient, and it supports a plethora of
image and image-like formats.
2025-03-14 20:57:12 -05:00
Dustin e158a095d3 receipts/add: Do not query Firefly for empty ID
The `transaction` field is usually included in the form submission, even
if it is empty.  To avoid querying Firefly for an invalid ID and logging
a useless error about it, we only query if the field is non-empty.
2025-03-14 20:27:20 -05:00
Dustin f3d31a7256 receipts/add: Skip updating notes if unchanged
If the value of the `notes` form field is the same as the current value
for the same field of an existing Firefly transaction, we do not need to
update it.
2025-03-14 20:27:18 -05:00
Dustin 1f4899feb3 receipts: Create/update Firefly III transactions
dustin/receipts/pipeline/head This commit looks good Details
The Add Receipt form can now create or update transactions in Firefly
III in certain circumstances:

* For existing transactions, if the description, amount, or notes
  submitted on the form differ from the corresponding values in Firefly,
  the Firefly transaction will be updated with the submitted information
* For gas station transactions, since Chase does not send useful
  notifications about these, there is now an option to create an
  entirely new transaction in Firefly, using the values provided in the
  form
* Similarly for refunds and deposits, which we also do not get helpful
  notifications about, the values in the form will be used to create a
  new transaction in Firefly

This functionality should help cover most of the edge cases that
`xactmon` cannot handle.
2025-03-13 20:02:35 -05:00
Dustin a09de49fbe receipts: Set Cache-Control header on photos
Some of the receipt photos can be quite large.  Since there's no
(direct) way to change receipt photos, we can tell the browser to cache
them for a long time to avoid having to download them every time the
list page is shown.
2025-03-11 22:18:28 -05:00
Dustin 0c088e6fc8 receipts: Attach receipt to Firefly transaction
If a specific transaction is selected on the Add Receipt form, the
uploaded receipt image will now be attached to that transaction in
Firefly.
2025-03-11 21:04:36 -05:00
Dustin 5c7225f077 Refactor backend
* Reorganizing code into more logical modules:
  - `routes` specifically for Rocket handler functions
  - `receipts` data model for receipts
  - `transactions` for Firefly transactions
* Encapsulate database operations for receipts using the repository
  pattern; move SQL queries to external files (`sqlx` can only use
  string literals or external files for queries, not variables or
  constants)
* Remove obsolete routes, templates for old transaction-focused pages
2025-03-11 20:05:41 -05:00