compute_price_for_parking_ticket(): add handling for PaymentMethod::Steps.

This commit is contained in:
Gerhard Hoffmann 2024-04-08 13:58:24 +02:00
parent 57d6b85f52
commit aba38d2614

View File

@ -428,14 +428,23 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
return calcState.set(CalcState::State::SUCCESS);
}
double cost = -1;
if (start_parking_time.isValid()) {
double cost = Calculator::GetInstance().GetCostFromDuration(
if (tariff->getPaymentOptions().pop_payment_method_id == PaymentMethod::Steps) {
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time);
if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
return calcState;
}
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time);
} else {
cost = Calculator::GetInstance().GetCostFromDuration(
tariff,
tariff->getPaymentOptions().pop_payment_method_id,
start_parking_time, // starting time
end_parking_time, // return value: end time
netto_parking_time, // minutes, netto
false, prepaid);
}
double minCost = tariff->getPaymentOptions().pop_min_price;
if (cost < minCost) {
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
@ -445,8 +454,10 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
// DEBUG
qCritical() << " -> calculated cost (price->netto) = " << cost;
price->brutto = price->vat = price->vat_percentage = 0;
price->units = cost;
price->netto = cost;
} else {
return calcState.set(CalcState::State::INVALID_START_DATE);
}