I'll enhance the app with a prominent, dedicated Expenses & Costs tracking system — linking every cost to specific fields or pigs, with full breakdowns.
I'll add a dedicated Expenses & Costs tab with a full table-like layout for recording every cost, plus update existing sections to track per-field and per-pig expenses. Let me rebuild the app with this prominent feature.
I need to update the store and all components for the new types. Let me do this systematically.
Many files need updating. Let me update all components in one batch:
I need to rewrite several files at once. Let me do them all:
Let me delete the old file and create the new ones:
Now let me create the Expenses Tracker — the main feature the user requested:
Let me fix the circular type reference and create the remaining files:
I need to import the types properly. Let me fix the ExpensesTracker:
Now let me fix Dashboard, Reports, and create IncomeTracker:
Now let me create IncomeTracker and fix Reports:
Now fix Reports.tsx:
The build is successful. Let me also add automatic expense creation when adding a potato field with costs, and when recording pig health/feed costs, so expenses are automatically tracked:
Let me update the PotatoFields to auto-create expense entries when adding a field, and add a quick "Record Costs" button on each field:
Let me update the PotatoFields to auto-create expense entries:
Now let me update the Pigs component to also auto-create expense records when recording health and feed costs:
Let me find and update the HealthForm and FeedForm in Pigs.tsx to auto-create expenses:
Let me update the form submissions to also create expenses. I'll create wrapper functions:
Also let me auto-create expense for pig purchase:
Now let me add a "Record Costs → Expenses" button on each potato field card so existing fields can push costs to the expense tracker:
Build successful. The app is now complete with a comprehensive expense and income tracking system. Here's a summary of everything that was added:
✅ What's New — Expenses & Income Columns
📋 Dedicated Expenses Tab (New)
- Table/column layout with Date | Category | Description | Linked To | Amount columns
- 12 expense categories: Seeds, Fertilizer, Pesticide, Feed, Labor, Medicine, Transport, Equipment, Water, Land Rent, Vet Fees, Miscellaneous
- 5 payment methods: Cash, M-Pesa, Bank, Credit, Other
- Link expenses to specific potato fields or pigs
- Search expenses by name, category, or linked entity
- Filter by category or date range (All Time / This Week / This Month)
- Visual breakdown bar showing cost distribution by category
- Total row at bottom of table
💰 Dedicated Income Tab (New)
- Table/column layout with Date | Source | Description | Amount columns
- 5 income sources: Potato Sale, Pig Sale, Piglet Sale, Other Sale, Other Income
- Link income to specific fields or pigs
- Search and filter by source
- Visual breakdown bar
🔄 Automatic Expense Creation
- When you add a potato field, all costs (seeds, fertilizer, labor, pesticide, other) are automatically recorded in the Expenses tab
- When you add a pig with purchase price, it's auto-recorded as an expense
- When you record health costs (vaccination, treatment), it's auto-added to expenses
- When you record feed costs, it's auto-added to expenses
- Manual "Record as Expenses" button on each potato field card to push costs anytime
📊 Updated Dashboard
- Shows total income, total expenses, and net profit at the top
- Cost breakdown with visual progress bars
- Recent activity feed showing both expenses and income
📈 Updated Reports
- Combined expense + income analytics
- Profit margin calculation
- Smart insights based on your data
Files built: src/types.ts, src/store/FarmContext.tsx, src/App.tsx, src/components/ExpensesTracker.tsx, src/components/Dashboard.tsx, src/components/IncomeTracker.tsx, src/components/Reports.tsx, src/components/PotatoFields.tsx, src/components/Pigs.tsx