fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-payroll] 26/27: fix for ATEN-480
Date Mon, 22 Jan 2018 15:29:42 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-payroll.git

commit 91bdfbf93ca07a6c20d6055487668f2a33ee4673
Author: mgeiss <mgeiss@mifos.org>
AuthorDate: Wed Oct 11 08:38:44 2017 +0200

    fix for ATEN-480
---
 .../io/mifos/payroll/api/v1/domain/PayrollConfiguration.java   | 10 +++++-----
 .../main/java/io/mifos/payroll/TestPayrollConfiguration.java   |  4 ++--
 .../java/io/mifos/payroll/domain/DomainObjectGenerator.java    |  4 ++--
 .../service/internal/service/PayrollConfigurationService.java  |  5 ++++-
 .../service/rest/PayrollConfigurationRestController.java       |  4 ++--
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/api/src/main/java/io/mifos/payroll/api/v1/domain/PayrollConfiguration.java b/api/src/main/java/io/mifos/payroll/api/v1/domain/PayrollConfiguration.java
index 5375a9a..ee4319f 100644
--- a/api/src/main/java/io/mifos/payroll/api/v1/domain/PayrollConfiguration.java
+++ b/api/src/main/java/io/mifos/payroll/api/v1/domain/PayrollConfiguration.java
@@ -18,15 +18,15 @@ package io.mifos.payroll.api.v1.domain;
 import io.mifos.core.lang.validation.constraints.ValidIdentifier;
 
 import javax.validation.Valid;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
 
 public class PayrollConfiguration {
 
   @ValidIdentifier(maxLength = 34)
   private String mainAccountNumber;
   @Valid
-  private Set<PayrollAllocation> payrollAllocations = new HashSet<>();
+  private List<PayrollAllocation> payrollAllocations = new ArrayList<>();
   private String createdBy;
   private String createdOn;
   private String lastModifiedBy;
@@ -44,11 +44,11 @@ public class PayrollConfiguration {
     this.mainAccountNumber = mainAccountNumber;
   }
 
-  public Set<PayrollAllocation> getPayrollAllocations() {
+  public List<PayrollAllocation> getPayrollAllocations() {
     return this.payrollAllocations;
   }
 
-  public void setPayrollAllocations(final Set<PayrollAllocation> payrollAllocations)
{
+  public void setPayrollAllocations(final List<PayrollAllocation> payrollAllocations)
{
     this.payrollAllocations = payrollAllocations;
   }
 
diff --git a/component-test/src/main/java/io/mifos/payroll/TestPayrollConfiguration.java b/component-test/src/main/java/io/mifos/payroll/TestPayrollConfiguration.java
index f2db0c4..3f7d8df 100644
--- a/component-test/src/main/java/io/mifos/payroll/TestPayrollConfiguration.java
+++ b/component-test/src/main/java/io/mifos/payroll/TestPayrollConfiguration.java
@@ -15,7 +15,7 @@
  */
 package io.mifos.payroll;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.Lists;
 import io.mifos.accounting.api.v1.domain.Account;
 import io.mifos.customer.api.v1.domain.Customer;
 import io.mifos.payroll.api.v1.EventConstants;
@@ -65,7 +65,7 @@ public class TestPayrollConfiguration extends AbstractPayrollTest {
     Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier));
 
     final PayrollAllocation newPayrollAllocation = new PayrollAllocation();
-    payrollConfiguration.setPayrollAllocations(Sets.newHashSet(newPayrollAllocation));
+    payrollConfiguration.setPayrollAllocations(Lists.newArrayList(newPayrollAllocation));
     newPayrollAllocation.setAccountNumber(RandomStringUtils.randomAlphanumeric(34));
     newPayrollAllocation.setAmount(BigDecimal.valueOf(15.00D));
     newPayrollAllocation.setProportional(Boolean.FALSE);
diff --git a/component-test/src/main/java/io/mifos/payroll/domain/DomainObjectGenerator.java
b/component-test/src/main/java/io/mifos/payroll/domain/DomainObjectGenerator.java
index 389cde2..695b7df 100644
--- a/component-test/src/main/java/io/mifos/payroll/domain/DomainObjectGenerator.java
+++ b/component-test/src/main/java/io/mifos/payroll/domain/DomainObjectGenerator.java
@@ -20,7 +20,7 @@ import io.mifos.payroll.api.v1.domain.PayrollConfiguration;
 import org.apache.commons.lang3.RandomStringUtils;
 
 import java.math.BigDecimal;
-import java.util.HashSet;
+import java.util.ArrayList;
 
 public class DomainObjectGenerator {
 
@@ -32,7 +32,7 @@ public class DomainObjectGenerator {
     final PayrollConfiguration payrollConfiguration = new PayrollConfiguration();
     payrollConfiguration.setMainAccountNumber(RandomStringUtils.randomAlphanumeric(34));
 
-    final HashSet<PayrollAllocation> payrollAllocations = new HashSet<>();
+    final ArrayList<PayrollAllocation> payrollAllocations = new ArrayList<>();
     payrollConfiguration.setPayrollAllocations(payrollAllocations);
 
     final PayrollAllocation savingsAllocation = new PayrollAllocation();
diff --git a/service/src/main/java/io/mifos/payroll/service/internal/service/PayrollConfigurationService.java
b/service/src/main/java/io/mifos/payroll/service/internal/service/PayrollConfigurationService.java
index eefeca3..34572dd 100644
--- a/service/src/main/java/io/mifos/payroll/service/internal/service/PayrollConfigurationService.java
+++ b/service/src/main/java/io/mifos/payroll/service/internal/service/PayrollConfigurationService.java
@@ -17,6 +17,7 @@ package io.mifos.payroll.service.internal.service;
 
 import io.mifos.accounting.api.v1.domain.Account;
 import io.mifos.customer.api.v1.domain.Customer;
+import io.mifos.payroll.api.v1.domain.PayrollAllocation;
 import io.mifos.payroll.api.v1.domain.PayrollConfiguration;
 import io.mifos.payroll.service.ServiceConstants;
 import io.mifos.payroll.service.internal.mapper.PayrollAllocationMapper;
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
+import java.util.Comparator;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
@@ -74,7 +76,8 @@ public class PayrollConfigurationService {
               this.payrollAllocationRepository.findByPayrollConfiguration(payrollConfigurationEntity)
                   .stream()
                   .map(PayrollAllocationMapper::map)
-              .collect(Collectors.toSet())
+                  .sorted(Comparator.comparing(PayrollAllocation::getAccountNumber))
+              .collect(Collectors.toList())
           );
 
           return payrollConfiguration;
diff --git a/service/src/main/java/io/mifos/payroll/service/rest/PayrollConfigurationRestController.java
b/service/src/main/java/io/mifos/payroll/service/rest/PayrollConfigurationRestController.java
index 70e3221..c8849a2 100644
--- a/service/src/main/java/io/mifos/payroll/service/rest/PayrollConfigurationRestController.java
+++ b/service/src/main/java/io/mifos/payroll/service/rest/PayrollConfigurationRestController.java
@@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
-import java.util.Set;
+import java.util.List;
 
 @RestController
 @RequestMapping("/customers/{identifier}/payroll")
@@ -83,7 +83,7 @@ public class PayrollConfigurationRestController {
 
     if (payrollConfiguration.getPayrollAllocations() != null) {
 
-      final Set<PayrollAllocation> payrollAllocations = payrollConfiguration.getPayrollAllocations();
+      final List<PayrollAllocation> payrollAllocations = payrollConfiguration.getPayrollAllocations();
 
       if (payrollAllocations.stream().anyMatch(payrollAllocation ->
           payrollAllocation.getAccountNumber().equals(payrollConfiguration.getMainAccountNumber())))
{

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message