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;
}
Aggregations