diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index d0926021..70c4ad46 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -1077,6 +1077,7 @@ exports.consumption = async (request, reply) => { const tanks = await Tank.find(tankQuery); const tankData = []; const tankconsumptionData = []; + let totalConsumptionForSelectedBlockAndTypeOfWater = 0; let totalBoreConsumptionForSelectedBlockAndTypeOfWater = 0; let totalBoreCapacityForSelectedBlockAndTypeOfWater = 0; let totalDrinkingConsumptionForSelectedBlockAndTypeOfWater = 0; @@ -1108,7 +1109,8 @@ exports.consumption = async (request, reply) => { }, 0); const consumption = (waterlevel_at_midnight + total_water_added_from_midnight) - waterlevel + total_consumption_from_records; - + totalConsumptionForSelectedBlockAndTypeOfWater += consumption; + // Add to the total consumption and capacities based on water type if (tank.typeOfWater === "bore" || tank.typeOfWater === "Bore Water") { totalBoreConsumptionForSelectedBlockAndTypeOfWater += consumption; @@ -1171,7 +1173,9 @@ exports.consumption = async (request, reply) => { typeofwater === "bore" ? totalBoreConsumptionForSelectedBlockAndTypeOfWater : totalDrinkingConsumptionForSelectedBlockAndTypeOfWater, - }), + } + ), + [`total consumption of ${typeofwater} and selected block`]: totalConsumptionForSelectedBlockAndTypeOfWater }; reply.send(response);