compute_price_for_parking_ticket(): compute paymentOptionIndex.

(a tariff-file can conatin more than one payment options).
This commit is contained in:
Gerhard Hoffmann 2024-04-19 13:28:35 +02:00
parent e2c02420f0
commit 1852f552a3

View File

@ -445,8 +445,11 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
bool prepaid)
{
CalcState calcState;
double minMin = tariff->getPaymentOptions().pop_min_time;
double maxMin = tariff->getPaymentOptions().pop_max_time;
int paymentOptionIndex = tariff->getPaymentOptionIndex(start_parking_time);
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
// DEBUG
qCritical() << "compute_price_for_parking_ticket() " << endl
@ -477,11 +480,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
double cost = -1;
if (start_parking_time.isValid()) {
if (tariff->getPaymentOptions().pop_payment_method_id == PaymentMethod::Steps) {
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time);
// 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) {
return calcState;
}
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time);
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
} else {
cost = Calculator::GetInstance().GetCostFromDuration(
tariff,
@ -491,7 +496,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
netto_parking_time, // minutes, netto
false, prepaid);
}
double minCost = tariff->getPaymentOptions().pop_min_price;
double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
if (cost < minCost) {
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);