Compare commits
81 Commits
2.3.99-2
...
fuchs-mueh
Author | SHA1 | Date | |
---|---|---|---|
96aad6b797
|
|||
648799629a | |||
84e2530767 | |||
ceb78772dd | |||
675ba60733 | |||
d86a688836 | |||
171b23eebb | |||
ae9a54bf02 | |||
84e61844ab | |||
328f7cb712 | |||
84dbfc7234 | |||
48cc6b1302 | |||
a6007ee89a | |||
192a37d93f | |||
b17f77b22a | |||
007978a0f8 | |||
80b21ac231 | |||
0a32d60827 | |||
26a50fb972 | |||
964ee17540 | |||
6ef57792ce | |||
ec9f7d9262 | |||
a2c40fa32a | |||
25b3143d88
|
|||
0856f10ca9 | |||
88c703ecc2
|
|||
465b2274a1 | |||
f946cd13e4
|
|||
8d1cbe7337
|
|||
62c52fd580 | |||
1023f6ede1 | |||
36b3e85d1b | |||
b394ed46cc | |||
3dda2d8355 | |||
1152c3824e | |||
4271c0fb31 | |||
24d9d4a0ff | |||
4bce854d77 | |||
138221759b | |||
9cb7d4aea6 | |||
cde490bab2 | |||
f0677374ec | |||
89b05ffadc | |||
260973cd09 | |||
3a98a14eb0
|
|||
7bf7108668 | |||
e5629ba4fd | |||
0d0d34cb87
|
|||
e4cb992aae | |||
cdeb625a15 | |||
589d89b73a | |||
7536f89d75 | |||
9a6b2b195d | |||
7233bc55c2 | |||
8fff7a76f6
|
|||
52b7c2390a | |||
894e23332f | |||
fbc255a6f2 | |||
24ab01695d | |||
37652d3b6a | |||
14fd7ddd39 | |||
ca3c3921d4 | |||
37620a06c1 | |||
9f4affca5a | |||
4f2c33cdc2 | |||
3cd02296b0 | |||
f1493f417f | |||
356e3be178 | |||
31b1dd1690 | |||
84d807930e
|
|||
dbf5b1f11d | |||
18f4e74eea
|
|||
29368ea850 | |||
b84f80887e | |||
bfd9f3b80c
|
|||
cb69d3ca2f
|
|||
4a2b15d086 | |||
63043931c2
|
|||
8dad8f00e8 | |||
1ea03f522c
|
|||
805a732c52 |
@@ -40,12 +40,12 @@ public:
|
||||
}
|
||||
|
||||
void ResetTimeSteps(int paymentOptionIndex) {
|
||||
if (m_timeSteps.size() > 0) {
|
||||
if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
}
|
||||
}
|
||||
QList<int> timeSteps(int paymentOptionIndex=0) const {
|
||||
if (m_timeSteps.size() > 0) {
|
||||
if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
|
||||
return m_timeSteps[paymentOptionIndex];
|
||||
}
|
||||
return QList<int>();
|
||||
@@ -133,10 +133,10 @@ private:
|
||||
int durationMinutes);
|
||||
|
||||
//
|
||||
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex=0) const;
|
||||
uint32_t GetPriceForStep(Configuration *cfg, int step) const {
|
||||
return GetPriceForTimeStep(cfg, step);
|
||||
}
|
||||
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const;
|
||||
//uint32_t GetPriceForStep(Configuration *cfg, int step) const {
|
||||
// return GetPriceForTimeStep(cfg, step, 0);
|
||||
//}
|
||||
uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
|
||||
uint32_t GetStepForPrice(Configuration *cfg, int price) const {
|
||||
return GetDurationForPrice(cfg, price);
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "tariff_interpolation.h"
|
||||
#include "tariff_prepaid.h"
|
||||
#include "tariff_carryover.h"
|
||||
#include "tariff_prepay.h"
|
||||
#include "tariff_permit_type.h"
|
||||
|
||||
#include <QVector>
|
||||
@@ -47,13 +48,15 @@ public:
|
||||
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
||||
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
||||
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
||||
using TariffPrepayOptionType = std::multimap<int, ATBPrepay>;
|
||||
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||
using TariffDurationType = std::multimap<int, ATBDuration>;
|
||||
|
||||
ATBProject project;
|
||||
ATBCurrency Currency;
|
||||
ATBDuration duration;
|
||||
|
||||
multimap<int, ATBDuration> Duration;
|
||||
TariffDurationType Duration;
|
||||
multimap<int, ATBPaymentMethod> PaymentMethod;
|
||||
multimap<int, ATBPaymentRate> PaymentRate;
|
||||
SpecialDaysWorktimeType SpecialDaysWorktime;
|
||||
@@ -70,6 +73,7 @@ public:
|
||||
TariffProductType TariffProduct;
|
||||
TariffInterpolationType TariffInterpolations;
|
||||
TariffPrepaidType TariffPrepaidOptions;
|
||||
TariffPrepayOptionType TariffPrepayOptions;
|
||||
TariffCarryOverType TariffCarryOverOptions;
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
class ATBDuration
|
||||
{
|
||||
@@ -12,20 +13,35 @@ public:
|
||||
, pun_duration_saved(0)
|
||||
, pun_duration_min(0)
|
||||
, pun_duration_max(0)
|
||||
, pun_interpolation_id(-1) {
|
||||
, pun_interpolation_id(-1)
|
||||
, pun_netto(false)
|
||||
, pun_brutto(false)
|
||||
, pun_fixed(false)
|
||||
, pun_mutable(false)
|
||||
, pun_round_to_next_24h_boundary(false)
|
||||
, pun_round_to_prev_24h_boundary(false)
|
||||
, pun_align_with_timepoint(QDateTime())
|
||||
, pun_next_step_correction(0) {
|
||||
}
|
||||
|
||||
friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
|
||||
QDebugStateSaver saver(debug);
|
||||
|
||||
debug.nospace()
|
||||
<< " pun_id: " << td.pun_id << "\n"
|
||||
<< " pun_label: " << QString::fromStdString(td.pun_label) << "\n"
|
||||
<< " pun_duration: " << td.pun_duration << "\n"
|
||||
<< " pun_duration_saved: " << td.pun_duration_saved << "\n"
|
||||
<< " pun_duration_min: " << td.pun_duration_min << "\n"
|
||||
<< " pun_duration_max: " << td.pun_duration_max << "\n"
|
||||
<< "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
|
||||
<< " pun_id: " << td.pun_id << "\n"
|
||||
<< " pun_label: " << QString::fromStdString(td.pun_label) << "\n"
|
||||
<< " pun_duration: " << td.pun_duration << "\n"
|
||||
<< " pun_duration_saved: " << td.pun_duration_saved << "\n"
|
||||
<< " pun_duration_min: " << td.pun_duration_min << "\n"
|
||||
<< " pun_duration_max: " << td.pun_duration_max << "\n"
|
||||
<< " pun_interpolation_id: " << td.pun_interpolation_id << "\n"
|
||||
<< " pun_netto: " << td.pun_netto << "\n"
|
||||
<< " pun_brutto: " << td.pun_brutto << "\n"
|
||||
<< " pun_fixed: " << td.pun_fixed << "\n"
|
||||
<< " pun_mutable: " << td.pun_mutable << "\n"
|
||||
<< "pun_round_to_next_24h_boundary: " << td.pun_round_to_next_24h_boundary << "\n"
|
||||
<< "pun_round_to_prev_24h_boundary: " << td.pun_round_to_prev_24h_boundary << "\n"
|
||||
<< " pun_align_with_timepoint: " << td.pun_align_with_timepoint << endl;
|
||||
|
||||
return debug;
|
||||
}
|
||||
@@ -33,8 +49,16 @@ public:
|
||||
int pun_id;
|
||||
std::string pun_label;
|
||||
int pun_duration;
|
||||
int pun_duration_saved;
|
||||
int pun_duration_min;
|
||||
int pun_duration_max;
|
||||
int pun_interpolation_id;
|
||||
int pun_duration_saved;
|
||||
int pun_duration_min;
|
||||
int pun_duration_max;
|
||||
int pun_interpolation_id;
|
||||
bool pun_netto; // the timestep expressed by this duration is a netto timestep
|
||||
bool pun_brutto; // the timestep expressed by this duration is a brutto timestep
|
||||
bool pun_fixed; // the value given in tariff-file is fixed (constant)
|
||||
bool pun_mutable; // the value could change
|
||||
bool pun_round_to_next_24h_boundary;
|
||||
bool pun_round_to_prev_24h_boundary;
|
||||
QDateTime pun_align_with_timepoint;
|
||||
int pun_next_step_correction;
|
||||
};
|
||||
|
@@ -13,16 +13,17 @@ enum MemberType
|
||||
WeekDaysWorkTimeType = 0x06,
|
||||
SpecialDaysWorktimeType = 0x07,
|
||||
SpecialDaysType = 0x08,
|
||||
PeriodYearType = 0x09,
|
||||
DailyTicketType = 0x0A,
|
||||
CustomerType = 0x0B,
|
||||
TimeBaseType = 0x0C,
|
||||
TimeRangeType = 0x0D,
|
||||
TimeStepConfigType = 0x0E,
|
||||
ProductType = 0x0F,
|
||||
InterpolationType = 0x10,
|
||||
PrepaidType = 0x11,
|
||||
CarryOverType = 0x12
|
||||
PeriodYearType = 0x09,
|
||||
DailyTicketType = 0x0A,
|
||||
CustomerType = 0x0B,
|
||||
TimeBaseType = 0x0C,
|
||||
TimeRangeType = 0x0D,
|
||||
TimeStepConfigType = 0x0E,
|
||||
ProductType = 0x0F,
|
||||
InterpolationType = 0x10,
|
||||
PrepaidType = 0x11, // deprecated
|
||||
CarryOverType = 0x12,
|
||||
PrepaidOptionType = 0x13,
|
||||
};
|
||||
|
||||
#endif // MEMBER_TYPE_H_INCLUDED
|
||||
|
@@ -28,6 +28,7 @@ public:
|
||||
pop_carry_over = -1;
|
||||
pop_carry_over_option_id = -1;
|
||||
pop_prepaid_option_id = -1;
|
||||
pop_prepay_option_id = -1;
|
||||
pop_truncate_last_interpolation_step = false;
|
||||
pop_accumulate_prices = false;
|
||||
pop_accumulate_durations = false;
|
||||
@@ -38,8 +39,10 @@ public:
|
||||
pop_daily_card_price = -1;
|
||||
pop_business_hours = -1;
|
||||
pop_time_step_config = -1;
|
||||
pop_use_only_upto_datetime = "";
|
||||
pop_use_only_for_duration = 0;
|
||||
pop_use_only_upto_datetime = ""; // deprecated
|
||||
pop_use_only_for_duration = 0; // deprecated
|
||||
pop_plus_steps = 1; // +: jump <x=1> steps forward
|
||||
pop_minus_steps = 1; // -: jump <x=1> steps backward
|
||||
}
|
||||
|
||||
int pop_id;
|
||||
@@ -59,7 +62,8 @@ public:
|
||||
int pop_carry_over;
|
||||
int pop_carry_over_option_id;
|
||||
bool pop_truncate_last_interpolation_step;
|
||||
int pop_prepaid_option_id;
|
||||
int pop_prepaid_option_id; // deprecated
|
||||
int pop_prepay_option_id;
|
||||
bool pop_carry_over_target;
|
||||
int pop_carry_over_time_range_id;
|
||||
int pop_carry_over_start_time_range;
|
||||
@@ -69,6 +73,8 @@ public:
|
||||
int pop_time_step_config;
|
||||
bool pop_accumulate_prices;
|
||||
bool pop_accumulate_durations;
|
||||
int pop_plus_steps;
|
||||
int pop_minus_steps;
|
||||
|
||||
struct ATBMaxDateTime {
|
||||
int direction;
|
||||
|
68
library/include/mobilisis/tariff_prepay.h
Normal file
68
library/include/mobilisis/tariff_prepay.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef TARIFF_PREPAY_H_INCLUDED
|
||||
#define TARIFF_PREPAY_H_INCLUDED
|
||||
|
||||
#include <QTime>
|
||||
|
||||
struct ATBPrepay {
|
||||
struct week {
|
||||
int day;
|
||||
bool prepaid; // yes/no
|
||||
QTime start; // only valid if prepaid == true
|
||||
QTime end;
|
||||
int duration;
|
||||
} prepay[8];
|
||||
|
||||
int id;
|
||||
|
||||
friend QDebug operator<<(QDebug debug, ATBPrepay const &pp) {
|
||||
QDebugStateSaver saver(debug);
|
||||
|
||||
debug.nospace()
|
||||
<< " id:" << pp.id << "\n"
|
||||
<< " **** Monday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Monday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Monday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Monday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Monday].prepaid << "\n"
|
||||
<< " **** Tuesday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Tuesday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Tuesday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Tuesday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Tuesday].prepaid << "\n"
|
||||
<< " **** Wednesday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Wednesday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Wednesday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Wednesday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Wednesday].prepaid << "\n"
|
||||
<< " **** Thursday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Thursday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Thursday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Thursday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Thursday].prepaid << "\n"
|
||||
<< " **** Friday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Friday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Friday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Friday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Friday].prepaid << "\n"
|
||||
<< " **** Saturday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Saturday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Saturday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Saturday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Saturday].prepaid << "\n"
|
||||
<< " **** Sunday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Sunday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Sunday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Sunday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Sunday].prepaid << "\n";
|
||||
|
||||
return debug;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TARIFF_CARRYOVER_H_INCLUDED
|
@@ -6,7 +6,7 @@
|
||||
#include <QDebugStateSaver>
|
||||
|
||||
struct ATBTimeStepConfig {
|
||||
enum class TimeStepConfig {STATIC=1, DYNAMIC=2};
|
||||
enum class TimeStepConfig {STATIC=1, DYNAMIC=2, RECOMPUTE_SOME=3};
|
||||
|
||||
ATBTimeStepConfig() = default;
|
||||
int tsconfig_id;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
|
||||
#include "day_of_week.h"
|
||||
#include "configuration.h"
|
||||
@@ -62,6 +63,7 @@ namespace Utilities {
|
||||
/// <returns></returns>
|
||||
bool IsYearPeriodActive(Configuration* cfg, struct tm* currentDateTime);
|
||||
bool IsYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime);
|
||||
std::optional<ATBPeriodYear> GetYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime);
|
||||
|
||||
/// <summary>
|
||||
/// Check permissions
|
||||
|
@@ -38,24 +38,24 @@ SOURCES += \
|
||||
src/tariff_global_defines.cpp
|
||||
|
||||
HEADERS += \
|
||||
include/mobilisis/calculator_functions.h \
|
||||
include/mobilisis/duration.h \
|
||||
include/mobilisis/payment_opt.h \
|
||||
include/mobilisis/spec_days.h \
|
||||
include/mobilisis/utilities.h \
|
||||
include/mobilisis/configuration.h \
|
||||
include/mobilisis/member_type.h \
|
||||
include/mobilisis/payment_option.h \
|
||||
include/mobilisis/spec_days_worktime.h \
|
||||
include/mobilisis/weekdays.h \
|
||||
include/mobilisis/currency.h \
|
||||
include/mobilisis/payment_method.h \
|
||||
include/mobilisis/payment_rate.h \
|
||||
include/mobilisis/time_range.h \
|
||||
include/mobilisis/weekdays_worktime.h \
|
||||
include/mobilisis/day_of_week.h \
|
||||
include/mobilisis/payment_mtd.h \
|
||||
include/mobilisis/period_year.h \
|
||||
include/mobilisis/calculator_functions.h \
|
||||
include/mobilisis/duration.h \
|
||||
include/mobilisis/payment_opt.h \
|
||||
include/mobilisis/spec_days.h \
|
||||
include/mobilisis/utilities.h \
|
||||
include/mobilisis/configuration.h \
|
||||
include/mobilisis/member_type.h \
|
||||
include/mobilisis/payment_option.h \
|
||||
include/mobilisis/spec_days_worktime.h \
|
||||
include/mobilisis/weekdays.h \
|
||||
include/mobilisis/currency.h \
|
||||
include/mobilisis/payment_method.h \
|
||||
include/mobilisis/payment_rate.h \
|
||||
include/mobilisis/time_range.h \
|
||||
include/mobilisis/weekdays_worktime.h \
|
||||
include/mobilisis/day_of_week.h \
|
||||
include/mobilisis/payment_mtd.h \
|
||||
include/mobilisis/period_year.h \
|
||||
include/mobilisis/time_range_header.h \
|
||||
include/mobilisis/tariff_cfg.h \
|
||||
include/mobilisis/tariff_calc.h \
|
||||
@@ -89,12 +89,14 @@ HEADERS += \
|
||||
include/mobilisis/tariff_interpolation.h \
|
||||
include/mobilisis/tariff_prepaid.h \
|
||||
include/mobilisis/tariff_carryover.h \
|
||||
include/mobilisis/tariff_prepay.h \
|
||||
include/mobilisis/tariff_global_defines.h
|
||||
|
||||
OTHER_FILES += src/main.cpp \
|
||||
../tariffs/tariff_korneuburg.json \
|
||||
../tariffs/tariff_linsinger_maschinenbau.json \
|
||||
../tariffs/tariff_naz.json
|
||||
# OTHER_FILES += src/main.cpp \
|
||||
# ../tariffs/tariff_korneuburg.json \
|
||||
# ../tariffs/tariff_linsinger_maschinenbau.json \
|
||||
# ../tariffs/tariff_naz.json \
|
||||
# /home/linux/customer_502/etc/psa_tariff/tariff03.json
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
|
@@ -3,6 +3,8 @@
|
||||
#include "calculator_functions.h"
|
||||
#include "payment_option.h"
|
||||
#include "utilities.h"
|
||||
#include "tariff_global_defines.h"
|
||||
#include "period_year.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
@@ -94,21 +96,56 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
int minPrice = -1;
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
minPrice = compute_product_price(cfg, permitType, start);
|
||||
} break;
|
||||
default:
|
||||
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
int payment_method_id = cfg->getPaymentOptions(paymentOptionIndex).pop_payment_method_id;
|
||||
|
||||
if (payment_method_id == PaymentMethod::Degressive) {
|
||||
// Degressive: new for Fuchs Technik (500), ValserAlm (Fane):
|
||||
// the minimal price has to be calculated, in cannot be hard coded into
|
||||
// the tariff file.
|
||||
// The working times have a reference into the payment rates. Two special
|
||||
// entries (with the numbers 1000/1001) point to the respective prices.
|
||||
switch(permitType) {
|
||||
default: {
|
||||
// find the correct work time range
|
||||
int weekDay = start.date().dayOfWeek();
|
||||
std::optional<QVector<ATBWeekDaysWorktime>> const &wd = cfg->getAllWeekDayWorkTimes();
|
||||
if (wd.has_value()) {
|
||||
QVector<ATBWeekDaysWorktime> const &vec = wd.value();
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
ATBWeekDaysWorktime const &wt = vec[i];
|
||||
if (wt.pwd_period_day_in_week_id == weekDay) {
|
||||
if (start.time() >= QTime::fromString(QString::fromStdString(wt.pwd_time_from), Qt::ISODate)
|
||||
&& start.time() <= QTime::fromString(QString::fromStdString(wt.pwd_time_to), Qt::ISODate)) {
|
||||
// found worktime range
|
||||
int pop_id = wt.pwd_pop_id; // 1000 or 1001
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
i = vec.size(); // to leave outer loop
|
||||
minPrice = itr->second.pra_price; // this is now the minimal price
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
minPrice = compute_product_price(cfg, permitType, start);
|
||||
} break;
|
||||
default:
|
||||
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
}
|
||||
}
|
||||
|
||||
return minPrice;
|
||||
@@ -211,8 +248,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
|
||||
if (product.size() > 0) {
|
||||
if (productStart && productEnd) {
|
||||
int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
|
||||
int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
|
||||
int pop_min_time = get_minimal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
|
||||
int pop_max_time = get_maximal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
|
||||
if (pop_max_time >= pop_min_time) {
|
||||
*productStart = start;
|
||||
*productEnd = start.addSecs(pop_max_time*60);
|
||||
@@ -290,6 +327,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
||||
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||
} else if (paymentMethodId == PaymentMethod::Degressive) {
|
||||
maxPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||
} else { // PaymentMethod::Linear -> e.g. szeged
|
||||
int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; // maxTime is given in minutes
|
||||
@@ -315,10 +354,20 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
break;
|
||||
case PERMIT_TYPE::DAY_TICKET_PKW:
|
||||
break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
|
||||
break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
|
||||
break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
||||
std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
|
||||
if (po.has_value()) {
|
||||
ATBPaymentOption option = po.value();
|
||||
return option.pop_max_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
||||
std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
|
||||
if (po.has_value()) {
|
||||
ATBPaymentOption option = po.value();
|
||||
return option.pop_max_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
|
||||
break;
|
||||
default: ;
|
||||
@@ -417,17 +466,23 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
int UpDown, PermitType const &permitType)
|
||||
{
|
||||
|
||||
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
||||
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
|
||||
|
||||
std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
|
||||
if (!paymentOption.has_value()) {
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
// FIXME
|
||||
//std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
|
||||
//if (!paymentOption.has_value()) {
|
||||
// qCritical() << " compute_next_timestep() ERROR";
|
||||
// return currentTimeMinutes;
|
||||
//}
|
||||
|
||||
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
qCritical() << " compute_next_timestep() payment option index: " << paymentOptionIndex;
|
||||
int const &pop_plus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_plus_steps;
|
||||
int const &pop_minus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_minus_steps;
|
||||
|
||||
qCritical() << __LINE__ << "compute_next_timestep() payment option index: " << paymentOptionIndex;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() plus steps: " << pop_plus_steps;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() minus steps: " << pop_minus_steps;
|
||||
|
||||
Configuration const *cfg = tariff;
|
||||
|
||||
@@ -435,19 +490,19 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
switch (paymentMethodId) {
|
||||
case PaymentMethod::Progressive:
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Progressive";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Progressive";
|
||||
break;
|
||||
case PaymentMethod::Degressive:
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Degressive";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Degressive";
|
||||
break;
|
||||
case PaymentMethod::Linear:
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Linear";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Linear";
|
||||
break;
|
||||
case PaymentMethod::Steps:
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Steps";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Steps";
|
||||
break;
|
||||
case PaymentMethod::Undefined:
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Undefined";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Undefined";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -455,61 +510,106 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||
if ((paymentMethodId == PaymentMethod::Steps) ||
|
||||
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
||||
(paymentMethodId == PaymentMethod::Progressive))
|
||||
(paymentMethodId == PaymentMethod::Progressive) ||
|
||||
// degressive tariff: e.g. Fuchs Technik (500)
|
||||
(paymentMethodId == PaymentMethod::Degressive))
|
||||
{
|
||||
// int paymentOptionIndex = 1;
|
||||
|
||||
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
||||
|
||||
int const size = stepList.size();
|
||||
if (size == 0) {
|
||||
qCritical() << "compute_next_timestep() *ERROR empty step-list*";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
|
||||
qCritical() << " compute_next_timestep() first time step:" << stepList[0];
|
||||
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
|
||||
qCritical() << " compute_next_timestep() currentTimeInMinutes:" << currentTimeMinutes;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() first time step:" << stepList[0];
|
||||
qCritical() << __LINE__ << "compute_next_timestep() timeSteps:" << stepList;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() currentTimeInMinutes:" << currentTimeMinutes;
|
||||
|
||||
// consider time shift: the step-list might have been computed at a
|
||||
// slightly different time point
|
||||
|
||||
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
|
||||
if (currentStepIndex == -1) {
|
||||
unsigned minimalDistance = ~0;
|
||||
int j = -1;
|
||||
for (int i = 0; i < stepList.size(); ++i) {
|
||||
unsigned distance = std::abs(stepList[i] - currentTimeMinutes);
|
||||
if (distance < minimalDistance) {
|
||||
minimalDistance = distance;
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
// max. tolerance set to 3 minutes
|
||||
unsigned const tolerance = std::min(minimalDistance, (unsigned)(3));
|
||||
if (j != -1) {
|
||||
stepList[j] = currentTimeMinutes;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
int maxStep = -1;
|
||||
if (size >= 2) {
|
||||
maxStep = stepList[1] - stepList[0];
|
||||
}
|
||||
int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
|
||||
// max. tolerance set to 5 minutes
|
||||
int const tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
|
||||
for (int i=0; i < stepList.size(); ++i) {
|
||||
if (std::abs(stepList[i] - currentTimeMinutes) <= tolerance) {
|
||||
qCritical().noquote()
|
||||
<< QString(" compute_next_timestep() correction stepList[%1]=%2 -> %3:")
|
||||
<< __LINE__ << QString("compute_next_timestep() correction stepList[%1]=%2 -> %3:")
|
||||
.arg(i).arg(stepList[0]).arg(currentTimeMinutes);
|
||||
stepList[i] = currentTimeMinutes;
|
||||
qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() NEW timeSteps:" << stepList;
|
||||
}
|
||||
}
|
||||
|
||||
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
|
||||
#endif
|
||||
|
||||
currentStepIndex = stepList.indexOf(currentTimeMinutes);
|
||||
qCritical() << __LINE__ << "compute_next_timestep() currentStepIndex (" << currentStepIndex << ")";
|
||||
|
||||
if (currentStepIndex == -1) {
|
||||
qCritical() << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
|
||||
if (UpDown == 1) { // UP
|
||||
if (stepList[currentStepIndex] == stepList.last()) {
|
||||
qCritical() << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
else {
|
||||
return stepList[currentStepIndex + 1];
|
||||
int const rest = currentStepIndex % pop_plus_steps;
|
||||
|
||||
if (rest) {
|
||||
currentStepIndex -= rest;
|
||||
}
|
||||
|
||||
qCritical() << __LINE__ << "compute_next_timestep() currentStepIndex (" << currentStepIndex << ")";
|
||||
|
||||
int const nextStepIndex = currentStepIndex + pop_plus_steps;
|
||||
|
||||
qCritical() << __LINE__ << "compute_next_timestep() next step index:" << nextStepIndex;
|
||||
if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
|
||||
qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
|
||||
return stepList[nextStepIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (UpDown == 0) { // DOWN
|
||||
if (stepList[currentStepIndex] == stepList.first()) {
|
||||
qCritical() << "compute_next_timestep() *NO PREVIOUS STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
qCritical() << __LINE__ << "compute_next_timestep() *NO PREVIOUS STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
else {
|
||||
return stepList[currentStepIndex - 1];
|
||||
int const nextStepIndex = currentStepIndex - pop_minus_steps;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() next step index:" << nextStepIndex;
|
||||
if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
|
||||
qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
|
||||
return stepList[nextStepIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
@@ -553,6 +653,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
time_t end_parking_time, // netto time in minutes
|
||||
struct price_t *price,
|
||||
PermitType permitType) { // permitType maps to product
|
||||
|
||||
CalcState calcState;
|
||||
|
||||
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
||||
@@ -611,7 +712,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
QDateTime &start_parking_time,
|
||||
QDateTime &start_parking_time_,
|
||||
int netto_parking_time,
|
||||
QDateTime &end_parking_time,
|
||||
struct price_t *price,
|
||||
@@ -620,7 +721,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
{
|
||||
CalcState calcState;
|
||||
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(start_parking_time);
|
||||
QDateTime start_parking_time(start_parking_time_);
|
||||
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
|
||||
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
@@ -632,8 +735,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
<< " netto_parking_time: " << netto_parking_time << endl
|
||||
<< " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
|
||||
<< " minMin: " << minMin << endl
|
||||
<< " maxMin: " << maxMin;
|
||||
|
||||
<< " maxMin: " << maxMin
|
||||
<< " prepaid: " << prepaid
|
||||
<< " permitType: " << permitType.toString();
|
||||
|
||||
if (netto_parking_time < 0) {
|
||||
calcState.setDesc(QString("end=%1, start=%2")
|
||||
@@ -655,38 +759,71 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
double cost = -1;
|
||||
if (start_parking_time.isValid()) {
|
||||
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
|
||||
if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Degressive) {
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
// hier muesste man unterscheiden: uebertrag oder nicht?
|
||||
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
|
||||
netto_parking_time, paymentOptionIndex);
|
||||
if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< calcState.toString();
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< calcState.toString();
|
||||
return calcState;
|
||||
}
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
|
||||
QList<int> lll = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time_);
|
||||
Q_UNUSED(tlist);
|
||||
|
||||
// netto_parking_time = compute_next_timestep(tariff, netto_parking_time, 1, permitType);
|
||||
|
||||
qCritical() << "LINE" << __LINE__ << "netto" << netto_parking_time << lll;
|
||||
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
// compute cost (price)
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
|
||||
end_parking_time = start_parking_time.addSecs(netto_parking_time*60);
|
||||
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
|
||||
int weekDay = start_parking_time.date().dayOfWeek();
|
||||
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
||||
|
||||
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
||||
if (yperiod.has_value()) {
|
||||
ATBPeriodYear const &period = yperiod.value();
|
||||
pop_carry_over_option_id = period.pye_id;
|
||||
qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
|
||||
}
|
||||
|
||||
QTime const carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||
int const carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||
|
||||
qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||
|
||||
// handle prepaid option
|
||||
QDateTime effectiveStartTime(start_parking_time);
|
||||
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
|
||||
if (prepaidOption.has_value()) {
|
||||
ATBPrepaid const &p = prepaidOption.value();
|
||||
if (p.never) {
|
||||
qCritical() << __func__ << __LINE__ << "prepaid: no";
|
||||
} else {
|
||||
if (start_parking_time.time() < p.static_end) { // static_end: e.g. 08:00:00
|
||||
effectiveStartTime.setTime(p.static_end);
|
||||
} else
|
||||
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
|
||||
effectiveStartTime.setTime(p.static_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle carry over
|
||||
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
||||
if (netto_parking_time > minutesUntilCarryOver) {
|
||||
int const rest = netto_parking_time - minutesUntilCarryOver;
|
||||
QDateTime s(effectiveStartTime);
|
||||
s = s.addSecs(minutesUntilCarryOver * 60);
|
||||
s = s.addSecs(carryOverDuration * 60);
|
||||
end_parking_time = s.addSecs(rest * 60);
|
||||
} else {
|
||||
end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
|
||||
}
|
||||
|
||||
} else {
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
@@ -703,8 +840,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
qCritical() << " end_parking_time: " << end_parking_time;
|
||||
qCritical() << " -> calculated cost (netto): " << cost;
|
||||
//qCritical() << __LINE__ << " end_parking_time: " << end_parking_time;
|
||||
//qCritical() << __LINE__ << " -> calculated cost (netto): " << cost;
|
||||
|
||||
price->brutto = price->vat = price->vat_percentage = 0;
|
||||
price->units = cost;
|
||||
@@ -714,6 +851,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||
}
|
||||
|
||||
if (end_parking_time.time().hour() == 0 && end_parking_time.time().minute() == 0) {
|
||||
end_parking_time = end_parking_time.addDays(-1);
|
||||
end_parking_time.setTime(QTime(23, 59, 0));
|
||||
}
|
||||
qCritical() << __func__ << __LINE__ << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
|
||||
|
||||
return calcState.set(CalcState::State::SUCCESS);
|
||||
}
|
||||
|
||||
@@ -731,15 +874,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
if (start.isValid()) {
|
||||
QString cs = start.toString(Qt::ISODate);
|
||||
|
||||
bool prepaid = true;
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
if (prepaid_option_id == 2) { // see tariff03.json for 502: 2 means no prepaid-option
|
||||
prepaid = false;
|
||||
}
|
||||
bool const nextDay = false;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||
qCritical() << " start (cs): " << cs;
|
||||
qCritical() << " price: " << price;
|
||||
qCritical() << "compute_duration_for_parking_ticket(1): ";
|
||||
qCritical() << " payment option index: " << paymentOptionIndex;
|
||||
qCritical() << " prepaid: " << prepaid;
|
||||
qCritical() << " start (cs): " << cs;
|
||||
qCritical() << " price: " << price;
|
||||
|
||||
duration = Calculator::GetInstance().GetDurationFromCost(tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
price, permitType, nextDay, prepaid).c_str();
|
||||
QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
|
||||
if (!d.isValid()) {
|
||||
calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
|
||||
@@ -760,13 +913,33 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
PermitType permitType)
|
||||
{
|
||||
CalcState calcState;
|
||||
|
||||
bool prepaid = true;
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
if (prepaid_option_id == 2) {
|
||||
prepaid = false;
|
||||
}
|
||||
bool const nextDay = false;
|
||||
|
||||
// DEBUG
|
||||
// if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "\ncompute_duration_for_parking_ticket(2):";
|
||||
qCritical() << " start time:" << start_parking_time.toString(Qt::ISODate);
|
||||
qCritical() << " payment option index:" << paymentOptionIndex;
|
||||
qCritical() << " prepaid:" << prepaid;
|
||||
qCritical() << " price:" << price;
|
||||
qCritical() << " permit type:" << permitType.toString() << endl;
|
||||
|
||||
// }
|
||||
|
||||
if (start_parking_time.isValid()) {
|
||||
QString cs = start_parking_time.toString(Qt::ISODate);
|
||||
QString endTime = Calculator::GetInstance().GetDurationFromCost(
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
price, permitType, nextDay, prepaid).c_str();
|
||||
|
||||
if (endTime == CalcState::SUCCESS) {
|
||||
calcState.setDesc(QString("SUCCESS"));
|
||||
@@ -828,15 +1001,21 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
} else {
|
||||
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
|
||||
|
||||
// DEBUG
|
||||
//qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||
//qCritical() << " endTime: " << endTime;
|
||||
//qCritical() << " ticketEndTime: " << ticketEndTime;
|
||||
|
||||
if (!ticketEndTime.isValid()) {
|
||||
calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
|
||||
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
|
||||
}
|
||||
|
||||
if (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
|
||||
ticketEndTime = ticketEndTime.addDays(-1);
|
||||
ticketEndTime.setTime(QTime(23, 59, 0));
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "\ncompute_duration_for_parking_ticket():";
|
||||
qCritical() << " start time:" << start_parking_time.toString(Qt::ISODate);
|
||||
qCritical() << " endTime:" << endTime;
|
||||
qCritical() << " ticketEndTime:" << ticketEndTime.toString(Qt::ISODate) << endl;
|
||||
}
|
||||
} else {
|
||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
||||
#include "tariff_business_hours.h"
|
||||
#include "tariff_global_defines.h"
|
||||
#include "tariff_carryover.h"
|
||||
#include "tariff_prepay.h"
|
||||
#include "tariff_global_defines.h"
|
||||
|
||||
#include <QString>
|
||||
@@ -35,6 +36,7 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
|
||||
if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
|
||||
if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
|
||||
if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
|
||||
if (strcmp(member_name, "PrepaidOption") == 0) return MemberType::PrepaidOptionType;
|
||||
else return MemberType::UnknownType;
|
||||
}
|
||||
|
||||
@@ -108,6 +110,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
ATBInterpolation TariffInterpolation;
|
||||
ATBPrepaid TariffPrepaidOption;
|
||||
ATBCarryOver TariffCarryOver;
|
||||
ATBPrepay TariffPrepayOption;
|
||||
|
||||
MemberType mb_type = MemberType::UnknownType;
|
||||
this->currentPaymentOptions.clear();
|
||||
@@ -141,7 +144,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
continue;
|
||||
}
|
||||
|
||||
qCritical() << " -" << mb_name;
|
||||
// qCritical() << " -" << mb_name;
|
||||
|
||||
// Get array for each JSON object member
|
||||
auto mb_array = document[mb_name].GetArray();
|
||||
@@ -171,6 +174,61 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
{
|
||||
case MemberType::UnknownType:
|
||||
break;
|
||||
case MemberType::PrepaidOptionType: {
|
||||
if (QString(inner_obj_name) == QString("prepaid_option_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
int const &x = k->value.GetInt();
|
||||
TariffPrepayOption.id = x;
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("prepaid_option_week")) {
|
||||
if (k->value.IsArray()) {
|
||||
auto days = k->value.GetArray();
|
||||
for (rapidjson::SizeType j=0; j < days.Size(); ++j) {
|
||||
if (days[j].IsObject()) {
|
||||
auto weekday = days[j].GetObject();
|
||||
for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) {
|
||||
int day = j+1; // 8 entries
|
||||
QString member(QString::fromStdString(w->name.GetString()));
|
||||
if (member == "prepaid_option_day") {
|
||||
if (w->value.IsInt()) {
|
||||
rapidjson::SizeType const d = w->value.GetInt();
|
||||
if (d != (j+1)) {
|
||||
qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
|
||||
}
|
||||
TariffPrepayOption.prepay[day].day = day;
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_duration") {
|
||||
if (w->value.IsInt()) {
|
||||
TariffPrepayOption.prepay[day].duration = w->value.GetInt();
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_prepaid") {
|
||||
if (w->value.IsBool()) {
|
||||
bool b = w->value.GetBool();
|
||||
TariffPrepayOption.prepay[day].prepaid = b;
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_start") {
|
||||
if (w->value.IsString()) {
|
||||
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
||||
TariffPrepayOption.prepay[day].start = t;
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_end") {
|
||||
if (w->value.IsString()) {
|
||||
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
||||
TariffPrepayOption.prepay[day].end = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} break;
|
||||
case MemberType::CarryOverType: {
|
||||
if (QString(inner_obj_name) == QString("carry_over_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
@@ -231,6 +289,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
}
|
||||
}
|
||||
} break;
|
||||
// deprecated
|
||||
case MemberType::PrepaidType: {
|
||||
if (QString(inner_obj_name) == QString("prepaid_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
@@ -598,6 +657,14 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
if (k->value.IsInt()) {
|
||||
this->currentPaymentOptions.last().pop_use_only_for_duration = k->value.GetInt();
|
||||
}
|
||||
} else if (strcmp(inner_obj_name, "pop_plus_steps") == 0) {
|
||||
if (k->value.IsInt()) {
|
||||
this->currentPaymentOptions.last().pop_plus_steps = k->value.GetInt();
|
||||
}
|
||||
} else if (strcmp(inner_obj_name, "pop_minus_steps") == 0) {
|
||||
if (k->value.IsInt()) {
|
||||
this->currentPaymentOptions.last().pop_minus_steps = k->value.GetInt();
|
||||
}
|
||||
} else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) {
|
||||
this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
|
||||
@@ -614,8 +681,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
||||
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) {
|
||||
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) { // deprecated
|
||||
this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_prepay_option_id") == 0) {
|
||||
this->currentPaymentOptions.last().pop_prepay_option_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
|
||||
this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
|
||||
} else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
|
||||
@@ -713,6 +782,42 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
} else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_netto") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_netto = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_brutto") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_brutto = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_fixed") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_fixed = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_mutable") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_mutable = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_round_to_next_24h_boundary") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_round_to_next_24h_boundary = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_round_to_prev_24h_boundary") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_round_to_prev_24h_boundary = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_align_with_timepoint") == 0) {
|
||||
if (k->value.IsString()) {
|
||||
QDateTime const &dt = QDateTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||
Duration.pun_align_with_timepoint = dt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MemberType::SpecialDaysWorktimeType:
|
||||
if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
|
||||
@@ -777,7 +882,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
} break;
|
||||
case MemberType::DurationType:
|
||||
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
|
||||
// qCritical() << Duration;
|
||||
//qCritical() << Duration;
|
||||
break;
|
||||
case MemberType::SpecialDaysWorktimeType:
|
||||
cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
|
||||
@@ -831,6 +936,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
|
||||
// qCritical() << TariffCarryOver;
|
||||
break;
|
||||
case MemberType::PrepaidOptionType:
|
||||
cfg->TariffPrepayOptions.insert(pair<int, ATBPrepay>(TariffPrepayOption.id, TariffPrepayOption));
|
||||
//qCritical() << TariffPrepayOption;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -882,7 +991,7 @@ std::optional<QDateTime> Configuration::getInterpolationEnd(QDateTime const &sta
|
||||
ATBInterpolation interpolation = ipolCheck.value();
|
||||
switch (duration.pun_interpolation_id) {
|
||||
case static_cast<int>(ATBInterpolation::NO_INTERPOLATION):
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
|
||||
break;
|
||||
case static_cast<int>(ATBInterpolation::STATIC_WALLCLOCK_TIME_VALUES):
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
@@ -987,6 +1096,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
|
||||
for (int opt=0; opt < numOptions; ++opt) {
|
||||
uint64_t const pop_id = getPaymentOptions(opt).pop_id;
|
||||
if (pop_id == (uint64_t)sd.ped_payment_option_id) {
|
||||
|
||||
qCritical() << __func__ << __LINE__ << opt;
|
||||
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
@@ -996,6 +1108,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
|
||||
for (int opt=0; opt < numOptions; ++opt) {
|
||||
uint64_t const pop_business_hours = getPaymentOptions(opt).pop_business_hours;
|
||||
|
||||
if (pop_business_hours == 0) { // 0 == 24/7
|
||||
return opt;
|
||||
}
|
||||
|
||||
uint64_t p = 0;
|
||||
int const dayOfWeek = dt.date().dayOfWeek();
|
||||
@@ -1026,6 +1141,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
|
||||
}
|
||||
|
||||
if ((pop_business_hours & p) == p) {
|
||||
|
||||
qCritical() << __func__ << __LINE__ << opt;
|
||||
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
@@ -1148,6 +1266,7 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
|
||||
if (paymentOptions) {
|
||||
QVector<ATBPaymentOption> const vec = paymentOptions.value();
|
||||
PermitType const p(permitType);
|
||||
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
if (vec[i].pop_product_name == p.toString()) {
|
||||
return i;
|
||||
@@ -1161,8 +1280,11 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
|
||||
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
|
||||
std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
|
||||
if (paymentOptions) {
|
||||
|
||||
|
||||
QVector<ATBPaymentOption> const vec = paymentOptions.value();
|
||||
PermitType const p(permitType);
|
||||
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
if (vec[i].pop_product_name == p.toString()) {
|
||||
return i;
|
||||
@@ -1310,11 +1432,14 @@ Configuration::getPaymentOptionsForAllKeys() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
// TODO: umbenennen: getPaymentOptionForPermitType
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForKey(PERMIT_TYPE permitType) const {
|
||||
return getPaymentOptionForKey(static_cast<int>(permitType));
|
||||
}
|
||||
|
||||
|
||||
// TODO: umbenennen: getPaymentOptionForPermitType
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForKey(int permitType) const {
|
||||
std::optional<ATBPaymentOption> value;
|
||||
@@ -1331,6 +1456,7 @@ Configuration::getPaymentOptionForKey(int permitType) const {
|
||||
return value;
|
||||
}
|
||||
|
||||
// TODO: umbenennen: getPaymentOptionForPermitType
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForKey(QString const &permitTypeStr) const {
|
||||
PERMIT_TYPE permitType = PermitType::toPermitType(permitTypeStr);
|
||||
|
@@ -215,6 +215,43 @@ bool Utilities::IsYearPeriodActive(Configuration const *cfg, QDateTime const &dt
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<ATBPeriodYear>
|
||||
Utilities::GetYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime) {
|
||||
|
||||
ATBPeriodYear period;
|
||||
std::optional<ATBPeriodYear> value;
|
||||
|
||||
for (multimap<int, ATBPeriodYear>::const_iterator it = cfg->YearPeriod.cbegin();
|
||||
it != cfg->YearPeriod.cend();
|
||||
++it) {
|
||||
QDate const s(currentDateTime.date().year(), it->second.pye_start_month, it->second.pye_start_day);
|
||||
QDate const e(currentDateTime.date().year(), it->second.pye_end_month, it->second.pye_end_day);
|
||||
|
||||
QDateTime start(currentDateTime);
|
||||
QDateTime end(currentDateTime);
|
||||
|
||||
start.setDate(s);
|
||||
end.setDate(e);
|
||||
|
||||
if (start.date().dayOfYear() < end.date().dayOfYear()) {
|
||||
// start and end in the same year
|
||||
if (currentDateTime.date().dayOfYear() >= start.date().dayOfYear() &&
|
||||
currentDateTime.date().dayOfYear() <= end.date().dayOfYear()) {
|
||||
value = value.value_or(it->second);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (currentDateTime.date().dayOfYear() >= start.date().dayOfYear() ||
|
||||
currentDateTime.date().dayOfYear() <= end.date().dayOfYear()) {
|
||||
value = value.value_or(it->second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
bool Utilities::CheckSpecialDay(Configuration* cfg, const char* currentDateTimeStr, int* specialDayId, double* specialDayPrice)
|
||||
{
|
||||
|
408
main/main.cpp
408
main/main.cpp
@@ -49,9 +49,9 @@ extern "C" char* strptime(const char* s,
|
||||
#define NEUHAUSER_STOCKERAU (0)
|
||||
#define KLEIPEDA_LITAUEN (0)
|
||||
#define SEXTEN (0)
|
||||
#define SCHNALS_LEITER_KIRCHL (1)
|
||||
#define SCHNALS_LEITER_KIRCHL (0)
|
||||
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
||||
#define VALSER_ALM (0)
|
||||
#define VALSER_ALM (1)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
@@ -354,7 +354,7 @@ int main() {
|
||||
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
return 0;
|
||||
// return 0;
|
||||
|
||||
CalcState cs;
|
||||
double cost;
|
||||
@@ -363,7 +363,7 @@ int main() {
|
||||
|
||||
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
|
||||
for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
|
||||
QDateTime s(QDate(2024, 5, 19 + day), QTime()); // 20: (whit) monday,..., 26: sunday
|
||||
QDateTime s(QDate(2024, 7, 29 + day), QTime()); // 20: (whit) monday,..., 26: sunday
|
||||
QDateTime end;
|
||||
|
||||
switch (day) {
|
||||
@@ -401,9 +401,11 @@ int main() {
|
||||
bool prepaid = true);
|
||||
*/
|
||||
|
||||
for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||
QDateTime start = s.addSecs(minutes * 60);
|
||||
QDateTime effectiveStart = start;
|
||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||
for (int minutes = 540; minutes <= 540; ++minutes) {
|
||||
// QDateTime start = s.addSecs(minutes * 60);
|
||||
QDateTime start(QDateTime::currentDateTime());
|
||||
QDateTime effectiveStart(QDateTime::currentDateTime());
|
||||
|
||||
if (start.time() < QTime(8, 0, 0)) {
|
||||
effectiveStart.setTime(QTime(8, 0, 0));
|
||||
@@ -415,55 +417,18 @@ int main() {
|
||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 2100; i += 10) {
|
||||
for (int i = 30; i <= 30; i += 10) {
|
||||
//for (int i = 2100; i <= 2100; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
durationInMinutes = pop_min_time;
|
||||
if (i > 0) {
|
||||
durationInMinutes += (i/10) * 4;
|
||||
}
|
||||
offsetInMinutes = 0;
|
||||
|
||||
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(22, 0, 0)) {
|
||||
if (effectiveStart.time().secsTo(QTime(22, 0, 0)) < (durationInMinutes * 60)) {
|
||||
offsetInMinutes = 600; // 22:00 -> 8:00
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
i += 20;
|
||||
}
|
||||
|
||||
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
||||
|
||||
if (day == Qt::Monday && minutes >= 480 && minutes <= 1320) {
|
||||
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << "| cost ............................." << cost;
|
||||
qCritical() << "| durationInMinutes ................" << durationInMinutes
|
||||
<< "(" << (durationInMinutes - 60) << "+ 60 )";
|
||||
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) { // return value
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||
} else {
|
||||
qCritical() << cs.toString();
|
||||
}
|
||||
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "cost ............................." << cost;
|
||||
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
|
||||
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
||||
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -552,7 +517,7 @@ int main() {
|
||||
*/
|
||||
|
||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||
for (int minutes = 0; minutes < 1440; minutes += 1) {
|
||||
for (int minutes = 480; minutes <= 480; minutes += 1) {
|
||||
QDateTime start = s.addSecs(minutes * 60);
|
||||
|
||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
@@ -569,66 +534,32 @@ int main() {
|
||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||
}
|
||||
|
||||
/*
|
||||
for (int i = 10; i <= 400; i += 10) {
|
||||
//for (int i = 2100; i <= 2100; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) { // return value
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
|
||||
durationInMinutes = pop_min_time;
|
||||
if (i > 0) {
|
||||
durationInMinutes += (i/10) * 4;
|
||||
}
|
||||
offsetInMinutes = 0;
|
||||
|
||||
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(19, 0, 0)) {
|
||||
if (effectiveStart.time().secsTo(QTime(19, 0, 0)) < (durationInMinutes * 60)) {
|
||||
offsetInMinutes = 780; // 19:00 -> 8:00
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
i += 20;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
||||
|
||||
if (day == Qt::Monday && minutes >= 480 && minutes <= 1140) {
|
||||
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << "| cost ............................." << cost;
|
||||
qCritical() << "| durationInMinutes ................" << durationInMinutes
|
||||
<< "(" << (durationInMinutes - 60) << "+ 60 )";
|
||||
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||
} else {
|
||||
// qCritical() << cs.toString();
|
||||
}
|
||||
}
|
||||
*/
|
||||
int netto_parking_time = 60;
|
||||
struct price_t price;
|
||||
|
||||
#if 0
|
||||
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "cost ............................." << cost;
|
||||
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
|
||||
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
||||
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
exit(-1);
|
||||
#endif
|
||||
qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
QDateTime const s = start;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
||||
qCritical() << "start" << s.toString(Qt::ISODate)
|
||||
<< "netto_parking_time" << netto_parking_time
|
||||
<< "< price" << price.netto
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,7 +668,7 @@ int main() {
|
||||
effectiveStart.setTime(QTime(7, 0, 0)); // next day
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
||||
for (int i = 200; i <= 200; i += 10) {
|
||||
cost = i;
|
||||
@@ -760,7 +691,7 @@ int main() {
|
||||
//for (int i = 2100; i <= 2100; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)))) { // return value
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
@@ -801,7 +732,7 @@ int main() {
|
||||
int pop_max_price;
|
||||
int pop_daily_card_price;
|
||||
|
||||
int zone = 2;
|
||||
int zone = 3;
|
||||
|
||||
if (zone == 1) {
|
||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
|
||||
@@ -810,7 +741,14 @@ int main() {
|
||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
|
||||
}
|
||||
if (zone == 3) {
|
||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
|
||||
//input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
|
||||
//input.open("/home/linux/customer_502/etc/psa_tariff/tariff01.json");
|
||||
|
||||
// schnals
|
||||
// input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
||||
|
||||
// muehlbach
|
||||
input.open("/opt/ptu5/opt/customer_504/etc/psa_tariff/tariff01.json");
|
||||
}
|
||||
|
||||
std::stringstream sstr;
|
||||
@@ -823,22 +761,85 @@ int main() {
|
||||
cout << endl;
|
||||
|
||||
if (isParsed) {
|
||||
pop_min_time = get_minimal_parkingtime(&cfg);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time: " << pop_min_time;
|
||||
qCritical() << " pop_max_time: " << pop_max_time;
|
||||
qCritical() << " pop_min_price: " << pop_min_price;
|
||||
qCritical() << " pop_max_price: " << pop_max_price;
|
||||
if (zone == 1 || zone == 3) {
|
||||
/*
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time_pkw: " << pop_min_time;
|
||||
qCritical() << " pop_max_time_pkw: " << pop_max_time;
|
||||
qCritical() << " pop_min_price_pkw: " << pop_min_price;
|
||||
qCritical() << " pop_max_price_pkw: " << pop_max_price;
|
||||
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time_bus: " << pop_min_time;
|
||||
qCritical() << " pop_max_time_bus: " << pop_max_time;
|
||||
qCritical() << " pop_min_price_bus: " << pop_min_price;
|
||||
qCritical() << " pop_max_price_bus: " << pop_max_price;
|
||||
*/
|
||||
}
|
||||
if (zone == 2) {
|
||||
pop_min_time = get_minimal_parkingtime(&cfg);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time: " << pop_min_time;
|
||||
qCritical() << " pop_max_time: " << pop_max_time;
|
||||
qCritical() << " pop_min_price: " << pop_min_price;
|
||||
qCritical() << " pop_max_price: " << pop_max_price;
|
||||
}
|
||||
|
||||
//QDateTime start = QDateTime::currentDateTime();
|
||||
//start.setTime(QTime(12, 0, 0));
|
||||
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
|
||||
//qCritical() << "TimeSteps" << timeSteps;
|
||||
//return 0;
|
||||
if (zone == 1) {
|
||||
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
||||
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << timeSteps;
|
||||
int Down = 0;
|
||||
int Up = 1;
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
||||
|
||||
if (paymentOptionIndex < 0) {
|
||||
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
||||
<< "< 0 for start" << start.toString(Qt::ISODate);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
QSet<uint32_t> const prices_pkw{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
||||
QSet<uint32_t> const prices_bus{3000, 6000, 9000, 12000, 15000, 18000, 21000};
|
||||
|
||||
QDateTime end;
|
||||
CalcState calcState;
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
|
||||
s.setTime(QTime(12, 0, 0));
|
||||
|
||||
//calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
// (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
//qCritical() << end.toString(Qt::ISODate);
|
||||
//qCritical() << calcState.toString();
|
||||
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)50, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
|
||||
qCritical() << end.toString(Qt::ISODate);
|
||||
qCritical() << calcState.toString();
|
||||
}
|
||||
|
||||
if (zone == 2) {
|
||||
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
||||
@@ -858,6 +859,16 @@ int main() {
|
||||
|
||||
QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
||||
|
||||
QDateTime end;
|
||||
CalcState calcState;
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
|
||||
s.setTime(QTime(18, 0, 0));
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)600, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
qCritical() << end.toString(Qt::ISODate);
|
||||
qCritical() << calcState.toString();
|
||||
#if 0
|
||||
|
||||
for (int i=0; i<timeSteps.size(); ++i) {
|
||||
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
||||
@@ -882,89 +893,110 @@ int main() {
|
||||
<< "(price so far:" << price << ")";
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (zone == 3) {
|
||||
int price;
|
||||
QDateTime productStart;
|
||||
QDateTime productEnd;
|
||||
//QDateTime xx(QDateTime::fromString("2024-07-31T00:00:00", Qt::ISODate));
|
||||
//xx = xx.addSecs(-60); // --> "2024-07-30T23:59:00"
|
||||
//qCritical() << xx.toString(Qt::ISODate);
|
||||
|
||||
//QDateTime s(QDateTime::currentDateTime());
|
||||
//s.setTime(QTime(12, 0, 0));
|
||||
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, s);
|
||||
//qCritical() << timeSteps;
|
||||
int Down = 0;
|
||||
int Up = 1;
|
||||
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
|
||||
if (paymentOptionIndex != 0) {
|
||||
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
||||
<< "< 0 for start" << start.toString(Qt::ISODate);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
//QSet<uint32_t> const prices1{800, 1600, 2400, 3200, 4000, 4800, 5600};
|
||||
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
|
||||
|
||||
QDateTime end;
|
||||
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
s.setTime(QTime(10, 0, 0));
|
||||
|
||||
#if 0
|
||||
start.setTime(QTime(0, 0, 0));
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
|
||||
qCritical() << QString("line=%1 price (%2) :")
|
||||
.arg(__LINE__)
|
||||
.arg(start.time().toString(Qt::ISODate)) << price;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
||||
|
||||
start.setTime(QTime(14, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex, s);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__)
|
||||
<< price;
|
||||
pop_daily_card_price = cfg.getPaymentOptions(paymentOptionIndex).pop_daily_card_price;
|
||||
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
|
||||
qCritical() << QString("line=%1 price:").arg(__LINE__) << price;
|
||||
int h = pop_min_time / 60;
|
||||
int m = pop_min_time % 60;
|
||||
qCritical().noquote() << QString(" pop_min_time %1 (%2h, %3m)").arg(pop_min_time).arg(h).arg(m);
|
||||
|
||||
start.setTime(QTime(15, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
h = pop_max_time / 60;
|
||||
m = pop_max_time % 60;
|
||||
qCritical().noquote()
|
||||
<< QString(" pop_max_time %1 (%2h, %3m)").arg(pop_max_time).arg(h).arg(m);
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
start.setTime(QTime(16, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
start.setTime(QTime(17, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
|
||||
//price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
//qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
//price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
|
||||
//qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
qCritical() << " pop_min_price " << pop_min_price;
|
||||
qCritical() << " pop_max_price " << pop_max_price;
|
||||
qCritical() << "pop_daily_card_price " << pop_daily_card_price;
|
||||
#endif
|
||||
CalcState calcState;
|
||||
|
||||
#if 1
|
||||
qCritical() << "start" << s.toString(Qt::ISODate);
|
||||
//for (int i = 1; i < 11; ++i) {
|
||||
for (int i = 0; i < 21; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)i*10,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
qCritical() << "RUN" << i << ": start" << s.toString(Qt::ISODate)
|
||||
<< ": price" << i*10 << "->" << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
#else
|
||||
for (int h = 0; h < 24; ++h) {
|
||||
start.setTime(QTime(h, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 %2 price (%3-%4) :")
|
||||
.arg(__LINE__)
|
||||
.arg(start.time().toString(Qt::ISODate))
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
struct price_t price;
|
||||
int netto_parking_time = 1440;
|
||||
|
||||
start = s;
|
||||
qCritical() << "RUN" << 0 << ": start" << s.toString(Qt::ISODate);
|
||||
|
||||
calcState = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
|
||||
end, &price,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
qCritical() << "RUN" << 0 << ": start" << start.toString(Qt::ISODate)
|
||||
<< ": price for netto-time" << netto_parking_time
|
||||
<< "->" << price.netto << "->" << end.toString(Qt::ISODate) << calcState.toString();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)minimal_parking_price + i*800,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
|
||||
// #else
|
||||
s.setTime(QTime(12, 0, 0));
|
||||
|
||||
minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS),
|
||||
paymentOptionIndex, s);
|
||||
|
||||
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)minimal_parking_price + i*800,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
|
||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1485,7 +1517,7 @@ int main() {
|
||||
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
||||
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
||||
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
if (cs.getStatus() != CalcState::State::SUCCESS) {
|
||||
if (start.time().hour() >= 8 && start.time().hour() < 18) {
|
||||
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
|
||||
@@ -1508,7 +1540,7 @@ int main() {
|
||||
}
|
||||
|
||||
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
|
||||
<< timeSteps.at(i) << "PRICE=" << price1;
|
||||
<< timeSteps.at(i) << "PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
|
||||
|
||||
|
||||
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
|
||||
@@ -1592,7 +1624,7 @@ int main() {
|
||||
double cost = 0;
|
||||
CalcState cs;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
||||
cost = price.netto;
|
||||
qCritical() << "step" << *step << ": cost" << cost;
|
||||
} else {
|
||||
@@ -1676,7 +1708,7 @@ int main() {
|
||||
double cost = 0;
|
||||
CalcState cs;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
||||
cost = price.netto;
|
||||
qCritical() << "step" << *step << ": cost" << cost;
|
||||
} else {
|
||||
@@ -1761,7 +1793,7 @@ int main() {
|
||||
double cost = 0;
|
||||
CalcState cs;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
||||
cost = price.netto;
|
||||
qCritical() << "step" << *step << ": cost" << cost;
|
||||
} else {
|
||||
@@ -1819,7 +1851,7 @@ int main() {
|
||||
double cost = 0;
|
||||
CalcState cs;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
||||
cost = price.netto;
|
||||
qCritical() << "step" << *step << ": cost" << cost;
|
||||
} else {
|
||||
@@ -1922,7 +1954,7 @@ int main() {
|
||||
CalcState cs;
|
||||
for (int i = 13, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
||||
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
qCritical() << endl;
|
||||
}
|
||||
|
||||
@@ -1947,7 +1979,7 @@ int main() {
|
||||
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
||||
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
||||
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
if (cs.getStatus() != CalcState::State::SUCCESS) {
|
||||
if (start.time().hour() >= 8 && start.time().hour() < 18) {
|
||||
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
|
||||
|
@@ -30,7 +30,9 @@ SOURCES += main.cpp
|
||||
# HEADERS +=
|
||||
|
||||
OTHER_FILES += \
|
||||
/home/linux/customer_505/etc/psa_tariff/tariff01.json
|
||||
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json \
|
||||
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json \
|
||||
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user