use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDisbursementVoucher.
/**
* @param dvDescription
* @param dvExplanation
* @param tripNumber
* @param travelerNetId
* @param initiatorNetId
* @param totalAmount
* @param checkStubText
* @return
* @throws Exception
*/
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDisbursementVoucherDocument dvDoc = null;
try {
dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dvDoc != null) {
dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
dvDoc.getDocumentHeader().setExplanation(dvExplanation);
dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
dvDoc.initiateDocument();
// Set vendor to traveler using netID provided
Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
for (EntityAffiliationContract entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
dvDoc.templateStudent(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
dvDoc.templateAlumni(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
dvDoc.templateEmployee(traveler);
}
}
}
dvDoc.setPayeeAssigned(true);
dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
dvDoc.setDisbVchrPaymentMethodCode("P");
dvDoc.setDisbVchrCheckStubText(checkStubText);
dvDoc.setTripId(tripNumber);
dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
return dvDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method submitTrip.
/**
*/
public String submitTrip(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
UserSession actualUserSession = GlobalVariables.getUserSession();
MessageMap globalErrorMap = GlobalVariables.getMessageMap();
try {
if (totalAmount > 0.00) {
return buildDisbursementVoucher(dvDescription, dvExplanation, tripNumber, travelerNetId, initiatorNetId, totalAmount, checkStubText);
} else {
return buildDistributionIncomeExpenseDocument(dvDescription, dvExplanation, tripNumber, initiatorNetId);
}
} finally {
GlobalVariables.setUserSession(actualUserSession);
GlobalVariables.setMessageMap(globalErrorMap);
}
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherDocumentBatchServiceImpl method loadDisbursementVouchers.
/**
* @see com.rsmart.kuali.kfs.fp.batch.service.DisbursementVoucherDocumentBatchService#loadDisbursementVouchers(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchFeed,
* com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchStatus, java.lang.String,
* org.kuali.kfs.kns.util.MessageMap)
*/
public void loadDisbursementVouchers(DisbursementVoucherBatchFeed batchFeed, DisbursementVoucherBatchStatus batchStatus, String incomingFileName, MessageMap MessageMap) {
// get new batch record for the load
DisbursementVoucherBatch disbursementVoucherBatch = getNewDisbursementVoucherBatch();
businessObjectService.save(disbursementVoucherBatch);
batchStatus.setUnitCode(batchFeed.getUnitCode());
boolean batchHasErrors = false;
for (BatchDisbursementVoucherDocument batchDisbursementVoucherDocument : batchFeed.getBatchDisbursementVoucherDocuments()) {
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_DV_RECORDS_READ, 1);
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_ACCOUNTING_RECORDS_READ, batchDisbursementVoucherDocument.getSourceAccountingLines().size());
// get defaults for DV chart/org
DisbursementVoucherBatchDefault batchDefault = null;
if (StringUtils.isNotBlank(batchFeed.getUnitCode())) {
batchDefault = getDisbursementVoucherBatchDefault(batchFeed.getUnitCode());
}
MessageMap documentMessageMap = new MessageMap();
batchFeedHelperService.performForceUppercase(DisbursementVoucherDocument.class.getName(), batchDisbursementVoucherDocument);
// create and route doc as system user
// create and route doc as system user
UserSession actualUserSession = GlobalVariables.getUserSession();
GlobalVariables.setUserSession(new UserSession(KFSConstants.SYSTEM_USER));
MessageMap globalMessageMap = GlobalVariables.getMessageMap();
GlobalVariables.setMessageMap(documentMessageMap);
DisbursementVoucherDocument disbursementVoucherDocument = null;
try {
disbursementVoucherDocument = populateDisbursementVoucherDocument(disbursementVoucherBatch, batchDisbursementVoucherDocument, batchDefault, documentMessageMap);
// if the document is valid create GLPEs, Save and Approve
if (documentMessageMap.hasNoErrors()) {
businessObjectService.save(disbursementVoucherDocument.getExtension());
documentService.routeDocument(disbursementVoucherDocument, "", null);
if (documentMessageMap.hasNoErrors()) {
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_DV_RECORDS_WRITTEN, 1);
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_ACCOUNTING_RECORDS_WRITTEN, disbursementVoucherDocument.getSourceAccountingLines().size());
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_GLPE_RECORDS_WRITTEN, disbursementVoucherDocument.getGeneralLedgerPendingEntries().size());
batchStatus.getBatchDisbursementVoucherDocuments().add(disbursementVoucherDocument);
}
}
} catch (WorkflowException e) {
LOG.error("Unable to route DV: " + e.getMessage());
throw new RuntimeException("Unable to route DV: " + e.getMessage(), e);
} catch (ValidationException e1) {
// will be reported in audit report
} finally {
GlobalVariables.setUserSession(actualUserSession);
GlobalVariables.setMessageMap(globalMessageMap);
}
if (documentMessageMap.hasErrors()) {
batchHasErrors = true;
}
// populate summary line and add to report
DisbursementVoucherBatchSummaryLine batchSummaryLine = populateBatchSummaryLine(disbursementVoucherDocument, documentMessageMap);
batchStatus.getBatchSummaryLines().add(batchSummaryLine);
}
// indicate in global map there were errors (for batch upload screen)
if (batchHasErrors) {
MessageMap.putError(KFSConstants.GLOBAL_ERRORS, FPKeyConstants.ERROR_BATCH_DISBURSEMENT_VOUCHER_ERRORS_NOTIFICATION);
}
batchFeedHelperService.removeDoneFile(incomingFileName);
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDistributionIncomeExpenseDocument.
/**
* @param diDescription
* @param diExplanation
* @param tripNumber
* @param initiatorNetId
* @return
* @throws Exception
*/
private String buildDistributionIncomeExpenseDocument(String diDescription, String diExplanation, String tripNumber, String initiatorNetId) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISTRIBUTION_INCOME_EXPENSE)) {
throw new RuntimeException("Initiator identified does not have permission to create a DI.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DI.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDistributionOfIncomeAndExpenseDocument diDoc = null;
try {
diDoc = (CuDistributionOfIncomeAndExpenseDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DistributionOfIncomeAndExpenseDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (diDoc != null) {
diDoc.getDocumentHeader().setDocumentDescription(diDescription);
diDoc.getDocumentHeader().setExplanation(diExplanation);
diDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
diDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
diDoc.setTripId(tripNumber);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(diDoc);
return diDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.kfs.krad.util.MessageMap in project cu-kfs by CU-CommunityApps.
the class CuBudgetAdjustmentDocumentBalancedValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
MessageMap errors = GlobalVariables.getMessageMap();
boolean balanced = true;
// check base amounts are equal
// KFSMI-3036
KualiInteger sourceBaseBudgetTotal = getAccountingDocumentForValidation().getSourceBaseBudgetIncomeTotal().subtract(getAccountingDocumentForValidation().getSourceBaseBudgetExpenseTotal());
KualiInteger targetBaseBudgetTotal = getAccountingDocumentForValidation().getTargetBaseBudgetIncomeTotal().subtract(getAccountingDocumentForValidation().getTargetBaseBudgetExpenseTotal());
if (sourceBaseBudgetTotal.compareTo(targetBaseBudgetTotal) != 0) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, KFSKeyConstants.ERROR_DOCUMENT_BA_BASE_AMOUNTS_BALANCED);
balanced = false;
}
// check document is balanced within the accounts
Map accountsMap = buildAccountBalanceMapForDocumentBalance(true);
for (KualiDecimal accountAmount : (Collection<KualiDecimal>) accountsMap.values()) {
if (accountAmount.isNonZero()) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, CUKFSKeyConstants.ERROR_DOCUMENT_BA_ACCOUNT_BASE_AMOUNTS_BALANCED);
balanced = false;
break;
}
}
// check current amounts balance, income stream balance Map should add to 0
Map incomeStreamMap = getAccountingDocumentForValidation().buildIncomeStreamBalanceMapForDocumentBalance();
KualiDecimal totalCurrentAmount = new KualiDecimal(0);
for (Iterator iter = incomeStreamMap.values().iterator(); iter.hasNext(); ) {
KualiDecimal streamAmount = (KualiDecimal) iter.next();
totalCurrentAmount = totalCurrentAmount.add(streamAmount);
}
if (totalCurrentAmount.isNonZero()) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, KFSKeyConstants.ERROR_DOCUMENT_BA_CURRENT_AMOUNTS_BALANCED);
balanced = false;
}
// check document is balanced within the accounts
accountsMap = buildAccountBalanceMapForDocumentBalance(false);
for (KualiDecimal accountAmount : (Collection<KualiDecimal>) accountsMap.values()) {
if (accountAmount.isNonZero()) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, CUKFSKeyConstants.ERROR_DOCUMENT_BA_ACCOUNT_AMOUNTS_BALANCED);
balanced = false;
break;
}
}
return balanced;
}
Aggregations