Skip to content
Permalink
Browse files
Merge pull request #5 from markusgeiss/develop
retrofitted percentage calculation for payroll distribution
  • Loading branch information
markusgeiss committed Oct 10, 2017
2 parents a797401 + f4bea51 commit 4a46a9904a1c1e4d4bb105c84172eb39cade74e6
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 4a46a99

Please sign in to comment.