# Cash Flow Management System Guide

## Overview
The Cash Flow Management system automatically tracks all cash movements in your POS system, providing real-time visibility into your cash drawer balance and helping you reconcile daily transactions.

## Features

### 1. Automatic Cash Movement Tracking
The system automatically records cash movements from:
- **Sales**: Cash sales are recorded as cash inflow
- **Expenses**: Cash expenses are recorded as cash outflow
- **Credit Settlements**: Customer credit payments made in cash

### 2. Shift Management
- **Opening Fund**: Start each shift by recording your initial cash amount
- **Closing Count**: End shifts by counting actual cash and comparing to expected balance
- **Variance Tracking**: Automatically calculates differences between expected and actual cash

### 3. Real-time Balance Monitoring
- View current cash balance at any time
- Track all cash movements throughout the day
- See running balance after each transaction

## How to Use

### Starting Your Shift
1. Go to **Cash Flow** in the sidebar menu
2. Click **Open Shift**
3. Enter your opening cash fund amount
4. Click **Open Shift** to start tracking

### During the Day
- The system automatically tracks cash movements from sales, expenses, and credit settlements
- View real-time balance and transaction history
- Add manual adjustments if needed (deposits, withdrawals, adjustments)

### Ending Your Shift
1. Count the actual cash in your drawer
2. Click **Close Shift**
3. Enter the actual cash count
4. Review the variance (difference between expected and actual)
5. Add notes if there's a significant variance
6. Click **Close Shift** to finalize

### Manual Transactions
You can add manual cash transactions:
- **Cash Deposit**: Money added to the drawer
- **Cash Withdrawal**: Money removed from the drawer
- **Adjustment**: Corrections for errors or discrepancies

## Mobile Compatibility
The cash flow interface is fully mobile-responsive:
- Compact table design for small screens
- Touch-friendly buttons and controls
- Optimized for portrait and landscape viewing

## Integration Points

### Sales Integration
- When a sale is processed with "Cash" payment method, it automatically records a cash movement
- Amount is added to the running cash balance
- Transaction is linked to the specific sale ID

### Expense Integration
- When an expense is recorded with "Cash" payment method, it automatically records a cash movement
- Amount is subtracted from the running cash balance
- Transaction is linked to the specific expense ID

### Credit Settlement Integration
- When a customer pays their credit balance in cash, it automatically records a cash movement
- Amount is added to the running cash balance
- Transaction is linked to the credit transaction ID

## Database Tables
The system uses two main tables:
- `{branch_code}_cash_movements`: Records each cash transaction
- `{branch_code}_cash_shifts`: Tracks shift opening/closing information

## Benefits
1. **Accurate Cash Tracking**: Eliminates manual cash counting errors
2. **Real-time Visibility**: Always know your current cash position
3. **Variance Detection**: Quickly identify discrepancies
4. **Audit Trail**: Complete history of all cash movements
5. **Branch-specific**: Each branch maintains separate cash tracking
6. **User-specific**: Track which cashier handled each transaction

## Tips for Best Practices
1. Always open a shift at the beginning of your day
2. Close your shift at the end of each day
3. Count cash carefully when closing
4. Investigate any significant variances immediately
5. Use manual adjustments sparingly and with proper documentation
6. Ensure all cash transactions go through the POS system

## Troubleshooting
- If you see no movements, ensure a shift is open for the current date
- If cash movements aren't appearing, verify the payment method is set to "Cash"
- For historical data, use the date filter to view previous days
- Contact your system administrator for database-related issues 