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-customer.git
commit be60ba631a8f6c76cfe84ac5ff2ec1713c6d7cec Author: mgeiss <[email protected]> AuthorDate: Sun Oct 22 07:51:00 2017 +0200 added application date for customer --- .../io/mifos/customer/api/v1/domain/Customer.java | 9 +++++++++ .../src/main/java/io/mifos/customer/TestCustomer.java | 7 +++++++ .../internal/command/handler/CustomerAggregate.java | 3 +++ .../service/internal/mapper/CustomerMapper.java | 6 ++++++ .../service/internal/repository/CustomerEntity.java | 13 +++++++++++++ .../mariadb/V9__add_application_date_to_customer.sql | 19 +++++++++++++++++++ 6 files changed, 57 insertions(+) diff --git a/api/src/main/java/io/mifos/customer/api/v1/domain/Customer.java b/api/src/main/java/io/mifos/customer/api/v1/domain/Customer.java index ee130b9..8dc20d8 100644 --- a/api/src/main/java/io/mifos/customer/api/v1/domain/Customer.java +++ b/api/src/main/java/io/mifos/customer/api/v1/domain/Customer.java @@ -60,6 +60,7 @@ public final class Customer { @Valid private List<ContactDetail> contactDetails; private State currentState; + private String applicationDate; private List<Value> customValues; private String createdBy; private String createdOn; @@ -182,6 +183,14 @@ public final class Customer { this.currentState = State.valueOf(currentState); } + public String getApplicationDate() { + return this.applicationDate; + } + + public void setApplicationDate(final String applicationDate) { + this.applicationDate = applicationDate; + } + public List<Value> getCustomValues() { return this.customValues; } diff --git a/component-test/src/main/java/io/mifos/customer/TestCustomer.java b/component-test/src/main/java/io/mifos/customer/TestCustomer.java index 5ce3f66..f5e53f3 100644 --- a/component-test/src/main/java/io/mifos/customer/TestCustomer.java +++ b/component-test/src/main/java/io/mifos/customer/TestCustomer.java @@ -15,6 +15,7 @@ */ package io.mifos.customer; +import io.mifos.core.lang.DateConverter; import io.mifos.customer.api.v1.CustomerEventConstants; import io.mifos.customer.api.v1.client.CustomerAlreadyExistsException; import io.mifos.customer.api.v1.client.CustomerNotFoundException; @@ -37,6 +38,8 @@ import org.junit.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; +import java.time.Clock; +import java.time.LocalDate; import java.util.Collections; import java.util.List; import java.util.stream.Stream; @@ -188,6 +191,7 @@ public class TestCustomer extends AbstractCustomerTest { final Customer activatedCustomer = this.customerManager.findCustomer(customer.getIdentifier()); Assert.assertEquals(Customer.State.ACTIVE.name(), activatedCustomer.getCurrentState()); + Assert.assertNotNull(activatedCustomer.getApplicationDate()); } @Test @@ -214,6 +218,8 @@ public class TestCustomer extends AbstractCustomerTest { @Test public void shouldUnlockClient() throws Exception { final Customer customer = CustomerGenerator.createRandomCustomer(); + final String applicationDate = DateConverter.toIsoString(LocalDate.now(Clock.systemUTC())); + customer.setApplicationDate(applicationDate); this.customerManager.createCustomer(customer); this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, customer.getIdentifier()); @@ -235,6 +241,7 @@ public class TestCustomer extends AbstractCustomerTest { final Customer unlockedCustomer = this.customerManager.findCustomer(customer.getIdentifier()); Assert.assertEquals(Customer.State.ACTIVE.name(), unlockedCustomer.getCurrentState()); + Assert.assertEquals(applicationDate, unlockedCustomer.getApplicationDate()); } @Test diff --git a/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java b/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java index 07e5ebc..3f67a20 100644 --- a/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java +++ b/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java @@ -179,6 +179,9 @@ public class CustomerAggregate { } customerEntity.setCurrentState(Customer.State.ACTIVE.name()); + if (customerEntity.getApplicationDate() == null) { + customerEntity.setApplicationDate(LocalDate.now(Clock.systemUTC())); + } customerEntity.setLastModifiedBy(UserContextHolder.checkedGetUser()); customerEntity.setLastModifiedOn(LocalDateTime.now(Clock.systemUTC())); diff --git a/service/src/main/java/io/mifos/customer/service/internal/mapper/CustomerMapper.java b/service/src/main/java/io/mifos/customer/service/internal/mapper/CustomerMapper.java index c319c01..6cf7569 100644 --- a/service/src/main/java/io/mifos/customer/service/internal/mapper/CustomerMapper.java +++ b/service/src/main/java/io/mifos/customer/service/internal/mapper/CustomerMapper.java @@ -45,6 +45,9 @@ public final class CustomerMapper { customerEntity.setAssignedOffice(customer.getAssignedOffice()); customerEntity.setAssignedEmployee(customer.getAssignedEmployee()); customerEntity.setCurrentState(customer.getCurrentState()); + if (customer.getApplicationDate() != null) { + customerEntity.setApplicationDate(DateConverter.dateFromIsoString(customer.getApplicationDate())); + } customerEntity.setCreatedBy(UserContextHolder.checkedGetUser()); customerEntity.setCreatedOn(LocalDateTime.now(Clock.systemUTC())); return customerEntity; @@ -64,6 +67,9 @@ public final class CustomerMapper { customer.setAssignedOffice(customerEntity.getAssignedOffice()); customer.setAssignedEmployee(customerEntity.getAssignedEmployee()); customer.setCurrentState(customerEntity.getCurrentState()); + if (customerEntity.getApplicationDate() != null) { + customer.setApplicationDate(DateConverter.toIsoString(customerEntity.getApplicationDate())); + } customer.setCreatedBy(customerEntity.getCreatedBy()); customer.setCreatedOn(DateConverter.toIsoString(customerEntity.getCreatedOn())); diff --git a/service/src/main/java/io/mifos/customer/service/internal/repository/CustomerEntity.java b/service/src/main/java/io/mifos/customer/service/internal/repository/CustomerEntity.java index 438eb4a..efa4c88 100644 --- a/service/src/main/java/io/mifos/customer/service/internal/repository/CustomerEntity.java +++ b/service/src/main/java/io/mifos/customer/service/internal/repository/CustomerEntity.java @@ -15,6 +15,7 @@ */ package io.mifos.customer.service.internal.repository; +import io.mifos.core.mariadb.util.LocalDateConverter; import io.mifos.core.mariadb.util.LocalDateTimeConverter; import javax.persistence.CascadeType; @@ -29,6 +30,7 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import java.sql.Date; +import java.time.LocalDate; import java.time.LocalDateTime; @Entity @@ -63,6 +65,9 @@ public class CustomerEntity { private String assignedEmployee; @Column(name = "current_state") private String currentState; + @Column(name = "application_date") + @Convert(converter = LocalDateConverter.class) + private LocalDate applicationDate; @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "address_id") private AddressEntity address; @@ -185,6 +190,14 @@ public class CustomerEntity { this.currentState = currentState; } + public LocalDate getApplicationDate() { + return this.applicationDate; + } + + public void setApplicationDate(final LocalDate applicationDate) { + this.applicationDate = applicationDate; + } + public AddressEntity getAddress() { return this.address; } diff --git a/service/src/main/resources/db/migrations/mariadb/V9__add_application_date_to_customer.sql b/service/src/main/resources/db/migrations/mariadb/V9__add_application_date_to_customer.sql new file mode 100644 index 0000000..e6fef03 --- /dev/null +++ b/service/src/main/resources/db/migrations/mariadb/V9__add_application_date_to_customer.sql @@ -0,0 +1,19 @@ +-- +-- 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. +-- + +ALTER TABLE maat_customers ADD application_date DATE NULL; + +UPDATE maat_customers set application_date = CURDATE() WHERE current_state <> 'PENDING'; -- To stop receiving notification emails like this one, please contact [email protected].
