use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method deleteSourceLine.
/**
* @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentActionBase#deleteSourceLine(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward deleteSourceLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
String[] indexes = getSelectedLineForAccounts(request);
int itemIndex = Integer.parseInt(indexes[0]);
int accountIndex = Integer.parseInt(indexes[1]);
if (itemIndex == -2) {
purchasingForm.getAccountDistributionsourceAccountingLines().remove(accountIndex);
} else {
PurApItem item = ((PurchasingAccountsPayableDocument) purchasingForm.getDocument()).getItem((itemIndex));
item.getSourceAccountingLines().remove(accountIndex);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderAmendmentHasUnitCostAndValidPercentage method validate.
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) event.getDocument();
List<PurApItem> items = purapDocument.getItems();
for (PurApItem item : items) {
if (item.isConsideredEntered()) {
BigDecimal unitPrice = ((PurchaseOrderItem) item).getItemUnitPrice();
List<PurApAccountingLine> lines = item.getSourceAccountingLines();
// check if unit price is zero or null and item has accounts associated with it
if ((unitPrice == null || (unitPrice.compareTo(BigDecimal.ZERO) == 0)) && lines.size() > 0) {
GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERRORS, CUKFSKeyConstants.ERROR_NO_UNIT_COST_WITH_ACCOUNTS, item.getItemIdentifierString());
valid = false;
}
if ((unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) != 0) && lines.size() == 0) {
GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERRORS, CUKFSKeyConstants.ERROR_UNIT_COST_W_O_ACCOUNT, item.getItemIdentifierString());
valid = false;
}
BigDecimal totalPercent = new BigDecimal(0);
for (PurApAccountingLine accountingLine : lines) {
totalPercent = totalPercent.add(accountingLine.getAccountLinePercent());
// if an account distribution is zero percent, invalid
if (accountingLine.getAccountLinePercent().compareTo(BigDecimal.ZERO) == 0) {
GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, CUKFSKeyConstants.ERROR_NO_ZERO_PERCENT_ACCOUNT_LINES_ALLOWED, item.getItemIdentifierString());
valid = false;
}
}
// if total percent is not 100, error
if (totalPercent.compareTo(new BigDecimal(100)) != 0) {
// KFSPTS-1769. if it is spawnpoa for unordered item, then don't check
if (!((purapDocument instanceof CuPurchaseOrderAmendmentDocument) && ((CuPurchaseOrderAmendmentDocument) purapDocument).isSpawnPoa())) {
GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_TOTAL, item.getItemIdentifierString());
valid = false;
}
}
}
}
return valid;
}
use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.
the class PurApItemBase method refreshNonUpdateableReferences.
@Override
public void refreshNonUpdateableReferences() {
PurchasingAccountsPayableDocument document = null;
PurchasingAccountsPayableDocument tempDocument = getPurapDocument();
if (tempDocument != null) {
Integer tempDocumentIdentifier = tempDocument.getPurapDocumentIdentifier();
if (tempDocumentIdentifier != null) {
document = this.getPurapDocument();
}
}
super.refreshNonUpdateableReferences();
if (ObjectUtils.isNotNull(document)) {
this.setPurapDocument(document);
}
}
use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingAccountsPayableTransactionalDocumentAuthorizerBase method addRoleQualification.
@Override
protected void addRoleQualification(Object businessObject, Map<String, String> attributes) {
super.addRoleQualification(businessObject, attributes);
attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "false");
PurchasingAccountsPayableDocument purapDoc = (PurchasingAccountsPayableDocument) businessObject;
if (purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier() != null) {
List<SensitiveData> sensitiveDataList = SpringContext.getBean(SensitiveDataService.class).getSensitiveDatasAssignedByRelatedDocId(purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier());
if (ObjectUtils.isNotNull(sensitiveDataList) && !sensitiveDataList.isEmpty()) {
StringBuffer sensitiveDataCodes = new StringBuffer();
for (SensitiveData sensitiveData : sensitiveDataList) {
if (ObjectUtils.isNotNull(sensitiveData)) {
sensitiveDataCodes.append(sensitiveData.getSensitiveDataCode()).append(";");
}
}
if (sensitiveDataCodes.length() > 0) {
attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "true");
attributes.put(PurapKimAttributes.SENSITIVE_DATA_CODE, sensitiveDataCodes.toString().substring(0, sensitiveDataCodes.length() - 1));
attributes.put(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER, purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier().toString());
}
// KFSUPGRADE-346
} else if (purapDoc.isSensitive()) {
attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "true");
}
}
}
use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingAddItemValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
GlobalVariables.getMessageMap().addToErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
// refresh itemType
PurApItem refreshedItem = getItemForValidation();
refreshedItem.refreshReferenceObject("itemType");
super.setItemForValidation(refreshedItem);
valid &= super.validate(event);
valid &= validateItemUnitPrice(getItemForValidation());
valid &= validateUnitOfMeasure(getItemForValidation());
if (getItemForValidation().getItemType().isLineItemIndicator()) {
valid &= validateItemDescription(getItemForValidation());
valid &= validateItemQuantity(getItemForValidation());
commodityCodeValidation.setItemForValidation(getItemForValidation());
valid &= commodityCodeValidation.validate(event);
// KFSPTS-2096
valid &= validateMixItemType(getItemForValidation(), (PurchasingAccountsPayableDocument) event.getDocument());
}
GlobalVariables.getMessageMap().removeFromErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
return valid;
}
Aggregations