Implemented compute_price_for_daily_ticket().

This commit is contained in:
Gerhard Hoffmann 2024-01-30 10:41:29 +01:00
parent 6bf3960349
commit 4c1cd45866

View File

@ -497,3 +497,27 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff
return calcState.set(CalcState::State::SUCCESS); return calcState.set(CalcState::State::SUCCESS);
} }
CalcState CALCULATE_LIBRARY_API compute_price_for_daily_ticket(
parking_tariff_t *tariff,
QDateTime const &startDatetime,
QDateTime &endDatetime,
PERMIT_TYPE permitType,
struct price_t *price) {// return value
CalcState calcState;
if (startDatetime.isValid()) {
if (std::optional<struct price_t> p =
Calculator::GetInstance().GetDailyTicketPrice(tariff,
startDatetime,
endDatetime,
permitType)) {
*price = p.value();
}
} else {
return calcState.set(CalcState::State::INVALID_START_DATE);
}
return calcState.set(CalcState::State::SUCCESS);
}