Implement GetDurationForPrice().
This commit is contained in:
parent
80e228b498
commit
4b35b1ffb7
@ -629,3 +629,21 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration const *cfg, uint8_t payme
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
|
||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||
|
||||
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 pra_price = cfg->PaymentRate.find(payment_unit_id)->second.pra_price;
|
||||
|
||||
if (price == pra_price) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
return durationUnit;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user