Skip to content
Permalink
Browse files
Merge pull request #2 from markusgeiss/develop
added cheque transaction
  • Loading branch information
markusgeiss committed Aug 22, 2017
2 parents 56a7470 + 192bfad commit 4cb25fe12a5daf32a6a2da4cf6cecc6efe6ad17b
Showing 19 changed files with 674 additions and 15 deletions.
@@ -0,0 +1,96 @@
/*
* Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.teller.api.v1.domain;

import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Valid;

public class Cheque {
@Valid
private MICR micr;
@NotEmpty
private String drawee;
@NotEmpty
private String drawer;
@NotEmpty
private String payee;
@NotEmpty
private String amount;
@NotEmpty
private String dateIssued;
private Boolean openCheque;

public Cheque() {
super();
}

public MICR getMicr() {
return this.micr;
}

public void setMicr(final MICR micr) {
this.micr = micr;
}

public String getDrawee() {
return this.drawee;
}

public void setDrawee(final String drawee) {
this.drawee = drawee;
}

public String getDrawer() {
return this.drawer;
}

public void setDrawer(final String drawer) {
this.drawer = drawer;
}

public String getPayee() {
return this.payee;
}

public void setPayee(final String payee) {
this.payee = payee;
}

public String getAmount() {
return this.amount;
}

public void setAmount(final String amount) {
this.amount = amount;
}

public String getDateIssued() {
return this.dateIssued;
}

public void setDateIssued(final String dateIssued) {
this.dateIssued = dateIssued;
}

public Boolean isOpenCheque() {
return this.openCheque;
}

public void setOpenCheque(final Boolean openCheque) {
this.openCheque = openCheque;
}
}
@@ -0,0 +1,55 @@
/*
* Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.teller.api.v1.domain;

import io.mifos.core.lang.validation.constraints.ValidIdentifier;

public class MICR {
@ValidIdentifier(maxLength = 8)
private String chequeNumber;
@ValidIdentifier(maxLength = 11)
private String branchSortCode;
@ValidIdentifier(maxLength = 34)
private String accountNumber;

public MICR() {
super();
}

public String getChequeNumber() {
return this.chequeNumber;
}

public void setChequeNumber(final String chequeNumber) {
this.chequeNumber = chequeNumber;
}

public String getBranchSortCode() {
return this.branchSortCode;
}

public void setBranchSortCode(final String branchSortCode) {
this.branchSortCode = branchSortCode;
}

public String getAccountNumber() {
return this.accountNumber;
}

public void setAccountNumber(final String accountNumber) {
this.accountNumber = accountNumber;
}
}
@@ -17,6 +17,7 @@

import io.mifos.core.lang.validation.constraints.ValidIdentifier;

import javax.validation.Valid;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;

@@ -50,6 +51,8 @@ public enum State {
@DecimalMin("0.00")
private Double amount;
private State state;
@Valid
private Cheque cheque;

public TellerTransaction() {
super();
@@ -142,4 +145,12 @@ public String getState() {
public void setState(final String state) {
this.state = State.valueOf(state);
}

public Cheque getCheque() {
return this.cheque;
}

public void setCheque(final Cheque cheque) {
this.cheque = cheque;
}
}
@@ -22,19 +22,24 @@
import io.mifos.teller.api.v1.EventConstants;
import io.mifos.teller.api.v1.client.TellerNotFoundException;
import io.mifos.teller.api.v1.client.TransactionProcessingException;
import io.mifos.teller.api.v1.domain.Cheque;
import io.mifos.teller.api.v1.domain.MICR;
import io.mifos.teller.api.v1.domain.Teller;
import io.mifos.teller.api.v1.domain.TellerManagementCommand;
import io.mifos.teller.api.v1.domain.TellerTransaction;
import io.mifos.teller.api.v1.domain.TellerTransactionCosts;
import io.mifos.teller.api.v1.domain.UnlockDrawerCommand;
import io.mifos.teller.service.internal.service.helper.ChequeService;
import io.mifos.teller.util.TellerGenerator;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.boot.test.mock.mockito.MockBean;

import java.time.Clock;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.Optional;
@@ -43,6 +48,9 @@ public class TestTellerOperation extends AbstractTellerTest {

private static Teller tellerUnderTest = null;

@MockBean
private ChequeService chequeService;

public TestTellerOperation() {
super();
}
@@ -500,4 +508,60 @@ public void shouldProcessRepayment() throws Exception {

super.testSubject.confirm(teller.getCode(), tellerTransactionCosts.getTellerTransactionIdentifier(), "CONFIRM", null);
}

@Test
public void shouldProcessCheque() throws Exception {
final Teller teller = this.prepareTeller();

final UnlockDrawerCommand unlockDrawerCommand = new UnlockDrawerCommand();
unlockDrawerCommand.setEmployeeIdentifier(AbstractTellerTest.TEST_USER);
unlockDrawerCommand.setPassword(teller.getPassword());

super.testSubject.unlockDrawer(teller.getCode(), unlockDrawerCommand);

super.eventRecorder.wait(EventConstants.AUTHENTICATE_TELLER, teller.getCode());

final TellerTransaction chequeTransaction = new TellerTransaction();
chequeTransaction.setTransactionType(ServiceConstants.TX_CHEQUE);
chequeTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
chequeTransaction.setProductIdentifier(RandomStringUtils.randomAlphanumeric(32));
chequeTransaction.setProductCaseIdentifier(RandomStringUtils.randomAlphanumeric(32));
chequeTransaction.setCustomerAccountIdentifier(RandomStringUtils.randomAlphanumeric(32));
chequeTransaction.setCustomerIdentifier(RandomStringUtils.randomAlphanumeric(32));
chequeTransaction.setClerk(AbstractTellerTest.TEST_USER);
chequeTransaction.setAmount(246.80D);

final MICR micr = new MICR();
micr.setChequeNumber("0011");
micr.setBranchSortCode("08154711");
micr.setAccountNumber("4711");

final Cheque cheque = new Cheque();
cheque.setMicr(micr);
cheque.setDrawee("whatever Bank");
cheque.setDrawer("Jane Doe");
cheque.setPayee("John Doe");
cheque.setDateIssued(DateConverter.toIsoString(LocalDate.now(Clock.systemUTC())));
cheque.setAmount("246.80");
cheque.setOpenCheque(Boolean.FALSE);
chequeTransaction.setCheque(cheque);

Mockito
.doAnswer(invocation -> {
final Account mockedAccount = new Account();
mockedAccount.setState(Account.State.OPEN.name());
return Optional.of(mockedAccount);
})
.when(super.accountingServiceSpy).findAccount(chequeTransaction.getCustomerAccountIdentifier());

final TellerTransactionCosts tellerTransactionCosts = super.testSubject.post(teller.getCode(), chequeTransaction);

super.testSubject.confirm(teller.getCode(), tellerTransactionCosts.getTellerTransactionIdentifier(),
"CONFIRM", null);

Assert.assertTrue(
super.eventRecorder.wait(EventConstants.CONFIRM_TRANSACTION,
tellerTransactionCosts.getTellerTransactionIdentifier())
);
}
}
@@ -26,7 +26,7 @@
<logger name="com" level="OFF"/>
<logger name="ch" level="OFF"/>

<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
@@ -34,6 +34,7 @@ dependencies {
[group: 'io.mifos.office', name: 'api', version: versions.frameworkoffice],
[group: 'io.mifos.accounting', name: 'api', version: versions.frameworkaccounting],
[group: 'io.mifos.deposit-account-management', name: 'api', version: versions.frameworkdeposit],
[group: 'io.kuelap.cheques', name: 'api', version: versions.frameworkcheque],
[group: 'io.mifos.portfolio', name: 'api', version: versions.frameworkportfolio],
[group: 'io.mifos.anubis', name: 'library', version: versions.frameworkanubis],
[group: 'com.google.code.gson', name: 'gson'],
@@ -27,6 +27,7 @@ public interface ServiceConstants {
String TX_CASH_DEPOSIT = "CDPT";
String TX_CASH_WITHDRAWAL = "CWDL";
String TX_REPAYMENT = "PPAY";
String TX_CHEQUE = "CCHQ";

String TX_DEPOSIT_ADJUSTMENT = "DAJT";
String TX_CREDIT_ADJUSTMENT = "CAJT";
@@ -17,6 +17,7 @@

import io.mifos.accounting.api.v1.client.LedgerManager;
import io.mifos.anubis.config.EnableAnubis;
import io.mifos.cheque.api.v1.client.ChequeManager;
import io.mifos.core.async.config.EnableAsync;
import io.mifos.core.cassandra.config.EnableCassandra;
import io.mifos.core.command.config.EnableCommandProcessing;
@@ -56,7 +57,8 @@
OrganizationManager.class,
LedgerManager.class,
DepositAccountManager.class,
PortfolioManager.class
PortfolioManager.class,
ChequeManager.class
}
)
@ComponentScan({

0 comments on commit 4cb25fe

Please sign in to comment.