Skip to content
Permalink
Browse files
initial commit
  • Loading branch information
mgeiss committed Sep 18, 2017
1 parent 08f8419 commit 118dd1df0e001f35cdbc3889f07915c5b60491b3
Showing 71 changed files with 2,715 additions and 781 deletions.
@@ -2,6 +2,7 @@
.idea
build/
target/
out/

# Ignore Gradle GUI config
gradle-app.setting
@@ -1,49 +1,6 @@
# Mifos I/O Template
# Mifos I/O Payroll

[![Join the chat at https://gitter.im/mifos-initiative/mifos.io](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mifos-initiative/mifos.io?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This project provides a template layout for all Mifos I/O microservices.

## Abstract
Mifos I/O is an application framework for digital financial services, a system to support nationwide and cross-national financial transactions and help to level and speed the creation of an inclusive, interconnected digital economy for every nation in the world.

## Steps needed to turn the template project into a real project

1. Git clone template into {project name} folder

git clone https://github.com/mifosio/template.git {project name}

2. Delete _.git_

rm -rf .git

3. Open settings.gradle and replace value of _rootProject.name_ with {project name}

4. Open root build.gradle and replace value of _version_ with 0.1.0-snapshot

6. Create Gradle wrapper

gradle wrapper

6. Open all module specific build.gradle files (api, service, and component-test) and replace value of _group_ with io.mifos.{project name}

7. Import project into IDE

8. Rename all io.mifos.template packages to io.mifos.{project name}

9. Open _SampleRestConfiguration_ and _SampleServiceConfiguration_, adjust @ComponentScan to reflect the new package name

10. Open _application.yml_ and replace _server.contextPath_ with /{project name}/v1/*

11. Open _bootstrap.yml_ and replace _spring.application.name_ with {project name}/v1/

12. Open _SampleTest_ and replace constructor argument of TestEnvironment in line 80 with {project name}/v1/

13. Run _SampleTest_

14. Replace the contents of the README with text describing your new project.

15. Happy coding! ; o)
This project provides functionality to configure payroll allocations and distribute payroll payments for customers.

## Versioning
The version numbers follow the [Semantic Versioning](http://semver.org/) scheme.
@@ -13,14 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.template.api.v1.events;
package io.mifos.payroll.api.v1;

@SuppressWarnings("unused")
public interface EventConstants {

String DESTINATION = "template-v1";
String DESTINATION = "payroll-v1";
String SELECTOR_NAME = "action";

// Migration events
String INITIALIZE = "initialize";

// Payroll configuration events
String PUT_CONFIGURATION = "put-configuration";
String SELECTOR_PUT_CONFIGURATION = SELECTOR_NAME + " = '" + PUT_CONFIGURATION + "'";

// Payroll distribution events
String POST_DISTRIBUTION = "post-distribution";
String SELECTOR_POST_DISTRIBUTION = SELECTOR_NAME + " = '" + POST_DISTRIBUTION + "'";


String POST_SAMPLE = "post-sample";
String SELECTOR_INITIALIZE = SELECTOR_NAME + " = '" + INITIALIZE + "'";
String SELECTOR_POST_SAMPLE = SELECTOR_NAME + " = '" + POST_SAMPLE + "'";
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.template.api.v1;
package io.mifos.payroll.api.v1;

@SuppressWarnings("unused")
public interface PermittableGroupIds {
String SAMPLE_MANAGEMENT = "template__v1__samples";
String SELF_MANAGEMENT = "template__v1__self";
String CONFIGURATION = "payroll__v1__configuration";
String DISTRIBUTION = "payroll__v1__distribution";
}
@@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.mifos.template.api.v1.client;
package io.mifos.payroll.api.v1.client;

@SuppressWarnings("WeakerAccess")
public class IamATeapotException extends RuntimeException {
public class CustomerNotFoundException extends RuntimeException {
}
@@ -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.
*/
package io.mifos.payroll.api.v1.client;

public class PayrollConfigurationNotFoundException extends RuntimeException {
}
@@ -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.
*/
package io.mifos.payroll.api.v1.client;

public class PayrollDistributionValidationException extends RuntimeException {
}
@@ -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.payroll.api.v1.client;

import io.mifos.core.api.annotation.ThrowsException;
import io.mifos.core.api.annotation.ThrowsExceptions;
import io.mifos.core.api.util.CustomFeignClientsConfiguration;
import io.mifos.payroll.api.v1.domain.PayrollCollectionHistory;
import io.mifos.payroll.api.v1.domain.PayrollCollectionSheet;
import io.mifos.payroll.api.v1.domain.PayrollConfiguration;
import io.mifos.payroll.api.v1.domain.PayrollPaymentPage;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.List;

@SuppressWarnings("unused")
@FeignClient(name="payroll-v1", path="/payroll/v1", configuration = CustomFeignClientsConfiguration.class)
public interface PayrollManager {

@RequestMapping(
value = "/customers/{identifier}/payroll",
method = RequestMethod.PUT,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
@ThrowsExceptions({
@ThrowsException(status = HttpStatus.NOT_FOUND, exception = CustomerNotFoundException.class),
@ThrowsException(status = HttpStatus.BAD_REQUEST, exception = PayrollDistributionValidationException.class)
})
void setPayrollConfiguration(@PathVariable(value = "identifier") final String customerIdentifier,
@RequestBody @Valid final PayrollConfiguration payrollConfiguration);

@RequestMapping(
value = "/customers/{identifier}/payroll",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
@ThrowsExceptions({
@ThrowsException(status = HttpStatus.NOT_FOUND, exception = PayrollConfigurationNotFoundException.class)
})
PayrollConfiguration findPayrollConfiguration(@PathVariable(value = "identifier") final String customerIdentifier);

@RequestMapping(
value = "/distribution",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
@ThrowsExceptions({
@ThrowsException(status = HttpStatus.BAD_REQUEST, exception = PayrollPaymentValidationException.class)
})
void distribute(@RequestBody @Valid final PayrollCollectionSheet payrollCollectionSheet);

@RequestMapping(
value = "/distribution",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
List<PayrollCollectionHistory> fetchDistributionHistory();

@RequestMapping(
value = "/distribution/{identifier}/payments",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
PayrollPaymentPage fetchPayments(@PathVariable("identifier") final String identifier,
@RequestParam(value = "pageIndex", required = false) final Integer pageIndex,
@RequestParam(value = "size", required = false) final Integer size,
@RequestParam(value = "sortColumn", required = false) final String sortColumn,
@RequestParam(value = "sortDirection", required = false) final String sortDirection);

}
@@ -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.
*/
package io.mifos.payroll.api.v1.client;

public class PayrollPaymentValidationException extends RuntimeException {
}
@@ -0,0 +1,62 @@
/*
* 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.payroll.api.v1.domain;

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

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

public class PayrollAllocation {

@ValidIdentifier(maxLength = 34)
private String accountNumber;
@NotNull
@DecimalMin("0.001")
@DecimalMax("9999999999.99999")
private BigDecimal amount;
private Boolean proportional = Boolean.FALSE;

public PayrollAllocation() {
super();
}

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

public void setAccountNumber(final String accountNumber) {
this.accountNumber = accountNumber;
}

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

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

public Boolean getProportional() {
return this.proportional;
}

public void setProportional(final Boolean proportional) {
this.proportional = proportional;
}
}

0 comments on commit 118dd1d

Please sign in to comment.