Bryce 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
2024-02-08 11:41:03 -08:00
2019-01-26 09:02:28 -08:00
2026-05-16 00:16:44 -07:00
2023-12-03 20:20:32 -08:00
2024-05-02 20:37:13 -07:00
2026-05-16 00:16:44 -07:00
2024-11-17 22:32:43 -08:00
ok.
2026-02-08 08:43:53 -08:00
2022-09-26 16:12:39 -07:00
2026-04-25 19:41:40 -07:00
2023-10-12 21:55:37 -07:00
2023-07-27 09:50:22 -07:00
2018-09-03 13:12:20 -07:00
2019-01-26 09:02:28 -08:00
2022-12-08 08:51:34 -08:00
2019-01-26 09:02:28 -08:00
2019-04-24 21:29:38 -07:00
2024-10-18 23:21:49 -07:00
2023-01-07 23:01:20 -08:00
2023-03-24 10:57:53 -07:00
2023-08-31 23:43:19 -07:00
2024-02-08 20:36:04 -08:00
2021-10-08 16:18:31 -07:00
fix
2022-06-23 08:44:44 -07:00
2025-09-11 23:00:42 -07:00
2024-03-14 07:16:59 -07:00
Description
No description provided
19 MiB
Languages
Clojure 90.9%
CSS 4.2%
Sass 2.3%
HTML 1.3%
HCL 0.4%
Other 0.7%