Search in sources :

Example 1 with AdvanceDepositDetail

use of org.kuali.kfs.fp.businessobject.AdvanceDepositDetail in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method createAdvanceDepositDocument.

/**
 * Creates a AdvanceDepositDocument from the List of transactions given.
 *
 * @param transaction List of CashReceiptDocument objects to be used for creating the document.
 * @return A AdvanceDepositDocument populated with the transactions provided.
 */
protected AdvanceDepositDocument createAdvanceDepositDocument(AchIncomeTransaction transaction) {
    AdvanceDepositDocument advanceDepositDocument;
    try {
        String detailReferenceNumber = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DETAIL_REFERENCE_NUMBER);
        String detailDescription = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DETAIL_DESCRIPTION);
        String bankCode = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.BANK_CODE);
        String documentDescription = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DOCUMENT_DESCRIPTION);
        advanceDepositDocument = (AdvanceDepositDocument) documentService.getNewDocument(KFSConstants.FinancialDocumentTypeCodes.ADVANCE_DEPOSIT);
        advanceDepositDocument.getDocumentHeader().setDocumentDescription(documentDescription);
        advanceDepositDocument.setCampusLocationCode(CuFPConstants.ADVANCE_DEPOSIT_DEFAULT_CAMPUS_CODE);
        advanceDepositDocument.setDepositDate(dateTimeService.convertToSqlDate(transaction.getBankTimestamp()));
        createSourceAccountingLine(transaction, advanceDepositDocument);
        AdvanceDepositDetail advanceDepositDetail = new AdvanceDepositDetail();
        advanceDepositDetail.setDocumentNumber(advanceDepositDocument.getDocumentNumber());
        advanceDepositDetail.setFinancialDocumentAdvanceDepositDate(dateTimeService.convertToSqlDate(transaction.getLoadTimestamp()));
        advanceDepositDetail.setFinancialDocumentAdvanceDepositAmount(transaction.getTransactionAmount());
        advanceDepositDetail.setFinancialDocumentAdvanceDepositReferenceNumber(detailReferenceNumber);
        advanceDepositDetail.setFinancialDocumentAdvanceDepositDescription(detailDescription);
        advanceDepositDetail.setFinancialDocumentBankCode(bankCode);
        Bank bank = bankService.getByPrimaryId(bankCode);
        advanceDepositDetail.setBank(bank);
        advanceDepositDocument.addAdvanceDeposit(advanceDepositDetail);
    } catch (WorkflowException | ParseException e) {
        LOG.error("Error creating advance deposit documents: " + e.getMessage(), e);
        throw new RuntimeException("Error creating advance deposit documents: " + e.getMessage(), e);
    }
    return advanceDepositDocument;
}
Also used : AdvanceDepositDetail(org.kuali.kfs.fp.businessobject.AdvanceDepositDetail) Bank(org.kuali.kfs.sys.businessobject.Bank) AdvanceDepositDocument(org.kuali.kfs.fp.document.AdvanceDepositDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ParseException(java.text.ParseException)

Aggregations

ParseException (java.text.ParseException)1 AdvanceDepositDetail (org.kuali.kfs.fp.businessobject.AdvanceDepositDetail)1 AdvanceDepositDocument (org.kuali.kfs.fp.document.AdvanceDepositDocument)1 Bank (org.kuali.kfs.sys.businessobject.Bank)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1