compute_duration_for_parking_ticket():

read prepaid-setting from tariff-file, if possible.
This commit is contained in:
Gerhard Hoffmann 2024-07-30 15:32:58 +02:00
parent 9a6b2b195d
commit 7536f89d75

View File

@ -802,15 +802,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
if (start.isValid()) {
QString cs = start.toString(Qt::ISODate);
bool prepaid = true;
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
if (prepaid_option_id == 2) { // see tariff03.json for 502: 2 means no prepaid-option
prepaid = false;
}
bool const nextDay = false;
// DEBUG
qCritical() << "compute_duration_for_parking_ticket(): ";
qCritical() << " start (cs): " << cs;
qCritical() << " price: " << price;
qCritical() << "compute_duration_for_parking_ticket(1): ";
qCritical() << " payment option index: " << paymentOptionIndex;
qCritical() << " prepaid: " << prepaid;
qCritical() << " start (cs): " << cs;
qCritical() << " price: " << price;
duration = Calculator::GetInstance().GetDurationFromCost(tariff,
tariff->getPaymentOptions().pop_payment_method_id,
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
cs.toLocal8Bit().constData(),
price, false, true).c_str();
price, permitType, nextDay, prepaid).c_str();
QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
if (!d.isValid()) {
calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
@ -831,13 +841,28 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
PermitType permitType)
{
CalcState calcState;
bool prepaid = true;
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
if (prepaid_option_id == 2) {
prepaid = false;
}
bool const nextDay = false;
// DEBUG
qCritical() << "compute_duration_for_parking_ticket(2): ";
qCritical() << " payment option index: " << paymentOptionIndex;
qCritical() << " prepaid: " << prepaid;
qCritical() << " price: " << price;
if (start_parking_time.isValid()) {
QString cs = start_parking_time.toString(Qt::ISODate);
QString endTime = Calculator::GetInstance().GetDurationFromCost(
tariff,
tariff->getPaymentOptions().pop_payment_method_id,
cs.toLocal8Bit().constData(),
price, permitType, false, true).c_str();
price, permitType, nextDay, prepaid).c_str();
if (endTime == CalcState::SUCCESS) {
calcState.setDesc(QString("SUCCESS"));