bug - incentives not allowed to be added ¶
Reported on 11/17/21.
background ¶
Maddie reported “I cannot add any Shift adjustments to the timesheets. When I click the green +, nothing happens. This affects the invoice report, so @IV Andy and I think that it is a Sev 2”
issue ¶
Approximately two weeks ago, multiple ‘automatic’ incentives
were being added to timesheet entries repeatedly.
The fix for this was to delete any ‘automatic’ incentives
before a recalculation. This would ensure that
any incentives which may be superseded by new date
definitions (new values taking effect on a date in
the middle of a pay period, for example), would
be removed altogether.
However, the determination for that was checking for an empty ‘label’ and ‘type’ record on the payroll adjustment record.
public function deleteAutomaticAdjustmentRowsForShift(Shift $shift): void
{
PayrollAdjustment::where('shift_id', $shift->id)
->where('label', '=', '') // empty string
->where('type', '=', '') // empty string
->delete();
}
However, when a new adjustment is manually added, it doesn’t start with a label, and thus was being added (correctly) then removed immediately afterward.
The fix is to also look for any adjustments that have no actor (user). Any manual incentives added will have an actor/user id.
public function deleteAutomaticAdjustmentRowsForShift(Shift $shift): void
{
PayrollAdjustment::where('shift_id', $shift->id)
->where('label', '=', '') // empty string
->where('type', '=', '') // empty string
->whereNull('actor_id') // added by system
->delete();
}