GetCostFromDuration():
1: Get payment method from tariff file. 2: Use tariffIs24_7() helper (Tariff for Schoenau is such a case) 3: Add new code for neuhauser/linsinger maschinenbau: Very similar to Schoenau, but here there are extra operating times 6.00-18.00 during the week, 6-12 on Saturday. Check if the current time is inside such time ranges and return associated price.
This commit is contained in:
parent
67b12f4b33
commit
a95a39a557
@ -217,12 +217,39 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
Q_UNUSED(payment_option);
|
||||
Q_UNUSED(nextDay);
|
||||
|
||||
if (cfg->YearPeriod.size() == 0
|
||||
&& cfg->SpecialDays.size() == 0
|
||||
&& cfg->SpecialDaysWorktime.size() == 0)
|
||||
{
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
if (tariffIs24_7(cfg)) {
|
||||
end_datetime = start_datetime.addSecs(durationMinutes*60);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
} else {
|
||||
if (Utilities::IsYearPeriodActive(cfg, start_datetime)) {
|
||||
if (!prepaid) {
|
||||
BusinessHours businessHours = Utilities::getBusinessHours(cfg, paymentMethodId);
|
||||
if (businessHours == BusinessHours::OnlyWeekDays) {
|
||||
int const weekdayId = start_datetime.date().dayOfWeek();
|
||||
|
||||
using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
|
||||
std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
|
||||
|
||||
for (WTIterator itr = p.first; itr != p.second; ++itr) {
|
||||
QTime const &from = Utilities::WeekDaysWorkTimeFrom(itr);
|
||||
QTime const &until = Utilities::WeekDaysWorkTimeUntil(itr);
|
||||
QTime const &startTime = start_datetime.time();
|
||||
|
||||
if (from <= startTime && startTime <= until) {
|
||||
end_datetime = start_datetime.addSecs(durationMinutes*60);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << "NOT YET IMPLEMENTED";
|
||||
end_datetime = QDateTime();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime start = start_datetime;
|
||||
|
Loading…
Reference in New Issue
Block a user