Commit Graph

180 Commits

Author SHA1 Message Date
2c8985203e improvements 2026-05-18 23:18:02 -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
Bryce
28a755e9a9 fixes invoice date filtering 2026-03-02 23:20:14 -08:00
f1036e257c Allows undoing autopayments 2025-02-03 13:34:19 -08:00
329a1dc0d4 Should make correct tooltip open 2025-02-03 12:11:38 -08:00
ac0dbef961 Makes link dropdown not get cut off 2025-01-31 19:22:24 -08:00
956d233fe1 bulk edit is now possible 2025-01-20 21:18:52 -08:00
747bf66206 Should fix invoice error 2025-01-20 15:49:30 -08:00
ca7a08452c Makes A&J Produce findable. 2025-01-17 20:53:17 -08:00
da2702f9e8 Supports more 2024-12-16 21:55:06 -08:00
b7826ad6ce uses the periods that are actually used. 2024-12-12 09:49:52 -08:00
ef7c127cd5 Makes tooltip, also makes date ranges work the way Ben asked for 2024-12-12 08:20:57 -08:00
aaeafae871 dates work again 2024-12-11 22:51:17 -08:00
98dcdb5a55 cleans stuff up. 2024-11-23 21:13:15 -08:00
39d8e6e71f simplified ui 2024-11-22 10:10:22 -08:00
a4a40fc9c2 applying feedback 2024-11-20 09:48:07 -08:00
a8c7c7eb8e cleans up grids 2024-11-18 19:41:54 -08:00
f634d8fd81 Making investigate improvements. 2024-11-17 22:01:48 -08:00
d119e01857 Adds advanced view 2024-11-13 20:03:04 -08:00
cb4f88f02a adds csv capability 2024-11-11 21:39:36 -08:00
0e5407072e fix 2024-11-10 22:11:07 -08:00
e9c9cd5fb0 fix 2024-11-10 22:10:21 -08:00
df3183f85c progress on reports. 2024-11-10 22:09:14 -08:00
966deb232a tweaks 2024-11-04 21:43:41 -08:00
71d7461eb9 Better experience for adding new journal entry 2024-11-04 13:23:37 -08:00
48d575fe70 create manual ledger experience 2024-10-28 15:18:07 -07:00
f859655aad profit and loss now works. 2024-10-26 19:11:08 -07:00
7ee99b3542 cash flows 2024-10-26 00:20:10 -07:00
864ecec1b2 balance sheet 2024-10-24 22:27:29 -07:00
f9d02e4798 Makes an experience for balance sheet multi choice 2024-10-24 22:21:52 -07:00
3da8bf054f Sets up multi date 2024-10-22 23:55:02 -07:00
4c05452774 makes more changes. 2024-10-18 21:34:29 -07:00
2311acb9a2 Dropdown works well 2024-10-18 21:00:50 -07:00
acaa2a7d1e improve look of search 2024-10-16 15:37:22 -07:00
70e76347e3 Looks good 2024-10-15 21:43:03 -07:00
9d22de1338 new balance sheet 2024-10-15 20:46:18 -07:00
ca27fcdb57 Fixes 2024-10-15 19:22:19 -07:00
631ee905da popper to tippy 2024-10-15 06:45:33 -07:00
ca5d90b17f investigate progress. 2024-10-14 23:21:48 -07:00
c0bcc33b68 Makes new balance sheet page. It's much faster. 2024-10-13 19:29:49 -07:00
fc64f81ace progress on sheet 2024-10-12 20:19:22 -07:00
06a23d4d10 balance sheet prep 2024-10-12 19:24:31 -07:00
427f50fb6b Improves balance sheet, starts moving it to new layout 2024-10-11 20:36:23 -07:00
046b70d593 fixes a couple loading issues, starts on report rendering. 2024-10-11 00:19:29 -07:00
67827b41d0 Adds float visibility 2024-08-28 21:49:40 -07:00
6fd609be3e Adds new ledger import page 2024-08-26 20:53:21 -07:00
c0d173125c hides link 2024-08-24 23:13:21 -07:00
bb7e0abeed External ledger 2024-08-24 23:12:14 -07:00
4316ebb34a Links for ledger, and bank account picker 2024-08-23 23:24:05 -07:00
ab5869b4fb fixes minor bug. 2024-08-23 22:04:08 -07:00