Ejemplo n.º 1
0
  /**
   * @org
   *     .kuali.kfs.module.endow.document.service.CurrentTaxLotService#getCurrentTaxLotBalancesForMatchingSecurityClassCode(String)
   */
  public Collection<CurrentTaxLotBalance> getCurrentTaxLotBalancesForMatchingSecurityClassCode(
      String securityClassCode) {
    Collection<CurrentTaxLotBalance> currentTaxLotBalances = new ArrayList();

    Collection<Security> securities = new ArrayList();

    if (StringUtils.isNotBlank(securityClassCode)) {
      Map criteria = new HashMap();

      if (dataDictionaryService.getAttributeForceUppercase(
          Security.class, EndowPropertyConstants.SECURITY_CLASS_CODE)) {
        securityClassCode = securityClassCode.toUpperCase();
      }
      criteria.put(EndowPropertyConstants.SECURITY_CLASS_CODE, securityClassCode);

      securities = businessObjectService.findMatching(Security.class, criteria);

      for (Security security : securities) {
        criteria.clear();
        criteria.put(EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_SECURITY_ID, security.getId());

        currentTaxLotBalances.addAll(
            businessObjectService.findMatching(HoldingHistory.class, criteria));
      }
    }

    return currentTaxLotBalances;
  }
  /**
   * Validates that the validateTaxLotsCostAndTransactionAmountLessOrEqualToSecurityCommitment
   * returns false when the SECURITY_ID has a class code type of A (Alternative Investments), and
   * the total END_HLDG_TAX_LOT_T: HLDG_COST for the SECURITY_ID plus the END_TRAN_LN_T: TRAN_AMT
   * exceeds the value in END_SEC_T: CMTMNT_AMT for the Security
   */
  public void testValidateTaxLotsCostAndTransactionAmountLessOrEqualToSecurityCommitment_False() {
    KEMID kemid = KemIdFixture.OPEN_KEMID_RECORD.createKemidRecord();
    // need to insert into END_HLDG_TAX_LOT_REBAL_T TABLE because of constraints....
    HoldingTaxLotRebalanceFixture.HOLDING_TAX_LOT_REBALANCE_RECORD
        .createHoldingTaxLotRebalanceRecord();
    HoldingTaxLot holdingTaxLot =
        HoldingTaxLotFixture.HOLDING_TAX_LOT_RECORD.createHoldingTaxLotRecord();
    SecurityReportingGroup reportingGroup =
        SecurityReportingGroupFixture.REPORTING_GROUP.createSecurityReportingGroup();
    EndowmentTransactionCode endowmentTransactionCode =
        EndowmentTransactionCodeFixture.INCOME_TRANSACTION_CODE.createEndowmentTransactionCode();
    ClassCode classCode =
        ClassCodeFixture.ALTERNATIVE_INVESTMENT_CLASS_CODE.createClassCodeRecord();
    Security security = SecurityFixture.ALTERNATIVE_INVEST_ACTIVE_SECURITY.createSecurityRecord();
    security.setCommitmentAmount(BigDecimal.ZERO);

    document.getTargetTransactionSecurity().setSecurityID(security.getId());
    document.getTargetTransactionSecurity().setSecurity(security);

    EndowmentTransactionLine endowmentTargetTransactionLine =
        EndowmentTransactionLineFixture.ENDOWMENT_TRANSACTIONAL_LINE_POSITIVE_AMT
            .createEndowmentTransactionLine(false);
    document.addTargetTransactionLine(
        (EndowmentTargetTransactionLine) endowmentTargetTransactionLine);

    assetIncreaseDocumentTaxLotsService.updateTransactionLineTaxLots(
        document, endowmentTargetTransactionLine);

    assertFalse(
        rule.validateTaxLotsCostAndTransactionAmountLessOrEqualToSecurityCommitment(document));
  }
  /** Validates that isSecurityActive returns false when an inactive security is added. */
  public void testActiveSecurity_False() {
    // add security details
    SecurityReportingGroup reportingGroup =
        SecurityReportingGroupFixture.REPORTING_GROUP.createSecurityReportingGroup();
    EndowmentTransactionCode endowmentTransactionCode =
        EndowmentTransactionCodeFixture.INCOME_TRANSACTION_CODE.createEndowmentTransactionCode();
    ClassCode classCode = ClassCodeFixture.LIABILITY_CLASS_CODE.createClassCodeRecord();
    Security security = SecurityFixture.INACTIVE_SECURITY.createSecurityRecord();
    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setSecurityID(security.getId());
    targetTransactionSecurity.setSecurity(security);

    document.setTargetTransactionSecurity(targetTransactionSecurity);

    assertFalse(rule.isSecurityActive(document, false));
  }
  /**
   * Validates that validateSecurityClassCodeTypeNotLiability returns true when a security with a
   * class code other that Liability is added.
   */
  public void testLiabilityClassCode_True() {
    // add security details
    SecurityReportingGroup reportingGroup =
        SecurityReportingGroupFixture.REPORTING_GROUP.createSecurityReportingGroup();
    EndowmentTransactionCode endowmentTransactionCode =
        EndowmentTransactionCodeFixture.INCOME_TRANSACTION_CODE.createEndowmentTransactionCode();
    ClassCode classCode = ClassCodeFixture.NOT_LIABILITY_CLASS_CODE.createClassCodeRecord();
    Security security = SecurityFixture.ACTIVE_SECURITY.createSecurityRecord();

    security.setClassCode(classCode);
    security.setSecurityClassCode(classCode.getCode());

    EndowmentTargetTransactionSecurity targetTransactionSecurity =
        new EndowmentTargetTransactionSecurity();
    targetTransactionSecurity.setSecurityID(security.getId());
    targetTransactionSecurity.setSecurity(security);

    document.getTargetTransactionSecurities().add(targetTransactionSecurity);

    assertTrue(rule.validateSecurityClassCodeTypeNotLiability(document, false));
  }