Implement:

getDailyTicketsForAllKeys(), getDailyTicketsForKey(), getPaymentRateForAllKeys(),
getPaymentRateForKey(), getCustomerForType() and getWeekDayWorkTime().
This commit is contained in:
Gerhard Hoffmann 2024-01-30 10:49:30 +01:00
parent 3a6a47725f
commit 5deaa48f8e

View File

@ -467,3 +467,112 @@ QVector<ATBPaymentOption> const &Configuration::getAllPaymentOptions() const {
QVector<ATBPaymentOption> &Configuration::getAllPaymentOptions() { QVector<ATBPaymentOption> &Configuration::getAllPaymentOptions() {
return this->currentPaymentOptions; return this->currentPaymentOptions;
} }
std::optional<QVector<ATBDailyTicket>>
Configuration::getDailyTicketsForAllKeys() const {
QVector<ATBDailyTicket> tickets;
std::optional<QVector<ATBDailyTicket>> value;
for (std::multimap<int, ATBDailyTicket>::const_iterator it = this->DailyTicket.cbegin();
it != this->DailyTicket.cend(); ++it) {
tickets.append(it->second);
}
if (tickets.size() > 0) {
value.value_or(tickets);
}
return value;
}
std::optional<QVector<ATBDailyTicket>>
Configuration::getDailyTicketsForKey(int key) const {
QVector<ATBDailyTicket> tickets;
std::optional<QVector<ATBDailyTicket>> value;
std::pair<
std::multimap<int, ATBDailyTicket>::const_iterator,
std::multimap<int, ATBDailyTicket>::const_iterator
> p = this->DailyTicket.equal_range(key);
for (std::multimap<int, ATBDailyTicket>::const_iterator it = p.first;
it != p.second; ++it) {
tickets.append(it->second);
}
if (tickets.size() > 0) {
value.value_or(tickets);
}
return value;
}
std::optional<QVector<ATBPaymentRate>>
Configuration::getPaymentRateForAllKeys() const {
QVector<ATBPaymentRate> paymentRates;
std::optional<QVector<ATBPaymentRate>> value;
for (std::multimap<int, ATBPaymentRate>::const_iterator it = this->PaymentRate.cbegin();
it != this->PaymentRate.cend(); ++it) {
paymentRates.append(it->second);
}
if (paymentRates.size() > 0) {
value.value_or(paymentRates);
}
return value;
}
std::optional<QVector<ATBPaymentRate>>
Configuration::getPaymentRateForKey(int key) const {
QVector<ATBPaymentRate> paymentRate;
std::optional<QVector<ATBPaymentRate>> value;
std::pair<
std::multimap<int, ATBPaymentRate>::const_iterator,
std::multimap<int, ATBPaymentRate>::const_iterator
> p = this->PaymentRate.equal_range(key);
for (std::multimap<int, ATBPaymentRate>::const_iterator it = p.first;
it != p.second; ++it) {
paymentRate.append(it->second);
}
if (paymentRate.size() > 0) {
value.value_or(paymentRate);
}
return value;
}
std::optional<ATBCustomer>
Configuration::getCustomerForType(ATBCustomer::CustomerType customerType) {
for (std::multimap<int, ATBCustomer>::const_iterator it = this->Customer.cbegin();
it != this->Customer.cend(); ++it) {
ATBCustomer const &customer = it->second;
if (customer.cust_type == customerType) {
return customer;
}
}
return std::nullopt;
}
std::optional<ATBWeekDaysWorktime>
Configuration::getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek) {
ATBWeekDaysWorktime worktime;
std::optional<ATBWeekDaysWorktime> value;
std::multimap<int, ATBWeekDaysWorktime>::const_iterator it = this->WeekDaysWorktime.find((int)dayOfWeek);
if (it != this->WeekDaysWorktime.cend()) {
ATBWeekDaysWorktime const &wt = it->second;
if (QTime::fromString(wt.pwd_time_from.c_str(), Qt::ISODate) >= time
&& QTime::fromString(wt.pwd_time_to.c_str(), Qt::ISODate) < time) {
value.value_or(wt);
}
}
return value;
}