use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method hasIcrSectionChanged.
// KFSUPGRADE-765 : Route edits to indirect cost to CG Resp ID
private boolean hasIcrSectionChanged() {
String maintAction = super.getMaintenanceAction();
boolean retval = false;
if ((maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) || (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION))) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.EXPENSE)) {
// We need to route only when the ICR data the user is submitting does NOT match the ICR data on the account
// "new" subAccount for data comparisons
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
// "existing" data that would have pre-populated
Account account = this.getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber());
if (ObjectUtils.isNotNull(account) && ObjectUtils.isNotNull(newSubAccount)) {
List<IndirectCostRecoveryAccount> acctIcr = account.getIndirectCostRecoveryAccounts();
List<A21IndirectCostRecoveryAccount> subAcctIcr = newSubAccount.getA21ActiveIndirectCostRecoveryAccounts();
if (CollectionUtils.isEmpty(subAcctIcr)) {
if (CollectionUtils.isEmpty(acctIcr)) {
retval = false;
} else {
retval = true;
}
} else {
if (CollectionUtils.isEmpty(acctIcr)) {
retval = true;
} else {
/*
* the ICR accounts on the sub account needs to match the active ICR accounts on the parent account.
*/
int activeAcctIcrCount = 0;
for (IndirectCostRecoveryAccount acct : acctIcr) {
if (acct.isActive()) {
activeAcctIcrCount++;
}
}
if (subAcctIcr.size() == activeAcctIcrCount) {
retval = isIcrSectionDataChanged(subAcctIcr, acctIcr);
} else {
retval = true;
}
}
}
}
}
} else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
// "new" subAccount for data comparisons
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
if (ObjectUtils.isNotNull(newSubAccount)) {
try {
MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
A21SubAccount oldSubAccount = (A21SubAccount) ((SubAccount) oldMaintDoc.getOldMaintainableObject().getDataObject()).getA21SubAccount();
retval = isIcrSectionChanged(newSubAccount, oldSubAccount);
} catch (Exception e) {
LOG.error("caught exception while getting subaccount old maintainable -> documentService.getByDocumentHeaderId(" + getDocumentNumber() + "). ", e);
}
}
}
return retval;
}
use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.
the class PayeeACHAccountExtractServiceImpl method addACHAccount.
/**
* Creates and routes a PAAT document to create a new ACH Account of the given payee type.
*/
protected String addACHAccount(Person payee, PayeeACHAccountExtractDetail achDetail, String payeeType) {
// Create and route a new PAAT (Payee ACH Account Maintenance) document.
String processingError = null;
try {
// Create document and set description.
MaintenanceDocument paatDocument = (MaintenanceDocument) documentService.getNewDocument(CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_MAINT_DOC_TYPE);
paatDocument.getDocumentHeader().setDocumentDescription(getDocumentDescription(payee, PayeeIdTypeCodes.ENTITY.equals(payeeType), true));
// Configure as "New" maintenance and get maintained object.
PayeeACHAccountMaintainableImpl maintainable = (PayeeACHAccountMaintainableImpl) paatDocument.getNewMaintainableObject();
maintainable.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
PayeeACHAccount achAccount = (PayeeACHAccount) maintainable.getDataObject();
// Setup payee ID and type.
if (PayeeIdTypeCodes.ENTITY.equals(payeeType)) {
achAccount.setPayeeIdNumber(payee.getEntityId());
} else if (PayeeIdTypeCodes.EMPLOYEE.equals(payeeType)) {
achAccount.setPayeeIdNumber(payee.getEmployeeId());
} else {
processingError = new String("addACHAccount: " + achDetail.getLogData() + ": Unexpected payee ID type '" + payeeType + "' for automated Payee during ACH Account creation attempt.");
LOG.error(processingError);
return processingError;
}
achAccount.setPayeeIdentifierTypeCode(payeeType);
// Setup other fields.
achAccount.setAchAccountGeneratedIdentifier(new KualiInteger(sequenceAccessorService.getNextAvailableSequenceNumber(PdpConstants.ACH_ACCOUNT_IDENTIFIER_SEQUENCE_NAME)));
achAccount.setAchTransactionType(getDirectDepositTransactionType());
achAccount.setBankRoutingNumber(achDetail.getBankRoutingNumber());
achAccount.setBankAccountNumber(achDetail.getBankAccountNumber());
achAccount.setBankAccountTypeCode(getACHTransactionCode(achDetail.getBankAccountType()));
if (StringUtils.isNotBlank(payee.getNameUnmasked())) {
achAccount.setPayeeName(payee.getNameUnmasked());
}
if (StringUtils.isNotBlank(payee.getEmailAddressUnmasked())) {
achAccount.setPayeeEmailAddress(payee.getEmailAddressUnmasked());
}
achAccount.setActive(true);
// Add a note indicating that this document was generated by a batch process.
addNote(paatDocument, parameterService.getParameterValueAsString(PayeeACHAccountExtractStep.class, CUPdpParameterConstants.GENERATED_PAYEE_ACH_ACCOUNT_DOC_NOTE_TEXT));
// Route the document and send notifications.
paatDocument = (MaintenanceDocument) documentService.routeDocument(paatDocument, KFSConstants.EMPTY_STRING, null);
sendPayeeACHAccountAddOrUpdateEmail((PayeeACHAccount) paatDocument.getNewMaintainableObject().getDataObject(), payee, getPayeeACHAccountAddOrUpdateEmailSubject(true), getUnresolvedPayeeACHAccountAddOrUpdateEmailBody(true));
} catch (Exception e) {
LOG.error("addACHAccount STE " + e.getStackTrace() + e.toString());
LOG.error(getFailRequestMessage(e));
processingError = new String("addACHAccount: " + achDetail.getLogData() + " STE was generated. " + getFailRequestMessage(e));
}
return processingError;
}
use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method addVendor.
/*
* create vendor document and route
*/
private String addVendor(VendorBatchDetail vendorBatch) {
GlobalVariables.setMessageMap(new MessageMap());
// create and route doc as system user
// GlobalVariables.setUserSession(new UserSession("kfs"));
LOG.info("addVendor " + vendorBatch.getLogData());
try {
MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, true));
VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
setupVendorDetailFields(vDetail, vendorBatch);
setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
vDetail.setVendorAddresses(getVendorAddresses(vendorBatch.getVendorAddresses(), vDetail));
vDetail.setVendorContacts(getVendorContacts(vendorBatch.getVendorContacts()));
VendorHeader vHeader = vDetail.getVendorHeader();
setupVendorHeaderFields(vHeader, vendorBatch);
vHeader.setVendorSupplierDiversities(getVendorSupplierDiversities(vendorBatch.getVendorSupplierDiversities()));
vDetail.setVendorHeader(vHeader);
vImpl.setBusinessObject(vDetail);
vendorDoc.setNewMaintainableObject(vImpl);
addNotes(vendorDoc, vendorBatch);
if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
}
documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
return vendorDoc.getDocumentNumber();
} catch (Exception e) {
LOG.info("addVendor STE " + e.getStackTrace() + e.toString());
return getFailRequestMessage(e);
}
}
use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method updateVendor.
/*
* update vendor record. vendor number must be valid.
*/
private String updateVendor(VendorBatchDetail vendorBatch) {
GlobalVariables.setMessageMap(new MessageMap());
try {
MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, false));
LOG.info("updateVendor " + vendorBatch.getLogData());
VendorDetail vendor = cuVendorService.getByVendorNumber(vendorBatch.getVendorNumber());
if (vendor != null) {
// Vendor does not eist
VendorMaintainableImpl oldVendorImpl = (VendorMaintainableImpl) vendorDoc.getOldMaintainableObject();
oldVendorImpl.setBusinessObject(vendor);
} else {
// Vendor does not eist
return "Failed request : Vendor " + vendorBatch.getVendorNumber() + " Not Found.";
}
VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_EDIT_ACTION);
vendorDoc.getNewMaintainableObject().setDocumentNumber(vendorDoc.getDocumentNumber());
vImpl.setBusinessObject((VendorDetail) ObjectUtils.deepCopy(vendor));
VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
setupVendorDetailFields(vDetail, vendorBatch);
setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
updateVendorAddresses(vendorBatch.getVendorAddresses(), vendor, vDetail);
updateVendorContacts(vendorBatch.getVendorContacts(), vendor, vDetail);
updateVendorSupplierDiversitys(vendorBatch.getVendorSupplierDiversities(), vendor, vDetail);
setupVendorHeaderFields(vDetail.getVendorHeader(), vendorBatch);
vImpl.setBusinessObject(vDetail);
vendorDoc.setNewMaintainableObject(vImpl);
addNotes(vendorDoc, vendorBatch);
// attachment
if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
}
// end attachment
documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
return vendorDoc.getDocumentNumber();
} catch (Exception e) {
LOG.info("updateVendor STE " + e.getStackTrace() + e.toString());
return getFailRequestMessage(e);
}
}
Aggregations