Compare commits
2 Commits
9bfea0f46d
...
e050a8a82a
Author | SHA1 | Date | |
---|---|---|---|
e050a8a82a | |||
68ba6808fa |
@ -456,11 +456,13 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||||||
double price_per_unit = 0.0f;
|
double price_per_unit = 0.0f;
|
||||||
QTime worktime_from;
|
QTime worktime_from;
|
||||||
QTime worktime_to;
|
QTime worktime_to;
|
||||||
|
double durationUnit = 60.0;
|
||||||
|
|
||||||
if(is_special_day)
|
if(is_special_day)
|
||||||
{
|
{
|
||||||
// Set special day price
|
// Set price_per_unit to special day price: at the end of the calculation
|
||||||
price_per_unit = Utilities::CalculatePricePerUnit(day_price);
|
// divide by durationUnit to get correct price.
|
||||||
|
price_per_unit = day_price;
|
||||||
worktime_from = QTime::fromString(cfg->SpecialDaysWorktime.find(current_special_day_id)->second.pedwt_time_from.c_str());
|
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());
|
worktime_to = QTime::fromString(cfg->SpecialDaysWorktime.find(current_special_day_id)->second.pedwt_time_to.c_str());
|
||||||
}
|
}
|
||||||
@ -472,8 +474,13 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||||||
day_price = cfg->PaymentRate.find(pop_id)->second.pra_price;
|
day_price = cfg->PaymentRate.find(pop_id)->second.pra_price;
|
||||||
|
|
||||||
int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
|
int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
|
||||||
double durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||||
price_per_unit = Utilities::CalculatePricePerUnit(day_price,durationUnit);
|
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;
|
||||||
|
|
||||||
// If no working day found, skip it (recursively call method again)
|
// If no working day found, skip it (recursively call method again)
|
||||||
size_t found = 0;
|
size_t found = 0;
|
||||||
@ -484,7 +491,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||||||
{
|
{
|
||||||
LOG_DEBUG("- No workday found, trying to find next available day");
|
LOG_DEBUG("- No workday found, trying to find next available day");
|
||||||
inputDate = inputDate.addDays(1);
|
inputDate = inputDate.addDays(1);
|
||||||
return floor(GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid));
|
return 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_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());
|
worktime_to = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_to.c_str());
|
||||||
@ -594,7 +601,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||||||
|
|
||||||
double ret_val = total_cost;
|
double ret_val = total_cost;
|
||||||
total_cost = 0.0f;
|
total_cost = 0.0f;
|
||||||
return ceil(ret_val);
|
return round(ret_val / durationUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user