You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ju...@apache.org on 2019/10/17 07:34:12 UTC
[fineract-cn-cheques] 13/44: added cheques receivable account
handling
This is an automated email from the ASF dual-hosted git repository.
juhan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-cheques.git
commit 9a4c9708a7de3ebd173aa79bde577be2451a5884
Author: mgeiss <mg...@mifos.org>
AuthorDate: Thu Sep 7 11:24:05 2017 +0200
added cheques receivable account handling
---
.../mifos/cheque/api/v1/domain/ChequeTransaction.java | 13 ++++++++++++-
.../src/main/java/io/mifos/cheque/TestCheques.java | 3 +++
.../src/main/java/io/mifos/cheque/TestMICR.java | 1 +
.../internal/command/ChequeTransactionCommand.java | 18 +++++++++++++-----
.../internal/command/handler/ChequeAggregate.java | 6 ++----
.../service/rest/ChequeTransactionRestController.java | 2 +-
6 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/api/src/main/java/io/mifos/cheque/api/v1/domain/ChequeTransaction.java b/api/src/main/java/io/mifos/cheque/api/v1/domain/ChequeTransaction.java
index bcdc5e0..43507bb 100644
--- a/api/src/main/java/io/mifos/cheque/api/v1/domain/ChequeTransaction.java
+++ b/api/src/main/java/io/mifos/cheque/api/v1/domain/ChequeTransaction.java
@@ -15,6 +15,7 @@
*/
package io.mifos.cheque.api.v1.domain;
+import io.mifos.core.lang.validation.constraints.ValidIdentifier;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.Valid;
@@ -25,7 +26,9 @@ public class ChequeTransaction {
@NotNull
@Valid
private Cheque cheque;
- @NotEmpty
+ @ValidIdentifier(maxLength = 34)
+ private String chequesReceivableAccount;
+ @ValidIdentifier(maxLength = 34)
private String creditorAccountNumber;
public ChequeTransaction() {
@@ -40,6 +43,14 @@ public class ChequeTransaction {
this.cheque = cheque;
}
+ public String getChequesReceivableAccount() {
+ return this.chequesReceivableAccount;
+ }
+
+ public void setChequesReceivableAccount(final String chequesReceivableAccount) {
+ this.chequesReceivableAccount = chequesReceivableAccount;
+ }
+
public String getCreditorAccountNumber() {
return this.creditorAccountNumber;
}
diff --git a/component-test/src/main/java/io/mifos/cheque/TestCheques.java b/component-test/src/main/java/io/mifos/cheque/TestCheques.java
index 5ed5c14..22cd88e 100644
--- a/component-test/src/main/java/io/mifos/cheque/TestCheques.java
+++ b/component-test/src/main/java/io/mifos/cheque/TestCheques.java
@@ -83,6 +83,7 @@ public class TestCheques extends AbstractChequeTest {
final ChequeTransaction chequeTransaction = new ChequeTransaction();
chequeTransaction.setCheque(randomCheque);
+ chequeTransaction.setChequesReceivableAccount(RandomStringUtils.randomAlphabetic(34));
chequeTransaction.setCreditorAccountNumber(RandomStringUtils.randomAlphanumeric(34));
super.chequeManager.process(chequeTransaction);
@@ -114,6 +115,7 @@ public class TestCheques extends AbstractChequeTest {
final ChequeTransaction chequeTransaction = new ChequeTransaction();
chequeTransaction.setCheque(randomCheque);
+ chequeTransaction.setChequesReceivableAccount(RandomStringUtils.randomAlphabetic(34));
chequeTransaction.setCreditorAccountNumber(RandomStringUtils.randomAlphanumeric(34));
super.chequeManager.process(chequeTransaction);
@@ -158,6 +160,7 @@ public class TestCheques extends AbstractChequeTest {
final ChequeTransaction chequeTransaction = new ChequeTransaction();
+ chequeTransaction.setChequesReceivableAccount(RandomStringUtils.randomAlphabetic(34));
chequeTransaction.setCheque(randomCheque);
chequeTransaction.setCreditorAccountNumber(RandomStringUtils.randomAlphanumeric(34));
super.chequeManager.process(chequeTransaction);
diff --git a/component-test/src/main/java/io/mifos/cheque/TestMICR.java b/component-test/src/main/java/io/mifos/cheque/TestMICR.java
index cc50bae..197c235 100644
--- a/component-test/src/main/java/io/mifos/cheque/TestMICR.java
+++ b/component-test/src/main/java/io/mifos/cheque/TestMICR.java
@@ -153,6 +153,7 @@ public class TestMICR extends AbstractChequeTest {
final ChequeTransaction chequeTransaction = new ChequeTransaction();
chequeTransaction.setCheque(randomCheque);
chequeTransaction.setCreditorAccountNumber(RandomStringUtils.randomAlphanumeric(34));
+ chequeTransaction.setChequesReceivableAccount(RandomStringUtils.randomAlphanumeric(34));
super.chequeManager.process(chequeTransaction);
Assert.assertTrue(
diff --git a/service/src/main/java/io/mifos/cheque/service/internal/command/ChequeTransactionCommand.java b/service/src/main/java/io/mifos/cheque/service/internal/command/ChequeTransactionCommand.java
index 81c46e6..21a5ab3 100644
--- a/service/src/main/java/io/mifos/cheque/service/internal/command/ChequeTransactionCommand.java
+++ b/service/src/main/java/io/mifos/cheque/service/internal/command/ChequeTransactionCommand.java
@@ -19,19 +19,27 @@ import io.mifos.cheque.api.v1.domain.Cheque;
public class ChequeTransactionCommand {
private final Cheque cheque;
- private final String creditorAccountNumber;
+ private final String chequesReceivableAccount;
+ private final String creditorAccount;
- public ChequeTransactionCommand(final Cheque cheque, final String creditorAccountNumber) {
+ public ChequeTransactionCommand(final Cheque cheque,
+ final String chequesReceivableAccount,
+ final String creditorAccount) {
super();
this.cheque = cheque;
- this.creditorAccountNumber = creditorAccountNumber;
+ this.chequesReceivableAccount = chequesReceivableAccount;
+ this.creditorAccount = creditorAccount;
}
public Cheque cheque() {
return this.cheque;
}
- public String creditorAccountNumber() {
- return this.creditorAccountNumber;
+ public String chequesReceivableAccount() {
+ return this.chequesReceivableAccount;
+ }
+
+ public String creditorAccount() {
+ return this.creditorAccount;
}
}
diff --git a/service/src/main/java/io/mifos/cheque/service/internal/command/handler/ChequeAggregate.java b/service/src/main/java/io/mifos/cheque/service/internal/command/handler/ChequeAggregate.java
index 3fa49d8..a3b1762 100644
--- a/service/src/main/java/io/mifos/cheque/service/internal/command/handler/ChequeAggregate.java
+++ b/service/src/main/java/io/mifos/cheque/service/internal/command/handler/ChequeAggregate.java
@@ -162,16 +162,14 @@ public class ChequeAggregate {
debtor.setAccountNumber(micr.getAccountNumber());
chequeEntity.setState(State.PROCESSED.name());
} else {
- debtor.setAccountNumber(
- this.depositService.getCashAccountForProduct(chequeTransactionCommand.creditorAccountNumber())
- );
+ debtor.setAccountNumber(chequeTransactionCommand.chequesReceivableAccount());
chequeEntity.setState(State.PENDING.name());
}
journalEntry.setDebtors(Sets.newHashSet(debtor));
final Creditor creditor = new Creditor();
creditor.setAmount(chequeEntity.getAmount().toString());
- creditor.setAccountNumber(chequeTransactionCommand.creditorAccountNumber());
+ creditor.setAccountNumber(chequeTransactionCommand.creditorAccount());
journalEntry.setCreditors(Sets.newHashSet(creditor));
this.accountingService.processJournalEntry(journalEntry);
diff --git a/service/src/main/java/io/mifos/cheque/service/rest/ChequeTransactionRestController.java b/service/src/main/java/io/mifos/cheque/service/rest/ChequeTransactionRestController.java
index b07d957..2d0018c 100644
--- a/service/src/main/java/io/mifos/cheque/service/rest/ChequeTransactionRestController.java
+++ b/service/src/main/java/io/mifos/cheque/service/rest/ChequeTransactionRestController.java
@@ -74,7 +74,7 @@ public class ChequeTransactionRestController {
MICRParser.toIdentifier(chequeTransaction.getCheque().getMicr()));
}
- this.commandGateway.process(new ChequeTransactionCommand(cheque, chequeTransaction.getCreditorAccountNumber()));
+ this.commandGateway.process(new ChequeTransactionCommand(cheque, chequeTransaction.getChequesReceivableAccount(), chequeTransaction.getCreditorAccountNumber()));
return ResponseEntity.accepted().build();
}