2023-11-27 16:09:38 +01:00
|
|
|
#pragma once
|
|
|
|
#include <cstring>
|
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include "day_of_week.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
#include "time_range.h"
|
|
|
|
#include "payment_method.h"
|
2023-12-12 10:20:02 +01:00
|
|
|
#include "tariff_business_hours.h"
|
2023-11-27 16:09:38 +01:00
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace Utilities {
|
|
|
|
/// <summary>
|
|
|
|
/// Get day of week from current date (Zeller's Algorithm), starting day is Sunday
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="date"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
DayOfWeek GetDayOfWeek(struct tm* tm);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Date and time parse helper function
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Returns time (tm) structure</returns>
|
|
|
|
struct tm DateTimeToStructTm(const char* dateTimeStr);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Date parse helper function
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Returns time (tm) structure</returns>
|
|
|
|
struct tm DateToStructTm(const char* dateStr);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Time parse helper function
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Returns time (tm) structure</returns>
|
|
|
|
struct tm TimeToStructTm(const char* timeStr, int year, int mon, int mday, int wday);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get current local time
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Returns time_t structure</returns>
|
|
|
|
time_t GetCurrentLocalTime();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Zeller's algorithm for determining day of week
|
|
|
|
/// </summary>
|
|
|
|
int ZellersAlgorithm(int day, int month, int year);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks if current datetime is in range between start and end month of parking worktime
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="tariff_cfg"></param>
|
|
|
|
/// <param name="currentDateTime"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
bool IsYearPeriodActive(Configuration* cfg, struct tm* currentDateTime);
|
|
|
|
bool IsYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Check permissions
|
|
|
|
/// </summary>
|
|
|
|
bool CheckSpecialDay(Configuration* cfg, const char* currentDateTimeStr, int* specialDayId, double* specialDayPrice);
|
|
|
|
bool CheckSpecialDay(Configuration const *cfg,
|
|
|
|
QDateTime const ¤tDateTimeS,
|
|
|
|
int* specialDayId, uint32_t *specialDayPrice);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Calculates price per unit
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pra_price"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
|
|
|
|
|
|
|
|
QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
|
|
|
|
QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
|
|
|
|
QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
|
|
|
QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
2024-02-15 16:11:41 +01:00
|
|
|
int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
|
|
|
// PaymentRate GetPaymentRate(Configuration const *cfg, );
|
2023-11-27 16:09:38 +01:00
|
|
|
bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
|
|
|
|
bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
|
|
|
|
PaymentMethod getPaymentMethodId(Configuration const *cfg);
|
2023-12-07 16:27:09 +01:00
|
|
|
|
|
|
|
int getMinimalParkingTime(Configuration const *cfg, PaymentMethod methodId);
|
|
|
|
int getMaximalParkingTime(Configuration const *cfg, PaymentMethod methodId);
|
|
|
|
uint32_t getMinimalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
|
|
|
uint32_t getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId);
|
2023-12-12 10:20:02 +01:00
|
|
|
BusinessHours getBusinessHours(Configuration const *cfg, PaymentMethod methodId);
|
|
|
|
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
|
|
|
|
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
2023-11-27 16:09:38 +01:00
|
|
|
}
|