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