diff --git a/app/db_mgr.py b/app/db_mgr.py index 87bb545..3177049 100644 --- a/app/db_mgr.py +++ b/app/db_mgr.py @@ -1,4 +1,4 @@ -from app.models import db +from app.models import db, Period def projects(): @@ -8,7 +8,7 @@ def projects(): """ current_period_id = get_current_period() sql_txt = """ - select p.id, p.name, sum(tc.charge_rate) as total_charge + select p.id, p.name, IFNULL(sum(tc.charge_rate), 0) as total_charge from project as p left join ( select c.project_id, c.charge_rate from charge c where c.period_id = {}) tc @@ -27,7 +27,7 @@ def agents(): """ current_period_id = get_current_period() sql_txt = """ - select a.id, a.firstname, a.secondname, sum(tc.charge_rate) as total_charge + select a.id, a.firstname, a.secondname, IFNULL (sum(tc.charge_rate), 0) as total_charge from agent as a left join ( select c.agent_id, c.charge_rate from charge c where c.period_id = {}) tc @@ -207,4 +207,5 @@ def get_current_period(): :return: the id of the period of current day """ # TODO: request on dates as soon as periods are dated + p = Period.query.filter(Period.name == '2021').one_or_none() return 14 -- libgit2 0.21.2