Skip to content

Commit

Permalink
BRS-654/655 adding formulae to backend (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronpettit authored Jun 29, 2022
1 parent d545c6e commit 04540f4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lambda/export/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ const CSV_SYSADMIN_SCHEMA = [
width: 63,
value: (report) => report.totalAttendanceParties,
},
{
column: "Frontcountry Cabins - Parties - Total Attendance",
type: Number,
width: 63,
value: (report) => report.calc_frontcountryCabins_parties_totalAttendance,
},
// Frontcountry Cabins - Camping
{
column: "Frontcountry Cabins - Camping - Gross camping revenue",
Expand Down
7 changes: 7 additions & 0 deletions lambda/export/invokable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {
basicNetRevenue,
frontcountryCampingPartyAttendance,
frontcountryCampingSecondCarAttendance,
frontcountryCabinsPartiesAttendance,
groupCampingStandardAttendance,
dayUseVehicleAttendance,
backcountryCabinsAttendance,
Expand Down Expand Up @@ -209,6 +210,11 @@ async function modifyReportForCSV(report) {
]).result;
break;
case "Frontcountry Cabins":
// Parties - TOTAL ATTENDANCE
report.calc_frontcountryCabins_parties_totalAttendance = frontcountryCabinsPartiesAttendance(
[report.totalAttendanceParties],
report.config.attendanceModifier
).result;
// NET REVENUE
report.calc_frontcountryCabins_camping_netRevenue = basicNetRevenue([
report.revenueGrossCamping,
Expand Down Expand Up @@ -237,6 +243,7 @@ async function modifyReportForCSV(report) {
// People and vehicles - VEHICLE ATTENDANCE
report.calc_dayUse_peopleAndVehicles_vehicleAttendance =
dayUseVehicleAttendance(
[report.peopleAndVehiclesTrail],
[report.peopleAndVehiclesVehicle],
[report.peopleAndVehiclesBus],
report.config.attendanceVehiclesModifier,
Expand Down
17 changes: 15 additions & 2 deletions lambda/formulaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ exports.frontcountryCampingSecondCarAttendance = function (attendances) {
};
};

exports.frontcountryCabinsPartiesAttendance = function (attendances, modifier) {
let formula = `Total attendance = Parties`;
if (modifier) {
formula += ` x ${modifier}`;
}
return {
result: formatTotalWithModifier(attendances, modifier),
formula: formula
};
};

exports.groupCampingStandardAttendance = function (attendances) {
return {
result: formatTotalWithModifier(attendances),
Expand All @@ -107,11 +118,13 @@ exports.groupCampingStandardAttendance = function (attendances) {
};

exports.dayUseVehicleAttendance = function (
trailCount,
vehicles,
buses,
vehicleMod,
busMod
) {
let trailCountTotal = totalWithModifier(trailCount);
let vehicleTotal = totalWithModifier(vehicles, vehicleMod);
let busTotal = totalWithModifier(buses, busMod);
let vehicleFormula = "Vehicles";
Expand All @@ -123,8 +136,8 @@ exports.dayUseVehicleAttendance = function (
busFormula = `(Bus count x ${busMod})`;
}
return {
result: formatTotalWithModifier([vehicleTotal, busTotal]),
formula: `Vehicle attendance = ${vehicleFormula} + ${busFormula}`,
result: formatTotalWithModifier([vehicleTotal, busTotal, trailCountTotal]),
formula: `Vehicle attendance = ${vehicleFormula} + ${busFormula} + Trail count`,
};
};

Expand Down

0 comments on commit 04540f4

Please sign in to comment.