This module is responsible for managing the credit of the user. It includes functionalities for creating, listing, and paying loans. The following endpoints are provided:
-
Description: Create a new loan for a given customer.
-
URL:
/loans -
Method:
POST -
Request Body:
{ "customerId": "string", "amount": "number", "interestRate": "number", "numberOfInstallments": "number" } -
Validation:
- Check if the customer has enough credit limit.
- Number of installments can only be 6, 9, 12, or 24.
- Interest rate must be between 0.1 and 0.5.
- All installments should have the same amount.
- The due date of installments should be the first day of the month.
-
Response:
{
"loanId": "string",
"customerId": "string",
"amount": "number",
"interestRate": "number",
"numberOfInstallments": "number",
"installments": [
{
"installmentId": "string",
"amount": "number",
"dueDate": "string"
}
]
}- Description: List all loans for a given customer.
- URL: /loans/{customerId}
- Method: GET
- Response:
[
{
"loanId": "string",
"customerId": "string",
"amount": "number",
"interestRate": "number",
"numberOfInstallments": "number",
"installments": [
{
"installmentId": "string",
"amount": "number",
"dueDate": "string"
}
]
}
]- Description: List all installments for a given loan.
- URL: /loans/{loanId}/installments
- Method: GET
- Response:
[
{
"installmentId": "string",
"amount": "number",
"dueDate": "string",
"isPaid": "boolean"
}
]- Description: Pay installment for a given loan and amount.ü
- URL: /loans/{loanId}/pay
- Method: POST
- Request Body:
{
"amount": "number"
}-
Validation:
- Installments should be paid wholly or not at all.
- Pay the earliest installment first.
- Installments due more than 3 months in the future cannot be paid.
-
Response:
{
"installmentsPaid": "number",
"totalAmountSpent": "number",
"isLoanPaidCompletely": "boolean"
}All endpoints should be authorized with an admin user and password.
-
Customer:
- id
- name
- surname
- creditLimit
- usedCreditLimit
-
Loan:
- id
- customerId
- loanAmount
- numberOfInstallments
- createDate
- isPaid
-
LoanInstallment:
- id
- loanId
- amount
- paidAmount
- dueDate
- paymentDate
- isPaid
- Clone the repository.
git clone https://github.com/FatihBozik/credit-module.git- Navigate to the project directory:
cd credit-module- Build the project:
./gradlew clean build-
Run the application:
./gradlew bootRun
Unit tests are provided to ensure the functionality of the application. To run the tests, use the following command:
./gradlew test- The application uses Postgres SQL database for simplicity.
- Documentation is important. Ensure to update this README for any changes in the application.
- Admin users can operate for all customers.
- Customer role users can operate for themselves.
- If an installment is paid before the due date, a discount is applied.
- If an installment is paid after the due date, a penalty is added.
The application is deployed and can be accessed at:
Host: api.credit-module.fatihbozik.com
Port: 8080
Environment: Test
This README provides a comprehensive overview of the Credit Module project,
its endpoints, and how to use the application.
Feel free to modify the README further based on any additional project-specific details or requirements.