3838import org .apache .fineract .client .models .PostAllowAttributeOverrides ;
3939import org .apache .fineract .client .models .PostPaymentAllocation ;
4040import org .apache .fineract .client .models .PostWorkingCapitalLoanProductsRequest ;
41+ import org .apache .fineract .client .models .PostWorkingCapitalLoanProductsRequest .AccountingRuleEnum ;
4142import org .apache .fineract .client .models .PutWorkingCapitalLoanProductsProductIdRequest ;
43+ import org .apache .fineract .test .data .accounttype .AccountTypeResolver ;
44+ import org .apache .fineract .test .data .accounttype .DefaultAccountType ;
4245import org .apache .fineract .test .data .delinquency .DelinquencyBucketType ;
4346import org .apache .fineract .test .data .delinquency .DelinquencyFrequencyType ;
4447import org .apache .fineract .test .data .delinquency .DelinquencyMinimumPayment ;
5053public class WorkingCapitalRequestFactory {
5154
5255 private final LoanProductsRequestFactory loanProductsRequestFactory ;
56+ private final AccountTypeResolver accountTypeResolver ;
5357
5458 public static final String WCLP_NAME_PREFIX = "WCLP-" ;
5559 public static final String WCLP_DESCRIPTION = "Working Capital Loan Product" ;
5660 public static final String PENALTY = "PENALTY" ;
5761 public static final String FEE = "FEE" ;
5862 public static final String PRINCIPAL = "PRINCIPAL" ;
5963
64+ public PostWorkingCapitalLoanProductsRequest defaultWorkingCapitalLoanProductRequestWithCashAccounting () {
65+ return defaultWorkingCapitalLoanProductRequest ()//
66+ .accountingRule (AccountingRuleEnum .CASH_BASED )//
67+ .fundSourceAccountId (accountTypeResolver .resolve (DefaultAccountType .SUSPENSE_CLEARING_ACCOUNT ))//
68+ .loanPortfolioAccountId (accountTypeResolver .resolve (DefaultAccountType .LOANS_RECEIVABLE ))//
69+ .transfersInSuspenseAccountId (accountTypeResolver .resolve (DefaultAccountType .TRANSFER_IN_SUSPENSE_ACCOUNT ))//
70+ .interestOnLoanAccountId (accountTypeResolver .resolve (DefaultAccountType .INTEREST_INCOME ))//
71+ .incomeFromFeeAccountId (accountTypeResolver .resolve (DefaultAccountType .FEE_INCOME ))//
72+ .incomeFromPenaltyAccountId (accountTypeResolver .resolve (DefaultAccountType .FEE_INCOME ))//
73+ .incomeFromRecoveryAccountId (accountTypeResolver .resolve (DefaultAccountType .RECOVERIES ))//
74+ .writeOffAccountId (accountTypeResolver .resolve (DefaultAccountType .WRITTEN_OFF ))//
75+ .overpaymentLiabilityAccountId (accountTypeResolver .resolve (DefaultAccountType .OVERPAYMENT_ACCOUNT ))//
76+ .goodwillCreditAccountId (accountTypeResolver .resolve (DefaultAccountType .GOODWILL_EXPENSE_ACCOUNT ))//
77+ .incomeFromGoodwillCreditInterestAccountId (accountTypeResolver .resolve (DefaultAccountType .INTEREST_INCOME_CHARGE_OFF ))//
78+ .incomeFromGoodwillCreditFeesAccountId (accountTypeResolver .resolve (DefaultAccountType .FEE_CHARGE_OFF ))//
79+ .incomeFromGoodwillCreditPenaltyAccountId (accountTypeResolver .resolve (DefaultAccountType .FEE_CHARGE_OFF ))//
80+ .incomeFromChargeOffInterestAccountId (accountTypeResolver .resolve (DefaultAccountType .INTEREST_INCOME_CHARGE_OFF ))//
81+ .incomeFromChargeOffFeesAccountId (accountTypeResolver .resolve (DefaultAccountType .FEE_CHARGE_OFF ))//
82+ .incomeFromChargeOffPenaltyAccountId (accountTypeResolver .resolve (DefaultAccountType .FEE_CHARGE_OFF ))//
83+ .chargeOffExpenseAccountId (accountTypeResolver .resolve (DefaultAccountType .CREDIT_LOSS_BAD_DEBT ))//
84+ .chargeOffFraudExpenseAccountId (accountTypeResolver .resolve (DefaultAccountType .CREDIT_LOSS_BAD_DEBT_FRAUD ));//
85+ }
86+
6087 public PostWorkingCapitalLoanProductsRequest defaultWorkingCapitalLoanProductRequest () {
6188 String name = Utils .randomStringGenerator (WCLP_NAME_PREFIX , 10 );
6289 String shortName = loanProductsRequestFactory .generateShortNameSafely ();
@@ -82,6 +109,7 @@ public PostWorkingCapitalLoanProductsRequest defaultWorkingCapitalLoanProductReq
82109 .delinquencyBucketId (DELINQUENCY_BUCKET_ID .longValue ())//
83110 .dateFormat (DATE_FORMAT )//
84111 .locale (LOCALE_EN )//
112+ .accountingRule (AccountingRuleEnum .NONE )//
85113 .paymentAllocation (List .of (//
86114 createPaymentAllocation (PostPaymentAllocation .TransactionTypeEnum .DEFAULT .getValue (),
87115 List .of (PENALTY , FEE , PRINCIPAL ))));//
0 commit comments