amount applied
Amount Applied Field
The Amount Applied field shows how much of a payment was allocated to a specific order.
Overview
When a payment is split across multiple orders, the "Amount Applied" field tracks exactly how much of the payment went to each order. This is stored in the payment_orders junction table.
Field Details
Data Type
- Type: Decimal number
- Format: Up to 10 digits, 2 decimal places
- Context: Junction table (payment_orders)
Relationship
payment_orders table:
├── payment_id: References the payment
├── order_id: References the order
└── amount_applied: Amount allocated from this payment to this order
How It Works
Example: Payment Split Across Orders
Payment: $500 total received
| Order | Amount Applied | Order Total | Outstanding After |
|---|---|---|---|
| #1001 | $300 | $400 | $100 |
| #1002 | $150 | $150 | $0 |
| #1003 | $50 | $200 | $150 |
Validation: $300 + $150 + $50 = $500 (matches payment amount)
Calculation Rules
Order Outstanding Amount
Outstanding = Order Total - SUM(amount_applied from all payments)
Multiple Payments to One Order
An order can have multiple "amount applied" entries from different payments:
| Payment | Amount Applied |
|---|---|
| #PAY-001 | $100 |
| #PAY-002 | $50 |
| #PAY-003 | $25 |
| Total | $175 |
If order total is $200, outstanding is $25.
Editing
Modifying Allocation
When editing a payment:
- Change the amount applied to each order
- System validates totals match payment amount
- Order outstanding amounts recalculate
Removing an Order
When removing an order from a payment:
- Amount applied for that order is deleted
- Payment total stays the same
- Must reallocate to other orders OR reduce payment amount