From 770d21295753c57d200eb79dd67b5191d849a5d8 Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Wed, 14 Apr 2021 10:49:13 +0200 Subject: [PATCH] Now add only non-zero charge --- app/commands/commands.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/commands/commands.py b/app/commands/commands.py index 3d91b85..6f23392 100644 --- a/app/commands/commands.py +++ b/app/commands/commands.py @@ -81,11 +81,19 @@ def feed_from_irap(csv_file_name): db.session.add(n_s) db.session.commit() + # Feed periods names + # Todo: should come from year column name + # for p in range(2011, 2030): n_p = Period(name=f"{p}") db.session.add(n_p) db.session.commit() + # Now feed the charges. + # + # At least one for each csv row + # At most one for each year + # for r in rows: p = Project.query.filter(Project.name == r[project_key]).one() a = Agent.query.filter(Agent.firstname == r[firstname_key], Agent.secondname == r[secondname_key]).one() @@ -96,8 +104,9 @@ def feed_from_irap(csv_file_name): try: charge = int(100 * float(charge)) except ValueError: - # print(f"Wrong charge {charge}") charge = 0 + if charge == 0: + continue n_c = Charge(agent_id=a.id, project_id=p.id, service_id=s.id, -- libgit2 0.21.2