GetPriceForTimeStep():
Use special flag 'pop_accumulate_prices' to add up prices given in the tariff json file.
This commit is contained in:
		@@ -2448,6 +2448,9 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
			
		||||
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const {
 | 
			
		||||
 | 
			
		||||
    int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
			
		||||
    int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
			
		||||
 | 
			
		||||
    uint32_t price = 0;
 | 
			
		||||
 | 
			
		||||
    for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
 | 
			
		||||
    {
 | 
			
		||||
@@ -2457,8 +2460,14 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
 | 
			
		||||
        Q_ASSERT(pun_id == payment_unit_id);
 | 
			
		||||
 | 
			
		||||
        int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
 | 
			
		||||
        if (pop_accumulate_prices) {
 | 
			
		||||
            price += itr->second.pra_price;
 | 
			
		||||
        } else {
 | 
			
		||||
            price = (uint32_t)(itr->second.pra_price);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (timeStep == pun_duration) {
 | 
			
		||||
            return (uint32_t)(itr->second.pra_price);
 | 
			
		||||
            return price;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user