public static BudgetEntity buildBudgetEntity( Object lineItem, BudgetAction budgetAction, String authority, BigDecimal alternateTotal) { BudgetEntity budgetEntity = new BudgetEntity(); BigDecimal icHeader = new BigDecimal(0); BigDecimal icLine = new BigDecimal(0); BigDecimal lineTotal = new BigDecimal(0); String commodity = ""; String formType = budgetAction.getType(); budgetEntity.setBudgetAction(budgetAction); budgetEntity.setUserCode(authority); if (formType.startsWith("REQ")) { RequisitionLine reqLine = (RequisitionLine) lineItem; icHeader = reqLine.getIcReqHeader(); icLine = reqLine.getIcReqLine(); lineTotal = reqLine.getLineTotal(); commodity = reqLine.getCommodityCode(); } else if (formType.startsWith("PO")) { PoLine poLine = (PoLine) lineItem; icHeader = poLine.getIcPoHeader(); icLine = poLine.getIcPoLine(); lineTotal = poLine.getLineTotal(); commodity = poLine.getCommodity(); } else if (formType.equalsIgnoreCase("IVC")) { InvoiceLine invoiceLine = (InvoiceLine) lineItem; icHeader = invoiceLine.getIcIvcHeader(); icLine = invoiceLine.getIcIvcLine(); lineTotal = invoiceLine.getLineTotal(); commodity = invoiceLine.getCommodity(); if (invoiceLine.getIcPoLine().compareTo(new BigDecimal(0)) != 0) { budgetEntity.setIcReferenceLine(invoiceLine.getIcRelPoLine()); } } budgetEntity.setIcHeader(icHeader); budgetEntity.setIcLine(icLine); budgetEntity.setCommodity(commodity); budgetEntity.setLineTotal(lineTotal); if (alternateTotal.compareTo(new BigDecimal(-1)) > 0) { budgetEntity.setDistributable(true); budgetEntity.setAlternateTotal(alternateTotal); } return budgetEntity; }
/** * Method executeTask. * * @param object * <p>incomingRequest */ public Object executeTask(Object object) throws Exception { Object ret = null; try { Map incomingRequest = (Map) object; RequisitionLine reqLine = (RequisitionLine) incomingRequest.get("requisitionLine"); reqLine.setBackordered(new BigDecimal(0)); reqLine.setStatus(DocumentStatus.CANCELLED); ret = reqLine; this.setStatus(Status.SUCCEEDED); } catch (Exception e) { Log.error(this, e.toString()); this.setStatus(Status.FAILED); } finally { return ret; } }
public Object executeTask(Object object) throws Exception { try { Map incomingRequest = (Map) object; String assignTo = (String) incomingRequest.get("assignTo"); if (Utility.isEmpty(assignTo)) { // Notification cannot be sent throw new Exception( "The notification cannot be sent because the assigned buyer user id was not specified (assignTo)."); } if (assignTo.equalsIgnoreCase("AUTORELEASE")) { // Notification should not be sent this.setStatus(Status.SUCCEEDED); return null; } if (assignTo.equalsIgnoreCase("UNASSIGNED")) { assignTo = "PURCHASING"; } String userId = (String) incomingRequest.get("userId"); String organizationId = (String) incomingRequest.get("organizationId"); RequisitionHeader requisitionHeader = (RequisitionHeader) incomingRequest.get("requisitionHeader"); List requisitionLineList = (List) incomingRequest.get("requisitionLineList"); String assignType = (String) incomingRequest.get("assignType"); if (assignType == null) { assignType = "MANUAL"; } UserProfile assignedBuyer = UserManager.getInstance().getUser(organizationId, assignTo); UserProfile requisitioner = UserManager.getInstance() .getUser(organizationId, requisitionHeader.getRequisitionerCode()); UserProfile owner = UserManager.getInstance().getUser(organizationId, requisitionHeader.getOwner()); StringBuffer message = new StringBuffer(); StringBuffer sendTo = new StringBuffer(); String sendFrom = UserManager.getInstance().getUser(organizationId, userId).getMailId(); if (Utility.isEmpty(sendFrom)) { sendFrom = PropertiesManager.getInstance(organizationId) .getProperty("MAILEVENTS", "AdminEmailAddr", ""); } if (!Utility.isEmpty(assignedBuyer.getMailId())) { sendTo.append(assignedBuyer.getMailId()); } if (!Utility.isEmpty(requisitioner.getMailId()) && assignType.equals("MANUAL")) { if (sendTo.length() > 0) { sendTo.append(";" + requisitioner.getMailId()); } else { sendTo.append(requisitioner.getMailId()); } } if (!Utility.isEmpty(owner.getMailId())) { if (sendTo.length() > 0) { sendTo.append(";" + owner.getMailId()); } else { sendTo.append(owner.getMailId()); } } if (!Utility.isEmpty(assignedBuyer.getMailId())) { message.append( "Request " + requisitionHeader.getRequisitionNumber() + " was assigned to " + assignedBuyer.getDisplayName() + " on " + HiltonUtility.getFormattedDate( requisitionHeader.getAssignedDate(), organizationId) + "."); message.append("\r"); message.append("\r"); message.append("This request contains the following items:"); message.append("\r"); for (int il = 0; il < requisitionLineList.size(); il++) { RequisitionLine requisitionLine = (RequisitionLine) requisitionLineList.get(il); message.append(requisitionLine.getLineNumber() + "." + " "); if (!Utility.isEmpty(requisitionLine.getItemNumber())) { message.append(requisitionLine.getItemNumber() + " - "); } message.append(requisitionLine.getDescription()); message.append("\r"); } incomingRequest.put( "SendQueue_subject", "Assignment Notification: Requisition " + requisitionHeader.getRequisitionNumber()); incomingRequest.put("SendQueue_sendfromtype", "E"); incomingRequest.put("SendQueue_sendfrom", sendFrom); incomingRequest.put("SendQueue_sendtotype", "E"); incomingRequest.put("SendQueue_action", "EN"); incomingRequest.put("SendQueue_messagetext", message.toString()); incomingRequest.put("SendQueue_owner", userId); incomingRequest.put("SendQueue_doctype", "REQ"); incomingRequest.put("SendQueue_docic", String.valueOf(requisitionHeader.getIcReqHeader())); incomingRequest.put("SendQueue_sendto", sendTo.toString()); PuridiomProcessLoader processLoader = new PuridiomProcessLoader(); PuridiomProcess process = processLoader.loadProcess("sendqueue-add.xml"); process.executeProcess(incomingRequest); this.status = process.getStatus(); if (this.getStatus() != Status.SUCCEEDED) { throw new Exception("The email record could not be written to the queue."); } } this.status = Status.SUCCEEDED; } catch (Exception e) { this.status = Status.FAILED; throw e; } return null; }