|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.fineract.test.factory; |
| 20 | + |
| 21 | +import java.math.BigDecimal; |
| 22 | +import java.time.format.DateTimeFormatter; |
| 23 | +import lombok.RequiredArgsConstructor; |
| 24 | +import org.apache.fineract.client.models.PostWorkingCapitalLoansRequest; |
| 25 | +import org.apache.fineract.client.models.PutWorkingCapitalLoansLoanIdRequest; |
| 26 | +import org.apache.fineract.test.data.workingcapitalproduct.DefaultWorkingCapitalLoanProduct; |
| 27 | +import org.apache.fineract.test.data.workingcapitalproduct.WorkingCapitalLoanProductResolver; |
| 28 | +import org.apache.fineract.test.helper.Utils; |
| 29 | +import org.springframework.stereotype.Component; |
| 30 | + |
| 31 | +@Component |
| 32 | +@RequiredArgsConstructor |
| 33 | +public class WorkingCapitalLoanRequestFactory { |
| 34 | + |
| 35 | + private final WorkingCapitalLoanProductResolver workingCapitalLoanProductResolver; |
| 36 | + |
| 37 | + public static final String DATE_FORMAT = "dd MMMM yyyy"; |
| 38 | + public static final String DEFAULT_LOCALE = "en"; |
| 39 | + public static final DefaultWorkingCapitalLoanProduct DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT = DefaultWorkingCapitalLoanProduct.WCLP; |
| 40 | + public static final BigDecimal DEFAULT_PRINCIPAL = new BigDecimal(100); |
| 41 | + public static final BigDecimal DEFAULT_TOTAL_PAYMENT = new BigDecimal(100); |
| 42 | + public static final BigDecimal DEFAULT_PERIOD_PAYMENT_RATE = new BigDecimal(1); |
| 43 | + public static final BigDecimal DEFAULT_DISCOUNT = BigDecimal.ZERO; |
| 44 | + |
| 45 | + public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT); |
| 46 | + public static final String DATE_SUBMIT_STRING = FORMATTER.format(Utils.now().minusMonths(1L)); |
| 47 | + |
| 48 | + public PostWorkingCapitalLoansRequest defaultWorkingCapitalLoansRequest(Long clientId) { |
| 49 | + return new PostWorkingCapitalLoansRequest()// |
| 50 | + .clientId(clientId)// |
| 51 | + .productId(workingCapitalLoanProductResolver.resolve(DEFAULT_WORKING_CAPITAL_LOAN_PRODUCT))// |
| 52 | + .submittedOnDate(DATE_SUBMIT_STRING)// |
| 53 | + .expectedDisbursementDate(DATE_SUBMIT_STRING)// |
| 54 | + .principalAmount(DEFAULT_PRINCIPAL)// |
| 55 | + .totalPayment(DEFAULT_TOTAL_PAYMENT)// |
| 56 | + .periodPaymentRate(DEFAULT_PERIOD_PAYMENT_RATE)// |
| 57 | + .discount(DEFAULT_DISCOUNT)// |
| 58 | + .locale(DEFAULT_LOCALE)// |
| 59 | + .dateFormat(DATE_FORMAT);// |
| 60 | + } |
| 61 | + |
| 62 | + public PutWorkingCapitalLoansLoanIdRequest defaultModifyWorkingCapitalLoansRequest() { |
| 63 | + return new PutWorkingCapitalLoansLoanIdRequest()// |
| 64 | + .locale(DEFAULT_LOCALE)// |
| 65 | + .dateFormat(DATE_FORMAT);// |
| 66 | + } |
| 67 | +} |
0 commit comments