Skip to content

Commit

Permalink
Payroll: Handle both cases of extra salary being sent to accrued bala…
Browse files Browse the repository at this point in the history
…nce (#912)
  • Loading branch information
sohkai authored and facuspagnuolo committed Jul 8, 2019
1 parent 14611ee commit 9f40e08
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions future-apps/payroll/contracts/Payroll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,14 @@ contract Payroll is EtherTokenConstant, IForwarder, IsContract, AragonApp {
// If they're being paid an amount that doesn't match perfectly with the adjusted time
// (up to a seconds' worth of salary), add the second and put the extra remaining salary
// into their accrued salary
uint256 extraSalary = currentSalaryPaid % salary;
// The extra check is to handle the case where someone requested less than one second of their salary
uint256 extraSalary = currentSalaryPaid < salary ? salary - currentSalaryPaid : currentSalaryPaid % salary;
if (extraSalary > 0) {
timeDiff = timeDiff.add(1);
employee.accruedSalary = salary - currentSalaryPaid;
employee.accruedSalary = extraSalary;
} else if (accruedSalary > 0) {
// We finally need to clear their accrued salary, but as an optimization, we only do
// this if they had a non-zero value before
employee.accruedSalary = 0;
}

Expand Down

0 comments on commit 9f40e08

Please sign in to comment.