Commit Graph

57 Commits

Author SHA1 Message Date
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
dc021b8ce0 trying simple fix for ledger changes. 2026-01-25 21:40:22 -08:00
96934b12fd Sample ledger show 2025-05-23 17:25:18 -07:00
581033001b Adds the ability to filter down to unbalanced 2025-03-11 21:07:51 -07:00
ad06418a69 minor improvements 2024-11-17 22:32:43 -08:00
df3183f85c progress on reports. 2024-11-10 22:09:14 -08:00
eed9bfbd11 merged 2024-11-08 13:58:52 -08:00
eda61593d8 other query fix 2024-11-08 12:42:53 -08:00
24cb9b10a2 Should fix excel sheet. 2024-11-08 08:57:42 -08:00
70e76347e3 Looks good 2024-10-15 21:43:03 -07:00
4e215c98ae Adds warning 2024-10-15 21:14:59 -07: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
8234db5623 Highlights plaid errors more clearly 2024-10-07 20:55:30 -07:00
cf81e3999c Adds ability to query for snapshots 2024-10-02 09:28:05 -07:00
4c8c3560d8 Updates allowed to change more than one entity at a time 2024-09-28 11:42:42 -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
22e92c819b Adds new expense report, with ability to break down by vendor 2024-04-19 21:48:28 -07:00
Bryce
9ea70005cb supports credits 2024-03-20 21:20:10 -07:00
9dc9078a0d make import more forgiving. 2024-03-07 21:57:06 -08:00
0a0978cce1 trying more logging 2024-03-07 21:13:52 -08:00
8eea36cd94 Maybe makes transactions less stuck 2024-03-07 20:41:12 -08:00
8063a8fcbd Builds client SSR approach, sunsets old cljs. 2024-02-07 21:22:56 -08:00
d1798f6b5c further cleans up POS 2023-09-28 20:41:00 -07:00
fddd3d9007 makes all sales orders use new grid helper 2023-09-27 23:52:57 -07:00
85597fd9eb ssr sales 2023-09-14 22:45:05 -07:00
766be867f7 various fixes. 2023-09-06 13:34:08 -07:00
a56d3b0b84 Should fix most of the authentication issues 2023-09-05 23:08:22 -07:00
Bryce
88eda03e7f Aside from urls and nomenclature, glimpse works. 2023-08-03 20:53:09 -07:00
Bryce
b6fe435063 Adds bottom paginator, fixes ledger issue triggered by cash payment, defaults coding to 100 percent 2023-06-26 20:33:14 -07:00
Bryce
534b6e35f2 imports invoices one at a time to avoid duplicating them 2023-05-30 12:30:58 -07:00
3ce9cceee0 Fixes a few issues discovered 2023-05-13 23:36:14 -07:00
2bb1da1636 (cloud) Makes POS page work again 2023-05-03 12:30:04 -07:00
2845f21227 Makes cloud functions installable remotely 2023-05-02 20:50:27 -07:00
f2025c2e65 made cloud tests work again. 2023-05-01 20:21:58 -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
8dae0fde10 (cloud) fixes issues encountered in testing. 2023-04-24 21:05:54 -07:00
0423b31d02 Fixes 1099 page 2023-04-06 19:57:32 -07:00
d924146f0e (cloud) implements plus for check printihng 2023-04-06 16:19:28 -07:00
2a0f736af7 makes POS page much less likely to break everything 2023-04-05 22:50:38 -07:00
bb8ca82328 switches to 90 days 2023-04-05 21:19:50 -07:00
500eb5641e (cloud) makes sales export queries super stinkin' fast 2023-04-05 17:21:03 -07:00
9c1376950b (cloud) makes sales export queries super stinkin' fast 2023-04-05 17:19:40 -07:00
406cddf6e6 setup for clients moving much faster 2023-04-05 14:42:25 -07:00
444315250e (cloud) adds basic capabilities for queries 2023-04-03 19:59:39 -07:00
2a3c538849 (cloud) deleting old approach 2023-04-03 12:32:04 -07:00
94d8346bac (cloud) moves pay to datomic ions. 2023-04-03 09:08:52 -07:00
6622aae589 no need for transact-with-ledger. 2023-04-03 09:04:33 -07:00