Another small fix on GetDurationFromCost()
This commit is contained in:
parent
2599513ef9
commit
2f8c8cab4c
@ -213,12 +213,12 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
//qDebug() <<"Timestamp:" << inputDate << ", total duration min: " << total_duration_min << ", money left = " << money_left;
|
||||
}
|
||||
|
||||
if ((total_duration_min < minMin) || (price / price_per_unit) < minMin)
|
||||
{
|
||||
LOG_DEBUG("Total duration is lower than min_min");
|
||||
inputDate.time() = worktime_from;
|
||||
total_duration_min = 0;
|
||||
}
|
||||
// if ((total_duration_min < minMin) || (price / price_per_unit) < minMin)
|
||||
// {
|
||||
// LOG_DEBUG("Total duration is lower than min_min");
|
||||
// inputDate.time() = worktime_from;
|
||||
// total_duration_min = 0;
|
||||
// }
|
||||
|
||||
double ret_val = 0;
|
||||
double calc_price = (int)total_duration_min - (int)price / price_per_unit;
|
||||
@ -227,12 +227,16 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
{
|
||||
inputDate.addSecs(-(int)ceil(calc_price) * 60);
|
||||
}
|
||||
ret_val = total_duration_min;
|
||||
|
||||
if(price >= min_price && total_duration_min >= minMin)
|
||||
qDebug() << "Valid until: " << inputDate.toString(Qt::ISODate);
|
||||
else qDebug() << "Parking not allowed";
|
||||
else
|
||||
{
|
||||
qDebug() << "Parking not allowed";
|
||||
total_duration_min = 0;
|
||||
}
|
||||
|
||||
ret_val = total_duration_min;
|
||||
if(ret_val < 0) ret_val = 0;
|
||||
qDebug() << "Duration: " << ret_val;
|
||||
if (ret_val <= 0) return "PARKING NOT ALLOWED";
|
||||
|
@ -36,7 +36,7 @@ int main() {
|
||||
memset(&price, 0x00, sizeof(price));
|
||||
QDateTime start = QDateTime::fromString("2023-05-11T07:50:00",Qt::ISODate); //QDateTime::currentDateTime();
|
||||
time_t start_parking_time = start.toSecsSinceEpoch() / 60;
|
||||
time_t end_parking_time = start_parking_time + 1236;
|
||||
time_t end_parking_time = start_parking_time + 610;
|
||||
|
||||
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,3090,duration))
|
||||
if(compute_duration_for_parking_ticket(tariff,start_parking_time,1525,duration))
|
||||
{
|
||||
qDebug() << "GetDurationFromCost() => duration=" << duration;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user