dustin/receipts/pipeline/head This commit looks goodDetails
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.
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.
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.
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.
dustin/receipts/pipeline/head This commit looks goodDetails
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.
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.
* 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