Implement added helpers.

This commit is contained in:
Gerhard Hoffmann 2023-12-12 10:22:34 +01:00
parent 4187598edf
commit 9dcf7a8f30

View File

@ -399,3 +399,30 @@ uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod
return firstDurationStep;
}
BusinessHours Utilities::getBusinessHours(Configuration const *cfg, PaymentMethod methodId) {
int businessHours = cfg->PaymentOption.find(methodId)->second.pop_business_hours;
switch (businessHours) {
case NoRestriction_24_7: return NoRestriction_24_7;
case OnlyWorkingDays: return OnlyWorkingDays;
case OnlyWeekDays: return OnlyWeekDays;
case OnlyWeekEnd: return OnlyWeekEnd;
case OnlyOfficialHolidays: return OnlyOfficialHolidays;
case OnlySpecialDays: return OnlySpecialDays;
case OnlySchoolHolidays: return OnlySchoolHolidays;
case SpecialAndSchoolHolidays: return SpecialAndSchoolHolidays;
case OnlyOpenForBusinessDays: return OnlyOpenForBusinessDays;
}
return NoBusinessHoursDefined;
}
uint32_t Utilities::computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id) {
int pop_id = cfg->PaymentOption.find(id)->second.pop_id;
return cfg->PaymentRate.find(pop_id)->second.pra_price;
}
double Utilities::computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id) {
int pop_id = cfg->PaymentOption.find(id)->second.pop_id;
int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
return (double)(cfg->Duration.find(durationId)->second.pun_duration);
}