diff --git a/models/scop_cotisation.py b/models/scop_cotisation.py index 0af48e4891115b08eaf504cbe687d7c002d92059..20ebcebbf4a4ba4545ccd0f58e0cdebd84cb57c9 100644 --- a/models/scop_cotisation.py +++ b/models/scop_cotisation.py @@ -120,3 +120,18 @@ class ScopCotisation(models.AbstractModel): ('end', '>', date(self.year, 1, 1)) ]).mapped('partner_id') return members + + def round_to_closest_multiple(self, float_to_round, multiple): + """ + :param float_to_round: + :param multiple: + :return: closest_multiple + """ + small_multiple = (float_to_round // multiple) * multiple + large_multiple = small_multiple + multiple + + # Return the closest of two + if abs(float_to_round - small_multiple) < large_multiple: + return small_multiple + else: + return large_multiple