retrofitted percentage calculation for payroll distribution
diff --git a/service/src/main/java/io/mifos/payroll/service/internal/service/adaptor/AccountingAdaptor.java b/service/src/main/java/io/mifos/payroll/service/internal/service/adaptor/AccountingAdaptor.java
index 14aa326..f7c549b 100644
--- a/service/src/main/java/io/mifos/payroll/service/internal/service/adaptor/AccountingAdaptor.java
+++ b/service/src/main/java/io/mifos/payroll/service/internal/service/adaptor/AccountingAdaptor.java
@@ -71,7 +71,8 @@
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 @@
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);