From 52497a3b20cee968f7aaf0732b1277891c8c8445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Poulain?= Date: Wed, 15 May 2024 12:46:40 +0200 Subject: [PATCH] =?UTF-8?q?fix(emballe):=20le=20reste=20peut=20=C3=AAtre?= =?UTF-8?q?=20nul?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fournée/core/templatetags/fournée_modify.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fournée/core/templatetags/fournée_modify.py b/fournée/core/templatetags/fournée_modify.py index ec4983d..b271880 100644 --- a/fournée/core/templatetags/fournée_modify.py +++ b/fournée/core/templatetags/fournée_modify.py @@ -17,6 +17,10 @@ def submit_row_tag(parser, token): def emballe(quantité, fourniture): quotient = quantité // fourniture.conditionnement reste = quantité % fourniture.conditionnement + if not reste and quotient == 1: + return f"{quotient} {fourniture.emballage}" + if not reste and quotient > 1: + return f"{quotient} {fourniture.emballage}s" if not quotient and reste < fourniture.conditionnement/2: return None if quotient == 1 and reste < fourniture.conditionnement/2: