Fix getPaymentMethodId(): check for valid iterator.

This commit is contained in:
Gerhard Hoffmann 2024-01-31 15:09:42 +01:00
parent 9438a535ea
commit 25a39fdc61

View File

@ -354,13 +354,14 @@ bool Utilities::isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymen
} }
PaymentMethod Utilities::getPaymentMethodId(Configuration const *cfg) { PaymentMethod Utilities::getPaymentMethodId(Configuration const *cfg) {
if (cfg->PaymentOption.size() != 1) { if (cfg->PaymentOption.size() == 0) {
return PaymentMethod::Undefined; return PaymentMethod::Undefined;
} }
std::multimap<int, ATBPaymentOption>::const_iterator it = std::multimap<int, ATBPaymentOption>::const_iterator it =
cfg->PaymentOption.cbegin(); cfg->PaymentOption.cbegin();
if (it != cfg->PaymentOption.cend()) {
switch (it->first) { switch (it->first) {
case PaymentMethod::Linear: case PaymentMethod::Linear:
return PaymentMethod::Linear; return PaymentMethod::Linear;
@ -371,6 +372,7 @@ PaymentMethod Utilities::getPaymentMethodId(Configuration const *cfg) {
case PaymentMethod::Progressive: case PaymentMethod::Progressive:
return PaymentMethod::Progressive; return PaymentMethod::Progressive;
} }
}
return PaymentMethod::Undefined; return PaymentMethod::Undefined;
} }