FINERACT-241 Include Add Note to Deposit and Withdrawal screen in savings account
This commit is contained in:
@@ -35,6 +35,7 @@ import org.apache.fineract.portfolio.group.domain.Group;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
|
||||
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccount;
|
||||
import org.apache.fineract.useradministration.domain.AppUser;
|
||||
|
||||
@@ -68,6 +69,10 @@ public class Note extends AbstractAuditableCustom<AppUser, Long> {
|
||||
@JoinColumn(name = "savings_account_id", nullable = true)
|
||||
private SavingsAccount savingsAccount;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "savings_account_transaction_id", nullable = true)
|
||||
private SavingsAccountTransaction savingsTransaction;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "share_account_id", nullable = true)
|
||||
private ShareAccount shareAccount;
|
||||
@@ -95,6 +100,19 @@ public class Note extends AbstractAuditableCustom<AppUser, Long> {
|
||||
return new Note(account, note);
|
||||
}
|
||||
|
||||
public static Note savingsTransactionNote(final SavingsAccount savingsAccount, final SavingsAccountTransaction savingsTransaction,
|
||||
final String note) {
|
||||
return new Note(savingsAccount, savingsTransaction, note);
|
||||
}
|
||||
|
||||
private Note(final SavingsAccount savingsAccount, final SavingsAccountTransaction savingsTransaction, final String note) {
|
||||
this.savingsAccount = savingsAccount;
|
||||
this.savingsTransaction = savingsTransaction;
|
||||
this.client = savingsAccount.getClient();
|
||||
this.note = note;
|
||||
this.noteTypeId = NoteType.SAVINGS_TRANSACTION.getValue();
|
||||
}
|
||||
|
||||
public static Note shareNote(final ShareAccount account, final String note) {
|
||||
return new Note(account, note);
|
||||
}
|
||||
|
||||
+2
-1
@@ -28,7 +28,8 @@ public enum NoteType {
|
||||
LOAN_TRANSACTION(300, "noteType.loan.transaction", "loanTransactions"), //
|
||||
SAVING_ACCOUNT(500, "noteType.saving", "savings"), //
|
||||
GROUP(600, "noteType.group", "groups"),
|
||||
SHARE_ACCOUNT(700, "noteType.shares", "accounts/share");
|
||||
SHARE_ACCOUNT(700, "noteType.shares", "accounts/share"),
|
||||
SAVINGS_TRANSACTION(800, "noteType.savings.transaction", "savingsTransactions");
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
|
||||
+6
-1
@@ -133,8 +133,13 @@ public class NoteReadPlatformServiceImpl implements NoteReadPlatformService {
|
||||
conditionSql = " n.loan_transaction_id = ? ";
|
||||
break;
|
||||
case SAVING_ACCOUNT:
|
||||
conditionSql = " n.saving_account_id = ? ";
|
||||
paramList.add(NoteType.SAVING_ACCOUNT.getValue());
|
||||
paramList.add(NoteType.SAVINGS_TRANSACTION.getValue());
|
||||
conditionSql = " n.saving_account_id = ? and ( n.note_type_enum = ? or n.note_type_enum = ? ) ";
|
||||
break;
|
||||
case SAVINGS_TRANSACTION:
|
||||
conditionSql = " n.savings_account_transaction_id = ? " ;
|
||||
break ;
|
||||
case GROUP:
|
||||
conditionSql = " n.group_id = ? ";
|
||||
break;
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class SavingsApiSetConstants extends SavingsApiConstants {
|
||||
|
||||
protected static final Set<String> SAVINGS_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(idParamName, "accountId", accountNoParamName, "currency", "amount", dateParamName,
|
||||
paymentDetailDataParamName, runningBalanceParamName, reversedParamName));
|
||||
paymentDetailDataParamName, runningBalanceParamName, reversedParamName, noteParamName));
|
||||
|
||||
protected static final Set<String> SAVINGS_ACCOUNT_CHARGES_RESPONSE_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(chargeIdParamName, savingsAccountChargeIdParamName, chargeNameParamName, penaltyParamName,
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class SavingsAccountConstant extends SavingsApiConstants {
|
||||
protected static final Set<String> SAVINGS_ACCOUNT_TRANSACTION_REQUEST_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(localeParamName, dateFormatParamName, transactionDateParamName, transactionAmountParamName,
|
||||
paymentTypeIdParamName, transactionAccountNumberParamName, checkNumberParamName,
|
||||
routingCodeParamName, receiptNumberParamName, bankNumberParamName));
|
||||
routingCodeParamName, receiptNumberParamName, bankNumberParamName, noteParamName));
|
||||
|
||||
protected static final Set<String> SAVINGS_ACCOUNT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(idParamName, accountNoParamName));
|
||||
|
||||
+18
-11
@@ -51,28 +51,30 @@ public class SavingsAccountTransactionData {
|
||||
private final AccountTransferData transfer;
|
||||
private final LocalDate submittedOnDate;
|
||||
private final boolean interestedPostedAsOn;
|
||||
|
||||
private final String submittedByUsername;
|
||||
private final String note ;
|
||||
|
||||
// templates
|
||||
final Collection<PaymentTypeData> paymentTypeOptions;
|
||||
|
||||
public static SavingsAccountTransactionData create(final Long id, final SavingsAccountTransactionEnumData transactionType,
|
||||
final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
|
||||
final CurrencyData currency, final BigDecimal amount, final BigDecimal outstandingChargeAmount,final BigDecimal runningBalance, final boolean reversed,
|
||||
final AccountTransferData transfer, final boolean interestedPostedAsOn) {
|
||||
final AccountTransferData transfer, final boolean interestedPostedAsOn, final String submittedByUsername, final String note) {
|
||||
final Collection<PaymentTypeData> paymentTypeOptions = null;
|
||||
return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency,
|
||||
amount, outstandingChargeAmount,runningBalance, reversed, transfer, paymentTypeOptions, interestedPostedAsOn);
|
||||
amount, outstandingChargeAmount,runningBalance, reversed, transfer, paymentTypeOptions, interestedPostedAsOn, submittedByUsername, note);
|
||||
}
|
||||
|
||||
public static SavingsAccountTransactionData create(final Long id, final SavingsAccountTransactionEnumData transactionType,
|
||||
final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
|
||||
final CurrencyData currency, final BigDecimal amount, final BigDecimal outstandingChargeAmount,
|
||||
final BigDecimal runningBalance, final boolean reversed, final AccountTransferData transfer, final LocalDate submittedOnDate,
|
||||
final boolean interestedPostedAsOn) {
|
||||
final boolean interestedPostedAsOn, final String submittedByUsername, final String note) {
|
||||
final Collection<PaymentTypeData> paymentTypeOptions = null;
|
||||
return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency,
|
||||
amount, outstandingChargeAmount, runningBalance, reversed, transfer, paymentTypeOptions, submittedOnDate,
|
||||
interestedPostedAsOn);
|
||||
interestedPostedAsOn, submittedByUsername, note);
|
||||
}
|
||||
|
||||
public static SavingsAccountTransactionData template(final Long savingsId, final String savingsAccountNo,
|
||||
@@ -86,8 +88,10 @@ public class SavingsAccountTransactionData {
|
||||
final PaymentDetailData paymentDetailData = null;
|
||||
final Collection<CodeValueData> paymentTypeOptions = null;
|
||||
final boolean interestedPostedAsOn = false;
|
||||
final String submittedByUsername = null;
|
||||
final String note = null ;
|
||||
return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, defaultLocalDate,
|
||||
currency, amount, outstandingChargeAmount, runningBalance, reversed, null, null, interestedPostedAsOn);
|
||||
currency, amount, outstandingChargeAmount, runningBalance, reversed, null, null, interestedPostedAsOn, submittedByUsername, note);
|
||||
}
|
||||
|
||||
public static SavingsAccountTransactionData templateOnTop(final SavingsAccountTransactionData savingsAccountTransactionData,
|
||||
@@ -96,24 +100,25 @@ public class SavingsAccountTransactionData {
|
||||
savingsAccountTransactionData.paymentDetailData, savingsAccountTransactionData.accountId,
|
||||
savingsAccountTransactionData.accountNo, savingsAccountTransactionData.date, savingsAccountTransactionData.currency,
|
||||
savingsAccountTransactionData.amount,savingsAccountTransactionData.outstandingChargeAmount, savingsAccountTransactionData.runningBalance, savingsAccountTransactionData.reversed,
|
||||
savingsAccountTransactionData.transfer, paymentTypeOptions, savingsAccountTransactionData.interestedPostedAsOn);
|
||||
savingsAccountTransactionData.transfer, paymentTypeOptions, savingsAccountTransactionData.interestedPostedAsOn,
|
||||
savingsAccountTransactionData.submittedByUsername, savingsAccountTransactionData.note);
|
||||
}
|
||||
|
||||
private SavingsAccountTransactionData(final Long id, final SavingsAccountTransactionEnumData transactionType,
|
||||
final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
|
||||
final CurrencyData currency, final BigDecimal amount, final BigDecimal outstandingChargeAmount,
|
||||
final BigDecimal runningBalance, final boolean reversed, final AccountTransferData transfer,
|
||||
final Collection<PaymentTypeData> paymentTypeOptions, final boolean interestedPostedAsOn) {
|
||||
final Collection<PaymentTypeData> paymentTypeOptions, final boolean interestedPostedAsOn, final String submittedByUsername, final String note) {
|
||||
|
||||
this(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency, amount, outstandingChargeAmount,
|
||||
runningBalance, reversed, transfer, paymentTypeOptions, null, interestedPostedAsOn);
|
||||
runningBalance, reversed, transfer, paymentTypeOptions, null, interestedPostedAsOn, submittedByUsername, note);
|
||||
}
|
||||
|
||||
private SavingsAccountTransactionData(final Long id, final SavingsAccountTransactionEnumData transactionType,
|
||||
final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date,
|
||||
final CurrencyData currency, final BigDecimal amount,final BigDecimal outstandingChargeAmount, final BigDecimal runningBalance, final boolean reversed,
|
||||
final AccountTransferData transfer, final Collection<PaymentTypeData> paymentTypeOptions, final LocalDate submittedOnDate,
|
||||
final boolean interestedPostedAsOn) {
|
||||
final boolean interestedPostedAsOn, final String submittedByUsername, final String note) {
|
||||
this.id = id;
|
||||
this.transactionType = transactionType;
|
||||
this.paymentDetailData = paymentDetailData;
|
||||
@@ -129,6 +134,8 @@ public class SavingsAccountTransactionData {
|
||||
this.paymentTypeOptions = paymentTypeOptions;
|
||||
this.submittedOnDate = submittedOnDate;
|
||||
this.interestedPostedAsOn = interestedPostedAsOn;
|
||||
this.submittedByUsername = submittedByUsername ;
|
||||
this.note = note ;
|
||||
}
|
||||
|
||||
public static SavingsAccountTransactionData withWithDrawalTransactionDetails(
|
||||
@@ -144,6 +151,6 @@ public class SavingsAccountTransactionData {
|
||||
savingsAccountTransactionData.amount, savingsAccountTransactionData.outstandingChargeAmount,
|
||||
savingsAccountTransactionData.runningBalance, savingsAccountTransactionData.reversed,
|
||||
savingsAccountTransactionData.transfer, savingsAccountTransactionData.paymentTypeOptions,
|
||||
savingsAccountTransactionData.interestedPostedAsOn);
|
||||
savingsAccountTransactionData.interestedPostedAsOn,savingsAccountTransactionData.submittedByUsername, savingsAccountTransactionData.note);
|
||||
}
|
||||
}
|
||||
+8
-3
@@ -974,6 +974,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
sqlBuilder.append("totran.transaction_date as toTransferDate, totran.amount as toTransferAmount,");
|
||||
sqlBuilder.append("totran.description as toTransferDescription,");
|
||||
sqlBuilder.append("sa.id as savingsId, sa.account_no as accountNo,");
|
||||
sqlBuilder.append(" au.username as submittedByUsername, ");
|
||||
sqlBuilder.append("pd.payment_type_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, ");
|
||||
sqlBuilder.append("pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, ");
|
||||
sqlBuilder
|
||||
@@ -988,7 +989,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
sqlBuilder.append("left join m_account_transfer_transaction totran on totran.to_savings_transaction_id = tr.id ");
|
||||
sqlBuilder.append("left join m_payment_detail pd on tr.payment_detail_id = pd.id ");
|
||||
sqlBuilder.append("left join m_payment_type pt on pd.payment_type_id = pt.id ");
|
||||
|
||||
sqlBuilder.append("left join m_appuser au on au.id=tr.appuser_id ");
|
||||
this.schemaSql = sqlBuilder.toString();
|
||||
}
|
||||
|
||||
@@ -1057,8 +1058,10 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
toTransferDescription, toTransferReversed);
|
||||
}
|
||||
final boolean postInterestAsOn = false;
|
||||
final String submittedByUsername = rs.getString("submittedByUsername");
|
||||
final String note = null ;
|
||||
return SavingsAccountTransactionData.create(id, transactionType, paymentDetailData, savingsId, accountNo, date, currency,
|
||||
amount, outstandingChargeAmount, runningBalance, reversed, transfer, postInterestAsOn);
|
||||
amount, outstandingChargeAmount, runningBalance, reversed, transfer, postInterestAsOn, submittedByUsername, note);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,8 +1456,10 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
final AccountTransferData transfer = null;
|
||||
final BigDecimal runningBalance = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "runningBalance");
|
||||
final boolean postInterestAsOn = false;
|
||||
final String submittedByUsername = null ;
|
||||
final String note = null ;
|
||||
return SavingsAccountTransactionData.create(savingsId, transactionType, paymentDetailData, savingsId, accountNo, duedate,
|
||||
currency, dueamount, outstandingChargeAmount, runningBalance, false, transfer, postInterestAsOn);
|
||||
currency, dueamount, outstandingChargeAmount, runningBalance, false, transfer, postInterestAsOn, submittedByUsername, note);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -782,6 +782,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
|
||||
sqlBuilder.append("tr.id as transactionId, tr.transaction_type_enum as transactionType, ");
|
||||
sqlBuilder.append("tr.transaction_date as transactionDate, tr.amount as transactionAmount,");
|
||||
sqlBuilder.append("tr.created_date as submittedOnDate,");
|
||||
sqlBuilder.append(" au.username as submittedByUsername, ");
|
||||
sqlBuilder.append(" nt.note as transactionNote, ") ;
|
||||
sqlBuilder.append("tr.running_balance_derived as runningBalance, tr.is_reversed as reversed,");
|
||||
sqlBuilder.append("fromtran.id as fromTransferId, fromtran.is_reversed as fromTransferReversed,");
|
||||
sqlBuilder.append("fromtran.transaction_date as fromTransferDate, fromtran.amount as fromTransferAmount,");
|
||||
@@ -805,7 +807,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
|
||||
sqlBuilder.append("left join m_account_transfer_transaction totran on totran.to_savings_transaction_id = tr.id ");
|
||||
sqlBuilder.append("left join m_payment_detail pd on tr.payment_detail_id = pd.id ");
|
||||
sqlBuilder.append("left join m_payment_type pt on pd.payment_type_id = pt.id ");
|
||||
|
||||
sqlBuilder.append(" left join m_appuser au on au.id=tr.appuser_id ");
|
||||
sqlBuilder.append(" left join m_note nt ON nt.savings_account_transaction_id=tr.id ") ;
|
||||
this.schemaSql = sqlBuilder.toString();
|
||||
}
|
||||
|
||||
@@ -877,9 +880,10 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
|
||||
transfer = AccountTransferData.transferBasicDetails(toTransferId, currency, toTransferAmount, toTransferDate,
|
||||
toTransferDescription, toTransferReversed);
|
||||
}
|
||||
|
||||
final String submittedByUsername = rs.getString("submittedByUsername");
|
||||
final String note = rs.getString("transactionNote") ;
|
||||
return SavingsAccountTransactionData.create(id, transactionType, paymentDetailData, savingsId, accountNo, date, currency,
|
||||
amount, outstandingChargeAmount, runningBalance, reversed, transfer, submittedOnDate, postInterestAsOn);
|
||||
amount, outstandingChargeAmount, runningBalance, reversed, transfer, submittedOnDate, postInterestAsOn, submittedByUsername, note);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+108
-94
@@ -125,16 +125,15 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
|
||||
final JournalEntryWritePlatformService journalEntryWritePlatformService,
|
||||
final SavingsAccountDomainService savingsAccountDomainService, final NoteRepository noteRepository,
|
||||
final AccountTransfersReadPlatformService accountTransfersReadPlatformService,
|
||||
final HolidayRepositoryWrapper holidayRepository, final WorkingDaysRepositoryWrapper workingDaysRepository,
|
||||
final AccountTransfersReadPlatformService accountTransfersReadPlatformService, final HolidayRepositoryWrapper holidayRepository,
|
||||
final WorkingDaysRepositoryWrapper workingDaysRepository,
|
||||
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
|
||||
final ChargeRepositoryWrapper chargeRepository, final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository,
|
||||
final SavingsAccountDataValidator fromApiJsonDeserializer,
|
||||
final StaffRepositoryWrapper staffRepository, final ConfigurationDomainService configurationDomainService,
|
||||
final SavingsAccountDataValidator fromApiJsonDeserializer, final StaffRepositoryWrapper staffRepository,
|
||||
final ConfigurationDomainService configurationDomainService,
|
||||
final DepositAccountOnHoldTransactionRepository depositAccountOnHoldTransactionRepository,
|
||||
final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService,
|
||||
final AppUserRepositoryWrapper appuserRepository,
|
||||
final StandingInstructionRepository standingInstructionRepository,
|
||||
final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService,
|
||||
final AppUserRepositoryWrapper appuserRepository, final StandingInstructionRepository standingInstructionRepository,
|
||||
final BusinessEventNotifierService businessEventNotifierService) {
|
||||
this.context = context;
|
||||
this.savingAccountRepositoryWrapper = savingAccountRepositoryWrapper;
|
||||
@@ -179,8 +178,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final Map<String, Object> changes = account.activate(user, command, DateUtils.getLocalDateOfTenant());
|
||||
|
||||
entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVING.getName(),
|
||||
StatusEnum.ACTIVATE.getCode().longValue(),EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(),
|
||||
account.productId());
|
||||
StatusEnum.ACTIVATE.getCode().longValue(), EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId());
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
final Locale locale = command.extractLocale();
|
||||
@@ -255,6 +253,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate,
|
||||
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction);
|
||||
|
||||
final String noteText = command.stringValueOfParameterNamed("note");
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
final Note note = Note.savingsTransactionNote(account, deposit, noteText);
|
||||
this.noteRepository.save(note) ;
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(deposit.getId()) //
|
||||
.withOfficeId(account.officeId()) //
|
||||
@@ -287,7 +291,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
||||
|
||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||
checkClientOrGroupActive(account);
|
||||
checkClientOrGroupActive(account);
|
||||
final boolean isAccountTransfer = false;
|
||||
final boolean isRegularTransaction = true;
|
||||
final boolean isApplyWithdrawFee = true;
|
||||
@@ -298,6 +302,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(account, fmt, transactionDate,
|
||||
transactionAmount, paymentDetail, transactionBooleanValues);
|
||||
|
||||
final String noteText = command.stringValueOfParameterNamed("note");
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
final Note note = Note.savingsTransactionNote(account, withdrawal, noteText);
|
||||
this.noteRepository.save(note) ;
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(withdrawal.getId()) //
|
||||
.withOfficeId(account.officeId()) //
|
||||
@@ -314,8 +324,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
AppUser user = getAppUserIfPresent();
|
||||
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||
savingsAccountChargeId, accountId);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository
|
||||
.findOneWithNotFoundDetection(savingsAccountChargeId, accountId);
|
||||
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MM yyyy");
|
||||
|
||||
@@ -344,7 +354,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
boolean isInterestTransfer = false;
|
||||
final LocalDate postInterestOnDate = null;
|
||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
financialYearBeginningMonth,postInterestOnDate);
|
||||
financialYearBeginningMonth, postInterestOnDate);
|
||||
|
||||
this.savingAccountRepositoryWrapper.save(account);
|
||||
|
||||
@@ -356,16 +366,17 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
.withSavingsId(savingsId) //
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult postInterest(final JsonCommand command) {
|
||||
|
||||
Long savingsId=command.getSavingsId();
|
||||
final boolean postInterestAs =command.booleanPrimitiveValueOfParameterNamed("isPostInterestAsOn");
|
||||
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
|
||||
|
||||
Long savingsId = command.getSavingsId();
|
||||
final boolean postInterestAs = command.booleanPrimitiveValueOfParameterNamed("isPostInterestAsOn");
|
||||
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
|
||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||
checkClientOrGroupActive(account);
|
||||
if (postInterestAs == true) {
|
||||
|
||||
|
||||
if (transactionDate == null) {
|
||||
|
||||
throw new PostInterestAsOnDateException(PostInterestAsOnException_TYPE.VALID_DATE); }
|
||||
@@ -373,15 +384,15 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
PostInterestAsOnException_TYPE.ACTIVATION_DATE); }
|
||||
List<SavingsAccountTransaction> savingTransactions = account.getTransactions();
|
||||
for (SavingsAccountTransaction savingTransaction : savingTransactions) {
|
||||
if (transactionDate.toDate().before(savingTransaction.getDateOf())) { throw new PostInterestAsOnDateException(
|
||||
PostInterestAsOnException_TYPE.LAST_TRANSACTION_DATE); }
|
||||
if (transactionDate.toDate().before(savingTransaction
|
||||
.getDateOf())) { throw new PostInterestAsOnDateException(PostInterestAsOnException_TYPE.LAST_TRANSACTION_DATE); }
|
||||
}
|
||||
|
||||
LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
if (transactionDate.isAfter(today)) { throw new PostInterestAsOnDateException(PostInterestAsOnException_TYPE.FUTURE_DATE); }
|
||||
|
||||
}
|
||||
postInterest(account,postInterestAs,transactionDate);
|
||||
postInterest(account, postInterestAs, transactionDate);
|
||||
|
||||
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_POST_INTEREST,
|
||||
constructEntityMap(BUSINESS_ENTITY.SAVING, account));
|
||||
@@ -396,7 +407,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void postInterest(final SavingsAccount account,final boolean postInterestAs,final LocalDate transactionDate) {
|
||||
public void postInterest(final SavingsAccount account, final boolean postInterestAs, final LocalDate transactionDate) {
|
||||
|
||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||
@@ -409,17 +420,18 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
final MathContext mc = new MathContext(10, MoneyHelper.getRoundingMode());
|
||||
boolean isInterestTransfer = false;
|
||||
LocalDate postInterestOnDate = null;
|
||||
if (postInterestAs) {
|
||||
postInterestOnDate = transactionDate;
|
||||
}
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,postInterestOnDate);
|
||||
LocalDate postInterestOnDate = null;
|
||||
if (postInterestAs) {
|
||||
postInterestOnDate = transactionDate;
|
||||
}
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,
|
||||
postInterestOnDate);
|
||||
// for generating transaction id's
|
||||
List<SavingsAccountTransaction> transactions = account.getTransactions();
|
||||
for (SavingsAccountTransaction accountTransaction : transactions) {
|
||||
if (accountTransaction.getId() == null) {
|
||||
this.savingsAccountTransactionRepository.save(accountTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.savingAccountRepositoryWrapper.saveAndFlush(account);
|
||||
@@ -427,7 +439,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult undoTransaction(final Long savingsId, final Long transactionId,
|
||||
final boolean allowAccountTransferModification) {
|
||||
@@ -445,14 +457,15 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
.findOneByIdAndSavingsAccountId(transactionId, savingsId);
|
||||
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
|
||||
|
||||
if (!allowAccountTransferModification
|
||||
&& this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.SAVINGS)) { throw new PlatformServiceUnavailableException(
|
||||
"error.msg.saving.account.transfer.transaction.update.not.allowed", "Savings account transaction:" + transactionId
|
||||
+ " update not allowed as it involves in account transfer", transactionId); }
|
||||
if (!allowAccountTransferModification && this.accountTransfersReadPlatformService.isAccountTransfer(transactionId,
|
||||
PortfolioAccountType.SAVINGS)) { throw new PlatformServiceUnavailableException(
|
||||
"error.msg.saving.account.transfer.transaction.update.not.allowed",
|
||||
"Savings account transaction:" + transactionId + " update not allowed as it involves in account transfer",
|
||||
transactionId); }
|
||||
|
||||
if (!account.allowModify()) { throw new PlatformServiceUnavailableException(
|
||||
"error.msg.saving.account.transaction.update.not.allowed", "Savings account transaction:" + transactionId
|
||||
+ " update not allowed for this savings type", transactionId); }
|
||||
if (!account
|
||||
.allowModify()) { throw new PlatformServiceUnavailableException("error.msg.saving.account.transaction.update.not.allowed",
|
||||
"Savings account transaction:" + transactionId + " update not allowed for this savings type", transactionId); }
|
||||
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
final MathContext mc = new MathContext(15, MoneyHelper.getRoundingMode());
|
||||
@@ -476,10 +489,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
checkClientOrGroupActive(account);
|
||||
if (savingsAccountTransaction.isPostInterestCalculationRequired()
|
||||
&& account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,postInterestOnDate);
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,
|
||||
postInterestOnDate);
|
||||
} else {
|
||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
financialYearBeginningMonth,postInterestOnDate);
|
||||
financialYearBeginningMonth, postInterestOnDate);
|
||||
}
|
||||
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
|
||||
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) {
|
||||
@@ -512,12 +526,14 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
.findOneByIdAndSavingsAccountId(transactionId, savingsId);
|
||||
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
|
||||
|
||||
if (!(savingsAccountTransaction.isDeposit() || savingsAccountTransaction.isWithdrawal()) || savingsAccountTransaction.isReversed()) { throw new TransactionUpdateNotAllowedException(
|
||||
savingsId, transactionId); }
|
||||
if (!(savingsAccountTransaction.isDeposit() || savingsAccountTransaction.isWithdrawal())
|
||||
|| savingsAccountTransaction.isReversed()) { throw new TransactionUpdateNotAllowedException(savingsId, transactionId); }
|
||||
|
||||
if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.SAVINGS)) { throw new PlatformServiceUnavailableException(
|
||||
"error.msg.saving.account.transfer.transaction.update.not.allowed", "Savings account transaction:" + transactionId
|
||||
+ " update not allowed as it involves in account transfer", transactionId); }
|
||||
if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId,
|
||||
PortfolioAccountType.SAVINGS)) { throw new PlatformServiceUnavailableException(
|
||||
"error.msg.saving.account.transfer.transaction.update.not.allowed",
|
||||
"Savings account transaction:" + transactionId + " update not allowed as it involves in account transfer",
|
||||
transactionId); }
|
||||
|
||||
this.savingsAccountTransactionDataValidator.validate(command);
|
||||
|
||||
@@ -527,9 +543,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
if (account.isNotActive()) {
|
||||
throwValidationForActiveStatus(SavingsApiConstants.adjustTransactionAction);
|
||||
}
|
||||
if (!account.allowModify()) { throw new PlatformServiceUnavailableException(
|
||||
"error.msg.saving.account.transaction.update.not.allowed", "Savings account transaction:" + transactionId
|
||||
+ " update not allowed for this savings type", transactionId); }
|
||||
if (!account
|
||||
.allowModify()) { throw new PlatformServiceUnavailableException("error.msg.saving.account.transaction.update.not.allowed",
|
||||
"Savings account transaction:" + transactionId + " update not allowed for this savings type", transactionId); }
|
||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
@@ -565,10 +581,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final LocalDate postInterestOnDate = null;
|
||||
if (account.isBeforeLastPostingPeriod(transactionDate)
|
||||
|| account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,postInterestOnDate);
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,
|
||||
postInterestOnDate);
|
||||
} else {
|
||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
financialYearBeginningMonth,postInterestOnDate);
|
||||
financialYearBeginningMonth, postInterestOnDate);
|
||||
}
|
||||
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
|
||||
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) {
|
||||
@@ -614,10 +631,10 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
@Override
|
||||
public CommandProcessingResult close(final Long savingsId, final JsonCommand command) {
|
||||
final AppUser user = this.context.authenticatedUser();
|
||||
|
||||
|
||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||
this.savingsAccountTransactionDataValidator.validateClosing(command, account);
|
||||
|
||||
|
||||
final boolean isLinkedWithAnyActiveLoan = this.accountAssociationsReadPlatformService.isLinkedWithAnyActiveAccount(savingsId);
|
||||
|
||||
if (isLinkedWithAnyActiveLoan) {
|
||||
@@ -627,8 +644,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
}
|
||||
|
||||
entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVING.getName(),
|
||||
StatusEnum.CLOSE.getCode().longValue(),EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(),
|
||||
account.productId());
|
||||
StatusEnum.CLOSE.getCode().longValue(), EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId());
|
||||
|
||||
final boolean isWithdrawBalance = command.booleanPrimitiveValueOfParameterNamed(withdrawBalanceParamName);
|
||||
|
||||
@@ -636,29 +652,26 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
||||
final boolean isPostInterest = command.booleanPrimitiveValueOfParameterNamed(SavingsApiConstants.postInterestValidationOnClosure);
|
||||
// postInterest(account,closedDate,flag);
|
||||
// postInterest(account,closedDate,flag);
|
||||
if (isPostInterest) {
|
||||
boolean postInterestOnClosingDate = false;
|
||||
List<SavingsAccountTransaction> savingTransactions = account.getTransactions();
|
||||
for (SavingsAccountTransaction savingTransaction : savingTransactions) {
|
||||
if (savingTransaction.isInterestPosting() && savingTransaction.isNotReversed()
|
||||
&& closedDate.isEqual(savingTransaction.getTransactionLocalDate())) {
|
||||
if (savingTransaction.isInterestPosting() && savingTransaction.isNotReversed()
|
||||
&& closedDate.isEqual(savingTransaction.getTransactionLocalDate())) {
|
||||
postInterestOnClosingDate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (postInterestOnClosingDate == false) { throw new PostInterestClosingDateException(); }
|
||||
}
|
||||
|
||||
|
||||
final Map<String, Object> changes = new LinkedHashMap<>();
|
||||
|
||||
if (isWithdrawBalance && account.getSummary().getAccountBalance(account.getCurrency()).isGreaterThanZero()) {
|
||||
|
||||
|
||||
|
||||
|
||||
final BigDecimal transactionAmount = account.getSummary().getAccountBalance();
|
||||
|
||||
|
||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
||||
|
||||
final boolean isAccountTransfer = false;
|
||||
@@ -686,7 +699,6 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_CLOSE,
|
||||
constructEntityMap(BUSINESS_ENTITY.SAVING, account));
|
||||
// disable all standing orders linked to the savings account
|
||||
@@ -830,11 +842,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
Integer chargeTimeType = chargeDefinition.getChargeTimeType();
|
||||
LocalDate dueAsOfDateParam = command.localDateValueOfParameterNamed(dueAsOfDateParamName);
|
||||
if((chargeTimeType.equals(ChargeTimeType.WITHDRAWAL_FEE.getValue())
|
||||
|| chargeTimeType.equals(ChargeTimeType.SAVINGS_NOACTIVITY_FEE.getValue()))
|
||||
&& dueAsOfDateParam != null){
|
||||
if ((chargeTimeType.equals(ChargeTimeType.WITHDRAWAL_FEE.getValue())
|
||||
|| chargeTimeType.equals(ChargeTimeType.SAVINGS_NOACTIVITY_FEE.getValue())) && dueAsOfDateParam != null) {
|
||||
baseDataValidator.reset().parameter(dueAsOfDateParamName).value(dueAsOfDateParam.toString(fmt))
|
||||
.failWithCodeNoParameterAddedToErrorCode("charge.due.date.is.invalid.for." + ChargeTimeType.fromInt(chargeTimeType).getCode());
|
||||
.failWithCodeNoParameterAddedToErrorCode(
|
||||
"charge.due.date.is.invalid.for." + ChargeTimeType.fromInt(chargeTimeType).getCode());
|
||||
}
|
||||
final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge.createNewFromJson(savingsAccount, chargeDefinition, command);
|
||||
|
||||
@@ -930,8 +942,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||
final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
|
||||
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||
savingsAccountChargeId, savingsAccountId);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository
|
||||
.findOneWithNotFoundDetection(savingsAccountChargeId, savingsAccountId);
|
||||
|
||||
// Get Savings account from savings charge
|
||||
final SavingsAccount account = savingsAccountCharge.savingsAccount();
|
||||
@@ -948,7 +960,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) {
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,
|
||||
postInterestOnDate);
|
||||
postInterestOnDate);
|
||||
} else {
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
@@ -983,8 +995,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountId);
|
||||
checkClientOrGroupActive(savingsAccount);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||
savingsAccountChargeId, savingsAccountId);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository
|
||||
.findOneWithNotFoundDetection(savingsAccountChargeId, savingsAccountId);
|
||||
|
||||
savingsAccount.removeCharge(savingsAccountCharge);
|
||||
this.savingAccountRepositoryWrapper.saveAndFlush(savingsAccount);
|
||||
@@ -1009,8 +1021,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final BigDecimal amountPaid = command.bigDecimalValueOfParameterNamed(amountParamName);
|
||||
final LocalDate transactionDate = command.localDateValueOfParameterNamed(dueAsOfDateParamName);
|
||||
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||
savingsAccountChargeId, savingsAccountId);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository
|
||||
.findOneWithNotFoundDetection(savingsAccountChargeId, savingsAccountId);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
@@ -1049,8 +1061,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
AppUser user = null;
|
||||
|
||||
final LocalDate transactionDate = DateUtils.getLocalDateOfTenant();
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||
savingsAccountChargeId, accountId);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository
|
||||
.findOneWithNotFoundDetection(savingsAccountChargeId, accountId);
|
||||
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MM yyyy");
|
||||
fmt.withZone(DateUtils.getDateTimeZoneOfTenant());
|
||||
@@ -1081,7 +1093,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,
|
||||
postInterestOnDate);
|
||||
postInterestOnDate);
|
||||
} else {
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
@@ -1123,8 +1135,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||
savingsAccountChargeId, savingsAccountId);
|
||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository
|
||||
.findOneWithNotFoundDetection(savingsAccountChargeId, savingsAccountId);
|
||||
|
||||
final SavingsAccount account = savingsAccountCharge.savingsAccount();
|
||||
this.savingAccountAssembler.assignSavingAccountHelpers(account);
|
||||
@@ -1202,16 +1214,16 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final LocalDate dateOfSavingsOfficerAssignment = command.localDateValueOfParameterNamed("assignmentDate");
|
||||
|
||||
if (fromSavingsOfficerId != null) {
|
||||
fromSavingsOfficer = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(fromSavingsOfficerId, savingsForUpdate
|
||||
.office().getHierarchy());
|
||||
fromSavingsOfficer = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(fromSavingsOfficerId,
|
||||
savingsForUpdate.office().getHierarchy());
|
||||
}
|
||||
if (toSavingsOfficerId != null) {
|
||||
toSavingsOfficer = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(toSavingsOfficerId, savingsForUpdate
|
||||
.office().getHierarchy());
|
||||
toSavingsOfficer = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(toSavingsOfficerId,
|
||||
savingsForUpdate.office().getHierarchy());
|
||||
actualChanges.put("toSavingsOfficerId", toSavingsOfficer.getId());
|
||||
}
|
||||
if (!savingsForUpdate.hasSavingsOfficer(fromSavingsOfficer)) { throw new SavingsOfficerAssignmentException(savingsAccountId,
|
||||
fromSavingsOfficerId); }
|
||||
if (!savingsForUpdate.hasSavingsOfficer(
|
||||
fromSavingsOfficer)) { throw new SavingsOfficerAssignmentException(savingsAccountId, fromSavingsOfficerId); }
|
||||
|
||||
savingsForUpdate.reassignSavingsOfficer(toSavingsOfficer, dateOfSavingsOfficerAssignment);
|
||||
|
||||
@@ -1281,7 +1293,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void setSubStatusInactive(Long savingsId){
|
||||
public void setSubStatusInactive(Long savingsId) {
|
||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||
@@ -1293,15 +1305,15 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void setSubStatusDormant(Long savingsId){
|
||||
public void setSubStatusDormant(Long savingsId) {
|
||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||
account.setSubStatusDormant();
|
||||
this.savingAccountRepositoryWrapper.save(account);
|
||||
this.savingAccountRepositoryWrapper.save(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void escheat(Long savingsId){
|
||||
public void escheat(Long savingsId) {
|
||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||
@@ -1310,8 +1322,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
this.savingAccountRepositoryWrapper.saveAndFlush(account);
|
||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
}
|
||||
|
||||
private AppUser getAppUserIfPresent() {
|
||||
|
||||
private AppUser getAppUserIfPresent() {
|
||||
AppUser user = null;
|
||||
if (this.context != null) {
|
||||
user = this.context.getAuthenticatedUserIfPresent();
|
||||
@@ -1319,10 +1331,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable all standing instructions linked to the savings account if the status is "closed"
|
||||
/**
|
||||
* Disable all standing instructions linked to the savings account if the
|
||||
* status is "closed"
|
||||
*
|
||||
* @param savingsAccount -- the savings account object
|
||||
* @param savingsAccount
|
||||
* -- the savings account object
|
||||
*
|
||||
**/
|
||||
@Transactional
|
||||
@@ -1331,7 +1345,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final Integer standingInstructionStatus = StandingInstructionStatus.ACTIVE.getValue();
|
||||
final Collection<AccountTransferStandingInstruction> accountTransferStandingInstructions = this.standingInstructionRepository
|
||||
.findBySavingsAccountAndStatus(savingsAccount, standingInstructionStatus);
|
||||
|
||||
|
||||
if (!accountTransferStandingInstructions.isEmpty()) {
|
||||
for (AccountTransferStandingInstruction accountTransferStandingInstruction : accountTransferStandingInstructions) {
|
||||
accountTransferStandingInstruction.updateStatus(StandingInstructionStatus.DISABLED.getValue());
|
||||
@@ -1346,7 +1360,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
map.put(entityEvent, entity);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult blockAccount(final Long savingsId) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user