User Story:
As a Garden manager, I want the system to calculate the health index of a garden, so I can understand its health status and prioritize gardens for maintenance.
Acceptance Criteria:
- The garden's "Health Index" (CAMPX__Health_Index__c) field should be set based on this formula:
((Total Plant Count - Total Unhealthy Plant Count)/Total Plant Count) * 100
- The field must be recalculated and updated when there is a change in either the "Total Plant Count" or "Total Unhealthy Plant Count"
- The field should be 0 if the "Total Plant Count" is zero or blank
Example Scenario:
- In the garden, there are initially 50 total roses, 5 of which are unhealthy. After adding 5 new healthy roses, the "Health Index" is
((55 - 5) / 55) * 100 = 90.91
. - The Fern Garden has 40 total ferns, with 3 unhealthy. When another fern is marked unhealthy, the total unhealthy becomes 4. The "Health Index" is
((40 - 4) / 40) * 100 = 90.00
. - If all 10 plants in a Herb Garden are removed, the "Health Index" would be ((0 - 10) / 0) * 100 = 0.