Commit Graph

109 Commits

Author SHA1 Message Date
ba87805d4c Add vendor pre-population for bulk code and individual edit forms
- Add vendor-changed HTMX handlers for both bulk code and individual edit
- Pre-populate default account at 100% when vendor is selected and no accounts exist
- Fix render-accounts-section to render from step-params correctly
- Change bulk code vendor-changed from hx-get to hx-post to include form data
- Add routes for vendor-changed endpoints
- Update e2e tests to cover vendor pre-population
- Run lein cljfmt fix across codebase
2026-05-21 14:45:19 -07:00
cc31d8849b Feat/Complete Sales Summaries (#5)
## Summary

Completes the automatic sales summary pipeline end-to-end: the `sales-summaries-v2` job now calculates aggregate totals, preserves manual adjustments, and automatically posts balanced journal entries to the ledger.

## What Changed

**New Datomic transaction function** (`upsert-sales-summary-ledger`)
- Transforms detailed `sales-summary-item`s into aggregated `journal-entry` lines grouped by account and ledger side
- Handles the full upsert: posts a new journal entry for summaries with mapped accounts, or retracts the orphaned entry if items no longer qualify

**Enhanced `sales-summaries-v2` job**
- Calculates and stores 13 aggregate total attributes (card/cash/food-app/gift-card payments, refunds, fees, discounts, tax, tip, returns, unknown, net)
- Preserves manual items (`manual? true`) during recalculation — only auto-calculated items are replaced

**Ledger reconciliation**
- `reconcile-ledger` now queries for sales summaries missing journal entries and repairs them via `:upsert-sales-summary-ledger`, alongside existing invoice and transaction repairs

**Schema**
- Added 13 `total-*` attributes on `sales-summary` (all `db.type/double`, no history)
- Registered the new transaction function in `tx.clj` and `datomic.clj`

**Admin UI cleanup**
- Resolved "clientize" and HTMX `client-id` TODOs in the sales summaries admin page
- `new-summary-item` now correctly passes `client-id` via `hx-vals`
- Removed stale TODO comments and placeholder code

## Files Changed (8)

| File | Purpose |
|------|---------|
| `iol_ion/.../upsert_sales_summary_ledger.clj` | New Datomic tx function |
| `iol_ion/.../tx.clj` | Register new tx function |
| `resources/schema.edn` | 13 new `total-*` attributes |
| `src/.../datomic.clj` | Load new tx namespace |
| `src/.../jobs/sales_summaries.clj` | Aggregate totals + manual item preservation |
| `src/.../ledger.clj` | Sales summary repair in `reconcile-ledger` |
| `src/.../ssr/admin/sales_summaries.clj` | UI TODO cleanup |
| `docs/plans/...plan.md` | Implementation plan document |

Co-authored-by: Bryce <bryce@integreatconsult.com>
Reviewed-on: #5
Co-authored-by: Bryce <bryce@brycecovertoperations.com>
Co-committed-by: Bryce <bryce@brycecovertoperations.com>
2026-05-16 00:16:44 -07:00
38ed981cba Recalculates running balance as report is run 2025-02-08 22:14:24 -08:00
45334bbbe3 import fix 2024-11-14 21:19:21 -08:00
c55d014685 fixes running balances 2024-11-14 21:13:21 -08:00
c0bcc33b68 Makes new balance sheet page. It's much faster. 2024-10-13 19:29:49 -07:00
427f50fb6b Improves balance sheet, starts moving it to new layout 2024-10-11 20:36:23 -07:00
4c8c3560d8 Updates allowed to change more than one entity at a time 2024-09-28 11:42:42 -07:00
35609e44bf makes it load the right value again 2024-09-27 17:03:22 -07:00
e25e2bfc46 logging updates, makes invoice voiding trigger refresh of running balances. 2024-09-27 16:59:35 -07:00
4c14e43734 Greatly simplifies keeping bank accounts in check 2024-09-27 15:59:21 -07:00
5366c0be59 tweak. 2024-09-26 00:11:49 -07:00
721cab056b error 2024-09-25 22:24:32 -07:00
db9e0dc459 makes solr ec2 based and adds resiliency to running balances. 2024-09-25 22:01:12 -07:00
c8f438f616 started work on bank comparisons. 2024-04-26 21:51:56 -07:00
f8690edbb8 Makes refresh much faster 2023-10-31 12:54:58 -07:00
425a995755 improves performance of running balance cache 2023-10-31 08:35:33 -07:00
86e9addf01 reconcile ledger had a small bug in it 2023-09-12 19:39:37 -07:00
611af7f9bb making tests work again. 2023-05-01 09:42:06 -07:00
b2ad7790cf Migrates back to datomic on-prem 2023-04-29 07:12:51 -07:00
2a3c538849 (cloud) deleting old approach 2023-04-03 12:32:04 -07:00
6622aae589 no need for transact-with-ledger. 2023-04-03 09:04:33 -07:00
55f941e07b (cloud) makes ledger correction mechanisms work again 2023-03-31 16:07:30 -07:00
6870aa416f Made ledger repair fast and work 2023-03-31 09:44:09 -07:00
5df47c8837 (cloud) running balance update way more streamlined now 2023-03-30 16:44:25 -07:00
c8ada656c8 starts logging in the event of an issue. 2023-03-30 11:11:17 -07:00
f0603d922a Attempts solution of retrying transaction 2023-03-30 06:27:04 -07:00
5a6a43f183 Dialing things down to avoid service unavailable. 2023-03-29 20:45:30 -07:00
53a1c497b5 (cloud) fixes build 2023-03-29 16:57:45 -07:00
420bd126bd Adds the ability to launch a job that restores a database 2023-03-29 16:46:36 -07:00
4f94602716 fixes issues with a neverending search. Also fixes client saving to match normal test. 2023-03-24 13:01:33 -07:00
7fd3528d0f (cloud) big performance fixes 2023-03-24 11:02:17 -07:00
e810612fbb (cloud) makes ledger running balances fast and smooth 2023-03-24 11:02:17 -07:00
0af50758bd (cloud) Added running balance cache for ledger 2023-03-24 11:02:17 -07:00
78519663ac Getting closer to datomic cloud 2023-03-24 10:57:50 -07:00
f7fe2b2bee Makes running datomic cloud work again 2023-03-24 10:56:35 -07:00
65ecee7014 making cloud runnable again. 2023-03-24 10:56:35 -07:00
d02fba2b44 Makes integreat run on datomic cloud 2023-03-24 10:56:28 -07:00
a811ff697a fixes 2022-12-19 12:24:28 -08:00
a206116ba8 Fixes issue where the db/id of a temporary id is different from the real one.
Cash payments always match invoices.
2022-09-30 05:49:43 -07:00
63254ba401 no need for ledger automation. 2022-09-27 17:04:47 -07:00
ed759bac31 More background task cleanup 2022-09-23 12:09:39 -07:00
5017d9bc67 splitting out background tasks 2022-09-18 06:51:17 -07:00
84f7e734f0 added suggestions 2022-07-26 07:01:18 -07:00
8a078e0086 fix broken ledger issue 2022-07-21 16:44:50 -07:00
616798cebf making ledger reconciliation be more user friendly. 2022-06-24 09:28:43 -07:00
57d65074e5 Makes reconciling the ledger a bit faster 2022-06-23 13:26:10 -07:00
1db8d7a52c much more background process tracking 2022-06-22 10:43:37 -07:00
3d92fe11b8 service check implementation 2022-06-21 16:46:13 -07:00
183ebf9da5 Heartbeats scheduled things so that I can do health on them 2022-06-21 15:48:50 -07:00