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.
|
||||
|
||||
|
||||
//#define DEBUG_GET_DURATION_FROM_COST 1
|
||||
// #define 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);
|
||||
#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);
|
||||
#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) {
|
||||
int const pra_price = itr->second.pra_price;
|
||||
if ((double)pra_price == cost) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
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;
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
if (pop_accumulate_prices) {
|
||||
price += pra_price;
|
||||
} else {
|
||||
price = pra_price;
|
||||
}
|
||||
|
||||
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;
|
||||
current_working_date_time_to.setTime(current_working_time_to);
|
||||
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << duration.pun_duration;
|
||||
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << duration.pun_duration * 60;
|
||||
qCritical() << DBG_HEADER << " DURATION ID" << duration.pun_id;
|
||||
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << durationInSecs / 60;
|
||||
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << durationInSecs;
|
||||
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
|
||||
<< current_working_date_time_to.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
|
||||
|
||||
return s.toStdString();
|
||||
}
|
||||
} // if ((double)price == cost) {
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user