GetDurationFromCost():
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
d4e03a51dd
commit
60002404da
@ -128,14 +128,40 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
// Get input date
|
// Get input date
|
||||||
QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
|
QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
|
||||||
|
|
||||||
// use tariff with structure as for instance Schnau, Koenigsee:
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
if (paymentMethodId == PaymentMethod::Steps) {
|
||||||
if (cfg->YearPeriod.size() == 0
|
if (tariffIs24_7(cfg)) {
|
||||||
&& cfg->SpecialDays.size() == 0
|
// use tariff with structure as for instance Schoenau, Koenigsee:
|
||||||
&& cfg->SpecialDaysWorktime.size() == 0)
|
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||||
{
|
inputDate = inputDate.addSecs(GetDurationForPrice(cfg, price) * 60);
|
||||||
inputDate = inputDate.addSecs(GetDurationForPrice(cfg, price) * 60);
|
return inputDate.toString(Qt::ISODate).toStdString();
|
||||||
return inputDate.toString(Qt::ISODate).toStdString();
|
} else {
|
||||||
|
QDateTime const &start = QDateTime::fromString(start_datetime, Qt::ISODate);
|
||||||
|
if (Utilities::IsYearPeriodActive(cfg, start)) {
|
||||||
|
if (!prepaid) {
|
||||||
|
BusinessHours businessHours = Utilities::getBusinessHours(cfg, paymentMethodId);
|
||||||
|
if (businessHours == BusinessHours::OnlyWeekDays) {
|
||||||
|
int const weekdayId = start.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.time();
|
||||||
|
|
||||||
|
if (from <= startTime && startTime <= until) {
|
||||||
|
return inputDate.addSecs(GetDurationForPrice(cfg, price) * 60).toString(Qt::ISODate).toStdString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "NOT YET IMPLEMENTED";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ticket t = private_GetDurationFromCost(cfg, inputDate, price, prepaid);
|
Ticket t = private_GetDurationFromCost(cfg, inputDate, price, prepaid);
|
||||||
|
Loading…
Reference in New Issue
Block a user