# VALIDATION RULES & BUSINESS RULES

[← Error Handling](./05-error-handling.md) | [Về Backend](./01-backend-architecture.md)

---

## 19.1. Asset Validation

- Asset code must be unique within project
- Serial number must be unique (if provided)
- Commissioning date cannot be in future
- Warranty end date must be after commissioning date
- Parent asset must exist and be valid type

---

## 19.2. Work Order Validation

- Scheduled end must be after scheduled start
- Actual end must be after actual start
- Total cost = Labor + Material + External
- Cannot close work order without completing all checklist items
- Cannot approve work order without cost estimate

---

## 19.3. Inventory Validation

- Stock level cannot go below 0
- Transaction quantity must be positive
- Unit cost must be positive
- Reorder point must be less than max stock level

---

## 19.4. Financial Validation

- Budget amount must be positive
- Transaction amount must be non-zero
- Meter reading must be greater than previous reading
- Revenue calculation: Energy × Tariff Rate

---

## 19.5. User & Permission Rules

- Email must be unique
- Password must meet complexity requirements
- User must have at least one role
- Cannot delete user with active work orders
- Cannot remove last admin user

---

**Back to**: [Backend Architecture](./01-backend-architecture.md)
