List of usage examples for java.text NumberFormat getCurrencyInstance
public static NumberFormat getCurrencyInstance(Locale inLocale)
From source file:com.intuit.tank.project.JobDetailFormatter.java
protected static String calculateCost(TankConfig config, JobInstance proposedJobInstance, List<JobRegion> regions, long simulationTime) { List<VmInstanceType> instanceTypes = config.getVmManagerConfig().getInstanceTypes(); BigDecimal costPerHour = new BigDecimal(.5D); for (VmInstanceType type : instanceTypes) { if (type.getName().equals(proposedJobInstance.getVmInstanceType())) { costPerHour = new BigDecimal(type.getCost()); break; }//w w w . j a va2s. co m } long time = simulationTime + proposedJobInstance.getRampTime(); int numMachines = 0; for (JobRegion region : regions) { int users = Integer.parseInt(region.getUsers()); if (users > 0) { numMachines += (int) Math.ceil((double) users / (double) proposedJobInstance.getNumUsersPerAgent()); } } // dynamoDB costs about 1.5 times the instance cost BigDecimal cost = estimateCost(numMachines, costPerHour, time); NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); return nf.format(cost.doubleValue()); }
From source file:biz.wolschon.fileformats.gnucash.baseclasses.SimpleAccount.java
/** * same as {@link #getBalance(Date)}. <br/> * ignores transactions after the current date+time. * @see #getBalance(Date)//from w w w.ja va 2 s . c o m */ public String getBalanceFormated(final Locale loc) { NumberFormat cf = NumberFormat.getCurrencyInstance(loc); cf.setCurrency(getCurrency()); return cf.format(getBalance()); }
From source file:pagecode.RPTs.OffenceUtil.java
private void processOffenceInfo() { logger.info("In OffenceUtil::processOffenceInfo"); if (true == isOffenceNumberValid()) { //TODO fix this to throw Exception if (this.request == null) { return; }/*from w w w.j a va 2 s . co m*/ HttpSession session = this.request.getSession(); try { //Map session = FacesContext.getCurrentInstance().getExternalContext().getSessionMap(); BackToMenu_Access backToMenu_Access = new BackToMenu_Access(); PageCodeBase.executeEJB(backToMenu_Access, session); OffenceInfo_am_Integrated_Access offenceInfo_am_Integrated_Access = new OffenceInfo_am_Integrated_Access(); offenceInfo_am_Integrated_Access.setCrt(StringUtils.rightPad(courtOfficeId.trim(), 4)); offenceInfo_am_Integrated_Access.setJur(StringUtils.rightPad(jurisdictionNumber.trim(), 3)); offenceInfo_am_Integrated_Access.setYr(StringUtils.rightPad(infoYear.trim(), 2)); offenceInfo_am_Integrated_Access.setInfPart1(StringUtils.rightPad(infoPrefix.trim(), 8)); offenceInfo_am_Integrated_Access.setInfPart2(StringUtils.rightPad(infoSuffix.trim(), 2)); if (null != countNumber && !countNumber.equals("")) { if (countNumber.trim().length() < 4) { countNumber = StringUtils.leftPad(countNumber.trim(), 4, "0"); } offenceInfo_am_Integrated_Access.setOther(StringUtils.rightPad(countNumber, 20)); } PageCodeBase.executeEJB(offenceInfo_am_Integrated_Access, session); if (!offenceInfo_am_Integrated_Access.getReturnMessage().trim().equals("")) { throw new Exception(offenceInfo_am_Integrated_Access.getReturnMessage().trim()); } paramOffenceNumber = courtOfficeId + " " + jurisdictionNumber + " " + infoYear + " " + infoPrefix + " " + infoSuffix; //Always sssume English isEnglish = true; if ("F".equalsIgnoreCase(offenceInfo_am_Integrated_Access.getLanguageCode().trim())) { isEnglish = false; } //NOTE: if runAsStandAlone == true then assume it is always French if (true == runAsStandAlone) { isEnglish = false; } paramInterpreterLanguage = offenceInfo_am_Integrated_Access.getInterpreterLangCode().trim(); if (!paramInterpreterLanguage.equals("")) { InterpreterLanguageUtil interpreterLanguageUtil = new InterpreterLanguageUtil(); interpreterLanguageUtil.setIsEnglish(isEnglish); interpreterLanguageUtil.setInterpreterLanguageUtil(paramInterpreterLanguage); paramInterpreterLanguage = interpreterLanguageUtil.getInterpreterLanguageDesc(); } IconDateUtil offenceDateUtil = new IconDateUtil(); offenceDateUtil.setIsEnglish(isEnglish); paramOffenceDate = ""; //YYMMDD if (!offenceInfo_am_Integrated_Access.getOffenceDateYear().trim().equals("") && !offenceInfo_am_Integrated_Access.getOffenceDateMonth().trim().equals("") && !offenceInfo_am_Integrated_Access.getOffenceDateDay().trim().equals("")) { offenceDateUtil.setIconDate(offenceInfo_am_Integrated_Access.getOffenceDateYear().trim() + offenceInfo_am_Integrated_Access.getOffenceDateMonth().trim() + offenceInfo_am_Integrated_Access.getOffenceDateDay().trim()); paramOffenceDate = offenceDateUtil.getDateWithSlashes(); } paramOfficerNumber = offenceInfo_am_Integrated_Access.getOfficerNumber().trim(); paramDriversLicenseNumber = offenceInfo_am_Integrated_Access.getDriversLicense().trim(); paramPlateNumber = offenceInfo_am_Integrated_Access.getPlateNumber().trim(); paramEnforcementAgency = offenceInfo_am_Integrated_Access.getEnforcementAgency().trim(); paramSex = offenceInfo_am_Integrated_Access.getSex().trim(); paramDateOfBirth = ""; //YYMMDD IconDateUtil dateOfBirthUtil = new IconDateUtil(); dateOfBirthUtil.setIsEnglish(isEnglish); if (!offenceInfo_am_Integrated_Access.getDateOfBirthYear().trim().equals("") && !offenceInfo_am_Integrated_Access.getDateOfBirthMonth().trim().equals("") && !offenceInfo_am_Integrated_Access.getDateOfBirthDay().trim().equals("")) { dateOfBirthUtil.setIconDate(offenceInfo_am_Integrated_Access.getDateOfBirthYear().trim() + offenceInfo_am_Integrated_Access.getDateOfBirthMonth().trim() + offenceInfo_am_Integrated_Access.getDateOfBirthDay().trim()); paramDateOfBirth = dateOfBirthUtil.getDateWithSlashes(); } paramCVOR = offenceInfo_am_Integrated_Access.getCvor().trim(); paramUnit = offenceInfo_am_Integrated_Access.getUnit().trim(); paramOffenderFullName = offenceInfo_am_Integrated_Access.getFirstName().trim(); paramOffenderFullName += " " + offenceInfo_am_Integrated_Access.getInitial().trim(); paramOffenderFullName += " " + offenceInfo_am_Integrated_Access.getLastName().trim(); paramAddressLine1 = offenceInfo_am_Integrated_Access.getAddressStreet().trim(); paramAddressLine2 = offenceInfo_am_Integrated_Access.getAddressCity().trim(); paramAddressLine2 += ", " + offenceInfo_am_Integrated_Access.getAddressProvince().trim(); paramAddressLine3 = offenceInfo_am_Integrated_Access.getAddressPostal().trim(); //Modified 2008-02-28 per Janes request //paramOffenceDay = offenceDateUtil.getStrDay(); paramOffenceDay = offenceDateUtil.getDayNonFormatted(); paramOffenceMonth = offenceDateUtil.getStrMonth(); paramOffenceYear = offenceDateUtil.getStrYear(); paramOffenceTime = ""; if (!offenceInfo_am_Integrated_Access.getOffenceDateTimeHour().trim().equals("") && !offenceInfo_am_Integrated_Access.getOffenceDateTimeMinute().trim().equals("")) { offenceDateUtil.setIconTime(offenceInfo_am_Integrated_Access.getOffenceDateTimeHour().trim() + offenceInfo_am_Integrated_Access.getOffenceDateTimeMinute().trim()); paramOffenceTime = offenceDateUtil.getFormatedTime(); } paramOffenceLocation = offenceInfo_am_Integrated_Access.getOffenceLocation().trim(); //Feb 16, 2009 - Anan paramTrialDay = offenceInfo_am_Integrated_Access.getTrialDay().trim(); paramTrialMonth = offenceInfo_am_Integrated_Access.getTrialMonth().trim(); paramTrailYear = offenceInfo_am_Integrated_Access.getTrailYear().trim(); paramTrailTimeHour = offenceInfo_am_Integrated_Access.getTrailTimeHour().trim(); paramTrailTimeMinute = offenceInfo_am_Integrated_Access.getTrailTimeMinute().trim(); paramTrailRoom = offenceInfo_am_Integrated_Access.getTrailRoom().trim(); paramTrailLocationCourtId = offenceInfo_am_Integrated_Access.getTrailLocationCourtId().trim(); //Added Mar 2, 2009 - Anan paramSentenceDateDay = offenceInfo_am_Integrated_Access.getSentenceDateDay().trim(); paramSentenceDateMonth = offenceInfo_am_Integrated_Access.getSentenceDateMonth().trim(); paramSentenceDateYear = offenceInfo_am_Integrated_Access.getSentenceDateYear().trim(); OffenceStatuteDescriptionUtil offenceStatuteDescriptionUtil = new OffenceStatuteDescriptionUtil(); offenceStatuteDescriptionUtil.setIsEnglish(this.isEnglish); // logger.info("Before setOffenceStatuteDescriptionUtil(...)\n" + // this.OCNT_STATU_CD + " " + // this.OCNT_SCTN_ID + " " + // this.OCNT_SUB_SCTN_ID + " " + // this.OCNT_PARA_ID + " " + // this.OCNT_OFNC_CLAS_ID + " " + // this.OCNT_BYLAW_CD // ); // offenceStatuteDescriptionUtil.setOffenceStatuteDescriptionUtil( // this.OCNT_STATU_CD, // this.OCNT_SCTN_ID, // this.OCNT_SUB_SCTN_ID, // this.OCNT_PARA_ID, // this.OCNT_OFNC_CLAS_ID, // this.OCNT_BYLAW_CD, offenceDateUtil // ); // Modified by Anan // January 14, 2009 // To integrate the French NoT into ICON v2.2 offenceStatuteDescriptionUtil.setOffenceStatuteDescriptionUtil( offenceInfo_am_Integrated_Access.getOffenceStatute().trim(), offenceInfo_am_Integrated_Access.getOffenceSection().trim(), offenceInfo_am_Integrated_Access.getOffenceSubSection().trim(), offenceInfo_am_Integrated_Access.getOffenceParagraph().trim(), offenceInfo_am_Integrated_Access.getOffenceClause().trim(), offenceInfo_am_Integrated_Access.getOffenceByLaw().trim(), offenceDateUtil); paramOffenceDesc = offenceStatuteDescriptionUtil.getOffenceDescription(); paramOffenceStatue = offenceStatuteDescriptionUtil.getStatuteDescription(); paramOffenceSection = offenceInfo_am_Integrated_Access.getOffenceSection().trim(); if (!offenceInfo_am_Integrated_Access.getOffenceSubSection().trim().equals("")) { paramOffenceSection += "(" + offenceInfo_am_Integrated_Access.getOffenceSubSection().trim() + ")"; } if (!offenceInfo_am_Integrated_Access.getOffenceParagraph().trim().equals("")) { paramOffenceSection += "(" + offenceInfo_am_Integrated_Access.getOffenceParagraph().trim() + ")"; } if (!offenceInfo_am_Integrated_Access.getOffenceClause().trim().equals("")) { paramOffenceSection += "(" + offenceInfo_am_Integrated_Access.getOffenceClause().trim() + ")"; } paramOffenceTotalPayable = ""; BigDecimal totalPayable; String tempAmount; tempAmount = offenceInfo_am_Integrated_Access.getOutstandingFineAmount().trim(); BigDecimal outstandingFineAmount = new BigDecimal( (null != tempAmount && !tempAmount.equals("") ? tempAmount : "0.0")); tempAmount = offenceInfo_am_Integrated_Access.getOutstandingCostAmount().trim(); BigDecimal outstandingCostAmount = new BigDecimal( (null != tempAmount && !tempAmount.equals("") ? tempAmount : "0.0")); totalPayable = outstandingFineAmount.add(outstandingCostAmount); NumberFormat formatUS = NumberFormat.getCurrencyInstance(Locale.US); paramOffenceTotalPayable = formatUS.format(totalPayable.doubleValue()); //Added Sep 13, 2011 to screenscrap appearance type paramAppearanceType = offenceInfo_am_Integrated_Access.getAppearanceType().trim(); } catch (Exception e) { paramOffenceNumber = ""; paramOffenceDate = ""; paramOfficerNumber = ""; paramDriversLicenseNumber = ""; paramPlateNumber = ""; paramEnforcementAgency = ""; paramSex = ""; paramDateOfBirth = ""; paramCVOR = ""; paramUnit = ""; paramOffenderFullName = ""; paramAddressLine1 = ""; paramAddressLine2 = ""; paramAddressLine3 = ""; paramOffenceDay = ""; paramOffenceMonth = ""; paramOffenceYear = ""; paramOffenceTime = ""; paramOffenceLocation = ""; paramOffenceDesc = ""; paramOffenceStatue = ""; paramOffenceSection = ""; paramOffenceTotalPayable = ""; paramInterpreterLanguage = ""; //Feb 16, 2009 - Anan paramTrialDay = ""; paramTrialMonth = ""; paramTrailYear = ""; paramTrailTimeHour = ""; paramTrailTimeMinute = ""; paramTrailRoom = ""; paramTrailLocationCourtId = ""; //Added Mar 2, 2009 - Anan paramSentenceDateDay = ""; paramSentenceDateMonth = ""; paramSentenceDateYear = ""; //Added Sep 13, 2011 - Anan paramAppearanceType = ""; returnMessage = e.getMessage(); e.printStackTrace(); } finally { BackToMenu_Access backToMenu_Access = new BackToMenu_Access(); PageCodeBase.executeEJB(backToMenu_Access, session); } } //if(true == isOffenceNumberValid()) }
From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderPdf.java
/** * Create a PDF using the given input parameters. * * @param po The PurchaseOrderDocument to be used to create the pdf. * @param document The pdf document whose margins have already been set. * @param writer The PdfWriter to write the pdf document into. * @param statusInquiryUrl The status inquiry url to be displayed on the pdf document. * @param campusName The campus name to be displayed on the pdf document. * @param contractLanguage The contract language to be displayed on the pdf document. * @param logoImage The logo image file name to be displayed on the pdf document. * @param directorSignatureImage The director signature image to be displayed on the pdf document. * @param directorName The director name to be displayed on the pdf document. * @param directorTitle The director title to be displayed on the pdf document. * @param contractManagerSignatureImage The contract manager signature image to be displayed on the pdf document. * @param isRetransmit The boolean to indicate whether this is for a retransmit purchase order document. * @param environment The current environment used (e.g. DEV if it is a development environment). * @param retransmitItems The items selected by the user to be retransmitted. * @throws DocumentException/*from w w w. j a v a 2s . co m*/ * @throws IOException */ private void createPdf(PurchaseOrderDocument po, Document document, PdfWriter writer, String statusInquiryUrl, String campusName, String contractLanguage, String logoImage, String directorSignatureImage, String directorName, String directorTitle, String contractManagerSignatureImage, boolean isRetransmit, String environment, List<PurchaseOrderItem> retransmitItems) throws DocumentException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("createPdf() started for po number " + po.getPurapDocumentIdentifier().toString()); } // These have to be set because they are used by the onOpenDocument() and onStartPage() methods. this.campusName = campusName; this.po = po; this.logoImage = logoImage; this.environment = environment; NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US); Collection errors = new ArrayList(); // Date format pattern: MM-dd-yyyy SimpleDateFormat sdf = PurApDateFormatUtils .getSimpleDateFormat(PurapConstants.NamedDateFormats.KUALI_SIMPLE_DATE_FORMAT_2); // This turns on the page events that handle the header and page numbers. PurchaseOrderPdf events = new PurchaseOrderPdf().getPageEvents(); writer.setPageEvent(this); // Passing in "this" lets it know about the po, campusName, etc. document.open(); PdfPCell cell; Paragraph p = new Paragraph(); // ***** Info table (vendor, address info) ***** LOG.debug("createPdf() info table started."); float[] infoWidths = { 0.50f, 0.50f }; PdfPTable infoTable = new PdfPTable(infoWidths); infoTable.setWidthPercentage(100); infoTable.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.setSplitLate(false); StringBuffer vendorInfo = new StringBuffer(); vendorInfo.append("\n"); if (StringUtils.isNotBlank(po.getVendorName())) { vendorInfo.append(" " + po.getVendorName() + "\n"); } vendorInfo.append(" ATTN: " + po.getVendorAttentionName() + "\n"); if (StringUtils.isNotBlank(po.getVendorLine1Address())) { vendorInfo.append(" " + po.getVendorLine1Address() + "\n"); } if (StringUtils.isNotBlank(po.getVendorLine2Address())) { vendorInfo.append(" " + po.getVendorLine2Address() + "\n"); } if (StringUtils.isNotBlank(po.getVendorCityName())) { vendorInfo.append(" " + po.getVendorCityName()); } if (StringUtils.isNotBlank(po.getVendorStateCode())) { vendorInfo.append(", " + po.getVendorStateCode()); } if (StringUtils.isNotBlank(po.getVendorAddressInternationalProvinceName())) { vendorInfo.append(", " + po.getVendorAddressInternationalProvinceName()); } if (StringUtils.isNotBlank(po.getVendorPostalCode())) { vendorInfo.append(" " + po.getVendorPostalCode() + "\n"); } else { vendorInfo.append("\n"); } if (!KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getVendorCountryCode()) && po.getVendorCountry() != null) { vendorInfo.append(" " + po.getVendorCountry().getName() + "\n\n"); } else { vendorInfo.append("\n\n"); } p = new Paragraph(); p.add(new Chunk(" Vendor", ver_5_normal)); p.add(new Chunk(vendorInfo.toString(), cour_7_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); StringBuffer shipToInfo = new StringBuffer(); shipToInfo.append("\n"); if (po.getAddressToVendorIndicator()) { // use receiving address shipToInfo.append(" " + po.getReceivingName() + "\n"); shipToInfo.append(" " + po.getReceivingLine1Address() + "\n"); if (StringUtils.isNotBlank(po.getReceivingLine2Address())) { shipToInfo.append(" " + po.getReceivingLine2Address() + "\n"); } shipToInfo.append(" " + po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " " + po.getReceivingPostalCode() + "\n"); if (StringUtils.isNotBlank(po.getReceivingCountryCode()) && !KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getReceivingCountryCode())) { shipToInfo.append(" " + po.getReceivingCountryName() + "\n"); } } else { // use delivery address shipToInfo.append(" " + po.getDeliveryToName() + "\n"); // extra space needed below to separate other text going on same PDF line String deliveryBuildingName = po.getDeliveryBuildingName() + " "; if (po.isDeliveryBuildingOtherIndicator()) { deliveryBuildingName = ""; } shipToInfo .append(" " + deliveryBuildingName + "Room #" + po.getDeliveryBuildingRoomNumber() + "\n"); shipToInfo.append(" " + po.getDeliveryBuildingLine1Address() + "\n"); if (StringUtils.isNotBlank(po.getDeliveryBuildingLine2Address())) { shipToInfo.append(" " + po.getDeliveryBuildingLine2Address() + "\n"); } shipToInfo.append(" " + po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " " + po.getDeliveryPostalCode() + "\n"); if (StringUtils.isNotBlank(po.getDeliveryCountryCode()) && !KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getDeliveryCountryCode())) { shipToInfo.append(" " + po.getDeliveryCountryName() + "\n"); } } // display deliveryToPhoneNumber disregard of whether receiving or delivery address is used shipToInfo.append(" " + po.getDeliveryToPhoneNumber()); /* // display deliveryToPhoneNumber based on the parameter indicator, disregard of whether receiving or delivery address is used boolean displayDeliveryPhoneNumber = SpringContext.getBean(ParameterService.class).getIndicatorParameter(PurchaseOrderDocument.class, PurapParameterConstants.DISPLAY_DELIVERY_PHONE_NUMBER_ON_PDF_IND); if (displayDeliveryPhoneNumber && StringUtils.isNotBlank(po.getDeliveryToPhoneNumber())) { shipToInfo.append(" " + po.getDeliveryToPhoneNumber()); } */ p = new Paragraph(); p.add(new Chunk(" Shipping Address", ver_5_normal)); p.add(new Chunk(shipToInfo.toString(), cour_7_normal)); cell = new PdfPCell(p); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Shipping Terms\n", ver_5_normal)); if (po.getVendorShippingPaymentTerms() != null && po.getVendorShippingTitle() != null) { p.add(new Chunk(" " + po.getVendorShippingPaymentTerms().getVendorShippingPaymentTermsDescription(), cour_7_normal)); p.add(new Chunk(" - " + po.getVendorShippingTitle().getVendorShippingTitleDescription(), cour_7_normal)); } else if (po.getVendorShippingPaymentTerms() != null && po.getVendorShippingTitle() == null) { p.add(new Chunk(" " + po.getVendorShippingPaymentTerms().getVendorShippingPaymentTermsDescription(), cour_7_normal)); } else if (po.getVendorShippingTitle() != null && po.getVendorShippingPaymentTerms() == null) { p.add(new Chunk(" " + po.getVendorShippingTitle().getVendorShippingTitleDescription(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Payment Terms\n", ver_5_normal)); if (po.getVendorPaymentTerms() != null) { p.add(new Chunk(" " + po.getVendorPaymentTerms().getVendorPaymentTermsDescription(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Delivery Required By\n", ver_5_normal)); if (po.getDeliveryRequiredDate() != null && po.getDeliveryRequiredDateReason() != null) { p.add(new Chunk(" " + sdf.format(po.getDeliveryRequiredDate()), cour_7_normal)); p.add(new Chunk(" - " + po.getDeliveryRequiredDateReason().getDeliveryRequiredDateReasonDescription(), cour_7_normal)); } else if (po.getDeliveryRequiredDate() != null && po.getDeliveryRequiredDateReason() == null) { p.add(new Chunk(" " + sdf.format(po.getDeliveryRequiredDate()), cour_7_normal)); } else if (po.getDeliveryRequiredDate() == null && po.getDeliveryRequiredDateReason() != null) { p.add(new Chunk(" " + po.getDeliveryRequiredDateReason().getDeliveryRequiredDateReasonDescription(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" ", ver_5_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); // Nested table for Order Date, etc. float[] nestedInfoWidths = { 0.50f, 0.50f }; PdfPTable nestedInfoTable = new PdfPTable(nestedInfoWidths); nestedInfoTable.setSplitLate(false); p = new Paragraph(); p.add(new Chunk(" Order Date\n", ver_5_normal)); String orderDate = ""; if (po.getPurchaseOrderInitialOpenTimestamp() != null) { orderDate = sdf.format(po.getPurchaseOrderInitialOpenTimestamp()); } else { // This date isn't set until the first time this document is printed, so will be null the first time; use today's date. orderDate = sdf.format(getDateTimeService().getCurrentSqlDate()); } p.add(new Chunk(" " + orderDate, cour_7_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Customer #\n", ver_5_normal)); if (po.getVendorCustomerNumber() != null) { p.add(new Chunk(" " + po.getVendorCustomerNumber(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Delivery Instructions\n", ver_5_normal)); if (StringUtils.isNotBlank(po.getDeliveryInstructionText())) { p.add(new Chunk(" " + po.getDeliveryInstructionText(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Contract ID\n", ver_5_normal)); if (po.getVendorContract() != null) { p.add(new Chunk(po.getVendorContract().getVendorContractName(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); // Add the nestedInfoTable to the infoTable cell = new PdfPCell(nestedInfoTable); cell.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.addCell(cell); StringBuffer billToInfo = new StringBuffer(); billToInfo.append("\n"); billToInfo.append(" " + po.getBillingName() + "\n"); billToInfo.append(" " + po.getBillingLine1Address() + "\n"); if (po.getBillingLine2Address() != null) { billToInfo.append(" " + po.getBillingLine2Address() + "\n"); } billToInfo.append(" " + po.getBillingCityName() + ", " + po.getBillingStateCode() + " " + po.getBillingPostalCode() + "\n"); if (po.getBillingPhoneNumber() != null) { billToInfo.append(" " + po.getBillingPhoneNumber()); } if (po.getBillingEmailAddress() != null) { billToInfo.append("\n " + po.getBillingEmailAddress()); } p = new Paragraph(); p.add(new Chunk(" Billing Address", ver_5_normal)); p.add(new Chunk(" " + billToInfo.toString(), cour_7_normal)); p.add(new Chunk("\n Invoice status inquiry: " + statusInquiryUrl, ver_6_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); document.add(infoTable); PdfPTable notesStipulationsTable = new PdfPTable(1); notesStipulationsTable.setWidthPercentage(100); notesStipulationsTable.setSplitLate(false); p = new Paragraph(); p.add(new Chunk(" Vendor Note(s)\n", ver_5_normal)); if (po.getVendorNoteText() != null) { p.add(new Chunk(" " + po.getVendorNoteText() + "\n", cour_7_normal)); } PdfPCell tableCell = new PdfPCell(p); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableCell.setVerticalAlignment(Element.ALIGN_TOP); notesStipulationsTable.addCell(tableCell); p = new Paragraph(); p.add(new Chunk(" Vendor Stipulations and Information\n", ver_5_normal)); if ((po.getPurchaseOrderBeginDate() != null) && (po.getPurchaseOrderEndDate() != null)) { p.add(new Chunk(" Order in effect from " + sdf.format(po.getPurchaseOrderBeginDate()) + " to " + sdf.format(po.getPurchaseOrderEndDate()) + ".\n", cour_7_normal)); } Collection<PurchaseOrderVendorStipulation> vendorStipulationsList = po.getPurchaseOrderVendorStipulations(); if (vendorStipulationsList.size() > 0) { StringBuffer vendorStipulations = new StringBuffer(); for (PurchaseOrderVendorStipulation povs : vendorStipulationsList) { vendorStipulations.append(" " + povs.getVendorStipulationDescription() + "\n"); } p.add(new Chunk(" " + vendorStipulations.toString(), cour_7_normal)); } tableCell = new PdfPCell(p); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableCell.setVerticalAlignment(Element.ALIGN_TOP); notesStipulationsTable.addCell(tableCell); document.add(notesStipulationsTable); // ***** Items table ***** LOG.debug("createPdf() items table started."); float[] itemsWidths = { 0.07f, 0.1f, 0.07f, 0.45f, 0.15f, 0.15f }; if (!po.isUseTaxIndicator()) { itemsWidths = ArrayUtils.add(itemsWidths, 0.14f); itemsWidths = ArrayUtils.add(itemsWidths, 0.15f); } PdfPTable itemsTable = new PdfPTable(itemsWidths.length); // itemsTable.setCellsFitPage(false); With this set to true a large cell will // skip to the next page. The default Table behaviour seems to be what we want: // start the large cell on the same page and continue it to the next. itemsTable.setWidthPercentage(100); itemsTable.setWidths(itemsWidths); itemsTable.setSplitLate(false); tableCell = new PdfPCell(new Paragraph("Item\nNo.", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Quantity", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("UOM", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Description", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Unit Cost", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Extended Cost", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); if (!po.isUseTaxIndicator()) { tableCell = new PdfPCell(new Paragraph("Tax Amount", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Total Amount", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); } Collection<PurchaseOrderItem> itemsList = new ArrayList(); if (isRetransmit) { itemsList = retransmitItems; } else { itemsList = po.getItems(); } for (PurchaseOrderItem poi : itemsList) { if ((poi.getItemType() != null) && (poi.getItemType().isLineItemIndicator() || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)) && lineItemDisplaysOnPdf(poi)) { String description = (poi.getItemCatalogNumber() != null) ? poi.getItemCatalogNumber().trim() + " - " : ""; description = description + ((poi.getItemDescription() != null) ? poi.getItemDescription().trim() : ""); if (StringUtils.isNotBlank(description)) { if (poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE)) { // If this is a full order discount or trade-in item, we add the item type description to the description. description = poi.getItemType().getItemTypeDescription() + " - " + description; } } // Above the line item types items display the line number; other types don't. if (poi.getItemType().isLineItemIndicator()) { tableCell = new PdfPCell(new Paragraph(poi.getItemLineNumber().toString(), cour_7_normal)); } else { tableCell = new PdfPCell(new Paragraph(" ", cour_7_normal)); } tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " "; tableCell = new PdfPCell(new Paragraph(quantity, cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph(poi.getItemUnitOfMeasureCode(), cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph(" " + description, cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); itemsTable.addCell(tableCell); String unitPrice = poi.getItemUnitPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString(); tableCell = new PdfPCell(new Paragraph(unitPrice + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); tableCell = new PdfPCell( new Paragraph(numberFormat.format(poi.getExtendedPrice()) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); if (!po.isUseTaxIndicator()) { KualiDecimal taxAmount = poi.getItemTaxAmount(); taxAmount = taxAmount == null ? KualiDecimal.ZERO : taxAmount; tableCell = new PdfPCell(new Paragraph(numberFormat.format(taxAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); tableCell = new PdfPCell( new Paragraph(numberFormat.format(poi.getTotalAmount()) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); } } } // Blank line before totals itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); if (!po.isUseTaxIndicator()) { itemsTable.addCell(" "); itemsTable.addCell(" "); } //Next Line if (!po.isUseTaxIndicator()) { //Print Total Prior to Tax itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = new PdfPCell(new Paragraph("Total Prior to Tax: ", ver_10_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); itemsTable.addCell(tableCell); itemsTable.addCell(" "); KualiDecimal totalDollarAmount = new KualiDecimal(BigDecimal.ZERO); if (po instanceof PurchaseOrderRetransmitDocument) { totalDollarAmount = ((PurchaseOrderRetransmitDocument) po) .getTotalPreTaxDollarAmountForRetransmit(); } else { totalDollarAmount = po.getTotalPreTaxDollarAmount(); } tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); //Print Total Tax itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = new PdfPCell(new Paragraph("Total Tax: ", ver_10_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); itemsTable.addCell(tableCell); itemsTable.addCell(" "); totalDollarAmount = new KualiDecimal(BigDecimal.ZERO); if (po instanceof PurchaseOrderRetransmitDocument) { totalDollarAmount = ((PurchaseOrderRetransmitDocument) po).getTotalTaxDollarAmountForRetransmit(); } else { totalDollarAmount = po.getTotalTaxAmount(); } tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); } // Totals line; first 3 cols empty itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); if (!po.isUseTaxIndicator()) { itemsTable.addCell(" "); itemsTable.addCell(" "); } tableCell = new PdfPCell(new Paragraph("Total order amount: ", ver_10_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); itemsTable.addCell(tableCell); itemsTable.addCell(" "); KualiDecimal totalDollarAmount = new KualiDecimal(BigDecimal.ZERO); if (po instanceof PurchaseOrderRetransmitDocument) { totalDollarAmount = ((PurchaseOrderRetransmitDocument) po).getTotalDollarAmountForRetransmit(); } else { totalDollarAmount = po.getTotalDollarAmount(); } tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); // Blank line after totals itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); if (!po.isUseTaxIndicator()) { itemsTable.addCell(" "); itemsTable.addCell(" "); } document.add(itemsTable); // Contract language. LOG.debug("createPdf() contract language started."); document.add(new Paragraph(contractLanguage, ver_6_normal)); document.add(new Paragraph("\n", ver_6_normal)); // ***** Signatures table ***** LOG.debug("createPdf() signatures table started."); float[] signaturesWidths = { 0.30f, 0.70f }; PdfPTable signaturesTable = new PdfPTable(signaturesWidths); signaturesTable.setWidthPercentage(100); signaturesTable.setHorizontalAlignment(Element.ALIGN_CENTER); signaturesTable.setSplitLate(false); // Director signature and "for more info" line; only on APOs if (po.getPurchaseOrderAutomaticIndicator()) { // Empty cell. cell = new PdfPCell(new Paragraph(" ", cour_7_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); //boolean displayRequestorEmail = true; //SpringContext.getBean(ParameterService.class).getIndicatorParameter(PurchaseOrderDocument.class, PurapParameterConstants.DISPLAY_REQUESTOR_EMAIL_ADDRESS_ON_PDF_IND); if (StringUtils.isBlank(po.getInstitutionContactName()) || StringUtils.isBlank(po.getInstitutionContactPhoneNumber()) || StringUtils.isBlank(po.getInstitutionContactEmailAddress())) { //String emailAddress = displayRequestorEmail ? " " + po.getRequestorPersonEmailAddress() : ""; //p = new Paragraph("For more information contact: " + po.getRequestorPersonName() + " " + po.getRequestorPersonPhoneNumber() + emailAddress, cour_7_normal); p = new Paragraph( "For more information contact: " + po.getRequestorPersonName() + " " + po.getRequestorPersonPhoneNumber() + " " + po.getRequestorPersonEmailAddress(), cour_7_normal); } else { //String emailAddress = displayRequestorEmail ? " " + po.getInstitutionContactEmailAddress() : ""; //p = new Paragraph("For more information contact: " + po.getInstitutionContactName() + " " + po.getInstitutionContactPhoneNumber() + emailAddress, cour_7_normal); p = new Paragraph("For more information contact: " + po.getInstitutionContactName() + " " + po.getInstitutionContactPhoneNumber() + " " + po.getInstitutionContactEmailAddress(), cour_7_normal); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(0); signaturesTable.addCell(cell); Image directorSignature = null; if (StringUtils.isNotBlank(directorSignatureImage)) { try { directorSignature = Image.getInstance(directorSignatureImage); } catch (FileNotFoundException e) { LOG.info("The director signature image [" + directorSignatureImage + "] is not available. Defaulting to the default image."); } } if (directorSignature == null) { // an empty cell if the contract manager signature image is not available. cell = new PdfPCell(); } else { directorSignature.scalePercent(30, 30); cell = new PdfPCell(directorSignature, false); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorderWidth(0); signaturesTable.addCell(cell); // Empty cell. cell = new PdfPCell(new Paragraph(" ", cour_7_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); } // Director name and title; on every pdf. p = new Paragraph(); if (LOG.isDebugEnabled()) { LOG.debug("createPdf() directorName parameter: " + directorName); } if (po.getPurchaseOrderAutomaticIndicator()) { // The signature is on the pdf; use small font. p.add(new Chunk(directorName, ver_6_normal)); } else { // The signature isn't on the pdf; use larger font. p.add(new Chunk(directorName, ver_10_normal)); } p.add(new Chunk("\n" + directorTitle, ver_4_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setBorderWidth(0); signaturesTable.addCell(cell); // Contract manager signature, name and phone; only on non-APOs if (!po.getPurchaseOrderAutomaticIndicator()) { Image contractManagerSignature = null; if (StringUtils.isNotBlank(contractManagerSignatureImage)) { try { contractManagerSignature = Image.getInstance(contractManagerSignatureImage); } catch (IOException e) { LOG.info("The contract manager image [" + contractManagerSignatureImage + "] is not available. Defaulting to the default image."); } } if (contractManagerSignature == null) { // an empty cell if the contract manager signature image is not available. cell = new PdfPCell(); } else { contractManagerSignature.scalePercent(15, 15); cell = new PdfPCell(contractManagerSignature, false); } cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorderWidth(0); signaturesTable.addCell(cell); // Empty cell. cell = new PdfPCell(new Paragraph(" ", ver_10_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); cell = new PdfPCell(new Paragraph(po.getContractManager().getContractManagerName() + " " + po.getContractManager().getContractManagerPhoneNumber(), cour_7_normal)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setBorderWidth(0); signaturesTable.addCell(cell); } else { // Empty cell. cell = new PdfPCell(new Paragraph(" ", ver_10_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); } document.add(signaturesTable); document.close(); LOG.debug("createPdf()pdf document closed."); }
From source file:taximetro.main.java
private void jButtonfinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonfinActionPerformed //Establecer de nuevo parametros de los botones de fin y comienzo carrera. jButtonfin.setEnabled(false);//from www . j a v a 2s . c o m jButtoncomienzo.setEnabled(true); //Parar el contador. cronometro.stop(); //Darle formato HH:mm:ss al resultado del contador. String tiempotexto = DurationFormatUtils.formatDuration(cronometro.getTime(), "HH:mm:ss"); //Guardar la hora de fin de carrera al presionar botn de fin carrera. Calendar tiempo = Calendar.getInstance(zona); //Dar formato a la hora de fin de carrera al presionar el boton de fin. DateFormat formatohoras = DateFormat.getTimeInstance(DateFormat.MEDIUM); String horafincarrera = formatohoras.format(tiempo.getTimeInMillis()); //Dar formato a la fecha. DateFormat formatotiempo = DateFormat.getDateInstance(DateFormat.LONG); String fechatexto = formatotiempo.format(tiempo.getTime()); //Calcular el coste del trayecto, a partir del tiempo del contador. float coste = (cronometro.getTime() / 1000) * (TARIFA / 60); float iva = coste * 0.21F; float costetotal = coste * 1.21F; //Dar formato al coste del trayecto. NumberFormat formatoeuro = NumberFormat.getCurrencyInstance(zona); //Escribir en el area de texto todos los parmetros. jTextAreaticket.append("TICKET:\n \n"); jTextAreaticket.append("=================\n"); jTextAreaticket.append("Ticket N: " + textoticket + " .\n"); jTextAreaticket.append("Fecha:\n" + fechatexto + " .\n\n"); jTextAreaticket.append("Hora de comienzo de carrera: " + horacomienzocarrera + " .\n"); jTextAreaticket.append("Hora de fin de carrera: " + horafincarrera + " .\n"); jTextAreaticket.append("El tiempo del trayecto es: " + tiempotexto + " .\n\n\n"); jTextAreaticket.append("Importe: " + formatoeuro.format(coste) + " .\n"); jTextAreaticket.append("IVA: " + formatoeuro.format(iva) + " .\n"); jTextAreaticket.append("Importe Total: " + formatoeuro.format(costetotal) + " .\n"); }
From source file:org.rythmengine.utils.S.java
/** * Format give data into currency using locale info from the engine specified * /* ww w . j av a 2 s . c o m*/ * <p>The method accept any data type. When <code>null</code> is found then * <code>NullPointerException</code> will be thrown out; if an <code>Number</code> * is passed in, it will be type cast to <code>Number</code>; otherwise * a <code>Double.valueOf(data.toString())</code> is used to find out * the number</p> * * @param template * @param data * @param currencyCode * @param locale * @return the currency */ public static String formatCurrency(ITemplate template, Object data, String currencyCode, Locale locale) { if (null == data) throw new NullPointerException(); Number number; if (data instanceof Number) { number = (Number) data; } else { number = Double.parseDouble(data.toString()); } if (null == locale) locale = I18N.locale(template); Currency currency = null == currencyCode ? Currency.getInstance(locale) : Currency.getInstance(currencyCode); NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale); numberFormat.setCurrency(currency); numberFormat.setMaximumFractionDigits(currency.getDefaultFractionDigits()); String s = numberFormat.format(number); s = s.replace(currency.getCurrencyCode(), currency.getSymbol(locale)); return s; }
From source file:pagecode.RPTs.OffenceUtil.java
private void processOffenceInfoOld() { logger.info("In OffenceUtil::processOffenceInfoOld"); String selectSql = null;// w w w.j a v a 2s. co m Connection iicfConnection = ReportsConnectionManager.getIICFConnection(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; if (null != iicfConnection && true == isOffenceNumberValid()) { try { String dbLetterPrefix; //If Offence is Red Light Camera or parking tickets then use //the "P" database [The photo radar DB] in IMS i.e. "P" tables in IICF if ("997".equals(jurisdictionNumber) || "901".equals(jurisdictionNumber)) { dbLetterPrefix = "P"; } else { dbLetterPrefix = "O"; } selectSql = "SELECT " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_CRT_OFC AS OFCS_CRT_OFC, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_JRSDCTN_NUM AS OFCS_JRSDCTN_NUM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_YY AS OFCS_INFO_YY, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_PREFIX AS OFCS_INFO_PREFIX, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_SUFFIX AS OFCS_INFO_SUFFIX, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_TRL_LANG_CD AS OFCS_TRL_LANG_CD, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INTERP_LANG_CD AS OFCS_INTERP_LANG_CD, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_CNT_NUM AS OCNT_CNT_NUM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_OFNC_DT AS OCNT_OFNC_DT, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_OFCR_BDG_NUM AS OFCS_OFCR_BDG_NUM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_LIC_PLATE_NUM AS OFCS_LIC_PLATE_NUM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_DRVR_LIC_PART_1 AS OFCS_DRVR_LIC_PART_1, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_DRVR_LIC_PART_2 AS OFCS_DRVR_LIC_PART_2, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_DRVR_LIC_PART_3 AS OFCS_DRVR_LIC_PART_3, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_ENF_AGCY AS OFCS_ENF_AGCY, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_SEX_CD AS OFCS_SEX_CD, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_BRTH_DT AS OFCS_BRTH_DT, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_CVOR_NUM AS OCNT_CVOR_NUM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_ENF_AGCY_DIV_CD AS OFCS_ENF_AGCY_DIV_CD, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_GVN_NM AS OFCS_GVN_NM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INIT AS OFCS_INIT, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_SRNM AS OFCS_SRNM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_ADDR_ST AS OFCS_ADDR_ST, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_ADDR_CTY AS OFCS_ADDR_CTY, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_ADDR_PROV AS OFCS_ADDR_PROV, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_ADDR_PSTL_CD AS OFCS_ADDR_PSTL_CD, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_TM AS OCNT_TM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_LOCN_DESC AS OCNT_LOCN_DESC, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_STATU_CD AS OCNT_STATU_CD, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_SCTN_ID AS OCNT_SCTN_ID, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_SUB_SCTN_ID AS OCNT_SUB_SCTN_ID, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_PARA_ID AS OCNT_PARA_ID, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_OFNC_CLAS_ID AS OCNT_OFNC_CLAS_ID, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_BYLAW_CD AS OCNT_BYLAW_CD " + "FROM " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT " + "WHERE " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "CNT_CNT_NUM = '0001' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_CRT_OFC = '" + courtOfficeId + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_JRSDCTN_NUM = '" + jurisdictionNumber + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_YY = '" + infoYear + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_PREFIX = '" + infoPrefix + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_SUFFIX = '" + infoSuffix + "' " + " " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "FCS_CRT_OFC = '" + courtOfficeId + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "FCS_JRSDCTN_NUM = '" + jurisdictionNumber + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "FCS_INFO_YY = '" + infoYear + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "FCS_INFO_PREFIX = '" + infoPrefix + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "CNT." + dbLetterPrefix + "FCS_INFO_SUFFIX = '" + infoSuffix + "' "; selectSql += " "; logger.info("+++++SQL: " + selectSql); //TODO remove this if (true) { //return; } preparedStatement = iicfConnection.prepareStatement(selectSql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); resultSet = preparedStatement.executeQuery(); resultSet.last(); int resultSetCount = resultSet.getRow(); logger.info("resultSetCount: " + resultSetCount); resultSet.beforeFirst(); if (resultSetCount != 1) { throw new Exception("Offence NOT found or MORE than one found!!!"); } else { //move to first record resultSet.next(); paramOffenceNumber = ""; if (null != resultSet.getString("OFCS_CRT_OFC")) { paramOffenceNumber = resultSet.getString("OFCS_CRT_OFC").trim() + " "; } if (null != resultSet.getString("OFCS_JRSDCTN_NUM")) { paramOffenceNumber += resultSet.getString("OFCS_JRSDCTN_NUM").trim() + " "; } if (null != resultSet.getString("OFCS_INFO_YY")) { paramOffenceNumber += resultSet.getString("OFCS_INFO_YY").trim() + " "; } if (null != resultSet.getString("OFCS_INFO_PREFIX")) { paramOffenceNumber += resultSet.getString("OFCS_INFO_PREFIX").trim() + " "; } if (null != resultSet.getString("OFCS_INFO_SUFFIX")) { paramOffenceNumber += resultSet.getString("OFCS_INFO_SUFFIX").trim(); } if (null != resultSet.getString("OFCS_TRL_LANG_CD")) { String langChar = resultSet.getString("OFCS_TRL_LANG_CD").trim(); isEnglish = (true == langChar.equalsIgnoreCase("F") ? false : true); } //NOTE: if runAsStandAlone == true then assume it is always French if (true == runAsStandAlone) { this.isEnglish = false; } paramInterpreterLanguage = ""; if (null != resultSet.getString("OFCS_INTERP_LANG_CD") && !resultSet.getString("OFCS_INTERP_LANG_CD").trim().equals("")) { paramInterpreterLanguage = resultSet.getString("OFCS_INTERP_LANG_CD").trim(); InterpreterLanguageUtil interpreterLanguageUtil = new InterpreterLanguageUtil(); interpreterLanguageUtil.setIsEnglish(this.isEnglish()); interpreterLanguageUtil.setInterpreterLanguageUtil(paramInterpreterLanguage); paramInterpreterLanguage = interpreterLanguageUtil.getInterpreterLanguageDesc(); } IconDateUtil offenceDateUtil = new IconDateUtil(); offenceDateUtil.setIsEnglish(this.isEnglish); paramOffenceDate = ""; if (null != resultSet.getString("OCNT_OFNC_DT")) { offenceDateUtil.setIconDate(resultSet.getString("OCNT_OFNC_DT").trim()); paramOffenceDate = offenceDateUtil.getDateWithSlashes(); } paramOfficerNumber = ""; if (null != resultSet.getString("OFCS_OFCR_BDG_NUM")) { paramOfficerNumber = resultSet.getString("OFCS_OFCR_BDG_NUM").trim(); } paramDriversLicenseNumber = ""; if (null != resultSet.getString("OFCS_DRVR_LIC_PART_1") && null != resultSet.getString("OFCS_DRVR_LIC_PART_2") && null != resultSet.getString("OFCS_DRVR_LIC_PART_1")) { paramDriversLicenseNumber = resultSet.getString("OFCS_DRVR_LIC_PART_1").trim() + "-" + resultSet.getString("OFCS_DRVR_LIC_PART_2").trim() + "-" + resultSet.getString("OFCS_DRVR_LIC_PART_3").trim(); } paramPlateNumber = ""; if (null != resultSet.getString("OFCS_LIC_PLATE_NUM")) { paramPlateNumber = resultSet.getString("OFCS_LIC_PLATE_NUM").trim(); } paramEnforcementAgency = ""; if (null != resultSet.getString("OFCS_ENF_AGCY")) { paramEnforcementAgency = resultSet.getString("OFCS_ENF_AGCY").trim(); } paramSex = ""; if (null != resultSet.getString("OFCS_SEX_CD")) { paramSex = resultSet.getString("OFCS_SEX_CD").trim(); } paramDateOfBirth = ""; IconDateUtil dateOfBirthUtil = new IconDateUtil(); if (null != resultSet.getString("OFCS_BRTH_DT")) { dateOfBirthUtil.setIconDate(resultSet.getString("OFCS_BRTH_DT").trim()); paramDateOfBirth = dateOfBirthUtil.getDateWithSlashes(); } paramCVOR = ""; if (null != resultSet.getString("OCNT_CVOR_NUM")) { paramCVOR = resultSet.getString("OCNT_CVOR_NUM").trim(); } paramUnit = ""; if (null != resultSet.getString("OFCS_ENF_AGCY_DIV_CD")) { paramUnit = resultSet.getString("OFCS_ENF_AGCY_DIV_CD").trim(); } paramOffenderFullName = ""; if (null != resultSet.getString("OFCS_GVN_NM")) { paramOffenderFullName = resultSet.getString("OFCS_GVN_NM").trim() + " "; } if (null != resultSet.getString("OFCS_INIT")) { paramOffenderFullName += resultSet.getString("OFCS_INIT").trim() + " "; } if (null != resultSet.getString("OFCS_SRNM")) { paramOffenderFullName += resultSet.getString("OFCS_SRNM").trim(); } paramAddressLine1 = ""; if (null != resultSet.getString("OFCS_ADDR_ST")) { paramAddressLine1 = resultSet.getString("OFCS_ADDR_ST").trim(); } paramAddressLine2 = ""; if (null != resultSet.getString("OFCS_ADDR_CTY")) { paramAddressLine2 = resultSet.getString("OFCS_ADDR_CTY").trim(); } if (null != resultSet.getString("OFCS_ADDR_PROV")) { paramAddressLine2 += ", " + resultSet.getString("OFCS_ADDR_PROV").trim(); } if (null != resultSet.getString("OFCS_ADDR_PSTL_CD")) { paramAddressLine3 = resultSet.getString("OFCS_ADDR_PSTL_CD").trim(); } paramOffenceDay = paramOffenceMonth = paramOffenceYear = ""; if (null != resultSet.getString("OCNT_OFNC_DT")) { offenceDateUtil.setIconDate(resultSet.getString("OCNT_OFNC_DT").trim()); paramOffenceDay = offenceDateUtil.getStrDay(); paramOffenceMonth = offenceDateUtil.getStrMonth(); paramOffenceYear = offenceDateUtil.getStrYear(); } //offenceDateUtil = iconDateUtil; paramOffenceTime = ""; if (null != resultSet.getString("OCNT_TM")) { offenceDateUtil.setIconTime(resultSet.getString("OCNT_TM").trim()); paramOffenceTime = offenceDateUtil.getFormatedTime(); } paramOffenceLocation = ""; if (null != resultSet.getString("OCNT_LOCN_DESC")) { paramOffenceLocation = resultSet.getString("OCNT_LOCN_DESC").trim(); } String tempOCNT_STATU_CD, tempOCNT_SCTN_ID, tempOCNT_SUB_SCTN_ID, tempOCNT_PARA_ID, tempOCNT_OFNC_CLAS_ID, tempOCNT_BYLAW_CD; tempOCNT_STATU_CD = ""; if (null != resultSet.getString("OCNT_STATU_CD")) { tempOCNT_STATU_CD = resultSet.getString("OCNT_STATU_CD").trim(); } tempOCNT_SCTN_ID = ""; if (null != resultSet.getString("OCNT_SCTN_ID")) { tempOCNT_SCTN_ID = resultSet.getString("OCNT_SCTN_ID").trim(); } tempOCNT_SUB_SCTN_ID = null; if (null != resultSet.getString("OCNT_SUB_SCTN_ID")) { tempOCNT_SUB_SCTN_ID = resultSet.getString("OCNT_SUB_SCTN_ID").trim(); } tempOCNT_PARA_ID = null; if (null != resultSet.getString("OCNT_PARA_ID")) { tempOCNT_PARA_ID = resultSet.getString("OCNT_PARA_ID").trim(); } tempOCNT_OFNC_CLAS_ID = null; if (null != resultSet.getString("OCNT_OFNC_CLAS_ID")) { tempOCNT_OFNC_CLAS_ID = resultSet.getString("OCNT_OFNC_CLAS_ID").trim(); } tempOCNT_BYLAW_CD = null; if (null != resultSet.getString("OCNT_BYLAW_CD")) { tempOCNT_BYLAW_CD = resultSet.getString("OCNT_BYLAW_CD").trim(); } OffenceStatuteDescriptionUtil offenceStatuteDescriptionUtil = new OffenceStatuteDescriptionUtil(); offenceStatuteDescriptionUtil.setIsEnglish(this.isEnglish); offenceStatuteDescriptionUtil.setOffenceStatuteDescriptionUtil(tempOCNT_STATU_CD, tempOCNT_SCTN_ID, tempOCNT_SUB_SCTN_ID, tempOCNT_PARA_ID, tempOCNT_OFNC_CLAS_ID, tempOCNT_BYLAW_CD, offenceDateUtil); paramOffenceDesc = offenceStatuteDescriptionUtil.getOffenceDescription(); paramOffenceStatue = offenceStatuteDescriptionUtil.getStatuteDescription(); paramOffenceSection = tempOCNT_SCTN_ID; if (null != tempOCNT_SUB_SCTN_ID && !tempOCNT_SUB_SCTN_ID.equals("")) { paramOffenceSection += "(" + tempOCNT_SUB_SCTN_ID + ")"; } if (null != tempOCNT_PARA_ID && !tempOCNT_PARA_ID.equals("")) { paramOffenceSection += "(" + tempOCNT_PARA_ID + ")"; } if (null != tempOCNT_OFNC_CLAS_ID && !tempOCNT_OFNC_CLAS_ID.equals("")) { paramOffenceSection += "(" + tempOCNT_OFNC_CLAS_ID + ")"; } //clean up for reuse if (null != preparedStatement) { preparedStatement.close(); preparedStatement = null; } if (null != resultSet) { resultSet.close(); resultSet = null; } selectSql = "SELECT " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_CRT_OFC AS OFCS_CRT_OFC, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_JRSDCTN_NUM AS OFCS_JRSDCTN_NUM, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_YY AS OFCS_INFO_YY, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_PREFIX AS OFCS_INFO_PREFIX, " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_SUFFIX AS OFCS_INFO_SUFFIX, " + " " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_TTL_FINE_AMT, " + " " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_PRE_PD_FINE_TTL_AMT, " + " " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_PRE_PD_COST_TTL_AMT " + "FROM " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS " + "INNER JOIN " + " " + ICON_SCHEMA_NAME + ".ICOSARRT " + " ON " + " ( " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_CRT_OFC = " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_CRT_OFC" + " ) " + " AND " + " ( " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_JRSDCTN_NUM = " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_JRSDCTN_NUM " + " ) " + " AND " + " ( " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_YY = " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_INFO_YY " + " ) " + " AND " + " ( " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_PREFIX = " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_INFO_PREFIX " + " ) " + " AND " + " ( " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_SUFFIX = " + ICON_SCHEMA_NAME + ".ICOSARRT.ARRT_INFO_SUFFIX " + " ) " + "WHERE " + " " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_CRT_OFC = '" + courtOfficeId + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_JRSDCTN_NUM = '" + jurisdictionNumber + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_YY = '" + infoYear + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_PREFIX = '" + infoPrefix + "' " + " AND " + ICON_SCHEMA_NAME + ".ICOS" + dbLetterPrefix + "FCS." + dbLetterPrefix + "FCS_INFO_SUFFIX = '" + infoSuffix + "' "; selectSql += " "; logger.info("+++++SQL: " + selectSql); preparedStatement = iicfConnection.prepareStatement(selectSql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); resultSet = preparedStatement.executeQuery(); resultSet.last(); resultSetCount = resultSet.getRow(); logger.info("resultSetCount: " + resultSetCount); resultSet.beforeFirst(); paramOffenceTotalPayable = ""; if (resultSetCount == 1) { resultSet.next(); // if(null != resultSet.getString("ARRT_TTL_FINE_AMT")){ // NumberFormat formatUS = NumberFormat.getCurrencyInstance(Locale.US); // //logger.info("formatUS: " + formatUS.format(resultSet.getDouble("ARRT_TTL_FINE_AMT")) ); // paramOffenceTotalPayable = formatUS.format(resultSet.getDouble("ARRT_TTL_FINE_AMT")); // } //ARRT_TTL_FINE_AMT, ARRT_PRE_PD_FINE_TTL_AMT, ARRT_PRE_PD_COST_TTL_AMT BigDecimal totalPayable; BigDecimal totalFineAmount = resultSet.getBigDecimal("ARRT_TTL_FINE_AMT"); BigDecimal totalPrePDFineAmount = resultSet.getBigDecimal("ARRT_PRE_PD_FINE_TTL_AMT"); BigDecimal totalPrePDCostAmount = resultSet.getBigDecimal("ARRT_PRE_PD_COST_TTL_AMT"); //these will never be null so NO need to check for null totalPayable = totalPrePDFineAmount.add(totalPrePDCostAmount); //IF(ARRT_PRE_PD_FINE_TTL_AMT + ARRT_PRE_PD_COST_TTL_AMT < 0) THEN if (totalPayable.compareTo(new BigDecimal("0.0")) < 0) { totalPayable = totalFineAmount; } NumberFormat formatUS = NumberFormat.getCurrencyInstance(Locale.US); paramOffenceTotalPayable = formatUS.format(totalPayable.doubleValue()); } } // if(resultSetCount != 1) } catch (SQLException sqlException) { sqlException.printStackTrace(); } catch (Exception e) { paramOffenceNumber = ""; paramOffenceDate = ""; paramOfficerNumber = ""; paramDriversLicenseNumber = ""; paramPlateNumber = ""; paramEnforcementAgency = ""; paramSex = ""; paramDateOfBirth = ""; paramCVOR = ""; paramUnit = ""; paramOffenderFullName = ""; paramAddressLine1 = ""; paramAddressLine2 = ""; paramAddressLine3 = ""; paramOffenceDay = ""; paramOffenceMonth = ""; paramOffenceYear = ""; paramOffenceTime = ""; paramOffenceLocation = ""; paramOffenceDesc = ""; paramOffenceStatue = ""; paramOffenceSection = ""; paramOffenceTotalPayable = ""; paramInterpreterLanguage = ""; e.printStackTrace(); } finally { // setDiscreteParameterValue(this, "paramOffenceNumber", "", paramOffenceNumber); // setDiscreteParameterValue(this, "paramOffenceDate", "", paramOffenceDate); // setDiscreteParameterValue(this, "paramOfficerNumber", "", paramOfficerNumber); // setDiscreteParameterValue(this, "paramDriversLicenseNumber", "", paramDriversLicenseNumber); // setDiscreteParameterValue(this, "paramPlateNumber", "", paramPlateNumber); // setDiscreteParameterValue(this, "paramEnforcementAgency", "", paramEnforcementAgency); // setDiscreteParameterValue(this, "paramSex", "", paramSex); // setDiscreteParameterValue(this, "paramDateOfBirth", "", paramDateOfBirth); // setDiscreteParameterValue(this, "paramCVOR", "", paramCVOR); // setDiscreteParameterValue(this, "paramUnit", "", paramUnit); // setDiscreteParameterValue(this, "paramOffenderFullName", "", paramOffenderFullName); // setDiscreteParameterValue(this, "paramAddressLine1", "", paramAddressLine1); // setDiscreteParameterValue(this, "paramAddressLine2", "", paramAddressLine2); // setDiscreteParameterValue(this, "paramAddressLine3", "", paramAddressLine3); // setDiscreteParameterValue(this, "paramOffenceDay", "", paramOffenceDay); // setDiscreteParameterValue(this, "paramOffenceMonth", "", paramOffenceMonth); // setDiscreteParameterValue(this, "paramOffenceYear", "", paramOffenceYear); // setDiscreteParameterValue(this, "paramOffenceTime", "", paramOffenceTime); // setDiscreteParameterValue(this, "paramOffenceLocation", "", paramOffenceLocation); // setDiscreteParameterValue(this, "paramOffenceDesc", "", paramOffenceDesc); // setDiscreteParameterValue(this, "paramOffenceStatue", "", paramOffenceStatue); // setDiscreteParameterValue(this, "paramOffenceSection", "", paramOffenceSection); // setDiscreteParameterValue(this, "paramOffenceTotalPayable", "", paramOffenceTotalPayable); // setDiscreteParameterValue(this, "paramTrialDay", "", paramTrialDay); // setDiscreteParameterValue(this, "parmaTrialMonth", "", parmaTrialMonth); // setDiscreteParameterValue(this, "paramTrailYear", "", paramTrailYear); // setDiscreteParameterValue(this, "paramTrailTimeHour", "", paramTrailTimeHour); // setDiscreteParameterValue(this, "paramTrailLocation", "", paramTrailLocationCourtOfficeId); // setDiscreteParameterValue(this, "paramIssuedAt", "", paramIssuedAt); // setDiscreteParameterValue(this, "paramIssuedDay", "", paramIssuedDay); // setDiscreteParameterValue(this, "paramIssuedMonth", "", paramIssuedMonth); // setDiscreteParameterValue(this, "paramIssuedYear", "", paramIssuedYear); // //Modified Oct 17, 2007 // setDiscreteParameterValue(this, "paramFormNumberLabel", "", paramFormNumberLabel); try { if (null != preparedStatement) { preparedStatement.close(); preparedStatement = null; } if (null != iicfConnection) { iicfConnection.close(); iicfConnection = null; } } catch (SQLException e1) { } } //try } //if(null != iicfConnection && true == isOffenceNumberValid()) }
From source file:com.MainFiles.Functions.java
public String fn_getAgentEODTransactions(String strAgentID, String strTerminalID, String intID) throws SQLException { String strResponse = ""; String SQL, sqlQuery = ""; String strTotalcredit = ""; String strdate = ""; double amount = 0; String strStatementPrinting = ""; String strTotaldebits = ""; int i = 1;//from w ww. j ava 2s .com Connection dbConnection = connections.getDBConnection(ECSERVER, ECDB, ECUSER, ECPASSWORD); try { NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "tz")); String strStoredProcedure = "{call SP_DAILY_TRANSACTIONS(?,?)}"; CallableStatement callableStatement = dbConnection.prepareCall(strStoredProcedure); callableStatement.setString(1, strTerminalID); callableStatement.registerOutParameter(2, java.sql.Types.VARCHAR); callableStatement.executeUpdate(); String strStatus = callableStatement.getString(2); if (strStatus.equals("1")) { String query = "select transactiontype,transactioncount,amount from tbagentsummary where serialnumber='" + strTerminalID + "'"; ResultSet rsrecordQuery = connections.ExecuteQueryReturnString(ECSERVER, query, ECPASSWORD, ECUSER, ECDB); while (rsrecordQuery.next()) { String strAmount = NumberFormat.getNumberInstance(Locale.US) .format(Double.parseDouble(rsrecordQuery.getString("AMOUNT").toString())); strStatementPrinting += " "; strStatementPrinting += PadSpaces(15, rsrecordQuery.getString("TRANSACTIONTYPE").toString(), "RIGHT"); strStatementPrinting += PadSpaces(4, rsrecordQuery.getString("TRANSACTIONCOUNT").toString(), "LEFT"); strStatementPrinting += PadSpaces(12, strAmount.replace("TZS", ""), "LEFT"); strStatementPrinting += "#"; } } String StrMerchantFloatAccount = fn_getAgentAccountNumber(strAgentID); strResponse += "AGENT ID: " + strAgentID + "#"; strResponse += "TRAN NUM: " + intID + "#"; strResponse += "ACCOUNT NUM: " + StrMerchantFloatAccount + "#"; strResponse += "--------------------------------" + "#"; strResponse += " " + "#"; strResponse += " EOD SUMMARY REPORT " + "#"; strResponse += " " + "#"; strResponse += " TRANS. COUNT AMOUNT" + "#"; strResponse += " " + "#"; strResponse += strStatementPrinting; strResponse += " " + "#"; strResponse += " " + "#"; return strResponse; } catch (Exception ex) { this.log("INFO :: Error on fn_getAgentEODTransactions " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } finally { dbConnection.close(); } return null; }
From source file:com.MainFiles.Functions.java
public String genHashDelimiterString(Map<String, String> hashDelimiterdetails, String intid) throws IOException, SQLException { NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "tz")); String hashDelimiterString = ""; String agentTeller;//from www .j ava 2 s .c o m String strMessage; String strMessage1; String strReasonDescription; String strAvailableBalance = ""; String strActualBalance = ""; String cardlesssmsmsg; String strCustomername = ""; String[] strBalance = null; String[] dataArray; String strAccountNo = ""; String strStatementPrinting = ""; String Status = ""; String Amount = ""; String Currency = ""; String CustomerName = ""; String response = ""; String invoiceNo = ""; if (hashDelimiterdetails.get("39").equals("00")) { hashDelimiterString += CustomerCopy(); } else { hashDelimiterString += AgentCopy(); } hashDelimiterString += this.strResponseHeader(hashDelimiterdetails.get("68")); hashDelimiterString += "AGENT ID: " + hashDelimiterdetails.get("104") + "#"; //Get Processing Code switch (hashDelimiterdetails.get("3")) { case "010000": //Cash Withdrawal hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": if (hashDelimiterdetails.get("48").equals("SUCCESS")) { try { strAccountNo = hashDelimiterdetails.get("102").toString(); String amountString = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))) .replace("TZS", ""); hashDelimiterString += " " + "#"; hashDelimiterString += " CASH WITHDRAWAL " + "#"; hashDelimiterString += " CASH WITHDRAWAL SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "ACCOUNT NUM: " + strAccountNo + "#"; hashDelimiterString += "AMOUNT: TZS " + amountString + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } } else { hashDelimiterString += " " + "#"; hashDelimiterString += " CASH WITHDRAWAL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CASH WITHDRAWAL FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " CASH WITHDRAWAL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CASH WITHDRAWAL FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "120000": //Merchant Payments hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": if (hashDelimiterdetails.get("48").equals("SUCCESS")) { try { strAccountNo = hashDelimiterdetails.get("102").toString(); String amountString = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))) .replace("TZS", ""); hashDelimiterString += " " + "#"; hashDelimiterString += " MERCHANT PAYMENT " + "#"; hashDelimiterString += " MERCHANT PAYMENT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "ACCOUNT NUM: " + strAccountNo + "#"; hashDelimiterString += "AMOUNT: TZS " + amountString + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } } else { hashDelimiterString += " " + "#"; hashDelimiterString += " MERCHANT PAYMENT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " MERCHANT PAYMENT FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " MERCHANT PAYMENT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " MERCHANT PAYMENT FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "340000": // Card Activation hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": hashDelimiterString += " " + "#"; hashDelimiterString += " CARD ACTIVATION " + "#"; hashDelimiterString += " CARD ACTIVATION SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " CARD ACTIVATION " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CARD ACTIVATION FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "320000": // Bill presentment strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("48")); switch (hashDelimiterdetails.get("39")) { case "00": switch (hashDelimiterdetails.get("100").toUpperCase()) { case "DSTV_INQ": response = getDSTVresponse(strReasonDescription); break; case "TRA_INQ": break; case "BRELA_INQ": dataArray = strReasonDescription.split("|"); Status = dataArray[1]; Amount = dataArray[3]; Currency = dataArray[4]; CustomerName = dataArray[5]; response = "STATUS: " + Status + " AMOUNT: " + Currency + " " + Amount + " CUSTOMER NAME: " + CustomerName; break; case "TPA_INQ": dataArray = strReasonDescription.split("~"); Status = dataArray[1]; Amount = dataArray[3]; Currency = dataArray[4]; CustomerName = dataArray[5]; response = "STATUS: " + Status + " AMOUNT: " + Currency + " " + Amount + " CUSTOMER NAME: " + CustomerName; break; } break; default: break; } this.SendPOSResponse(hashDelimiterString, intid); break; case "210000": // Cash Deposit hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); String amountString = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))).replace("TZS", ""); switch (hashDelimiterdetails.get("39")) { case "00": if (hashDelimiterdetails.get("48").toUpperCase().equals("SUCCESS")) { try { String strAccountNumber = hashDelimiterdetails.get("103").toString(); String RecipientName = ""; if (hashDelimiterdetails.containsKey("89")) { RecipientName = "ACC NAME:" + hashDelimiterdetails.get("89"); } else { RecipientName = "ACC NAME:" + getCustomerDetails((hashDelimiterdetails.get("103"))); } hashDelimiterString += " " + "#"; hashDelimiterString += " CASH DEPOSIT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CASH DEPOSIT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "AMOUNT: TZS " + amountString + "#"; hashDelimiterString += "TO ACCOUNT: " + (hashDelimiterdetails.get("103")) + "#"; hashDelimiterString += stringBuilder(RecipientName) + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } } else { hashDelimiterString += " " + "#"; hashDelimiterString += " CASH DEPOSIT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CASH DEPOSIT FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " CASH DEPOSIT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CASH DEPOSIT FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "310000": //Balance Inquiry hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": try { String[] strBal = hashDelimiterdetails.get("54").split("\\|"); String strAccountNumber = hashDelimiterdetails.get("102").toString(); strAvailableBalance = formatter.format(Double.valueOf(strBal[0])).replace("TZS", ""); strActualBalance = formatter.format(Double.valueOf(strBal[1])).replace("TZS", ""); hashDelimiterString += " " + "#"; hashDelimiterString += " BALANCE ENQUIRY " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "ACCOUNT NUM: " + (hashDelimiterdetails.get("102")) + "#"; hashDelimiterString += "AVAIL BALANCE: TZS " + strAvailableBalance + "#"; hashDelimiterString += "ACTUAL BALANCE:TZS " + strActualBalance + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " BALANCE ENQUIRY " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " BALANCE ENQUIRY FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "300000": // Agent balances hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": try { String[] strBal = hashDelimiterdetails.get("54").split("\\|"); String strAccountNumber = hashDelimiterdetails.get("102").toString(); strAvailableBalance = formatter.format(Double.valueOf(strBal[0])).replace("TZS", ""); strActualBalance = formatter.format(Double.valueOf(strBal[1])).replace("TZS", ""); hashDelimiterString += " " + "#"; hashDelimiterString += " AGENT BALANCE ENQUIRY " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "ACCOUNT NUM: " + hashDelimiterdetails.get("102").toString() + "#"; hashDelimiterString += "AVAIL BALANCE: TZS" + strAvailableBalance + "#"; hashDelimiterString += "ACTUAL BALANCE: TZS" + strActualBalance + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " AGENT BALANCE ENQUIRY " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " AGENT BALANCE FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "380000": // Mini Statement hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; try { if (hashDelimiterdetails.get("48").contains("~")) { String[] strStatementData = hashDelimiterdetails.get("48").split("~"); for (int i = 0; i < strStatementData.length; i++) { strStatementPrinting += strStatementData[i] + "#"; } } switch (hashDelimiterdetails.get("39")) { case "00": hashDelimiterString += " " + "#"; hashDelimiterString += " MINISTATEMENT ENQUIRY " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "ACCOUNT NUM: " + (hashDelimiterdetails.get("102")) + "#"; hashDelimiterString += strStatementPrinting + "#"; hashDelimiterString += " " + "#"; break; default: strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); hashDelimiterString += " " + "#"; hashDelimiterString += " MINISTATEMENT ENQUIRY " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " MINISTATEMENT ENQUIRY FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } break; case "400000": // FUNDS TRANSFER hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); String StramountString = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))).replace("TZS", ""); switch (hashDelimiterdetails.get("39")) { case "00": if (hashDelimiterdetails.get("48").toUpperCase().equals("SUCCESS")) { try { String strAccountNumber = hashDelimiterdetails.get("103").toString(); String SendersName = "ACC NAME:" + getCustomerDetails((hashDelimiterdetails.get("102"))); String RecipientsName = "ACC NAME:" + getCustomerDetails((hashDelimiterdetails.get("103"))); hashDelimiterString += " " + "#"; hashDelimiterString += " FUNDS TRANSFER " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " FUNDS TRANSFER SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += "AMOUNT: TZS " + StramountString + "#"; hashDelimiterString += "FROM ACCOUNT: " + (hashDelimiterdetails.get("102")) + "#"; hashDelimiterString += stringBuilder(SendersName) + "#"; hashDelimiterString += "TO ACCOUNT: " + (hashDelimiterdetails.get("103")) + "#"; hashDelimiterString += stringBuilder(RecipientsName) + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } } else { hashDelimiterString += " " + "#"; hashDelimiterString += " FUNDS TRANSFER " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " FUNDS TRANSFER FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " FUNDS TRANSFER " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " FUNDS TRANSFER FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "420000": // Airtime Topup hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": try { String strAccountNumber = hashDelimiterdetails.get("102").toString(); String strAmount = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))) .replace("TZS", ""); hashDelimiterString += " " + "#"; hashDelimiterString += " AIRTIME TOPUP " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " AIRTIME TOPUP SUCCESSFUL " + "#"; hashDelimiterString += "ACCOUNT NUM: " + strAccountNumber + "#"; hashDelimiterString += "AMOUNT: TZS " + strAmount + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " AIRTIME TOPUP " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " AIRTIME TOPUP FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "500000": //Bills Payments strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; switch (hashDelimiterdetails.get("39")) { case "00": if (hashDelimiterdetails.get("48").toString().trim().equalsIgnoreCase("NOPURCHASE")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += stringBuilder(hashDelimiterdetails.get("48")) + "#"; hashDelimiterString += " " + "#"; } else { // LUKU PREPAID String strAmount = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))) .replace("TZS", ""); String strToken = ""; if (hashDelimiterdetails.get("100").equals("LUKUPREPAID")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " LUKU PAYMENT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += " TOKEN NUM: " + stringBuilder(hashDelimiterdetails.get("48")) + "#"; hashDelimiterString += " AMOUNT PAID:TZS " + strAmount + "#"; hashDelimiterString += " " + "#"; } //AZAMTV if (hashDelimiterdetails.get("100").equals("AZAMTV")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " AZAM TV PAYMENT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += getAZAMTVResponse(hashDelimiterdetails.get("48")); hashDelimiterString += " " + "#"; } //STARTIMES TV if (hashDelimiterdetails.get("100").equals("STARTIMESTV")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " STARTIMES TV PAYMENT SUCCESSFUL" + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += getStartimesResponse(hashDelimiterdetails.get("48")); hashDelimiterString += " " + "#"; } //DAWASCO PAYMENT if (hashDelimiterdetails.get("100").equals("DAWASCO")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " DAWASCO PAYMENT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += " TOKEN NUM: " + stringBuilder(hashDelimiterdetails.get("48")) + "#"; hashDelimiterString += " AMOUNT PAID: " + strAmount + "#"; hashDelimiterString += " " + "#"; } //ZUKU PAYMENT if (hashDelimiterdetails.get("100").equals("ZUKU")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " ZUKU PAYMENT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += getZukuresponse(hashDelimiterdetails.get("48")); hashDelimiterString += " " + "#"; } //NHC PAYMENT if (hashDelimiterdetails.get("100").equals("NHC")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " NHC PAYMENT SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += " TOKEN NUM: " + stringBuilder(hashDelimiterdetails.get("48")); hashDelimiterString += " AMOUNT PAID: " + strAmount + "#"; hashDelimiterString += " " + "#"; } //PRECISIONAIR PAYMENT if (hashDelimiterdetails.get("100").equals("PRECISIONAIR")) { hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += "PRECISION AIR PAYMENT SUCCESSFUL" + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " METER NUM: " + hashDelimiterdetails.get("65") + "#"; hashDelimiterString += " TICKET NUM: " + stringBuilder(hashDelimiterdetails.get("48")) + "#"; hashDelimiterString += " AMOUNT PAID: " + strAmount + "#"; hashDelimiterString += " " + "#"; } } break; default: hashDelimiterString += " BILL PAYMENT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " BILL PAYMENT FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "620000": //Cardless Origination hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": String[] strBal = hashDelimiterdetails.get("54").split("|"); try { strAvailableBalance = strBal[0]; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } try { strActualBalance = strBal[1]; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } hashDelimiterString += " " + "#"; hashDelimiterString += " CARDLESS ORIGINATION " + "#"; hashDelimiterString += " CARDLESS TRANSFER SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; if (hashDelimiterdetails.get("80").isEmpty()) { } else { hashDelimiterString += " Your 4 digit code is " + hashDelimiterdetails.get("80").substring(0, 4) + "#"; } hashDelimiterString += "Please send it to the Receipient" + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += "Amount . " + NumberFormat.getNumberInstance(Locale.US) .format(Double.parseDouble(hashDelimiterdetails.get("4"))) + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += "Avail. " + NumberFormat.getNumberInstance(Locale.US).format(Double.parseDouble(strAvailableBalance)) + "#"; hashDelimiterString += "Actual. " + NumberFormat.getNumberInstance(Locale.US).format(Double.parseDouble(strActualBalance)) + "#"; cardlesssmsmsg = "Dear Customer, Your 4 digit code is " + hashDelimiterdetails.get("80").substring(0, 4) + ", kindly send this to the recipient"; break; default: strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); hashDelimiterString += " " + "#"; hashDelimiterString += " CARDLESS ORIGINATION " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CARDLESS ORIGINATION FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; case "630000": //Cardless Fullfillment try { hashDelimiterString += "Ref No: " + hashDelimiterdetails.get("37") + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": String strAmount = formatter.format(Double.valueOf(hashDelimiterdetails.get("4"))) .replace("TZS", ""); hashDelimiterString += " " + "#"; hashDelimiterString += " CARDLESS FULLFILMENT " + "#"; hashDelimiterString += "CARDLESS FULLFILLMENT SUCCESSFUL" + "#"; hashDelimiterString += "AMOUNT: " + strAmount + "#"; hashDelimiterString += " " + "#"; break; default: strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); hashDelimiterString += " " + "#"; hashDelimiterString += " CARDLESS FULLFILMENT " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " CARDLESS FULLFILMENT FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); } catch (Exception ex) { this.log("\nINFO genHashDelimeterString() :: " + ex.getMessage() + "\n" + StackTraceWriter(ex), "ERROR"); } break; case "720000": //Reversal Request hashDelimiterString += "TRAN NUM: " + hashDelimiterdetails.get("37") + "#"; hashDelimiterString += "--------------------------------" + "#"; hashDelimiterString += " " + "#"; strReasonDescription = this.getResponseCode(hashDelimiterdetails.get("39")); switch (hashDelimiterdetails.get("39")) { case "00": if (hashDelimiterdetails.get("48").equals("SUCCESS")) { try { hashDelimiterString += " " + "#"; hashDelimiterString += " REVERSAL REQUEST " + "#"; hashDelimiterString += " REVERSAL REQUEST SUCCESSFUL " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " " + "#"; } catch (Exception ex) { this.log("INFO : Function genHashDelimiterString " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } } else { hashDelimiterString += " " + "#"; hashDelimiterString += " REVERSAL REQUEST " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " REVERSAL REQUEST FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; } break; default: hashDelimiterString += " " + "#"; hashDelimiterString += " REVERSAL REQUEST " + "#"; hashDelimiterString += " " + "#"; hashDelimiterString += " REVERSAL REQUEST FAILED " + "#"; hashDelimiterString += " " + stringBuilder(InterpretResponse(hashDelimiterdetails.get("48").toString())) + "#"; hashDelimiterString += " " + "#"; break; } hashDelimiterString += this.strResponseFooter(hashDelimiterdetails.get("104")); if (hashDelimiterdetails.get("39").equals("00")) { String strReplace = hashDelimiterString.replace("CUSTOMER COPY", "AGENT COPY"); hashDelimiterString += strReplace; } this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; default: hashDelimiterString = "TRANSACTION CODE NOT DEFINED#--------------------------------#"; hashDelimiterString += ""; this.SendPOSResponse(hashDelimiterString, intid); updateTransactionResponse(hashDelimiterdetails, intid, hashDelimiterString); break; } return hashDelimiterString; }