예제 #1
0
  public int loadTransactionIntoOriginEntryTable(OriginEntryGroup group) {
    int numberOfInputData = Integer.valueOf(properties.getProperty("numOfData"));
    businessObjectService.save(group);

    int[] fieldLength = this.getFieldLength(fieldLengthList);
    List<LaborOriginEntry> originEntries =
        this.loadInputData(
            LaborOriginEntry.class, "data", numberOfInputData, keyFieldList, fieldLength);
    for (LaborOriginEntry entry : originEntries) {
      entry.setEntryGroupId(group.getId());
    }

    businessObjectService.save(originEntries);
    return originEntries.size();
  }
  protected void buildSubTree(
      String principalName, BudgetConstructionOrganizationReports bcOrgRpts, int curLevel) {

    curLevel++;
    BudgetConstructionPullup bcPullup = new BudgetConstructionPullup();
    bcPullup.setPrincipalId(principalName);
    bcPullup.setChartOfAccountsCode(bcOrgRpts.getChartOfAccountsCode());
    bcPullup.setOrganizationCode(bcOrgRpts.getOrganizationCode());
    bcPullup.setReportsToChartOfAccountsCode(bcOrgRpts.getReportsToChartOfAccountsCode());
    bcPullup.setReportsToOrganizationCode(bcOrgRpts.getReportsToOrganizationCode());
    bcPullup.setPullFlag(new Integer(0));
    businessObjectService.save(bcPullup);

    if (curLevel <= MAXLEVEL) {
      // getActiveChildOrgs does not return orgs that report to themselves
      List childOrgs =
          budgetConstructionOrganizationReportsService.getActiveChildOrgs(
              bcOrgRpts.getChartOfAccountsCode(), bcOrgRpts.getOrganizationCode());
      if (childOrgs.size() > 0) {
        for (Iterator iter = childOrgs.iterator(); iter.hasNext(); ) {
          BudgetConstructionOrganizationReports bcOrg =
              (BudgetConstructionOrganizationReports) iter.next();
          buildSubTree(principalName, bcOrg, curLevel);
        }
      }
    } else {
      LOG.warn(
          String.format(
              "\n%s/%s reports to organization more than maxlevel of %d",
              bcOrgRpts.getChartOfAccountsCode(), bcOrgRpts.getOrganizationCode(), MAXLEVEL));
    }
  }
  /**
   * @see
   *     org.kuali.kfs.module.tem.batch.service.CreditCardDataImportService#importCreditCardDataFile(java.lang.String,
   *     org.kuali.kfs.sys.batch.BatchInputFileType)
   */
  @Override
  public boolean importCreditCardDataFile(String dataFileName, BatchInputFileType inputFileType) {

    try {
      FileInputStream fileContents = new FileInputStream(dataFileName);

      byte[] fileByteContent = IOUtils.toByteArray(fileContents);
      CreditCardImportData creditCardData =
          (CreditCardImportData) batchInputFileService.parse(inputFileType, fileByteContent);
      IOUtils.closeQuietly(fileContents);

      LOG.info("Credit Card Import - validating: " + dataFileName);
      List<CreditCardStagingData> validCreditCardList =
          validateCreditCardData(creditCardData, dataFileName);
      if (!validCreditCardList.isEmpty()) {
        businessObjectService.save(validCreditCardList);
      }
    } catch (Exception ex) {
      LOG.error("Failed to process the file : " + dataFileName, ex);
      moveErrorFile(dataFileName, creditCardDataFileErrorDirectory);
      return false;
    } finally {
      removeDoneFiles(dataFileName);
    }
    return true;
  }
예제 #4
0
  /**
   * This overridden updates an existing Rule in the Repository
   *
   * @see
   *     org.kuali.rice.krms.impl.repository.RuleBoService#updateRule(org.kuali.rice.krms.api.repository.rule.RuleDefinition)
   */
  @Override
  public void updateRule(RuleDefinition rule) {
    if (rule == null) {
      throw new IllegalArgumentException("rule is null");
    }

    // must already exist to be able to update
    final String ruleIdKey = rule.getId();
    final RuleBo existing = businessObjectService.findBySinglePrimaryKey(RuleBo.class, ruleIdKey);
    if (existing == null) {
      throw new IllegalStateException("the rule does not exist: " + rule);
    }
    final RuleDefinition toUpdate;
    if (!existing.getId().equals(rule.getId())) {
      // if passed in id does not match existing id, correct it
      final RuleDefinition.Builder builder = RuleDefinition.Builder.create(rule);
      builder.setId(existing.getId());
      toUpdate = builder.build();
    } else {
      toUpdate = rule;
    }

    // copy all updateable fields to bo
    RuleBo boToUpdate = RuleBo.from(toUpdate);

    // delete any old, existing attributes
    Map<String, String> fields = new HashMap<String, String>(1);
    fields.put(PropertyNames.Rule.RULE_ID, toUpdate.getId());
    businessObjectService.deleteMatching(RuleAttributeBo.class, fields);

    // update the rule and create new attributes
    businessObjectService.save(boToUpdate);
  }
  /**
   * @see
   *     org.kuali.kfs.module.endow.batch.service.AvailableCashUpdateService#InsertAvailableCash(KemidCurrentCash)
   *     Method to clear all the records in the kemidCurrentAvailableBalance table
   */
  public void InsertAvailableCash(KEMIDCurrentAvailableBalance kemidCurrentAvailableBalance) {
    if (kemidCurrentAvailableBalance == null) {
      throw new IllegalArgumentException("invalid (null) kemidCurrentAvailableBalance");
    }

    businessObjectService.save(kemidCurrentAvailableBalance);
  }
예제 #6
0
  /**
   * @see
   *     org.kuali.kfs.module.endow.document.service.CurrentTaxLotService#getByPrimaryKey(java.lang.String,
   *     java.lang.String, java.lang.String, int, java.lang.String)
   */
  public void updateCurrentTaxLotBalance(CurrentTaxLotBalance currentTaxLotBalance) {
    if (currentTaxLotBalance == null) {
      throw new IllegalArgumentException("invalid (null) currentTaxLotBalance");
    }

    businessObjectService.save(currentTaxLotBalance);
  }
  @Transactional
  protected boolean processCreditCardStagingExpense(CreditCardStagingData creditCard) {
    LOG.info("Creating historical travel expense for credit card: " + creditCard.getId());
    HistoricalTravelExpense expense =
        travelExpenseService.createHistoricalTravelExpense(creditCard);
    businessObjectService.save(expense);

    // Mark as moved to historical
    creditCard.setErrorCode(CreditCardStagingDataErrorCodes.CREDIT_CARD_MOVED_TO_HISTORICAL);
    LOG.info(
        "Finished creating historical travel expense for credit card: "
            + creditCard.getId()
            + " Historical Travel Expense: "
            + expense.getId());
    businessObjectService.save(creditCard);

    return true;
  }
  /** @see org.kuali.rice.kns.maintenance.Maintainable#saveBusinessObject() */
  @Override
  public void saveBusinessObject() {
    BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);

    GlobalBusinessObject gbo = (GlobalBusinessObject) businessObject;

    // delete any indicated BOs
    List<PersistableBusinessObject> bosToDeactivate = gbo.generateDeactivationsToPersist();
    if (bosToDeactivate != null) {
      if (!bosToDeactivate.isEmpty()) {
        boService.save(bosToDeactivate);
      }
    }

    // OJB caches the any ObjectCodes that are retrieved from the database.  If multiple queries
    // return the same row (identified by the PK
    // values), OJB will return the same instance of the ObjectCode.  However, in
    // generateGlobalChangesToPersist(), the ObjectCode returned by
    // OJB is altered, meaning that any subsequent OJB calls will return the altered object.  The
    // following cache will store the active statuses
    // of object codes affected by this global document before generateGlobalChangesToPersist()
    // alters them.
    Map<String, Boolean> objectCodeActiveStatusCache =
        buildObjectCodeActiveStatusCache((ObjectCodeGlobal) gbo);

    SubObjectTrickleDownInactivationService subObjectTrickleDownInactivationService =
        SpringContext.getBean(SubObjectTrickleDownInactivationService.class);
    // persist any indicated BOs
    List<PersistableBusinessObject> bosToPersist = gbo.generateGlobalChangesToPersist();
    if (bosToPersist != null) {
      if (!bosToPersist.isEmpty()) {
        for (PersistableBusinessObject bo : bosToPersist) {
          ObjectCode objectCode = (ObjectCode) bo;

          boService.save(objectCode);

          if (isInactivatingObjectCode(objectCode, objectCodeActiveStatusCache)) {
            subObjectTrickleDownInactivationService.trickleDownInactivateSubObjects(
                objectCode, getDocumentNumber());
          }
        }
      }
    }
  }
예제 #9
0
  public int loadTransactionIntoGLEntryTable() {
    int numberOfInputData = Integer.valueOf(properties.getProperty("numOfData"));
    int[] fieldLength = this.getFieldLength(fieldLengthList);

    List<LaborGeneralLedgerEntry> laborGLEntries =
        this.loadInputData(
            LaborGeneralLedgerEntry.class, "data", numberOfInputData, keyFieldList, fieldLength);
    businessObjectService.save(laborGLEntries);

    return laborGLEntries.size();
  }
 @Override
 public <T> T save(T dataObject) {
   if (dataObject instanceof Collection) {
     Collection<Object> newList = new ArrayList<Object>(((Collection) dataObject).size());
     for (Object obj : (Collection<?>) dataObject) {
       newList.add(save(obj));
     }
     return (T) newList;
   } else {
     return (T) businessObjectService.save((PersistableBusinessObject) dataObject);
   }
 }
 /**
  * @see
  *     org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#updateReportedDate(String)
  */
 @Override
 public void updateReportedDate(String docNumber) {
   HashMap<String, String> criteria = new HashMap<String, String>();
   criteria.put("documentNumber", docNumber);
   CustomerInvoiceDocument customerInvoiceDocument =
       businessObjectService.findByPrimaryKey(CustomerInvoiceDocument.class, criteria);
   Date reportedDate = dateTimeService.getCurrentSqlDate();
   if (ObjectUtils.isNotNull(customerInvoiceDocument)) {
     customerInvoiceDocument.setReportedDate(reportedDate);
     businessObjectService.save(customerInvoiceDocument);
   }
 }
예제 #12
0
  @SuppressWarnings("deprecation")
  @ConfigureContext(shouldCommitTransactions = false)
  public void testOJBConfiguration() throws Exception {
    TemProfile profile = new TemProfile();
    Integer newProfileId =
        sas.getNextAvailableSequenceNumber(TemConstants.TEM_PROFILE_SEQ_NAME).intValue();
    profile.setProfileId(newProfileId);
    profile.getTemProfileAddress().setProfileId(newProfileId);
    profile.setCustomerNumber("555555555");
    profile.setPrincipalId("66666666");
    profile.setDateOfBirth(new Date(Date.parse("03/03/1975")));
    profile.setCitizenship("United States");
    profile.setDriversLicenseExpDate(new Date(Date.parse("03/03/2014")));
    profile.setDriversLicenseNumber("B43212345");
    profile.setUpdatedBy("jamey");
    profile.setLastUpdate(new Date(Date.parse("03/03/2011")));
    profile.setGender("M");
    profile.setNonResidentAlien(false);
    profile.setHomeDeptChartOfAccountsCode("UA");
    profile.setHomeDeptOrgCode("VPIT");

    List<TravelerType> travelerTypes =
        (List<TravelerType>)
            businessObjectService.findMatching(TravelerType.class, new HashMap<String, Object>());
    profile.setTravelerType(travelerTypes.get(0));
    profile.setTravelerTypeCode(profile.getTravelerType().getCode());

    businessObjectService.save(profile);

    Map<String, Object> values = new HashMap<String, Object>();
    values.put(TemPropertyConstants.TemProfileProperties.PROFILE_ID, profile.getProfileId());

    List<TemProfile> profileList =
        (List<TemProfile>) businessObjectService.findMatching(TemProfile.class, values);
    try {
      assertTrue(profile.getCustomerNumber().equals(profileList.get(0).getCustomerNumber()));
      assertTrue(profile.getPrincipalId().equals(profileList.get(0).getPrincipalId()));
      assertTrue(profile.getDateOfBirth().equals(profileList.get(0).getDateOfBirth()));
      assertTrue(profile.getCitizenship().equals(profileList.get(0).getCitizenship()));
      assertTrue(
          profile.getDriversLicenseExpDate().equals(profileList.get(0).getDriversLicenseExpDate()));
      assertTrue(
          profile.getDriversLicenseNumber().equals(profileList.get(0).getDriversLicenseNumber()));
      assertTrue(profile.getUpdatedBy().equals(profileList.get(0).getUpdatedBy()));
      assertTrue(profile.getLastUpdate().equals(profileList.get(0).getLastUpdate()));
      assertTrue(profile.getGender().equals(profileList.get(0).getGender()));
      assertTrue(profile.getNonResidentAlien().equals(profileList.get(0).getNonResidentAlien()));
      assertTrue(profile.getHomeDepartment().equals(profileList.get(0).getHomeDepartment()));
    } catch (Exception e) {
      assert (false);
    }
  }
  /**
   * @see
   *     org.kuali.kfs.module.bc.document.service.BudgetOrganizationTreeService#resetPullFlag(java.lang.String)
   */
  public void resetPullFlag(String principalId) {

    if (StringUtils.isBlank(principalId)) {
      throw new IllegalArgumentException("String parameter principalId was null or blank.");
    }
    List<BudgetConstructionPullup> results =
        budgetConstructionDao.getBudgetConstructionPullupFlagSetByUserId(principalId);
    if (!results.isEmpty()) {
      for (BudgetConstructionPullup selOrg : results) {
        selOrg.setPullFlag(OrgSelControlOption.NO.getKey());
      }
      businessObjectService.save(results);
    }
  }
  public void testHasPendingLaborLedgerEntryWithAccount() throws Exception {
    String testTarget = "hasPendingLaborLedgerEntryWithAccount";
    int numberOfTestData = Integer.valueOf(properties.getProperty(testTarget + ".numOfData"));
    String accountFieldNames = properties.getProperty(testTarget + ".accountFieldNames");

    // prepare test data -- put the test data into data store
    String prefixForInput = testTarget + ".testData";
    List<LaborLedgerPendingEntry> inputDataList =
        TestDataPreparator.buildTestDataList(
            LaborLedgerPendingEntry.class, properties, prefixForInput, numberOfTestData);
    businessObjectService.save(inputDataList);

    // test primary scenarios -- everything is correct and the expected results can be retrieved
    String prefixForValidAccount = testTarget + ".accountWithResults";
    int numOfValidAccounts =
        Integer.valueOf(properties.getProperty(prefixForValidAccount + ".numOfData"));
    List<Account> validAccounts =
        TestDataPreparator.buildTestDataList(
            Account.class,
            properties,
            prefixForValidAccount,
            accountFieldNames,
            deliminator,
            numOfValidAccounts);
    for (Account account : validAccounts) {
      assertTrue(
          "At least one record can be found.",
          laborLedgerPendingEntryService.hasPendingLaborLedgerEntry(
              account.getChartOfAccountsCode(), account.getAccountNumber()));
    }

    // test secondary scenarios -- the input is not correct and nothing can be returned
    String prefixForInvalidAccount = testTarget + ".accountWithoutResults";
    int numOfInvalidAccounts =
        Integer.valueOf(properties.getProperty(prefixForInvalidAccount + ".numOfData"));
    List<Account> invalidAccounts =
        TestDataPreparator.buildTestDataList(
            Account.class,
            properties,
            prefixForInvalidAccount,
            accountFieldNames,
            deliminator,
            numOfInvalidAccounts);
    for (Account account : invalidAccounts) {
      assertFalse(
          "Must not find anything.",
          laborLedgerPendingEntryService.hasPendingLaborLedgerEntry(
              account.getChartOfAccountsCode(), account.getAccountNumber()));
    }
  }
  /**
   * @see
   *     org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#convertDiscountsToPaidApplieds(org.kuali.kfs.module.ar.document.CustomerInvoiceDocument)
   */
  @Override
  public void convertDiscountsToPaidApplieds(CustomerInvoiceDocument invoice) {

    // this needs a little explanation. we have to calculate manually
    // whether we've written off the whole thing, because the regular
    // code uses the invoice paid applieds to discount, but since those
    // are added but not committed in this transaction, they're also not
    // visible in this transaction, so we do it manually.
    KualiDecimal openAmount = invoice.getOpenAmount();

    String invoiceNumber = invoice.getDocumentNumber();
    List<CustomerInvoiceDetail> discounts = invoice.getDiscounts();

    // retrieve the number of current paid applieds, so we dont have item number overlap
    Integer paidAppliedItemNumber = 0;

    for (CustomerInvoiceDetail discount : discounts) {

      // if credit amount is zero, do nothing
      if (KualiDecimal.ZERO.equals(discount.getAmount())) {
        continue;
      }

      if (paidAppliedItemNumber == 0) {
        paidAppliedItemNumber =
            invoicePaidAppliedService.getNumberOfInvoicePaidAppliedsForInvoiceDetail(
                invoiceNumber, discount.getInvoiceItemNumber());
      }

      // create and save the paidApplied
      InvoicePaidApplied invoicePaidApplied = new InvoicePaidApplied();
      invoicePaidApplied.setDocumentNumber(invoiceNumber);
      invoicePaidApplied.setPaidAppliedItemNumber(paidAppliedItemNumber++);
      invoicePaidApplied.setFinancialDocumentReferenceInvoiceNumber(invoiceNumber);
      invoicePaidApplied.setInvoiceItemNumber(discount.getInvoiceItemNumber());
      invoicePaidApplied.setUniversityFiscalYear(universityDateService.getCurrentFiscalYear());
      invoicePaidApplied.setUniversityFiscalPeriodCode(
          universityDateService.getCurrentUniversityDate().getUniversityFiscalAccountingPeriod());
      invoicePaidApplied.setInvoiceItemAppliedAmount(discount.getAmount().abs());
      openAmount = openAmount.subtract(discount.getAmount().abs());
      businessObjectService.save(invoicePaidApplied);
    }

    // if its open, but now with a zero openamount, then close it
    if (KualiDecimal.ZERO.equals(openAmount)) {
      invoice.setOpenInvoiceIndicator(false);
      invoice.setClosedDate(dateTimeService.getCurrentSqlDate());
      documentService.updateDocument(invoice);
    }
  }
예제 #16
0
 /**
  * This overridden creates a KRMS Rule in the repository
  *
  * @see
  *     org.kuali.rice.krms.impl.repository.RuleBoService#createRule(org.kuali.rice.krms.api.repository.rule.RuleDefinition)
  */
 @Override
 public RuleDefinition createRule(RuleDefinition rule) {
   if (rule == null) {
     throw new IllegalArgumentException("rule is null");
   }
   final String nameKey = rule.getName();
   final String namespaceKey = rule.getNamespace();
   final RuleDefinition existing = getRuleByNameAndNamespace(nameKey, namespaceKey);
   if (existing != null) {
     throw new IllegalStateException("the rule to create already exists: " + rule);
   }
   RuleBo ruleBo = RuleBo.from(rule);
   businessObjectService.save(ruleBo);
   return RuleBo.to(ruleBo);
 }
 /**
  * @see
  *     org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#updateReportedInvoiceInfo(CustomerStatementResultHolder)
  */
 @Override
 public void updateReportedInvoiceInfo(CustomerStatementResultHolder data) {
   HashMap<String, String> criteria = new HashMap<String, String>();
   criteria.put("customerNumber", data.getCustomerNumber());
   CustomerBillingStatement customerBillingStatement =
       businessObjectService.findByPrimaryKey(CustomerBillingStatement.class, criteria);
   if (ObjectUtils.isNotNull(customerBillingStatement)) {
     customerBillingStatement.setPreviouslyBilledAmount(data.getCurrentBilledAmount());
     customerBillingStatement.setReportedDate(dateTimeService.getCurrentSqlDate());
   } else {
     customerBillingStatement = new CustomerBillingStatement();
     customerBillingStatement.setCustomerNumber(data.getCustomerNumber());
     customerBillingStatement.setPreviouslyBilledAmount(data.getCurrentBilledAmount());
     customerBillingStatement.setReportedDate(dateTimeService.getCurrentSqlDate());
   }
   businessObjectService.save(customerBillingStatement);
 }
예제 #18
0
  /**
   * This method will create a {@link FunctionDefintion} as described by the function passed in.
   *
   * @see
   *     org.kuali.rice.krms.impl.repository.FunctionBoService#createFunction(org.kuali.rice.krms.api.repository.function.FunctionDefinition)
   */
  @Override
  public FunctionDefinition createFunction(FunctionDefinition function) {
    if (function == null) {
      throw new IllegalArgumentException("function is null");
    }

    final String nameKey = function.getName();
    final String namespaceKey = function.getNamespace();
    final FunctionDefinition existing = getFunctionByNameAndNamespace(nameKey, namespaceKey);
    if (existing != null
        && existing.getName().equals(nameKey)
        && existing.getNamespace().equals(namespaceKey)) {
      throw new IllegalStateException("the function to create already exists: " + function);
    }

    FunctionBo functionBo = FunctionBo.from(function);
    businessObjectService.save(functionBo);
    return FunctionBo.to(functionBo);
  }
예제 #19
0
  /**
   * This overridden method updates an existing Function in the repository
   *
   * @see
   *     org.kuali.rice.krms.impl.repository.FunctionBoService#updateFunction(org.kuali.rice.krms.api.repository.function.FunctionDefinition)
   */
  @Override
  public void updateFunction(FunctionDefinition function) {
    if (function == null) {
      throw new IllegalArgumentException("function is null");
    }

    final String functionIdKey = function.getId();
    final FunctionDefinition existing = getFunctionById(functionIdKey);
    if (existing == null) {
      throw new IllegalStateException("the function does not exist: " + function);
    }
    final FunctionDefinition toUpdate;
    if (!existing.getId().equals(function.getId())) {
      final FunctionDefinition.Builder builder = FunctionDefinition.Builder.create(function);
      builder.setId(existing.getId());
      toUpdate = builder.build();
    } else {
      toUpdate = function;
    }

    businessObjectService.save(FunctionBo.from(toUpdate));
  }
예제 #20
0
  private int loadInputData(
      String propertyKeyPrefix,
      int numberOfInputData,
      List<String> keyFieldList,
      int[] fieldLength) {
    int count = 0;
    for (int i = 1; i <= numberOfInputData; i++) {
      String propertyKey = propertyKeyPrefix + i;
      PendingLedgerEntryForTesting inputData = new PendingLedgerEntryForTesting();
      ObjectUtil.populateBusinessObject(
          inputData, properties, propertyKey, fieldLength, keyFieldList);

      if (businessObjectService.countMatching(
              LaborLedgerPendingEntry.class, inputData.getPrimaryKeyMap())
          <= 0) {
        inputData.setFinancialDocumentApprovedCode(
            KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
        businessObjectService.save(inputData);
        count++;
      }
    }
    return count;
  }
예제 #21
0
  @Override
  public void updateSponsorProposalNumber(
      Long institutionalProposalId, String sponsorProposalNumber) {
    if (institutionalProposalId == null) {
      throw new IllegalArgumentException("institutionalProposalId is null");
    }

    if (StringUtils.isBlank(sponsorProposalNumber)) {
      throw new IllegalArgumentException("sponsorProposalNumber is blank");
    }

    final InstitutionalProposal ip =
        businessObjectService.findByPrimaryKey(
            InstitutionalProposal.class,
            Collections.singletonMap("proposalId", institutionalProposalId));

    if (ip != null) {
      if (StringUtils.isBlank(ip.getSponsorProposalNumber())) {
        ip.setSponsorProposalNumber(sponsorProposalNumber);
        businessObjectService.save(ip);
      }
    }
  }
  @Override
  public ProtocolReviewer createProtocolReviewer(
      String principalId,
      boolean nonEmployeeFlag,
      String reviewerTypeCode,
      ProtocolSubmissionBase protocolSubmission) {
    ProtocolReviewer reviewer = createNewProtocolReviewerInstanceHook();
    reviewer.setProtocolIdFk(protocolSubmission.getProtocolId());
    reviewer.setSubmissionIdFk(protocolSubmission.getSubmissionId());
    reviewer.setProtocolNumber(protocolSubmission.getProtocolNumber());
    reviewer.setSequenceNumber(protocolSubmission.getSequenceNumber());
    reviewer.setSubmissionNumber(protocolSubmission.getSubmissionNumber());
    if (!nonEmployeeFlag) {
      reviewer.setPersonId(principalId);
    } else {
      reviewer.setRolodexId(Integer.parseInt(principalId));
    }
    reviewer.setNonEmployeeFlag(nonEmployeeFlag);
    reviewer.setReviewerTypeCode(reviewerTypeCode);

    businessObjectService.save(reviewer);

    return reviewer;
  }
 @Override
 public void closeCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument) {
   customerInvoiceDocument.setOpenInvoiceIndicator(false);
   customerInvoiceDocument.setClosedDate(dateTimeService.getCurrentSqlDate());
   businessObjectService.save(customerInvoiceDocument);
 }
예제 #24
0
 public static void setUpData() {
   BusinessObjectService businessObjectService =
       SpringContext.getBean(BusinessObjectService.class);
   businessObjectService.save(getAll());
 }
  @Override
  public void completeCustomerCreditMemo(CustomerCreditMemoDocument creditMemo) {

    //  retrieve the document and make sure its not already closed, crash if so
    String invoiceNumber = creditMemo.getFinancialDocumentReferenceInvoiceNumber();
    CustomerInvoiceDocument invoice;
    try {
      invoice = (CustomerInvoiceDocument) documentService.getByDocumentHeaderId(invoiceNumber);
    } catch (WorkflowException e) {
      throw new RuntimeException(
          "A WorkflowException was generated when trying to load Customer Invoice #"
              + invoiceNumber
              + ".",
          e);
    }
    if (!invoice.isOpenInvoiceIndicator()) {
      throw new UnsupportedOperationException(
          "The CreditMemo Document #"
              + creditMemo.getDocumentNumber()
              + " attempted to credit "
              + "an Invoice [#"
              + invoiceNumber
              + "] that was already closed.  This is not supported.");
    }

    // this needs a little explanation.  we have to calculate manually
    // whether we've written off the whole thing, because the regular
    // code uses the invoice paid applieds to discount, but since those
    // are added but not committed in this transaction, they're also not
    // visible in this transaction, so we do it manually.
    KualiDecimal openAmount = invoice.getOpenAmount();

    Integer paidAppliedItemNumber = 0;

    //  retrieve the customer invoice details, and generate paid applieds for each
    List<CustomerCreditMemoDetail> details = creditMemo.getCreditMemoDetails();
    for (CustomerCreditMemoDetail detail : details) {
      CustomerInvoiceDetail invoiceDetail = detail.getCustomerInvoiceDetail();

      //   if credit amount is zero, do nothing
      if (detail.getCreditMemoLineTotalAmount().isZero()) {
        continue;
      }

      //  if credit amount is greater than the open amount, crash and complain
      if (detail
          .getCreditMemoLineTotalAmount()
          .abs()
          .isGreaterThan(invoiceDetail.getAmountOpen())) {
        throw new UnsupportedOperationException(
            "The credit detail for CreditMemo Document #"
                + creditMemo.getDocumentNumber()
                + " attempted "
                + "to credit more than the Open Amount on the Invoice Detail.  This is not supported.");
      }

      //  retrieve the number of current paid applieds, so we dont have item number overlap
      if (paidAppliedItemNumber == 0) {
        paidAppliedItemNumber =
            paidAppliedService.getNumberOfInvoicePaidAppliedsForInvoiceDetail(
                invoiceNumber, invoiceDetail.getInvoiceItemNumber());
      }

      //  create and save the paidApplied
      InvoicePaidApplied invoicePaidApplied = new InvoicePaidApplied();
      invoicePaidApplied.setDocumentNumber(creditMemo.getDocumentNumber());
      invoicePaidApplied.setPaidAppliedItemNumber(paidAppliedItemNumber++);
      invoicePaidApplied.setFinancialDocumentReferenceInvoiceNumber(invoiceNumber);
      invoicePaidApplied.setInvoiceItemNumber(invoiceDetail.getInvoiceItemNumber());
      invoicePaidApplied.setUniversityFiscalYear(universityDateService.getCurrentFiscalYear());
      invoicePaidApplied.setUniversityFiscalPeriodCode(
          universityDateService.getCurrentUniversityDate().getUniversityFiscalAccountingPeriod());
      invoicePaidApplied.setInvoiceItemAppliedAmount(detail.getCreditMemoLineTotalAmount().abs());
      openAmount = openAmount.subtract(detail.getCreditMemoLineTotalAmount().abs());
      businessObjectService.save(invoicePaidApplied);
    }

    //   if its open, but now with a zero openamount, then close it
    if (invoice.isOpenInvoiceIndicator() && KualiDecimal.ZERO.equals(openAmount)) {
      customerInvoiceDocumentService.addCloseNote(
          invoice, creditMemo.getDocumentHeader().getWorkflowDocument());
      invoice.setOpenInvoiceIndicator(false);
      invoice.setClosedDate(dateTimeService.getCurrentSqlDate());
      documentService.updateDocument(invoice);
    }
  }
  /* (non-Javadoc)
   * @see edu.cornell.kfs.coa.service.AccountReversionImportService#importAccountReversions()
   */
  public void importAccountReversions(File f) {

    // KFSPTS-2174 : Repurposed this batch job to append the loaded values to the existing table,
    // rather than delete all current values and reload the tables from scratch
    //		arid.destroyAccountReversionsAndDetails();
    int count = 0;
    String objectCode =
        parameterService.getParameterValueAsString(
            "KFS-COA", "Reversion", "CASH_REVERSION_OBJECT_CODE");

    Integer fiscalYear =
        Integer.parseInt(
            parameterService.getParameterValueAsString(
                "KFS-COA", "Reversion", "ACCOUNT_REVERSION_FISCAL_YEAR"));

    try {
      CSVReader reader = new CSVReader(new FileReader(f));
      List<String[]> lines = reader.readAll();

      Object[] array = lines.toArray();
      LOG.info("Read: " + lines.toArray().length + " records");
      for (int i = 0; i < array.length; i++) {
        String[] line = (String[]) array[i];
        String fromChart = line[0];
        String fromAcct = line[1];

        String toChart = line[2];
        String toAcct = line[3];
        LOG.info("Creating Reversion for: from account: " + fromAcct + ": to account " + toAcct);
        if (StringUtils.isNotBlank(fromChart)
            && StringUtils.isNotBlank(fromAcct)
            && StringUtils.isNotBlank(toChart)
            && StringUtils.isNotBlank(toAcct)) {

          AccountReversion exists = null;
          Map<String, String> pks = new HashMap<String, String>();

          pks.put("UNIV_FISCAL_YR", String.valueOf(fiscalYear));
          pks.put("FIN_COA_CD", fromChart);
          pks.put("ACCT_NBR", fromAcct);
          exists =
              (AccountReversion)
                  SpringContext.getBean(BusinessObjectService.class)
                      .findByPrimaryKey(AccountReversion.class, pks);

          if (ObjectUtils.isNotNull(exists)) {

            LOG.info(
                "Account Reversion already exists for this fiscal year ("
                    + fiscalYear
                    + "): from account: "
                    + fromAcct
                    + ": to account "
                    + toAcct);
            continue;
          }

          // Validate from account; cannot add account reversion if account does not exist
          Account fromAcctExists = null;
          fromAcctExists =
              SpringContext.getBean(AccountService.class).getByPrimaryId(fromChart, fromAcct);
          if (ObjectUtils.isNull(fromAcctExists)) {
            LOG.info("From account (" + fromAcct + ") does not exist.");
            LOG.info(
                "Account Reversion already exists for this fiscal year ("
                    + fiscalYear
                    + "): from account: "
                    + fromAcct
                    + ": to account "
                    + toAcct);
            continue;
          }

          // Validate to account; cannot add account reversion if account does not exist
          Account toAcctExists = null;
          toAcctExists =
              SpringContext.getBean(AccountService.class).getByPrimaryId(fromChart, fromAcct);
          if (ObjectUtils.isNull(toAcctExists)) {
            LOG.info("To account (" + toAcct + ") does not exist.");
            LOG.info(
                "Account Reversion already exists for this fiscal year ("
                    + fiscalYear
                    + "): from account: "
                    + fromAcct
                    + ": to account "
                    + toAcct);
            continue;
          }

          AccountReversion accountReversion = new AccountReversion();

          accountReversion.setUniversityFiscalYear(fiscalYear);
          accountReversion.setChartOfAccountsCode(fromChart);
          accountReversion.setAccountNumber(fromAcct);

          accountReversion.setBudgetReversionChartOfAccountsCode(toChart);
          accountReversion.setBudgetReversionAccountNumber(toAcct);
          accountReversion.setCashReversionFinancialChartOfAccountsCode(toChart);
          accountReversion.setCashReversionAccountNumber(toAcct);
          accountReversion.setCarryForwardByObjectCodeIndicator(false);
          accountReversion.setActive(true);

          AccountReversionDetail accountReversionDetail = new AccountReversionDetail();
          accountReversionDetail.setUniversityFiscalYear(fiscalYear);
          accountReversionDetail.setChartOfAccountsCode(fromChart);
          accountReversionDetail.setAccountNumber(fromAcct);
          accountReversionDetail.setAccountReversionCategoryCode("A1");
          accountReversionDetail.setAccountReversionCode("CA");
          accountReversionDetail.setAccountReversionObjectCode(objectCode);
          accountReversionDetail.setActive(true);

          accountReversion.addAccountReversionDetail(accountReversionDetail);
          boService.save(accountReversion);
          count++;
        }
      }
      reader.close();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      LOG.info("Wrote: " + count + " records");
    }
  }