use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImplTest method testRejectDocumentCreationInvalidData.
public void testRejectDocumentCreationInvalidData() throws Exception {
String rejectFile = "reject.xml";
RequisitionDocument reqDoc = RequisitionFixture.REQ_NON_B2B_WITH_ITEMS.createRequisition();
Integer reqId = reqDoc.getPurapDocumentIdentifier();
PurchaseOrderDocument poDocument = createPODoc(reqId);
poDocument.setVendorShippingPaymentTermsCode("AL");
poDocument.setVendorPaymentTermsCode("00N30");
poDocument.refreshNonUpdateableReferences();
AccountingDocumentTestUtils.saveDocument(poDocument, documentService);
String poNumber = String.valueOf(poDocument.getPurapDocumentIdentifier());
String vendorDUNS = "133251074";
String xmlChunk = CuElectronicInvoiceHelperServiceFixture.getCXMLForRejectDocCreation(vendorDUNS, poNumber);
writeXMLFile(xmlChunk, rejectFile);
ElectronicInvoiceLoad load = cuElectronicInvoiceHelperService.loadElectronicInvoices();
assertTrue(load.containsRejects());
ElectronicInvoiceRejectDocument rejectDoc = (ElectronicInvoiceRejectDocument) load.getRejectDocuments().get(0);
assertNotNull(rejectDoc);
assertEquals(rejectDoc.getInvoiceFileName(), rejectFile);
assertEquals(1, rejectDoc.getInvoiceRejectReasons().size());
File rejectedFileInRejectDir = new File(electronicInvoiceInputFileType.getDirectoryPath() + File.separator + "reject" + File.separator + rejectFile);
assertTrue(rejectedFileInRejectDir.exists());
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class CuPurapAccountingServiceImplTest method testUpdateAccountAmounts_AccountingLinePercentChanged.
public void testUpdateAccountAmounts_AccountingLinePercentChanged() throws Exception {
changeCurrentUser(UserNameFixture.ccs1);
// Save the requisition with items, but without accounting lines and then add the accounting lines and save again
// This odd methodology is to workaround an NPE that occurs when access security is enabled and refreshNonUpdatableReferences
// is called on the account. For some reason the RequisitionItem cannot be found in ojb's cache and so when
// it is attempted to be instantiated and constructor methods called, an NPE is thrown. This little dance works around the exception.
// More analysis could probably be done to determine the root cause and address it, but for now this is good enough.
RequisitionDocument requisitionDocument = RequisitionFixture.REQ_NON_B2B_WITH_ITEMS.createRequisition(documentService);
requisitionDocument.getFinancialSystemDocumentHeader().setFinancialDocumentTotalAmount(new KualiDecimal(200));
RequisitionItem item = RequisitionItemFixture.REQ_ITEM3.createRequisitionItem(false);
requisitionDocument.addItem(item);
AccountingDocumentTestUtils.saveDocument(requisitionDocument, documentService);
requisitionDocument.refreshNonUpdateableReferences();
item.getSourceAccountingLines().add(PurapAccountingLineFixture.REQ_ITEM_ACCT_LINE3.createRequisitionAccount(item.getItemIdentifier()));
item.getSourceAccountingLines().add(PurapAccountingLineFixture.REQ_ITEM_ACCT_LINE3.createRequisitionAccount(item.getItemIdentifier()));
item.refreshNonUpdateableReferences();
AccountingDocumentTestUtils.saveDocument(requisitionDocument, documentService);
PurchaseOrderDocument purchaseOrderDocument = (PurchaseOrderDocument) documentService.getNewDocument(PurchaseOrderDocument.class);
purchaseOrderDocument.populatePurchaseOrderFromRequisition(requisitionDocument);
purchaseOrderDocument.setContractManagerCode(10);
purchaseOrderDocument.setPurchaseOrderCurrentIndicator(true);
purchaseOrderDocument.getDocumentHeader().setDocumentDescription("Description");
purchaseOrderDocument.setApplicationDocumentStatus(PurchaseOrderStatuses.APPDOC_OPEN);
purchaseOrderDocument.refreshNonUpdateableReferences();
purchaseOrderDocument.setVendorShippingPaymentTermsCode("AL");
purchaseOrderDocument.setVendorPaymentTermsCode("00N30");
purchaseOrderDocument.refreshNonUpdateableReferences();
AccountingDocumentTestUtils.saveDocument(purchaseOrderDocument, documentService);
changeCurrentUser(UserNameFixture.mo14);
PaymentRequestDocument paymentRequestDocument = PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(purchaseOrderDocument.getPurapDocumentIdentifier());
paymentRequestDocument.initiateDocument();
paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(purchaseOrderDocument);
paymentRequestDocument.setApplicationDocumentStatus(PurapConstants.PaymentRequestStatuses.APPDOC_AWAITING_FISCAL_REVIEW);
paymentRequestDocument.getItem(0).setExtendedPrice(new KualiDecimal(1));
paymentRequestDocument.getItem(1).setExtendedPrice(new KualiDecimal(4));
((PaymentRequestAccount) (((PaymentRequestItem) paymentRequestDocument.getItems().get(1)).getSourceAccountingLine(0))).setAmount(new KualiDecimal(3));
((PaymentRequestAccount) (((PaymentRequestItem) paymentRequestDocument.getItems().get(1)).getSourceAccountingLine(1))).setAmount(new KualiDecimal(1));
cuPurapAccountingServiceImpl.updateAccountAmounts(paymentRequestDocument);
assertEquals(new BigDecimal(75).setScale(2), ((PaymentRequestAccount) (((PaymentRequestItem) paymentRequestDocument.getItems().get(1)).getSourceAccountingLine(0))).getAccountLinePercent());
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class CuPurapAccountingServiceImplTest method testUpdateAccountAmounts_AccountingLinePercentUnchanged.
public void testUpdateAccountAmounts_AccountingLinePercentUnchanged() throws Exception {
changeCurrentUser(UserNameFixture.ccs1);
// Save the requisition with items, but without accounting lines and then add the accounting lines and save again
// This odd methodology is to workaround an NPE that occurs when access security is enabled and refreshNonUpdatableReferences
// is called on the account. For some reason the RequisitionItem cannot be found in ojb's cache and so when
// it is attempted to be instantiated and constructor methods called, an NPE is thrown. This little dance works around the exception.
// More analysis could probably be done to determine the root cause and address it, but for now this is good enough.
RequisitionDocument requisitionDocument = RequisitionFixture.REQ_NON_B2B_WITH_ITEMS.createRequisition(documentService);
requisitionDocument.getFinancialSystemDocumentHeader().setFinancialDocumentTotalAmount(new KualiDecimal(200));
RequisitionItem item = RequisitionItemFixture.REQ_ITEM3.createRequisitionItem(false);
requisitionDocument.addItem(item);
AccountingDocumentTestUtils.saveDocument(requisitionDocument, documentService);
requisitionDocument.refreshNonUpdateableReferences();
item.getSourceAccountingLines().add(PurapAccountingLineFixture.REQ_ITEM_ACCT_LINE3.createRequisitionAccount(item.getItemIdentifier()));
item.getSourceAccountingLines().add(PurapAccountingLineFixture.REQ_ITEM_ACCT_LINE3.createRequisitionAccount(item.getItemIdentifier()));
item.refreshNonUpdateableReferences();
AccountingDocumentTestUtils.saveDocument(requisitionDocument, documentService);
PurchaseOrderDocument purchaseOrderDocument = (PurchaseOrderDocument) documentService.getNewDocument(PurchaseOrderDocument.class);
purchaseOrderDocument.populatePurchaseOrderFromRequisition(requisitionDocument);
purchaseOrderDocument.setContractManagerCode(10);
purchaseOrderDocument.setPurchaseOrderCurrentIndicator(true);
purchaseOrderDocument.getDocumentHeader().setDocumentDescription("Description");
purchaseOrderDocument.setApplicationDocumentStatus(PurchaseOrderStatuses.APPDOC_OPEN);
purchaseOrderDocument.refreshNonUpdateableReferences();
purchaseOrderDocument.setVendorShippingPaymentTermsCode("AL");
purchaseOrderDocument.setVendorPaymentTermsCode("00N30");
purchaseOrderDocument.refreshNonUpdateableReferences();
AccountingDocumentTestUtils.saveDocument(purchaseOrderDocument, documentService);
changeCurrentUser(UserNameFixture.mo14);
PaymentRequestDocument paymentRequestDocument = PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(purchaseOrderDocument.getPurapDocumentIdentifier());
paymentRequestDocument.initiateDocument();
paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(purchaseOrderDocument);
paymentRequestDocument.setApplicationDocumentStatus(PurapConstants.PaymentRequestStatuses.APPDOC_IN_PROCESS);
paymentRequestDocument.getItem(0).setExtendedPrice(new KualiDecimal(1));
paymentRequestDocument.getItem(1).setExtendedPrice(new KualiDecimal(4));
((PaymentRequestAccount) (((PaymentRequestItem) paymentRequestDocument.getItems().get(1)).getSourceAccountingLine(0))).setAmount(new KualiDecimal(3));
((PaymentRequestAccount) (((PaymentRequestItem) paymentRequestDocument.getItems().get(1)).getSourceAccountingLine(1))).setAmount(new KualiDecimal(1));
cuPurapAccountingServiceImpl.updateAccountAmounts(paymentRequestDocument);
assertEquals(new BigDecimal(50).setScale(2), ((PaymentRequestAccount) (((PaymentRequestItem) paymentRequestDocument.getItems().get(1)).getSourceAccountingLine(0))).getAccountLinePercent());
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class PurchaseOrderDocumentPresentationController method canRoute.
@Override
public boolean canRoute(Document document) {
PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
String statusCode = poDocument.getApplicationDocumentStatus();
if (StringUtils.equals(statusCode, PurchaseOrderStatuses.APPDOC_WAITING_FOR_DEPARTMENT) || StringUtils.equals(statusCode, PurchaseOrderStatuses.APPDOC_WAITING_FOR_VENDOR) || StringUtils.equals(statusCode, PurchaseOrderStatuses.APPDOC_QUOTE)) {
return false;
}
if (poDocument.isPendingSplit()) {
return false;
}
return super.canRoute(document);
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method changeSystem.
public ActionForward changeSystem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
if (question == null) {
String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASING_QUESTION_CONFIRM_CHANGE_SYSTEM);
return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText, KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
} else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
// Add a note if system change occurs when the document is a PO that is being amended.
if ((document instanceof PurchaseOrderDocument) && (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(document.getApplicationDocumentStatus()))) {
Integer poId = document.getPurapDocumentIdentifier();
PurchaseOrderDocument currentPO = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(poId);
String oldSystemTypeCode = "";
if (currentPO != null) {
oldSystemTypeCode = currentPO.getCapitalAssetSystemTypeCode();
}
CapitalAssetSystemType oldSystemType = new CapitalAssetSystemType();
oldSystemType.setCapitalAssetSystemTypeCode(oldSystemTypeCode);
Map<String, String> keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(oldSystemType);
oldSystemType = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(CapitalAssetSystemType.class, keys);
String description = ((oldSystemType == null) ? "(NONE)" : oldSystemType.getCapitalAssetSystemTypeDescription());
if (document instanceof PurchaseOrderAmendmentDocument) {
String noteText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASE_ORDER_AMEND_MESSAGE_CHANGE_SYSTEM_TYPE);
noteText = StringUtils.replace(noteText, "{0}", description);
try {
Note systemTypeChangeNote = getDocumentService().createNoteFromDocument(document, noteText);
purchasingForm.setNewNote(systemTypeChangeNote);
insertBONote(mapping, purchasingForm, request, response);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
if (form instanceof RequisitionForm) {
((RequisitionForm) form).resetNewPurchasingCapitalAssetLocationLine();
}
// remove capital assets from db
if (document instanceof PurchaseOrderAmendmentDocument) {
for (PurchasingCapitalAssetItem assetItem : document.getPurchasingCapitalAssetItems()) {
SpringContext.getBean(BusinessObjectService.class).delete((PersistableBusinessObject) assetItem);
}
}
document.clearCapitalAssetFields();
SpringContext.getBean(PurapService.class).saveDocumentNoValidation(document);
KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PURCHASING_MESSAGE_SYSTEM_CHANGED);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Aggregations