FINERACT-2181: Refactor code quality
This commit is contained in:
committed by
Adam Saghy
parent
a308a96bed
commit
9e12e3b1cd
+2
-1
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.acme.fineract.portfolio.note.service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.portfolio.note.data.NoteData;
|
||||
@@ -43,6 +44,6 @@ public class AcmeNoteReadPlatformService implements NoteReadPlatformService, Ini
|
||||
|
||||
@Override
|
||||
public List<NoteData> retrieveNotesByResource(Long resourceId, Integer noteTypeId) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class AcmeNoteServiceStepDefinitions implements En {
|
||||
});
|
||||
|
||||
When("/^The user retrieves the service of interface class (.*)$/", (String interfaceClassName) -> {
|
||||
contextRunner.run((ctx) -> {
|
||||
contextRunner.run(ctx -> {
|
||||
this.interfaceClass = Class.forName(interfaceClassName.trim());
|
||||
|
||||
assertThat(this.interfaceClass.isInterface()).isTrue();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ final class AccrualAccountingApiResourceSwagger {
|
||||
public String locale;
|
||||
@Schema(example = "dd MMMM yyyy")
|
||||
public String dateFormat;
|
||||
@Schema(example = "04 June 2014", description = "which specifies periodic accruals should happen till the given Date", required = true)
|
||||
@Schema(example = "04 June 2014", description = "which specifies periodic accruals should happen till the given Date")
|
||||
public String tillDate;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class GLClosuresApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Operation(summary = "Update an Accounting closure", description = "Once an accounting closure is created, only the comments associated with it may be edited")
|
||||
@RequestBody(content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.PutGlClosuresRequest.class, required = true)))
|
||||
@RequestBody(content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.PutGlClosuresRequest.class)))
|
||||
@ApiResponses({
|
||||
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLClosuresApiResourceSwagger.PutGlClosuresResponse.class))) })
|
||||
public CommandProcessingResult updateGLClosure(@PathParam("glClosureId") @Parameter(description = "glClosureId") final Long glClosureId,
|
||||
|
||||
+8
-9
@@ -59,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccountWritePlatformService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GLAccountWritePlatformServiceJpaRepositoryImpl.class);
|
||||
private static final String GL_ACCOUNT = "glAccount";
|
||||
|
||||
private final GLAccountRepository glAccountRepository;
|
||||
private final JournalEntryRepository glJournalEntryRepository;
|
||||
@@ -146,13 +147,11 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
/**
|
||||
* a detail account cannot be changed to a header account if transactions are already logged against it
|
||||
**/
|
||||
if (changesOnly.containsKey(GLAccountJsonInputParams.USAGE.getValue())) {
|
||||
if (glAccount.isHeaderAccount()) {
|
||||
final boolean journalEntriesForAccountExist = this.glJournalEntryRepository
|
||||
.exists((root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("glAccount").get("id"), glAccountId));
|
||||
if (journalEntriesForAccountExist) {
|
||||
throw new GLAccountInvalidUpdateException(GlAccountInvalidUpdateReason.TRANSANCTIONS_LOGGED, glAccountId);
|
||||
}
|
||||
if (changesOnly.containsKey(GLAccountJsonInputParams.USAGE.getValue()) && glAccount.isHeaderAccount()) {
|
||||
final boolean journalEntriesForAccountExist = this.glJournalEntryRepository
|
||||
.exists((root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get(GL_ACCOUNT).get("id"), glAccountId));
|
||||
if (journalEntriesForAccountExist) {
|
||||
throw new GLAccountInvalidUpdateException(GlAccountInvalidUpdateReason.TRANSANCTIONS_LOGGED, glAccountId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,13 +193,13 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
|
||||
// does this account have transactions logged against it
|
||||
final boolean journalEntriesForAccountExist = this.glJournalEntryRepository
|
||||
.exists((root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("glAccount").get("id"), glAccountId));
|
||||
.exists((root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get(GL_ACCOUNT).get("id"), glAccountId));
|
||||
if (journalEntriesForAccountExist) {
|
||||
throw new GLAccountInvalidDeleteException(GlAccountInvalidDeleteReason.TRANSACTIONS_LOGGED, glAccountId);
|
||||
}
|
||||
// does this account mapped to product
|
||||
final boolean accountMappingForAccountExists = this.productToGLAccountMappingRepository
|
||||
.exists((root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("glAccount").get("id"), glAccountId));
|
||||
.exists((root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get(GL_ACCOUNT).get("id"), glAccountId));
|
||||
if (accountMappingForAccountExists) {
|
||||
throw new GLAccountInvalidDeleteException(GlAccountInvalidDeleteReason.PRODUCT_MAPPING, glAccountId);
|
||||
}
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
final ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(productId,
|
||||
portfolioProductType.getValue(), accountTypeId);
|
||||
if (accountMapping == null) {
|
||||
ArrayList<String> optionalProductToGLAccountMappingEntries = new ArrayList<String>();
|
||||
ArrayList<String> optionalProductToGLAccountMappingEntries = new ArrayList<>();
|
||||
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.GOODWILL_CREDIT.getValue());
|
||||
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_INTEREST.getValue());
|
||||
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.INCOME_FROM_CHARGE_OFF_FEES.getValue());
|
||||
@@ -560,7 +560,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
public void deleteProductToGLAccountMapping(final Long loanProductId, final PortfolioProductType portfolioProductType) {
|
||||
final List<ProductToGLAccountMapping> productToGLAccountMappings = this.accountMappingRepository
|
||||
.findByProductIdAndProductType(loanProductId, portfolioProductType.getValue());
|
||||
if (productToGLAccountMappings != null && productToGLAccountMappings.size() > 0) {
|
||||
if (productToGLAccountMappings != null && !productToGLAccountMappings.isEmpty()) {
|
||||
this.accountMappingRepository.deleteAllInBatch(productToGLAccountMappings);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -262,7 +262,7 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
|
||||
LoanProductProvisioningEntryRowMapper mapper = new LoanProductProvisioningEntryRowMapper();
|
||||
final String sql = "select " + mapper.getSchema() + " where entry.criteria_id = ?";
|
||||
Collection<LoanProductProvisioningEntryData> entries = this.jdbcTemplate.query(sql, mapper, criteriaId); // NOSONAR
|
||||
if (entries != null && entries.size() > 0) {
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
Long entryId = ((LoanProductProvisioningEntryData) entries.toArray()[0]).getHistoryId();
|
||||
ProvisioningEntryDataMapper mapper1 = new ProvisioningEntryDataMapper();
|
||||
final String sql1 = "select " + mapper1.getSchema() + " where entry.id = ?";
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public enum AccountingRuleJsonInputParams {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString().replace("_", " ");
|
||||
return name().replace("_", " ");
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
|
||||
+2
-2
@@ -52,9 +52,9 @@ public class AccountingRuleData {
|
||||
|
||||
// template
|
||||
@SuppressWarnings("unused")
|
||||
private List<OfficeData> allowedOffices = new ArrayList<OfficeData>();
|
||||
private List<OfficeData> allowedOffices = new ArrayList<>();
|
||||
@SuppressWarnings("unused")
|
||||
private List<GLAccountData> allowedAccounts = new ArrayList<GLAccountData>();
|
||||
private List<GLAccountData> allowedAccounts = new ArrayList<>();
|
||||
@SuppressWarnings("unused")
|
||||
private Collection<CodeValueData> allowedCreditTagOptions;
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
+3
-4
@@ -138,10 +138,9 @@ public class AccountingRule extends AbstractPersistableCustom<Long> {
|
||||
if (this.accountToCredit == null) {
|
||||
this.allowMultipleCreditEntries = newValue;
|
||||
}
|
||||
} else if (paramName.equals(AccountingRuleJsonInputParams.ALLOW_MULTIPLE_DEBIT_ENTRIES.getValue())) {
|
||||
if (this.accountToDebit == null) {
|
||||
this.allowMultipleDebitEntries = newValue;
|
||||
}
|
||||
} else if (paramName.equals(AccountingRuleJsonInputParams.ALLOW_MULTIPLE_DEBIT_ENTRIES.getValue())
|
||||
&& this.accountToDebit == null) {
|
||||
this.allowMultipleDebitEntries = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -33,21 +33,21 @@ public class AccountingRuleInvalidException extends AbstractPlatformDomainRuleEx
|
||||
ACCOUNTING_CLOSED; //
|
||||
|
||||
public String errorMessage() {
|
||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
if (name().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
return "Accounting closures cannot be made for a future date";
|
||||
} else if (name().toString().equalsIgnoreCase("ACCOUNTING_CLOSED")) {
|
||||
} else if (name().equalsIgnoreCase("ACCOUNTING_CLOSED")) {
|
||||
return "Accounting Closure for this branch has already been defined for a greater date";
|
||||
}
|
||||
return name().toString();
|
||||
return name();
|
||||
}
|
||||
|
||||
public String errorCode() {
|
||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
if (name().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
return "error.msg.glclosure.invalid.future.date";
|
||||
} else if (name().toString().equalsIgnoreCase("ACCOUNTING_CLOSED")) {
|
||||
} else if (name().equalsIgnoreCase("ACCOUNTING_CLOSED")) {
|
||||
return "error.msg.glclosure.invalid.accounting.closed";
|
||||
}
|
||||
return name().toString();
|
||||
return name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -111,8 +111,8 @@ public class AccountingRuleWritePlatformServiceJpaRepositoryImpl implements Acco
|
||||
// get the GL Accounts or tags to Debit and Credit
|
||||
final String[] debitTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.DEBIT_ACCOUNT_TAGS.getValue());
|
||||
final String[] creditTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.CREDIT_ACCOUNT_TAGS.getValue());
|
||||
final Set<String> incomingDebitTags = debitTags == null ? new HashSet<String>() : new HashSet<>(Arrays.asList(debitTags));
|
||||
final Set<String> incomingCreditTags = creditTags == null ? new HashSet<String>() : new HashSet<>(Arrays.asList(creditTags));
|
||||
final Set<String> incomingDebitTags = debitTags == null ? new HashSet<>() : new HashSet<>(Arrays.asList(debitTags));
|
||||
final Set<String> incomingCreditTags = creditTags == null ? new HashSet<>() : new HashSet<>(Arrays.asList(creditTags));
|
||||
final Long accountToDebitId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_DEBIT.getValue());
|
||||
final Long accountToCreditId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_CREDIT.getValue());
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public abstract class JournalEntryBusinessEvent extends AbstractBusinessEvent<Jo
|
||||
|
||||
private static final String CATEGORY = "Accounting";
|
||||
|
||||
public JournalEntryBusinessEvent(JournalEntry value) {
|
||||
protected JournalEntryBusinessEvent(JournalEntry value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user