/**
   * Sets the encumbrance code of the line based on the balance type.
   *
   * @param sourceLine - line to set code on
   */
  protected void populateSourceAccountingLineEncumbranceCode(SourceAccountingLine sourceLine) {
    BalanceType selectedBalanceType = getSelectedBalanceType();
    if (ObjectUtils.isNotNull(selectedBalanceType)) {
      selectedBalanceType.refresh();
      sourceLine.setBalanceTyp(selectedBalanceType);
      sourceLine.setBalanceTypeCode(selectedBalanceType.getCode());

      // set the encumbrance update code appropriately
      // KFSMI-5565 remove the default encumbrance code
      // no more default encumbrance code
      //            if
      // (KFSConstants.BALANCE_TYPE_EXTERNAL_ENCUMBRANCE.equals(selectedBalanceType.getCode())) {
      //
      // sourceLine.setEncumbranceUpdateCode(KFSConstants.JOURNAL_VOUCHER_ENCUMBRANCE_UPDATE_CODE_BALANCE_TYPE_EXTERNAL_ENCUMBRANCE);
      //            }
      //            else {
      //                sourceLine.setEncumbranceUpdateCode(null);
      //            }
    } else {
      // it's the first time in, the form will be empty the first time in
      // set up default selection value
      selectedBalanceType = getPopulatedBalanceTypeInstance(KFSConstants.BALANCE_TYPE_ACTUAL);
      setSelectedBalanceType(selectedBalanceType);
      setOriginalBalanceType(selectedBalanceType.getCode());

      sourceLine.setEncumbranceUpdateCode(null);
    }
  }
예제 #2
0
 /**
  * Compares SourceAccounts to see whether those fields which are displayed in the SummaryAccount
  * tab are faithfully represented, with the exception of the Amount, which changes.
  *
  * @param sourceAccount The generated SourceAccountingLine
  * @param correctSourceAccount The SourceAccountingLine which we think should contain correct
  *     values
  */
 private void compareSourceAccounts(
     SourceAccountingLine sourceAccount, SourceAccountingLine correctSourceAccount) {
   Map source = sourceAccount.getValuesMap();
   Map correct = correctSourceAccount.getValuesMap();
   assertEquals(source.get("chartOfAccountsCode"), correct.get("chartOfAccountsCode"));
   assertEquals(source.get("accountNumber"), correct.get("accountNumber"));
   assertEquals(source.get("subAccountNumber"), correct.get("subAccountNumber"));
   assertEquals(source.get("financialObjectCode"), correct.get("financialObjectCode"));
   assertEquals(source.get("financialSubObjectCode"), correct.get("financialSubObjectCode"));
   assertEquals(source.get("projectCode"), correct.get("projectCode"));
   assertEquals(source.get("organizationReferenceId"), correct.get("organizationReferenceId"));
   assertEquals(
       source.get("organizationDocumentNumber"), correct.get("organizationDocumentNumber"));
 }
예제 #3
0
 /**
  * Asserts that, for each original source account, there is exactly one source account in the
  * summary, regardless of whether there is more than one instance of this account in the original.
  *
  * @param sourceLines The List<SourceAccountingLine> from after the summary
  * @param originalSourceAccounts The original List<SourceAccountingLine>
  */
 private void checkAccountConsolidation(
     List<SourceAccountingLine> sourceLines, List<SourceAccountingLine> originalSourceAccounts) {
   for (int i = 0; i < sourceLines.size(); i++) {
     SourceAccountingLine originalSourceAccount = originalSourceAccounts.get(i);
     boolean containsOneAccount = false;
     for (SourceAccountingLine sourceAccount : sourceLines) {
       if (StringUtils.equals(
           sourceAccount.getAccountNumber(), originalSourceAccount.getAccountNumber())) {
         if (containsOneAccount == false) {
           containsOneAccount = true;
         } else {
           fail();
         }
       }
     }
     assertTrue(containsOneAccount);
   }
 }
  /**
   * Looks up all of the generating lines and stores essential information about them on documents
   * given by the matchingAdvanceDepositDocumentNumbers parameter and matching the given
   * organization reference id
   *
   * @param matchingAdvanceDepositDocumentNumbers the document numbers of matching advance deposit
   *     documents in lookup form
   * @param organizationReferenceId the organization reference id the accounting line must match
   * @return a List of essential information about each of the matching accounting lines
   */
  protected List<GeneratingLineHolder> getGeneratingLinesForDocuments(
      String matchingAdvanceDepositDocumentNumbers, String organizationReferenceId) {
    List<GeneratingLineHolder> holders = new ArrayList<GeneratingLineHolder>();

    Map fields = new HashMap();
    fields.put("documentNumber", matchingAdvanceDepositDocumentNumbers);
    fields.put("organizationReferenceId", organizationReferenceId);

    Collection als =
        getLookupService().findCollectionBySearchUnbounded(SourceAccountingLine.class, fields);
    for (Object alAsObject : als) {
      final SourceAccountingLine accountingLine = (SourceAccountingLine) alAsObject;
      holders.add(
          new GeneratingLineHolder(
              accountingLine.getDocumentNumber(), accountingLine.getSequenceNumber()));
    }

    return holders;
  }
 /**
  * This constructor is used for comparison for accounting line only items
  *
  * @param line
  */
 public AccountingLineDistributionKey(SourceAccountingLine line) {
   this.chartOfAccountsCode = line.getChartOfAccountsCode();
   this.accountNumber = line.getAccountNumber();
   this.financialObjectCode = line.getFinancialObjectCode();
   this.subAccountNumber = line.getSubAccountNumber();
   this.financialSubObjectCode = line.getFinancialSubObjectCode();
   this.projectCode = line.getProjectCode();
   this.organizationReferenceId = line.getOrganizationReferenceId();
 }
예제 #6
0
 @Override
 public void setDocumentNumber(String documentNumber) {
   super.setDocumentNumber(documentNumber);
 }
예제 #7
0
 @Override
 public void refreshNonUpdateableReferences() {
   super.refreshNonUpdateableReferences();
 }
예제 #8
0
 /** @see org.kuali.rice.krad.bo.PersistableBusinessObjectBase#refresh() */
 @Override
 public void refresh() {
   super.refresh();
   this.updateAmountBasedOnQuantityAndUnitPrice();
 }
  /**
   * @see
   *     org.kuali.rice.krad.bo.AccountingLineParserBase#performCustomSourceAccountingLinePopulation(java.util.Map,
   *     org.kuali.rice.krad.bo.SourceAccountingLine, java.lang.String)
   */
  @Override
  protected void performCustomSourceAccountingLinePopulation(
      Map<String, String> attributeValueMap,
      SourceAccountingLine sourceAccountingLine,
      String accountingLineAsString) {
    // chose debit/credit
    String debitValue = attributeValueMap.remove(DEBIT);
    String creditValue = attributeValueMap.remove(CREDIT);
    KualiDecimal debitAmount = null;
    try {
      if (StringUtils.isNotBlank(debitValue)) {
        debitAmount = new KualiDecimal(debitValue);
      }
    } catch (NumberFormatException e) {
      String[] errorParameters = {
        debitValue,
        retrieveAttributeLabel(sourceAccountingLine.getClass(), DEBIT),
        accountingLineAsString
      };
      throw new AccountingLineParserException(
          "invalid (NaN) '" + DEBIT + "=" + debitValue + " for " + accountingLineAsString,
          ERROR_INVALID_PROPERTY_VALUE,
          errorParameters);
    }
    KualiDecimal creditAmount = null;
    try {
      if (StringUtils.isNotBlank(creditValue)) {
        creditAmount = new KualiDecimal(creditValue);
      }
    } catch (NumberFormatException e) {
      String[] errorParameters = {
        creditValue,
        retrieveAttributeLabel(sourceAccountingLine.getClass(), CREDIT),
        accountingLineAsString
      };
      throw new AccountingLineParserException(
          "invalid (NaN) '" + CREDIT + "=" + creditValue + " for " + accountingLineAsString,
          ERROR_INVALID_PROPERTY_VALUE,
          errorParameters);
    }

    KualiDecimal amount = null;
    String debitCreditCode = null;
    if (debitAmount != null && debitAmount.isNonZero()) {
      amount = debitAmount;
      debitCreditCode = KFSConstants.GL_DEBIT_CODE;
    }

    if (creditAmount != null && creditAmount.isNonZero()) {
      amount = creditAmount;
      debitCreditCode = KFSConstants.GL_CREDIT_CODE;
    }

    sourceAccountingLine.setAmount(amount);
    sourceAccountingLine.setDebitCreditCode(debitCreditCode);

    boolean isFinancialOffsetGeneration =
        SpringContext.getBean(BalanceTypeService.class)
            .getBalanceTypeByCode(balanceTypeCode)
            .isFinancialOffsetGenerationIndicator();
    if (isFinancialOffsetGeneration
        || StringUtils.equals(balanceTypeCode, KFSConstants.BALANCE_TYPE_EXTERNAL_ENCUMBRANCE)) {
      super.performCustomSourceAccountingLinePopulation(
          attributeValueMap, sourceAccountingLine, accountingLineAsString);
    }
    sourceAccountingLine.setBalanceTypeCode(balanceTypeCode);
  }