Add Other Purchases to budget page

- New other_purchases table (date, total, notes)
- /api/other CRUD endpoints
- Budget stats now include other costs in cost/egg and cost/dozen math
- Budget page: new Log Other Purchases form, stat cards for other costs,
  combined Purchase History table showing feed and other entries together

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 22:47:57 -08:00
parent ceb0780663
commit 404fd0510f
8 changed files with 351 additions and 77 deletions

View File

@@ -29,6 +29,7 @@
<h2>All-Time</h2>
<div class="stats-grid" style="margin-bottom: 1rem;">
<div class="stat-card"><div class="label">Total Feed Cost</div><div class="value" id="b-cost-total"></div></div>
<div class="stat-card"><div class="label">Other Costs</div><div class="value" id="b-other-total"></div></div>
<div class="stat-card"><div class="label">Total Eggs</div><div class="value" id="b-eggs-total"></div></div>
<div class="stat-card accent"><div class="label">Cost / Egg</div><div class="value" id="b-cpe"></div></div>
<div class="stat-card accent"><div class="label">Cost / Dozen</div><div class="value" id="b-cpd"></div></div>
@@ -38,6 +39,7 @@
<h2>Last 30 Days</h2>
<div class="stats-grid" style="margin-bottom: 2rem;">
<div class="stat-card"><div class="label">Feed Cost (30d)</div><div class="value" id="b-cost-30d"></div></div>
<div class="stat-card"><div class="label">Other Costs (30d)</div><div class="value" id="b-other-30d"></div></div>
<div class="stat-card"><div class="label">Eggs (30d)</div><div class="value" id="b-eggs-30d"></div></div>
<div class="stat-card accent"><div class="label">Cost / Egg (30d)</div><div class="value" id="b-cpe-30d"></div></div>
<div class="stat-card accent"><div class="label">Cost / Dozen (30d)</div><div class="value" id="b-cpd-30d"></div></div>
@@ -75,6 +77,30 @@
</form>
</div>
<!-- Log other purchase -->
<div class="card">
<h2>Log Other Purchases</h2>
<form id="other-form">
<div class="form-grid">
<div class="form-group">
<label for="other-date">Date</label>
<input type="date" id="other-date" required>
</div>
<div class="form-group">
<label for="other-total">Total ($)</label>
<input type="number" id="other-total" min="0.01" step="0.01" required placeholder="0.00">
</div>
<div class="form-group span-full">
<label for="other-notes">Note</label>
<textarea id="other-notes" placeholder="e.g. Snacks, Bedding, Shelter Costs…"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Save Purchase</button>
</div>
</div>
</form>
</div>
<!-- Purchase history -->
<h2>Purchase History</h2>
<div class="table-wrap">
@@ -82,17 +108,17 @@
<thead>
<tr>
<th>Date</th>
<th>Bags</th>
<th>Price / Bag</th>
<th>Type</th>
<th>Details</th>
<th>Total</th>
<th>Notes</th>
<th></th>
</tr>
</thead>
<tbody id="feed-body">
<tbody id="purchase-body">
<tr class="empty-row"><td colspan="6">Loading…</td></tr>
</tbody>
<tfoot id="feed-foot"></tfoot>
<tfoot id="purchase-foot"></tfoot>
</table>
</div>
</main>