fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-teller] 22/30: check if employee is already assigned
Date Mon, 22 Jan 2018 15:32:20 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-teller.git

commit 23688fb1f9002c562595d8ca23c7b20057980a80
Author: mgeiss <mgeiss@mifos.org>
AuthorDate: Wed Jun 28 17:45:06 2017 +0200

    check if employee is already assigned
---
 .../teller/service/internal/repository/TellerRepository.java   |  2 ++
 .../service/internal/service/TellerManagementService.java      |  4 ++++
 .../teller/service/rest/TellerManagementRestController.java    | 10 ++++++----
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/service/src/main/java/io/mifos/teller/service/internal/repository/TellerRepository.java
b/service/src/main/java/io/mifos/teller/service/internal/repository/TellerRepository.java
index 530cb19..af5761e 100644
--- a/service/src/main/java/io/mifos/teller/service/internal/repository/TellerRepository.java
+++ b/service/src/main/java/io/mifos/teller/service/internal/repository/TellerRepository.java
@@ -27,4 +27,6 @@ public interface TellerRepository extends JpaRepository<TellerEntity,
Long> {
   Optional<TellerEntity> findByIdentifier(final String identifier);
 
   List<TellerEntity> findByOfficeIdentifier(final String officeIdentifier);
+
+  Optional<TellerEntity> findFirstByAssignedEmployeeIdentifier(final String employeeIdentifier);
 }
diff --git a/service/src/main/java/io/mifos/teller/service/internal/service/TellerManagementService.java
b/service/src/main/java/io/mifos/teller/service/internal/service/TellerManagementService.java
index c90d2ba..0a00d76 100644
--- a/service/src/main/java/io/mifos/teller/service/internal/service/TellerManagementService.java
+++ b/service/src/main/java/io/mifos/teller/service/internal/service/TellerManagementService.java
@@ -106,4 +106,8 @@ public class TellerManagementService {
 
     return tellerEntries;
   }
+
+  public Optional<Teller> findByAssignedEmployee(final String employeeIdentifier) {
+    return this.tellerRepository.findFirstByAssignedEmployeeIdentifier(employeeIdentifier).map(TellerMapper::map);
+  }
 }
diff --git a/service/src/main/java/io/mifos/teller/service/rest/TellerManagementRestController.java
b/service/src/main/java/io/mifos/teller/service/rest/TellerManagementRestController.java
index 454d02c..4ff84cb 100644
--- a/service/src/main/java/io/mifos/teller/service/rest/TellerManagementRestController.java
+++ b/service/src/main/java/io/mifos/teller/service/rest/TellerManagementRestController.java
@@ -166,10 +166,6 @@ public class TellerManagementRestController {
                             @RequestBody @Valid final TellerManagementCommand tellerManagementCommand)
{
     final Teller teller = this.verifyTeller(tellerCode);
 
-    if (tellerManagementCommand.getAmount() != null && tellerManagementCommand.getAmount()
> teller.getCashdrawLimit()) {
-      throw ServiceException.badRequest("Adjustment exceeds cashdraw limit.");
-    }
-
     final TellerManagementCommand.Action action = TellerManagementCommand.Action.valueOf(tellerManagementCommand.getAction());
     switch (action) {
       case OPEN:
@@ -215,6 +211,12 @@ public class TellerManagementRestController {
   }
 
   private void verifyEmployee(final String employeeIdentifier) {
+    final Optional<Teller> optionalTeller = this.tellerManagementService.findByAssignedEmployee(employeeIdentifier);
+    if (optionalTeller.isPresent()) {
+      throw ServiceException.conflict("Employee {0} already assigned to teller {1}.",
+          employeeIdentifier, optionalTeller.get().getCode());
+    }
+
     if (!this.organizationService.employeeExists(employeeIdentifier)) {
       throw ServiceException.badRequest("Employee {0} not found.", employeeIdentifier);
     }

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

Mime
View raw message