Commit Graph

6 Commits (166d86cf5887508513ccde729ee096b643015f23)

Author SHA1 Message Date
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 dfa5ed407b receipt-form: Prompt before leaving unfinished form
Whenever any of the fields on the page are changed, the form will be
marked as "dirty" until it is submitted.  If the form is "dirty" and the
user tries to navigate away from the page, the browser will prompt for
confirmation before leaving the page.
2025-03-11 21:05:52 -05:00
Dustin 16701a6313 receipt-form: Add auto-fill feature
The Add Receipt form now has a dropdown box that will automatically
populate the data fields from the properties of an existing transaction.
This will be helpful for the cases where the transaction was created
automatically, but still needs a receipt attached to it (e.g. Wal-Mart,
Target, etc. purchases and restaurants).
2025-03-11 07:51:49 -05:00
Dustin a475f58def js: Factor out getResponseError utility function
This function factors out the logic of extracting an error message from
a `Response` object into a reusable utility function.  This will allow
other pages to use the same logic without duplicating it.
2025-03-10 18:22:32 -05:00
Dustin e2b14ecf10 receipt-form: Omit empty uploaded file
If there is no file to be uploaded, then we must not send the value of
the `photo` file input.  Doing so causes two files to be uploaded, the
first one being a zero-byte file with no name, and the second one being
the one we captured from the camera.  The server only uses the first
uploaded file if there are multiple, so the correct file is never used.
2025-03-09 21:04:15 -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