|
|
@ -1201,8 +1201,18 @@ exports.consumption = async (request, reply) => {
|
|
|
|
return acc + parseInt(record.consumption, 10);
|
|
|
|
return acc + parseInt(record.consumption, 10);
|
|
|
|
}, 0);
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
const consumption = (waterlevel_at_midnight + total_water_added_from_midnight) - waterlevel + total_consumption_from_records;
|
|
|
|
let consumption;
|
|
|
|
totalConsumptionForSelectedBlockAndTypeOfWater += consumption;
|
|
|
|
|
|
|
|
|
|
|
|
const isSameTime = start.getTime() === end.getTime();
|
|
|
|
|
|
|
|
const isToday = moment(start).isSame(moment(), 'day');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isSameTime && !isToday) {
|
|
|
|
|
|
|
|
// Same date & time and NOT today => use only records
|
|
|
|
|
|
|
|
consumption = total_consumption_from_records;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Normal case => use full calculation
|
|
|
|
|
|
|
|
consumption = (waterlevel_at_midnight + total_water_added_from_midnight) - waterlevel + total_consumption_from_records;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add to the total consumption and capacities based on water type
|
|
|
|
// Add to the total consumption and capacities based on water type
|
|
|
|
if (tank.typeOfWater === "bore" || tank.typeOfWater === "Bore Water") {
|
|
|
|
if (tank.typeOfWater === "bore" || tank.typeOfWater === "Bore Water") {
|
|
|
|