/** * calculates the remainder of fiscal year estimated income for pooled funds * * @param security * @param holdingTaxLot * @return amount */ protected BigDecimal getRemainderOfFiscalYearEstimatedIncomeForPooledFunds( Security security, HoldingTaxLot holdingTaxLot) { BigDecimal amount = BigDecimal.ZERO; if (ObjectUtils.isNull(security.getIncomeNextPayDate()) || ObjectUtils.isNull(security.getFrequencyCode())) { return amount; } Date nextIncomeDueDate = security.getIncomeNextPayDate(); if (ObjectUtils.isNull(nextIncomeDueDate)) { return amount; } Date fiscalYearEndDate = getFiscalYearEndDate(); // BONDS - rule 4.a if (nextIncomeDueDate.after(fiscalYearEndDate)) { return BigDecimal.ZERO; } // rule 4.b if (nextIncomeDueDate.before(fiscalYearEndDate)) { String incomePayFrequency = security.getIncomePayFrequency(); if (ObjectUtils.isNull(incomePayFrequency)) { return amount; } Date lastPaymentDate = getLastPaymentDate(incomePayFrequency, fiscalYearEndDate); long paymentsRemaining = getTotalPaymentsRemaining( lastPaymentDate, fiscalYearEndDate, incomePayFrequency, nextIncomeDueDate); long totalNumberOfPayments = kEMService.getTotalNumberOfPaymentsForFiscalYear(); amount = KEMCalculationRoundingHelper.multiply( holdingTaxLot.getUnits(), security.getIncomeRate(), EndowConstants.Scale.SECURITY_MARKET_VALUE); amount = amount.multiply(BigDecimal.valueOf(paymentsRemaining)); amount = KEMCalculationRoundingHelper.divide( amount, BigDecimal.valueOf(totalNumberOfPayments), EndowConstants.Scale.SECURITY_MARKET_VALUE); amount = amount.add(holdingTaxLot.getCurrentAccrual()); } return amount; }
/** * Service Method to create a new current tax lot balance record and copy HoldingTaxLot record to * it * * @param holdingTaxLot * @return currentTaxLotBalance */ public CurrentTaxLotBalance copyHoldingTaxLotToCurrentTaxLotBalance(HoldingTaxLot holdingTaxLot) { CurrentTaxLotBalance currentTaxLotBalance = new CurrentTaxLotBalance(); currentTaxLotBalance.setKemid(holdingTaxLot.getKemid()); currentTaxLotBalance.setSecurityId(holdingTaxLot.getSecurityId()); currentTaxLotBalance.setRegistrationCode(holdingTaxLot.getRegistrationCode()); currentTaxLotBalance.setLotNumber(holdingTaxLot.getLotNumber()); currentTaxLotBalance.setIncomePrincipalIndicator(holdingTaxLot.getIncomePrincipalIndicator()); currentTaxLotBalance.setUnits(holdingTaxLot.getUnits()); currentTaxLotBalance.setCost(holdingTaxLot.getCost()); currentTaxLotBalance.setAcquiredDate(holdingTaxLot.getAcquiredDate()); currentTaxLotBalance.setPriorAccrual(holdingTaxLot.getPriorAccrual()); currentTaxLotBalance.setCurrentAccrual(holdingTaxLot.getCurrentAccrual()); currentTaxLotBalance.setLastTransactionDate(holdingTaxLot.getLastTransactionDate()); return currentTaxLotBalance; }
/** * calculates the remainder of fiscal year estimated income for cash * * @param security * @param holdingTaxLot * @return amount */ protected BigDecimal getRemainderOfFiscalYearEstimatedIncomeForCash( Security security, HoldingTaxLot holdingTaxLot) { BigDecimal amount = BigDecimal.ZERO; if (ObjectUtils.isNull(security.getIncomeRate()) || security.getIncomeRate().compareTo(BigDecimal.ZERO) == 0) { return amount; } Date nextIncomeDueDate = security.getIncomeNextPayDate(); Date fiscalYearEndDate = getFiscalYearEndDate(); String incomePayFrequency = security.getIncomePayFrequency(); if (ObjectUtils.isNull(nextIncomeDueDate) || ObjectUtils.isNull(incomePayFrequency)) { return amount; } // BONDS - rule 3.a if (nextIncomeDueDate.after(fiscalYearEndDate)) { return BigDecimal.ZERO; } // rule 3.b if (nextIncomeDueDate.before(fiscalYearEndDate)) { Date lastPaymentDate = getLastPaymentDate(incomePayFrequency, fiscalYearEndDate); long daysToLastPayment = getTotalDaysToLastPayment(lastPaymentDate, nextIncomeDueDate); amount = KEMCalculationRoundingHelper.multiply( holdingTaxLot.getUnits(), security.getIncomeRate(), EndowConstants.Scale.SECURITY_MARKET_VALUE); amount = amount.multiply(BigDecimal.valueOf(daysToLastPayment)); amount = KEMCalculationRoundingHelper.divide( amount, BigDecimal.valueOf(EndowConstants.NUMBER_OF_DAYS_IN_YEAR), EndowConstants.Scale.SECURITY_MARKET_VALUE); amount = amount.add(holdingTaxLot.getCurrentAccrual()); } return amount; }