GetDurationFromCost():
expanded. still to be tested.
This commit is contained in:
parent
f7be0e471a
commit
b5804408f4
@ -176,7 +176,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
// in this case, adapt inputDate accordingly.
|
// in this case, adapt inputDate accordingly.
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_GET_DURATION_FROM_COST 1
|
// #define DEBUG_GET_DURATION_FROM_COST 1
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||||
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||||
#endif
|
#endif
|
||||||
@ -267,24 +267,41 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||||
|
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||||
|
int price = 0;
|
||||||
|
int durationInSecs = 0;
|
||||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||||
int const pra_price = itr->second.pra_price;
|
int const pra_price = itr->second.pra_price;
|
||||||
if ((double)pra_price == cost) {
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
if (pop_accumulate_prices) {
|
||||||
auto search = cfg->Duration.find(durationId);
|
price += pra_price;
|
||||||
if (search != cfg->Duration.end()) {
|
} else {
|
||||||
// found now the duration in minutes
|
price = pra_price;
|
||||||
// check if we are still inside the working-time-range
|
}
|
||||||
ATBDuration duration = search->second;
|
|
||||||
|
|
||||||
int durationInSecs = duration.pun_duration * 60;
|
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||||
|
|
||||||
|
auto search = cfg->Duration.find(durationId);
|
||||||
|
if (search != cfg->Duration.end()) {
|
||||||
|
// found now the duration in minutes
|
||||||
|
// check if we are still inside the working-time-range
|
||||||
|
ATBDuration duration = search->second;
|
||||||
|
//if (pop_accumulate_durations) {
|
||||||
|
// durationInSecs += duration.pun_duration * 60;
|
||||||
|
//} else {
|
||||||
|
durationInSecs = duration.pun_duration * 60;
|
||||||
|
//}
|
||||||
|
|
||||||
|
if ((double)price == cost) {
|
||||||
QDateTime current_working_date_time_to = inputDate;
|
QDateTime current_working_date_time_to = inputDate;
|
||||||
current_working_date_time_to.setTime(current_working_time_to);
|
current_working_date_time_to.setTime(current_working_time_to);
|
||||||
|
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||||
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << duration.pun_duration;
|
qCritical() << DBG_HEADER << " DURATION ID" << duration.pun_id;
|
||||||
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << duration.pun_duration * 60;
|
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << durationInSecs / 60;
|
||||||
|
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << durationInSecs;
|
||||||
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
|
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
|
||||||
<< current_working_date_time_to.toString(Qt::ISODate);
|
<< current_working_date_time_to.toString(Qt::ISODate);
|
||||||
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
|
||||||
@ -368,7 +385,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return s.toStdString();
|
return s.toStdString();
|
||||||
}
|
} // if ((double)price == cost) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user