use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceMatchingServiceImpl method validateCatalogNumber.
protected void validateCatalogNumber(ElectronicInvoiceItemHolder itemHolder) {
PurchaseOrderItem poItem = itemHolder.getPurchaseOrderItem();
ElectronicInvoiceOrderHolder orderHolder = itemHolder.getInvoiceOrderHolder();
String invoiceCatalogNumberStripped = itemHolder.getCatalogNumberStripped();
String poCatalogNumberStripped = ElectronicInvoiceUtils.stripSplChars(poItem.getItemCatalogNumber());
/**
* If Catalog number in invoice and po are not empty, create reject reason if it doesn't match
*/
if (StringUtils.isNotBlank(invoiceCatalogNumberStripped) && StringUtils.isNotBlank(poCatalogNumberStripped)) {
if (!StringUtils.equalsIgnoreCase(poCatalogNumberStripped, invoiceCatalogNumberStripped)) {
String extraDescription = "Invoice Catalog No:" + invoiceCatalogNumberStripped + ", PO Catalog No:" + poCatalogNumberStripped;
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.CATALOG_NUMBER_MISMATCH, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_CATALOG_NUMBER, PurapKeyConstants.ERROR_REJECT_CATALOG_MISMATCH);
}
} else {
/**
* If catalog number is empty in PO/&Invoice, check whether the catalog check is required for the requisition source.
* If exists in param, create reject reason.
* If not exists, continue with UOM and unit price match.
*/
String reqSourceRequiringCatalogMatch = SpringContext.getBean(ParameterService.class).getParameterValueAsString(ElectronicInvoiceStep.class, PurapParameterConstants.ElectronicInvoiceParameters.REQUISITION_SOURCES_REQUIRING_CATALOG_MATCHING);
String requisitionSourceCodeInPO = orderHolder.getPurchaseOrderDocument().getRequisitionSourceCode();
if (StringUtils.isNotEmpty(reqSourceRequiringCatalogMatch)) {
String[] requisitionSourcesFromParam = StringUtils.split(reqSourceRequiringCatalogMatch, ';');
if (ArrayUtils.contains(requisitionSourcesFromParam, requisitionSourceCodeInPO)) {
String extraDescription = "Invoice Catalog No:" + invoiceCatalogNumberStripped + ", PO Catalog No:" + poItem.getItemCatalogNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.CATALOG_NUMBER_MISMATCH, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_CATALOG_NUMBER, PurapKeyConstants.ERROR_REJECT_CATALOG_MISMATCH);
}
}
}
}
use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceMatchingServiceImpl method validateInvoiceItem.
protected void validateInvoiceItem(ElectronicInvoiceItemHolder itemHolder, Set poLineNumbers, Set invLineNumbers) {
PurchaseOrderItem poItem = itemHolder.getPurchaseOrderItem();
ElectronicInvoiceOrderHolder orderHolder = itemHolder.getInvoiceOrderHolder();
boolean isNonMatching = false;
if (poItem == null) {
// investigating. this should stay because the inv line should have the correcrt invitemline# set up
String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.NO_MATCHING_PO_ITEM, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_INVOICE__ITEM_NOMATCH);
return;
}
// only noqty item. the old behavior for qty item does not check the duplicate inv line#
if (invLineNumbers.contains(((CuElectronicInvoiceItemHolder) itemHolder).getInvLineNumber()) && poItem.isNoQtyItem()) {
String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.DUPLIATE_INVOICE_LINE_ITEM, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_PO_ITEM_DUPLICATE);
return;
} else {
invLineNumbers.add(((CuElectronicInvoiceItemHolder) itemHolder).getInvLineNumber());
}
if (poLineNumbers.contains(itemHolder.getInvoiceItemLineNumber())) {
// TODO : investigating Do NOT commit. Duplicate is not OK for qty item
if (!poItem.isNoQtyItem()) {
String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.DUPLIATE_INVOICE_LINE_ITEM, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_PO_ITEM_DUPLICATE);
return;
} else {
((CuElectronicInvoiceOrderHolder) orderHolder).getNonMatchItems().add((CuElectronicInvoiceItemHolder) itemHolder);
isNonMatching = true;
}
} else {
poLineNumbers.add(itemHolder.getInvoiceItemLineNumber());
}
if (!poItem.isItemActiveIndicator()) {
String extraDescription = "PO Item Line Number:" + poItem.getItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.INACTIVE_LINE_ITEM, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_PO_ITEM_INACTIVE);
return;
}
// KFSPTS-1719 skip this if po is noqty item
if (!itemHolder.isCatalogNumberAcceptIndicatorEnabled() && !poItem.isNoQtyItem()) {
validateCatalogNumber(itemHolder);
if (orderHolder.isInvoiceRejected()) {
return;
}
}
if (!itemHolder.isUnitOfMeasureAcceptIndicatorEnabled()) {
// KFSUPGRADE-485 : if po is no qty but inv is qty, then is it necessary to check here ? should not matter
if (!poItem.isNoQtyItem() && !StringUtils.equalsIgnoreCase(poItem.getItemUnitOfMeasureCode(), itemHolder.getInvoiceItemUnitOfMeasureCode())) {
String extraDescription = "Invoice UOM:" + itemHolder.getInvoiceItemUnitOfMeasureCode() + ", PO UOM:" + poItem.getItemUnitOfMeasureCode();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.UNIT_OF_MEASURE_MISMATCH, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_UOM, PurapKeyConstants.ERROR_REJECT_UOM_MISMATCH);
return;
}
}
validateUnitPrice(itemHolder);
if (orderHolder.isInvoiceRejected()) {
return;
}
validateSalesTax(itemHolder);
if (orderHolder.isInvoiceRejected()) {
return;
}
// KFSPTS-1719, KFSUPGRADE-485 : this is more appropriate to check if item is non-qty. because user can potentially enter qty for non-qty item
if (!poItem.isNoQtyItem()) {
// if (poItem.getItemQuantity() != null) {
validateQtyBasedItem(itemHolder);
} else {
validateNonQtyBasedItem(itemHolder);
}
}
use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceMatchingServiceImpl method validateNonQtyBasedItem.
protected void validateNonQtyBasedItem(ElectronicInvoiceItemHolder itemHolder) {
PurchaseOrderItem poItem = itemHolder.getPurchaseOrderItem();
String fileName = itemHolder.getInvoiceOrderHolder().getFileName();
ElectronicInvoiceOrderHolder orderHolder = itemHolder.getInvoiceOrderHolder();
// Only validation is that the invoice amount (amount of PayReq) can not be greater than the extended cost minus amount paid
if (itemHolder.getInvoiceItemSubTotalAmount().setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR).compareTo(poItem.getExtendedPrice().subtract(poItem.getItemInvoicedTotalAmount()).bigDecimalValue()) > 0) {
String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.PO_ITEM_AMT_LESSTHAN_INVOICE_ITEM_AMT, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_POITEM_LESS_OUTSTANDING_EMCUMBERED_AMOUNT);
return;
}
if ((KualiDecimal.ZERO.compareTo(poItem.getItemOutstandingEncumberedAmount())) >= 0) {
// we have no dollars left encumbered on the po item
String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.OUTSTANDING_ENCUMBERED_AMT_AVAILABLE, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_POITEM_OUTSTANDING_EMCUMBERED_AMOUNT);
return;
} else {
// KFSUPGRADE-485
if (((itemHolder.getInvoiceItemSubTotalAmount().setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)).compareTo(poItem.getItemOutstandingEncumberedAmount().bigDecimalValue())) > 0 || ((getItemTotalAmount(itemHolder).setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)).compareTo(poItem.getItemOutstandingEncumberedAmount().bigDecimalValue())) > 0) {
String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.PO_ITEM_AMT_LESSTHAN_INVOICE_ITEM_AMT, extraDescription, orderHolder.getFileName());
orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_POITEM_LESS_OUTSTANDING_EMCUMBERED_AMOUNT);
return;
}
}
}
use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem in project cu-kfs by CU-CommunityApps.
the class CuPurapGeneralLedgerServiceImplTest method testReencumberEncumbrance.
public void testReencumberEncumbrance() throws Exception {
changeCurrentUser(UserNameFixture.ccs1);
PurchaseOrderDocument po = PurchaseOrderFixture.PO_NON_B2B_OPEN_WITH_ITEMS.createPurchaseOrderdDocument(SpringContext.getBean(DocumentService.class));
po.setVendorShippingPaymentTermsCode("AL");
po.setVendorPaymentTermsCode("00N30");
po.getItem(0).setItemQuantity(new KualiDecimal(6));
((PurchaseOrderItem) po.getItem(0)).setItemInvoicedTotalQuantity(new KualiDecimal(4));
po.refreshNonUpdateableReferences();
AccountingDocumentTestUtils.saveDocument(po, SpringContext.getBean(DocumentService.class));
changeCurrentUser(UserNameFixture.mo14);
CuPaymentRequestDocument preq = (CuPaymentRequestDocument) PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(po.getPurapDocumentIdentifier());
preq.initiateDocument();
preq.populatePaymentRequestFromPurchaseOrder(po);
preq.setPaymentMethodCode("F");
preq.setApplicationDocumentStatus(PurapConstants.PaymentRequestStatuses.APPDOC_AWAITING_ACCOUNTS_PAYABLE_REVIEW);
((PaymentRequestItem) (preq.getItems().get(0))).setExtendedPrice(KualiDecimal.ZERO);
((PaymentRequestItem) (preq.getItems().get(0))).setItemUnitPrice(BigDecimal.ZERO);
((PaymentRequestItem) (preq.getItems().get(0))).setItemQuantity(new KualiDecimal(2));
AccountingDocumentTestUtils.saveDocument(preq, SpringContext.getBean(DocumentService.class));
cuPurapGeneralLedgerServiceImpl.reencumberEncumbrance(preq);
PurchaseOrderDocument po2 = purchaseOrderService.getCurrentPurchaseOrder(preq.getPurchaseOrderIdentifier());
assertEquals(new KualiDecimal(2), ((PurchaseOrderItem) po2.getItem(0)).getItemInvoicedTotalQuantity());
}
use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem in project cu-kfs by CU-CommunityApps.
the class CuB2BPurchaseOrderSciquestServiceImpl method verifyCxmlPOData.
public String verifyCxmlPOData(PurchaseOrderDocument purchaseOrder, String requisitionInitiatorPrincipalId, String password, ContractManager contractManager, String contractManagerEmail, String vendorDuns) {
StringBuffer errors = new StringBuffer();
if (ObjectUtils.isNull(purchaseOrder)) {
LOG.error("verifyCxmlPOData() The Purchase Order is null.");
errors.append("Error occurred retrieving Purchase Order\n");
return errors.toString();
}
if (ObjectUtils.isNull(contractManager)) {
LOG.error("verifyCxmlPOData() The contractManager is null.");
errors.append("Error occurred retrieving Contract Manager\n");
return errors.toString();
}
if (StringUtils.isEmpty(password)) {
LOG.error("verifyCxmlPOData() The B2B PO password is required for the cXML PO but is missing.");
errors.append("Missing Data: B2B PO password\n");
}
if (ObjectUtils.isNull(purchaseOrder.getPurapDocumentIdentifier())) {
LOG.error("verifyCxmlPOData() The purchase order Id is required for the cXML PO but is missing.");
errors.append("Missing Data: Purchase Order ID\n");
}
if (StringUtils.isEmpty(requisitionInitiatorPrincipalId)) {
LOG.error("verifyCxmlPOData() The requisition initiator principal name is required for the cXML PO but is missing.");
errors.append("Missing Data: Requisition Initiator Principal Name\n");
}
if (ObjectUtils.isNull(purchaseOrder.getPurchaseOrderCreateTimestamp())) {
LOG.error("verifyCxmlPOData() The PO create date is required for the cXML PO but is null.");
errors.append("Create Date\n");
}
if (StringUtils.isEmpty(contractManager.getContractManagerPhoneNumber())) {
LOG.error("verifyCxmlPOData() The contract manager phone number is required for the cXML PO but is missing.");
errors.append("Missing Data: Contract Manager Phone Number\n");
}
if (StringUtils.isEmpty(contractManager.getContractManagerName())) {
LOG.error("verifyCxmlPOData() The contract manager name is required for the cXML PO but is missing.");
errors.append("Missing Data: Contract Manager Name\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryCampusCode())) {
LOG.error("verifyCxmlPOData() The Delivery Campus Code is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery Campus Code\n");
}
if (StringUtils.isEmpty(purchaseOrder.getBillingName())) {
LOG.error("verifyCxmlPOData() The Delivery Billing Name is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery Billing Name\n");
}
if (StringUtils.isEmpty(purchaseOrder.getBillingLine1Address())) {
LOG.error("verifyCxmlPOData() The Billing Line 1 Address is required for the cXML PO but is missing.");
errors.append("Missing Data: Billing Line 1 Address\n");
}
if (StringUtils.isEmpty(purchaseOrder.getBillingLine2Address())) {
LOG.error("verifyCxmlPOData() The Billing Line 2 Address is required for the cXML PO but is missing.");
errors.append("Missing Data: Billing Line 2 Address\n");
}
if (StringUtils.isEmpty(purchaseOrder.getBillingCityName())) {
LOG.error("verifyCxmlPOData() The Billing Address City Name is required for the cXML PO but is missing.");
errors.append("Missing Data: Billing Address City Name\n");
}
if (StringUtils.isEmpty(purchaseOrder.getBillingStateCode())) {
LOG.error("verifyCxmlPOData() The Billing Address State Code is required for the cXML PO but is missing.");
errors.append("Missing Data: Billing Address State Code\n");
}
if (StringUtils.isEmpty(purchaseOrder.getBillingPostalCode())) {
LOG.error("verifyCxmlPOData() The Billing Address Postal Code is required for the cXML PO but is missing.");
errors.append("Missing Data: Billing Address Postal Code\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryToName())) {
LOG.error("verifyCxmlPOData() The Delivery To Name is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery To Name\n");
}
if (StringUtils.isEmpty(contractManagerEmail)) {
LOG.error("verifyCxmlPOData() The Contract Manager Email is required for the cXML PO but is missing.");
errors.append("Missing Data: Contract Manager Email\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryToEmailAddress())) {
LOG.error("verifyCxmlPOData() The Requesting Person Email Address is required for the cXML PO but is missing.");
errors.append("Missing Data: Requesting Person Email Address\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryToPhoneNumber())) {
LOG.error("verifyCxmlPOData() The Requesting Person Phone Number is required for the cXML PO but is missing.");
errors.append("Missing Data: Requesting Person Phone Number\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryBuildingLine1Address())) {
LOG.error("verifyCxmlPOData() The Delivery Line 1 Address is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery Line 1 Address\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryToName())) {
LOG.error("verifyCxmlPOData() The Delivery To Name is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery To Name\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryCityName())) {
LOG.error("verifyCxmlPOData() The Delivery City Name is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery City Name\n");
}
// KFSUPGRADE-405 KFSPTS-1796
if (StringUtils.equals(KFSConstants.COUNTRY_CODE_UNITED_STATES, purchaseOrder.getDeliveryCountryCode())) {
if (StringUtils.isEmpty(purchaseOrder.getDeliveryStateCode())) {
LOG.error("verifyCxmlPOData() The Delivery State is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery State\n");
}
if (StringUtils.isEmpty(purchaseOrder.getDeliveryPostalCode())) {
LOG.error("verifyCxmlPOData() The Delivery Postal Code is required for the cXML PO but is missing.");
errors.append("Missing Data: Delivery Postal Code\n");
}
}
// verify item data
List detailList = purchaseOrder.getItems();
for (Iterator iter = detailList.iterator(); iter.hasNext(); ) {
PurchaseOrderItem poi = (PurchaseOrderItem) iter.next();
// CU enhancement for non-qty to exclude from qty/uom/catalog# check
boolean nonQuantityOrder = PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equals(poi.getItemTypeCode());
if (ObjectUtils.isNotNull(poi.getItemType()) && poi.getItemType().isLineItemIndicator()) {
if (ObjectUtils.isNull(poi.getItemLineNumber())) {
LOG.error("verifyCxmlPOData() The Item Line Number is required for the cXML PO but is missing.");
errors.append("Missing Data: Item Line Number\n");
}
// CU : added B2B & nonqty Check
if (!nonQuantityOrder && StringUtils.isEmpty(poi.getItemCatalogNumber()) && PurapConstants.RequisitionSources.B2B.equals(purchaseOrder.getRequisitionSourceCode())) {
LOG.error("verifyCxmlPOData() The Catalog Number for item number " + poi.getItemLineNumber() + " is required for the cXML PO but is missing.");
errors.append("Missing Data: Item#" + poi.getItemLineNumber() + " - Catalog Number\n");
}
if (StringUtils.isEmpty(poi.getItemDescription())) {
LOG.error("verifyCxmlPOData() The Description for item number " + poi.getItemLineNumber() + " is required for the cXML PO but is missing.");
errors.append("Missing Data: Item#" + poi.getItemLineNumber() + " - Description\n");
}
// CU : added nonqtyorder check
if (!nonQuantityOrder && StringUtils.isEmpty(poi.getItemUnitOfMeasureCode())) {
LOG.error("verifyCxmlPOData() The Unit Of Measure Code for item number " + poi.getItemLineNumber() + " is required for the cXML PO but is missing.");
errors.append("Missing Data: Item#" + poi.getItemLineNumber() + " - Unit Of Measure\n");
}
// CU : added B2B Check
if (StringUtils.isEmpty(poi.getExternalOrganizationB2bProductTypeName()) && PurapConstants.RequisitionSources.B2B.equals(purchaseOrder.getRequisitionSourceCode())) {
LOG.error("verifyCxmlPOData() The External Org B2B Product Type Name for item number " + poi.getItemLineNumber() + " is required for the cXML PO but is missing.");
errors.append("Missing Data: Item#" + poi.getItemLineNumber() + " - External Org B2B Product Type Name\n");
}
// CU : added nonqtyorder check
if (!nonQuantityOrder && poi.getItemQuantity() == null) {
LOG.error("verifyCxmlPOData() The Order Quantity for item number " + poi.getItemLineNumber() + " is required for the cXML PO but is missing.");
errors.append("Missing Data: Item#" + poi.getItemLineNumber() + " - Order Quantity\n");
}
if (poi.getItemUnitPrice() == null) {
LOG.error("verifyCxmlPOData() The Unit Price for item number " + poi.getItemLineNumber() + " is required for the cXML PO but is missing.");
errors.append("Missing Data: Item#" + poi.getItemLineNumber() + " - Unit Price\n");
}
}
}
return errors.toString();
}
Aggregations