Added general specific exceptions to accept errorCodes and exceptions
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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 org.apache.fineract.accounting.journalentry.exception;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||||
|
|
||||||
|
public class JournalEntryRuntimeException extends AbstractPlatformDomainRuleException {
|
||||||
|
|
||||||
|
public JournalEntryRuntimeException(String errorCode, String errorMessage) {
|
||||||
|
super(errorCode, errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-4
@@ -52,6 +52,8 @@ import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
|
|||||||
import org.apache.fineract.accounting.journalentry.exception.JournalEntriesNotFoundException;
|
import org.apache.fineract.accounting.journalentry.exception.JournalEntriesNotFoundException;
|
||||||
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException;
|
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException;
|
||||||
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GL_JOURNAL_ENTRY_INVALID_REASON;
|
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GL_JOURNAL_ENTRY_INVALID_REASON;
|
||||||
|
|
||||||
|
import org.apache.fineract.accounting.journalentry.exception.JournalEntryRuntimeException;
|
||||||
import org.apache.fineract.accounting.journalentry.serialization.JournalEntryCommandFromApiJsonDeserializer;
|
import org.apache.fineract.accounting.journalentry.serialization.JournalEntryCommandFromApiJsonDeserializer;
|
||||||
import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType;
|
import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType;
|
||||||
import org.apache.fineract.accounting.provisioning.domain.LoanProductProvisioningEntry;
|
import org.apache.fineract.accounting.provisioning.domain.LoanProductProvisioningEntry;
|
||||||
@@ -255,7 +257,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (credits.length != validCredits.length) { throw new RuntimeException("Invalid credits"); }
|
if (credits.length != validCredits.length) {
|
||||||
|
throw new JournalEntryRuntimeException("error.msg.glJournalEntry.invalid.credits", "Invalid Credits.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debits != null && debits.length > 0) {
|
if (debits != null && debits.length > 0) {
|
||||||
@@ -268,9 +272,11 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
|||||||
validDebits[i] = debit;
|
validDebits[i] = debit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debits.length != validDebits.length) { throw new RuntimeException("Invalid debits"); }
|
if (debits.length != validDebits.length) {
|
||||||
}
|
throw new JournalEntryRuntimeException("error.msg.glJournalEntry.invalid.debits","Invalid Debits");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDebitAndCreditAmounts(final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits) {
|
private void checkDebitAndCreditAmounts(final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits) {
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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 org.apache.fineract.infrastructure.campaigns.sms.exception;
|
||||||
|
|
||||||
|
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||||
|
|
||||||
|
public class SmsRuntimeException extends AbstractPlatformDomainRuleException {
|
||||||
|
|
||||||
|
public SmsRuntimeException(String errorCode, String errorMessage) {
|
||||||
|
super(errorCode, errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-4
@@ -34,6 +34,7 @@ import javax.annotation.PostConstruct;
|
|||||||
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType;
|
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType;
|
||||||
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign;
|
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign;
|
||||||
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaignRepository;
|
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaignRepository;
|
||||||
|
import org.apache.fineract.infrastructure.campaigns.sms.exception.SmsRuntimeException;
|
||||||
import org.apache.fineract.infrastructure.sms.domain.SmsMessage;
|
import org.apache.fineract.infrastructure.sms.domain.SmsMessage;
|
||||||
import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository;
|
import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository;
|
||||||
import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService;
|
import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService;
|
||||||
@@ -204,10 +205,12 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
|
|||||||
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
|
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
|
||||||
if (campaignOffice
|
if (campaignOffice
|
||||||
.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
|
.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
|
||||||
throw new RuntimeException();
|
throw new SmsRuntimeException("error.msg.no.office",
|
||||||
|
"Office not found for the id");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException();
|
throw new SmsRuntimeException("error.msg.no.id.attribute",
|
||||||
|
"Office Id attribute is notfound");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,10 +261,12 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
|
|||||||
if (key.equals("officeId")) {
|
if (key.equals("officeId")) {
|
||||||
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
|
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
|
||||||
if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
|
if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
|
||||||
throw new RuntimeException();
|
throw new SmsRuntimeException("error.msg.no.office",
|
||||||
|
"Office not found for the id");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException();
|
throw new SmsRuntimeException("error.msg.no.id.attribute",
|
||||||
|
"Office Id attribute is notfound");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -51,6 +51,7 @@ import org.apache.fineract.useradministration.domain.AppUserRepositoryWrapper;
|
|||||||
import org.joda.time.Days;
|
import org.joda.time.Days;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -266,7 +267,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
|||||||
|
|
||||||
private void addAccrualAccounting(LoanScheduleAccrualData scheduleAccrualData, BigDecimal amount, BigDecimal interestportion,
|
private void addAccrualAccounting(LoanScheduleAccrualData scheduleAccrualData, BigDecimal amount, BigDecimal interestportion,
|
||||||
BigDecimal totalAccInterest, BigDecimal feeportion, BigDecimal totalAccFee, BigDecimal penaltyportion,
|
BigDecimal totalAccInterest, BigDecimal feeportion, BigDecimal totalAccFee, BigDecimal penaltyportion,
|
||||||
BigDecimal totalAccPenalty, final LocalDate accruedTill) throws Exception {
|
BigDecimal totalAccPenalty, final LocalDate accruedTill) throws DataAccessException {
|
||||||
String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,transaction_type_enum,transaction_date,amount,interest_portion_derived,"
|
String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,transaction_type_enum,transaction_date,amount,interest_portion_derived,"
|
||||||
+ "fee_charges_portion_derived,penalty_charges_portion_derived, submitted_on_date) VALUES (?, ?, 0, ?, ?, ?, ?, ?, ?, ?)";
|
+ "fee_charges_portion_derived,penalty_charges_portion_derived, submitted_on_date) VALUES (?, ?, 0, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(),
|
this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(),
|
||||||
@@ -485,7 +486,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void addIncomeAndAccrualTransactions(Long loanId) throws Exception {
|
public void addIncomeAndAccrualTransactions(Long loanId) throws LoanNotFoundException {
|
||||||
if (loanId != null) {
|
if (loanId != null) {
|
||||||
Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true);
|
Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true);
|
||||||
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
||||||
|
|||||||
Reference in New Issue
Block a user