From 9ca45e613f70bde5bb49006c2dbcd0e931d3386e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 27 Nov 2023 16:15:18 +0100 Subject: [PATCH] Return a ticket from private_GetCostFromDuration(). Add helpers findWorkTimeRange() and findNextWorkTimeRange(). --- .../include/mobilisis/calculator_functions.h | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/library/include/mobilisis/calculator_functions.h b/library/include/mobilisis/calculator_functions.h index bad0566..f757d76 100644 --- a/library/include/mobilisis/calculator_functions.h +++ b/library/include/mobilisis/calculator_functions.h @@ -1,7 +1,14 @@ -#pragma once +#ifndef CALCULATOR_FUNCTIONS_H_INCLUDED +#define CALCULATOR_FUNCTIONS_H_INCLUDED + #include +#include + #include "configuration.h" #include "payment_method.h" +#include "ticket.h" +#include "tariff_time_range.h" + #include using namespace std; @@ -49,13 +56,13 @@ private: int getMinimalParkingTime(Configuration const *cfg, PaymentMethod methodId); int getMaximalParkingTime(Configuration const *cfg, PaymentMethod methodId); - uint32_t private_GetCostFromDuration(Configuration const* cfg, - QDateTime const &start, - QDateTime &end, - int durationMinutes, - bool nextDay = false, - bool prepaid = false, - bool overtime = false); + Ticket private_GetCostFromDuration(Configuration const* cfg, + QDateTime const &start, + QDateTime &end, + int &durationMinutes, + bool nextDay = false, + bool prepaid = false, + bool overtime = false); bool checkDurationMinutes(bool overTime, int minParkingTime, int maxParkingTime, @@ -64,4 +71,13 @@ private: // uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep) const; uint32_t GetDurationForPrice(Configuration *cfg, int price) const; + + int findWorkTimeRange(QDateTime const &dt, + QScopedArrayPointer const &worktime, + size_t size); + int findNextWorkTimeRange(QDateTime const &dt, + QScopedArrayPointer const &worktime, + size_t size); }; + +#endif // CALCULATOR_FUNCTIONS_H_INCLUDED