/**
   * Calculates Gain or Loss for the tax lot line and determines if it's long term or short term
   *
   * @param holdingTaxLot
   * @param taxLotLine
   * @param valueReceived
   * @param originalCost
   */
  private void calculateGainLoss(
      HoldingTaxLot holdingTaxLot,
      EndowmentTransactionTaxLotLine taxLotLine,
      BigDecimal valueReceived,
      BigDecimal originalCost) {
    BigDecimal gainOrLoss = valueReceived.subtract(originalCost);
    gainOrLoss = gainOrLoss.setScale(2, BigDecimal.ROUND_HALF_UP);

    // Determine if short or long term gain/loss
    Date currentDate = kemService.getCurrentDate();
    Date acquiredDate = holdingTaxLot.getAcquiredDate();

    Calendar calendarAcquiredDate = Calendar.getInstance();
    calendarAcquiredDate.setTime(acquiredDate);
    calendarAcquiredDate.add(Calendar.MONTH, EndowConstants.SHORT_VS_LONG_TERM_PERIOD);

    if (calendarAcquiredDate.getTime().before(currentDate)) {
      // long term gain/loss
      taxLotLine.setLotLongTermGainLoss(gainOrLoss);
    }
    // short term gain/loss
    else {
      taxLotLine.setLotShortTermGainLoss(gainOrLoss);
    }
  }