Skip to content
Permalink
Browse files
fix for ATEN-480
  • Loading branch information
mgeiss committed Oct 11, 2017
1 parent 4a46a99 commit 91bdfbf93ca07a6c20d6055487668f2a33ee4673
Showing 5 changed files with 15 additions and 12 deletions.
@@ -18,15 +18,15 @@
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 void setMainAccountNumber(final String mainAccountNumber) {
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;
}

@@ -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 void shouldUpdatePayrollDistribution() throws Exception {
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);
@@ -20,7 +20,7 @@
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 static PayrollConfiguration getPayrollConfiguration() {
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();
@@ -17,6 +17,7 @@

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.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.Optional;
import java.util.stream.Collectors;

@@ -74,7 +76,8 @@ public Optional<PayrollConfiguration> findPayrollConfiguration(final String cust
this.payrollAllocationRepository.findByPayrollConfiguration(payrollConfigurationEntity)
.stream()
.map(PayrollAllocationMapper::map)
.collect(Collectors.toSet())
.sorted(Comparator.comparing(PayrollAllocation::getAccountNumber))
.collect(Collectors.toList())
);

return payrollConfiguration;
@@ -39,7 +39,7 @@
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 ResponseEntity<Void> setPayrollConfiguration(@PathVariable(value = "ident

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()))) {

0 comments on commit 91bdfbf

Please sign in to comment.