Fix with min time in GetDurationFromCost
This commit is contained in:
parent
1142efaec2
commit
6b3c1cbf0c
@ -43,6 +43,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
double min_price = 0;
|
||||
min_price = cfg->PaymentOption.find(payment_option)->second.pop_min_price;
|
||||
|
||||
if(price < min_price)
|
||||
{
|
||||
return "PARKING NOT ALLOWED";
|
||||
@ -109,6 +110,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
|
||||
if (price_per_unit < 0) price_per_unit = 1.0f;
|
||||
|
||||
if((price/price_per_unit) < minMin) return "PARKING NOT ALLOWED";
|
||||
LOG_DEBUG("Calculated price per minute: ", price_per_unit);
|
||||
|
||||
if (price_per_unit < 0)
|
||||
|
@ -34,9 +34,9 @@ int main() {
|
||||
if (init_tariff(&tariff, "C:\\Users\\MROD\\Documents\\QtCreator\\build-MOBILISIS-Calculator-Desktop_Qt_5_12_12_MSVC2017_32bit-Debug\\main\\etc\\psa_tariff\\zone1.json")) {
|
||||
struct price_t price;
|
||||
memset(&price, 0x00, sizeof(price));
|
||||
QDateTime start = QDateTime::fromString("2023-05-12T15:00:34",Qt::ISODate); //QDateTime::currentDateTime();
|
||||
QDateTime start = QDateTime::fromString("2023-05-12T15:00:38",Qt::ISODate); //QDateTime::currentDateTime();
|
||||
time_t start_parking_time = start.toSecsSinceEpoch() / 60;
|
||||
time_t end_parking_time = start_parking_time + 610;
|
||||
time_t end_parking_time = start_parking_time + 15;
|
||||
|
||||
if (compute_price_for_parking_ticket(tariff,
|
||||
start_parking_time,
|
||||
@ -46,7 +46,7 @@ int main() {
|
||||
}
|
||||
|
||||
QString duration;
|
||||
if(compute_duration_for_parking_ticket(tariff,start_parking_time,188,duration))
|
||||
if(compute_duration_for_parking_ticket(tariff,start_parking_time,37.5,duration))
|
||||
{
|
||||
qDebug() << "GetDurationFromCost() => duration=" << duration;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user