Skip to content
Extraits de code Groupes Projets
Valider 18576880 rédigé par jordan's avatar jordan
Parcourir les fichiers

[add] function to round float to closest multiple

parent d76e63ad
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -120,3 +120,18 @@ class ScopCotisation(models.AbstractModel): ...@@ -120,3 +120,18 @@ class ScopCotisation(models.AbstractModel):
('end', '>', date(self.year, 1, 1)) ('end', '>', date(self.year, 1, 1))
]).mapped('partner_id') ]).mapped('partner_id')
return members 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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter