Compare commits

..

2 Commits

Author SHA1 Message Date
b05950fc37 test case for fuchs/muelbach 2024-08-14 12:26:09 +02:00
1c6c9f934d compute_price_for_parking_ticket():
Minor: added debug output.
2024-08-14 12:05:29 +02:00
2 changed files with 23 additions and 21 deletions

View File

@ -726,13 +726,14 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time); QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time);
//Q_UNUSED(tlist); //Q_UNUSED(tlist);
qCritical() << __func__ << __LINE__ << tlist;
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time; double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time; double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
// netto_parking_time = minMin; // netto_parking_time = minMin;
if (DBG_LEVEL >= DBG_DEBUG) { //if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "compute_price_for_parking_ticket() " << endl qCritical() << "compute_price_for_parking_ticket() " << endl
<< " paymentOptionIndex: " << paymentOptionIndex << endl << " paymentOptionIndex: " << paymentOptionIndex << endl
<< " start_parking_time: " << start_parking_time << endl << " start_parking_time: " << start_parking_time << endl
@ -743,7 +744,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
<< " maxMin: " << maxMin << endl << " maxMin: " << maxMin << endl
<< " prepaid: " << prepaid << endl << " prepaid: " << prepaid << endl
<< " permitType: " << permitType.toString(); << " permitType: " << permitType.toString();
} //}
if (netto_parking_time < 0) { if (netto_parking_time < 0) {
calcState.setDesc(QString("end=%1, start=%2") calcState.setDesc(QString("end=%1, start=%2")
@ -847,8 +848,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
} }
// DEBUG // DEBUG
//qCritical() << __LINE__ << " end_parking_time: " << end_parking_time; // qCritical() << __LINE__ << " end_parking_time: " << end_parking_time;
//qCritical() << __LINE__ << " -> calculated cost (netto): " << cost; qCritical() << __LINE__ << " -> calculated cost (netto): " << cost;
price->brutto = price->vat = price->vat_percentage = 0; price->brutto = price->vat = price->vat_percentage = 0;
price->units = cost; price->units = cost;
@ -862,7 +863,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
end_parking_time = end_parking_time.addDays(-1); end_parking_time = end_parking_time.addDays(-1);
end_parking_time.setTime(QTime(23, 59, 0)); end_parking_time.setTime(QTime(23, 59, 0));
} }
//qCritical() << __func__ << __LINE__ << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
qCritical() << __func__ << __LINE__ << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
return calcState.set(CalcState::State::SUCCESS); return calcState.set(CalcState::State::SUCCESS);
} }

View File

@ -732,16 +732,16 @@ int main() {
if (isParsed) { if (isParsed) {
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING); PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
pop_min_time = get_minimal_parkingtime(&cfg, permitType); //pop_min_time = get_minimal_parkingtime(&cfg, permitType);
pop_max_time = get_maximal_parkingtime(&cfg, permitType); //pop_max_time = get_maximal_parkingtime(&cfg, permitType);
pop_min_price = get_minimal_parkingprice(&cfg, permitType); //pop_min_price = get_minimal_parkingprice(&cfg, permitType);
pop_max_price = get_maximal_parkingprice(&cfg, permitType); //pop_max_price = get_maximal_parkingprice(&cfg, permitType);
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price; //pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
qCritical() << " pop_min_time: " << pop_min_time; //qCritical() << " pop_min_time: " << pop_min_time;
qCritical() << " pop_max_time: " << pop_max_time; //qCritical() << " pop_max_time: " << pop_max_time;
qCritical() << " pop_min_price: " << pop_min_price; //qCritical() << " pop_min_price: " << pop_min_price;
qCritical() << " pop_max_price: " << pop_max_price; //qCritical() << " pop_max_price: " << pop_max_price;
CalcState cs; CalcState cs;
double cost; double cost;
@ -749,8 +749,8 @@ int main() {
int offsetInMinutes = 0; int offsetInMinutes = 0;
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) { // for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
for (int day = Qt::Monday; day <= Qt::Monday; ++day) { for (int day = Qt::Wednesday; day <= Qt::Wednesday; ++day) {
QDateTime s(QDate(2024, 7, 21 + day), QTime(0, 0, 0)); QDateTime s(QDate(2024, 8, 11 + day), QTime(0, 0, 0));
QDateTime end; QDateTime end;
switch (day) { switch (day) {
@ -778,7 +778,7 @@ int main() {
} }
//for (int minutes = 0; minutes < 1440; ++minutes) { //for (int minutes = 0; minutes < 1440; ++minutes) {
for (int minutes = 420; minutes <= 420; minutes += 1) { for (int minutes = 491; minutes <= 491; minutes += 1) {
QDateTime start = s.addSecs(minutes * 60); QDateTime start = s.addSecs(minutes * 60);
//qCritical() << "start" << start.toString(Qt::ISODate); //qCritical() << "start" << start.toString(Qt::ISODate);
@ -797,7 +797,7 @@ int main() {
effectiveStart.setTime(QTime(7, 0, 0)); // next day effectiveStart.setTime(QTime(7, 0, 0)); // next day
} }
// #if 0 #if 0
qCritical() << ""; qCritical() << "";
qCritical() << "compute_duration_for_parking_ticket"; qCritical() << "compute_duration_for_parking_ticket";
qCritical() << "==================================="; qCritical() << "===================================";
@ -818,12 +818,12 @@ int main() {
<< "> end" << end.toString(Qt::ISODate); << "> end" << end.toString(Qt::ISODate);
} }
// #else #else
qCritical() << ""; qCritical() << "";
qCritical() << "compute_price_for_parking_ticket"; qCritical() << "compute_price_for_parking_ticket";
qCritical() << "================================"; qCritical() << "================================";
for (int netto_parking_time = 180; netto_parking_time <= (180 + 720*3); netto_parking_time += 36) { for (int netto_parking_time = 180; netto_parking_time <= (180 + 720*3); netto_parking_time += 720) {
QDateTime end; QDateTime end;
struct price_t price; struct price_t price;
cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, permitType, true); cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, permitType, true);
@ -831,7 +831,7 @@ int main() {
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate) qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate)
<< "price" << price.netto; << "price" << price.netto;
} }
// #endif #endif
} }
} }
} }