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,22 +354,24 @@ bool Utilities::isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymen
}
PaymentMethod Utilities::getPaymentMethodId(Configuration const *cfg) {
if (cfg->PaymentOption.size() != 1) {
if (cfg->PaymentOption.size() == 0) {
return PaymentMethod::Undefined;
}
std::multimap<int, ATBPaymentOption>::const_iterator it =
cfg->PaymentOption.cbegin();
switch (it->first) {
case PaymentMethod::Linear:
return PaymentMethod::Linear;
case PaymentMethod::Steps:
return PaymentMethod::Steps;
case PaymentMethod::Degressive:
return PaymentMethod::Degressive;
case PaymentMethod::Progressive:
return PaymentMethod::Progressive;
if (it != cfg->PaymentOption.cend()) {
switch (it->first) {
case PaymentMethod::Linear:
return PaymentMethod::Linear;
case PaymentMethod::Steps:
return PaymentMethod::Steps;
case PaymentMethod::Degressive:
return PaymentMethod::Degressive;
case PaymentMethod::Progressive:
return PaymentMethod::Progressive;
}
}
return PaymentMethod::Undefined;