Compare commits

..

No commits in common. "e050a8a82a9256c170f846f8b702cb73987f7406" and "9bfea0f46d4abea1cef5d3120d05838a29ffc458" have entirely different histories.

View File

@ -456,13 +456,11 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
double price_per_unit = 0.0f;
QTime worktime_from;
QTime worktime_to;
double durationUnit = 60.0;
if(is_special_day)
{
// Set price_per_unit to special day price: at the end of the calculation
// divide by durationUnit to get correct price.
price_per_unit = day_price;
// Set special day price
price_per_unit = Utilities::CalculatePricePerUnit(day_price);
worktime_from = QTime::fromString(cfg->SpecialDaysWorktime.find(current_special_day_id)->second.pedwt_time_from.c_str());
worktime_to = QTime::fromString(cfg->SpecialDaysWorktime.find(current_special_day_id)->second.pedwt_time_to.c_str());
}
@ -474,13 +472,8 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
day_price = cfg->PaymentRate.find(pop_id)->second.pra_price;
int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
if (durationUnit == 0) {
durationUnit = 60.0;
}
// Set price_per_unit to day price: at the end of the calculation
// divide by durationUnit to get correct price.
price_per_unit = day_price;
double durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
price_per_unit = Utilities::CalculatePricePerUnit(day_price,durationUnit);
// If no working day found, skip it (recursively call method again)
size_t found = 0;
@ -491,7 +484,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
{
LOG_DEBUG("- No workday found, trying to find next available day");
inputDate = inputDate.addDays(1);
return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid);
return floor(GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid));
}
worktime_from = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_from.c_str());
worktime_to = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_to.c_str());
@ -601,7 +594,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
double ret_val = total_cost;
total_cost = 0.0f;
return round(ret_val / durationUnit);
return ceil(ret_val);
}