Fix: GetDurationFromCost for PaymentMethod::Steps
This commit is contained in:
		@@ -118,17 +118,21 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                            bool nextDay,
 | 
					                                            bool nextDay,
 | 
				
			||||||
                                            bool prepaid)
 | 
					                                            bool prepaid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Get input date
 | 
				
			||||||
 | 
					    QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // use tariff with structure as for instance Schnau, Koenigsee:
 | 
					    // use tariff with structure as for instance Schnau, Koenigsee:
 | 
				
			||||||
    // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
					    // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
				
			||||||
    if (cfg->YearPeriod.size() == 0
 | 
					    if (cfg->YearPeriod.size() == 0
 | 
				
			||||||
        && cfg->SpecialDays.size() == 0
 | 
					        && cfg->SpecialDays.size() == 0
 | 
				
			||||||
        && cfg->SpecialDaysWorktime.size() == 0)
 | 
					        && cfg->SpecialDaysWorktime.size() == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return QString().setNum(GetDurationForPrice(cfg, price)).toStdString();
 | 
					        inputDate = inputDate.addSecs(GetDurationForPrice(cfg, price) * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return inputDate.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get input date
 | 
					 | 
				
			||||||
    QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get day of week
 | 
					    // Get day of week
 | 
				
			||||||
    int weekdayId = 0;
 | 
					    int weekdayId = 0;
 | 
				
			||||||
@@ -633,14 +637,16 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep) const
 | 
				
			|||||||
uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
 | 
					uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
 | 
				
			||||||
    int const pop_id = cfg->getPaymentOptions().pop_id;
 | 
					    int const pop_id = cfg->getPaymentOptions().pop_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
 | 
					    for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        int const payment_unit_id = itr->second.pra_payment_unit_id;
 | 
					        int const payment_unit_id = itr->second.pra_payment_unit_id;
 | 
				
			||||||
        int const pra_price = cfg->PaymentRate.find(payment_unit_id)->second.pra_price;
 | 
					        int const pra_price = itr->second.pra_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (price == pra_price) {
 | 
					        if (price == pra_price) {
 | 
				
			||||||
            int const durationId = itr->second.pra_payment_unit_id;
 | 
					            int const durationId = itr->second.pra_payment_unit_id;
 | 
				
			||||||
            int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
 | 
					            int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return durationUnit;
 | 
					            return durationUnit;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user