Commit Graph

7 Commits (master)

Author SHA1 Message Date
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 e4ddfbd025 Run DB migrations at startup
Naturally, we need the database schema in place in order to use it.
2025-03-09 20:55:26 -05:00
Dustin da9d336817 Store receipts in the database
Rethinking the workflow again.  Requiring the transaction to be present
in Firefly already will be problematic for two very important cases:

* Gas station purchase never show up in Firefly automatically
* HSA purchase show up hours or days later and have no information
  besides the amount

These are arguably the most important cases, since they are the ones
that really need receipts in order to keep the transaction register
correct.  Thus, we need a different way to handle these types of
transactions.

Really, what I need is a way to associate transaction data with an image
I really liked the original idea of storing receipts in Paperless, but
that ended up not working out because the OCR failed miserably and thus
made it impossible to search, so finding a receipt meant looking at each
image individually.  I think, therefore, the best solution is to store
the images along with manually-entered data.

To implement this new functionality, I am using `sqlx`, a SQL toolkit
for Rust.  It's not exactly an ORM, nor does it have a dynamic query
builder like SQLAlchemy, but it does have compile-time checking of
query strings and can produce type-safe query results.  Rocket has
support for managing its connection pools as part of the server state,
so that simplifies usage quite a bit.

On the front-end, I factored out the camera image capture into an HTML
custom element, `camera-input`.  I did not update the original form to
use it, since I imagine that workflow will actually go away entirely.
2025-03-09 19:55:08 -05:00
Dustin 545baa1c36 Use Rocket's Figment for configuration
Instead of reading our own TOML file for configuration, we can hook into
Rocket's [built-in configuration system][0].  Although it doesn't matter
much right now, it may if we end up using Rocket's SQL [database
integration][1], because it uses the same mechanism.  Without making
this change, we would end up with two configuration files in that case.

[0]: https://rocket.rs/guide/v0.5/configuration/#extracting-values
[1]: https://rocket.rs/guide/v0.5/state/#databases
2025-03-09 07:07:55 -05:00
Dustin 0c6f9385e6 Fetch transactions from Firefly III
This is all pretty straightforward.  The only real problem is that
the search results only contain matching transactions *splits*.  Since
transactions themselves do not have an amount, the value shown in the
_Amount_ column on the transaction list may be incorrect if a
transaction contains multiple splits and some of them do not match the
search query.
2025-03-08 16:01:08 -06:00
Dustin b55fb893e2 Implement basic page navigation w/ mock data
Obviously, we'll replace the mock `Database` with a Firefly III API
client, but this is here for now to support the UI interactions.
2025-03-08 11:16:35 -06:00
Dustin 9a7b083f82 Initial commit 2025-03-05 18:02:52 -06:00