Commit 732a5f85 by Administrator

Merge branch '5015-prevention-decalage-compteur-rattrapage-et-points' into 'dev_cooperatic'

5015 prevention decalage compteur rattrapage et points

See merge request !249
parents 18211df1 bf5f0a70
Pipeline #3138 failed with stage
in 1 minute 5 seconds
...@@ -401,8 +401,10 @@ def update_members_makeups_core(members_data, res): ...@@ -401,8 +401,10 @@ def update_members_makeups_core(members_data, res):
# Update member standard points, for standard members only # Update member standard points, for standard members only
if member_data["member_shift_type"] == "standard": if member_data["member_shift_type"] == "standard":
# Set points to minus the number of makeups to do (limited to -2) # Set points to minus the number of makeups to do + the makeups to come (limited to -2)
target_points = - int(member_data["target_makeups_nb"]) cs = CagetteShift()
shift_data = cs.get_shift_partner(int(member_data["member_id"]))
target_points = - int(member_data["target_makeups_nb"]) - sum(1 for value in shift_data if value['is_makeup'])
if (target_points < -2): if (target_points < -2):
target_points = -2 target_points = -2
...@@ -411,6 +413,7 @@ def update_members_makeups_core(members_data, res): ...@@ -411,6 +413,7 @@ def update_members_makeups_core(members_data, res):
# Don't update if no change # Don't update if no change
if points_diff == 0: if points_diff == 0:
res["res"][-1]['standard_points'] = member_points
continue continue
if member_points > target_points: if member_points > target_points:
...@@ -427,6 +430,9 @@ def update_members_makeups_core(members_data, res): ...@@ -427,6 +430,9 @@ def update_members_makeups_core(members_data, res):
} }
cm.update_member_points(data) cm.update_member_points(data)
#There are some odoo process happening here that could change the actual number of points
#so we want to fetch it again to send it back
res["res"][-1]['standard_points'] = cm.get_member_points("standard")
# Better to call run_process_target_status now, otherwise partner remains # Better to call run_process_target_status now, otherwise partner remains
# in alert until routine is called (every 5 minutes). It is a bit weird for users and # in alert until routine is called (every 5 minutes). It is a bit weird for users and
# allocation of rattrapages before the routine is executed will not trigger change to delay state ! # allocation of rattrapages before the routine is executed will not trigger change to delay state !
......
...@@ -314,21 +314,6 @@ function update_members_makeups(member_ids, action, description) { ...@@ -314,21 +314,6 @@ function update_members_makeups(member_ids, action, description) {
} else { } else {
makeups_members[member_index].makeups_to_do -= 1; makeups_members[member_index].makeups_to_do -= 1;
} }
if (makeups_members[member_index].shift_type === 'standard') {
if (action === "increment") {
if (makeups_members[member_index].display_std_points >= -1)
makeups_members[member_index].display_std_points -= 1;
} else if (makeups_members[member_index].display_std_points < 0) {
makeups_members[member_index].display_std_points += 1;
}
} else {
if (action === "increment") {
if (makeups_members[member_index].display_ftop_points >= -1)
makeups_members[member_index].display_ftop_points -= 1;
} else {
makeups_members[member_index].display_ftop_points += 1;
}
}
data.push({ data.push({
member_id: mid, member_id: mid,
...@@ -347,8 +332,17 @@ function update_members_makeups(member_ids, action, description) { ...@@ -347,8 +332,17 @@ function update_members_makeups(member_ids, action, description) {
dataType:"json", dataType:"json",
traditional: true, traditional: true,
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
success: function() { success: function(res) {
selected_rows = []; selected_rows = [];
for (element of res['res']) {
member_index = makeups_members.findIndex(m => m.id == element['mid']);
if (makeups_members[member_index].shift_type === 'standard') {
makeups_members[member_index].display_std_points = element['standard_points']
}
//there is no point change when shift_type is not standard
//and I think operation on rattrapages should definitely be forbidden for ftop because it
//has no sense !!
}
display_makeups_members(); display_makeups_members();
closeModal(); closeModal();
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment