Skip to content
Permalink
Browse files
retrofitted percentage calculation for payroll distribution
  • Loading branch information
mgeiss committed Oct 10, 2017
1 parent a797401 commit f4bea51b1a89d70a36d77649b74c3f5baac3513a
Showing 1 changed file with 4 additions and 3 deletions.
@@ -71,7 +71,8 @@ public Optional<String> postPayrollPayment(final PayrollCollectionEntity payroll
final PayrollPayment payrollPayment,
final PayrollConfiguration payrollConfiguration) {

final MathContext mathContext = new MathContext(2, RoundingMode.HALF_EVEN);
final MathContext mathContextAmount = new MathContext(2, RoundingMode.HALF_EVEN);
final MathContext mathContextPercentage = new MathContext(5, RoundingMode.HALF_EVEN);

final JournalEntry journalEntry = new JournalEntry();
journalEntry.setTransactionIdentifier(UUID.randomUUID().toString());
@@ -95,8 +96,8 @@ public Optional<String> postPayrollPayment(final PayrollCollectionEntity payroll
allocationCreditor.setAmount(payrollAllocation.getAmount().toString());
} else {
final BigDecimal value = payrollPayment.getSalary().multiply(
payrollAllocation.getAmount().divide(BigDecimal.valueOf(100.00D), mathContext)
).round(mathContext);
payrollAllocation.getAmount().divide(BigDecimal.valueOf(100.00D), mathContextPercentage)
).round(mathContextAmount);
allocationCreditor.setAmount(value.toString());
}
creditors.add(allocationCreditor);

0 comments on commit f4bea51

Please sign in to comment.