Example usage for com.lowagie.text Element ALIGN_CENTER

List of usage examples for com.lowagie.text Element ALIGN_CENTER

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_CENTER.

Prototype

int ALIGN_CENTER

To view the source code for com.lowagie.text Element ALIGN_CENTER.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

private PdfPTable createMbTable() throws DocumentException {
    PdfPTable mbTable;/*  ww w  . j  a  va  2  s . co m*/
    if (includeRevisionTypeColumn) {
        mbTable = new PdfPTable(12);
        mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f });
    } else {
        mbTable = new PdfPTable(11);
        mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f });
    }
    // main table
    mbTable.setWidthPercentage(100);

    try {
        final Font font = new Font();
        font.setSize(8);
        mbTable.getDefaultCell().setPadding(3);
        mbTable.getDefaultCell().setBorderWidth(1);
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.slno"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.schno"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.descofwork"), font)));
        if (includeRevisionTypeColumn)
            mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.revisiontype"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.completedmeasurement"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unitrate"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unit"), font)));
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.totalvalueofcomplwork"), font)));

        // start creating tables for previous measurements
        final PdfPTable previousMbTable = createPreviousMbTable();
        final PdfPCell previousMbCell = new PdfPCell(previousMbTable);
        previousMbCell.setColspan(2);
        mbTable.addCell(previousMbCell);

        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentmeasurement"), font)));

        // last column
        mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentcost"), font)));
    } catch (final RuntimeException e) {
        throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e);
    }
    return mbTable;
}

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

public PdfPTable createPreviousMbTable() {
    final PdfPTable previousMbTable = new PdfPTable(2);
    final Font font = new Font();
    font.setSize(8);//  ww w  . j av a  2 s . com
    previousMbTable.getDefaultCell().setBorderWidth(1);
    previousMbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    previousMbTable.getDefaultCell().setColspan(2);
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.previousmeasurement"), font)));
    previousMbTable.getDefaultCell().setColspan(1);
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.pageno"), font)));
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.measurements"), font)));
    return previousMbTable;
}

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

private PdfPTable createMbData(final PdfPTable mbTable, final MBHeader mbHeader) {
    Integer i = 0;// w ww  .j a v a2s  .  c o  m
    double uomFactor = 0.0;

    // iterating mbdetails
    for (final MBDetails mbDetails : mbHeader.getMbDetails()) {
        String description = "";
        String per = "";
        String schNo = "";
        double currentMeasurement;
        currentMeasurement = mbDetails.getQuantity();
        ++i;
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        mbTable.addCell(rightPara(8, i.toString()));
        final WorkOrderActivity workOrderActivity = mbDetails.getWorkOrderActivity();
        final Activity activity = workOrderActivity.getActivity();
        if (activity != null) {
            if (activity.getSchedule() != null && activity.getSchedule().getCode() != null)
                schNo = activity.getSchedule().getCode();
            mbTable.addCell(rightPara(8, schNo));

            // start sor/non sor description
            if (activity.getSchedule() != null && activity.getSchedule().getDescription() != null)
                description = activity.getSchedule().getDescription();

            if (activity.getNonSor() != null && activity.getNonSor().getDescription() != null)
                description = activity.getNonSor().getDescription();

            mbTable.addCell(makeParaWithFont(8, description, Element.ALIGN_LEFT));
            // end sor/non sor description
        }
        // for completedMeasurement area --------------->Cumulative quantity
        // including current entry= Cumulative upto previous entry + Current
        // MB entry
        // ( cumulative MB measurement for line item) for selected MB
        // including MB entry

        if (includeRevisionTypeColumn) {
            if (activity.getRevisionType() == null)
                mbTable.addCell(makePara(8, ""));
            if (activity.getRevisionType() != null && activity.getRevisionType().toString()
                    .equalsIgnoreCase(RevisionType.NON_TENDERED_ITEM.toString()))
                mbTable.addCell(makePara(8, "Non Tendered"));
            if (activity.getRevisionType() != null && activity.getRevisionType().toString()
                    .equalsIgnoreCase(RevisionType.LUMP_SUM_ITEM.toString()))
                mbTable.addCell(makePara(8, "Lump Sum"));
        }

        double completedMeasurement;
        double cumlPrevMb;
        try {

            long woaId = 0l;
            if (workOrderActivity.getId() != null)
                woaId = workOrderActivity.getId();

            cumlPrevMb = measurementBookService.prevCumulativeQuantityIncludingCQ(woaId, mbHeader.getId(),
                    workOrderActivity.getActivity().getId(), mbHeader.getWorkOrder());

        } catch (final Exception e) {
            cumlPrevMb = 0.0;
        }
        completedMeasurement = cumlPrevMb + currentMeasurement;
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        mbTable.addCell(rightPara(8, completedMeasurement));

        double approveRateWo = workOrderActivity.getApprovedRate();
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        mbTable.addCell(rightPara(8, formatter.format(approveRateWo)));

        // start unit
        if (activity != null) {
            // umofactor for conversion of rate and amount
            uomFactor = activity.getConversionFactor();
            if (logger.isDebugEnabled())
                logger.debug("----------uomFactor------------" + uomFactor);

            mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            if (activity.getSchedule() != null && activity.getSchedule().getUom() != null
                    && activity.getSchedule().getUom().getUom() != null)
                per = activity.getSchedule().getUom().getUom();
            if (activity.getNonSor() != null && activity.getNonSor().getUom() != null
                    && activity.getNonSor().getUom().getUom() != null)
                per = activity.getNonSor().getUom().getUom();
            mbTable.addCell(centerPara(8, per));
            // end start unit
        } // end of if activity

        /*
         * measurementBookService.prevCumulativeAmount(workOrderActivity.getId ()); total work completed------->(completed
         * mesurement(col 5) * rate) here rate is wo.getAprovedrate added uom factor on april4th 2010
         */
        final double workCompleted = completedMeasurement * approveRateWo * uomFactor;
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        mbTable.addCell(rightPara(8, formatter.format(workCompleted)));

        // previous measurements a)pageno and b)measurements
        // a)Page no: for last MB entry for forline item---->page-no call
        // api
        Integer frompageNo = null;
        Integer topageNo = null;

        final MBHeader resultHeader = workOrderService.findLastMBPageNoForLineItem(workOrderActivity,
                mbHeader.getId());
        if (resultHeader != null) {
            frompageNo = resultHeader.getFromPageNo();
            topageNo = resultHeader.getToPageNo();
        }

        String pageNoInfo = "";
        if (frompageNo != null)
            pageNoInfo = resultHeader.getMbRefNo() + "/" + frompageNo.toString();
        if (topageNo != null)
            pageNoInfo = pageNoInfo + "-" + topageNo;

        mbTable.addCell(rightPara(8, pageNoInfo));
        // b)Cumulative measurement recorded for the previous MB entry for
        // line item( Cumulative measurements-current MB entry)
        mbTable.addCell(rightPara(8, cumlPrevMb));

        // Current Finalised Measurements a)Current MB entry and b) Column6
        // Estimate Percentage
        // a)Current MB entry---->Measurements (Col5-8) i.e (area-previous
        // measurement)

        mbTable.addCell(rightPara(8, currentMeasurement));

        // current cost
        double currentCost;
        currentCost = currentMeasurement * approveRateWo * uomFactor;
        mbTable.addCell(rightPara(8, formatter.format(currentCost)));
        // } //end of if mbDetails
    } // end of for loop
    return mbTable;
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public void generatePDF() {
    nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(10);/*  w ww . j ava 2  s .c  om*/
    final List<String> tenderTypeList = worksService.getTendertypeList();
    if (tenderTypeList != null && !tenderTypeList.isEmpty())
        percTenderType = tenderTypeList.get(0);
    final String headerText = pdfLabel.get("tenderNegotiationpdf.header");
    try {
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(makePara(cityName, Element.ALIGN_RIGHT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getWorksPackage() != null) {
            worksPackgeReq = YES;
            worksPackage = tenderResponse.getTenderEstimate().getWorksPackage();
        }
        String deptName = "";
        if (YES.equalsIgnoreCase(worksPackgeReq)) {
            deptName = tenderResponse.getTenderEstimate().getWorksPackage().getDepartment().getName();
            document.add(makePara(deptName, Element.ALIGN_RIGHT));
            if (getWardList(worksPackage) != null)
                document.add(makePara(
                        pdfLabel.get("tenderNegotiationpdf.ward") + "/"
                                + pdfLabel.get("tenderNegotiationpdf.zone") + getWardList(worksPackage),
                        Element.ALIGN_LEFT));
        } else {
            if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment()
                            .getName() != null)
                deptName = tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment()
                        .getName();
            document.add(makePara(deptName, Element.ALIGN_RIGHT));
            if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getParent() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getWard() != null)
                document.add(makePara(pdfLabel.get("tenderNegotiationpdf.ward") + "/"
                        + pdfLabel.get("tenderNegotiationpdf.zone")
                        + tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getName() + "/"
                        + tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getParent()
                                .getName(),
                        Element.ALIGN_LEFT));
        }
        if (YES.equalsIgnoreCase(worksPackgeReq))
            document.add(makePara(
                    pdfLabel.get("tenderNegotiationpdf.nameofwork")
                            + tenderResponse.getTenderEstimate().getWorksPackage().getName(),
                    Element.ALIGN_LEFT));
        else if (tenderResponse != null && tenderResponse.getTenderEstimate() != null)
            document.add(makePara(
                    pdfLabel.get("tenderNegotiationpdf.nameofwork")
                            + tenderResponse.getTenderEstimate().getAbstractEstimate().getName(),
                    Element.ALIGN_LEFT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getTenderHeader() != null
                && tenderResponse.getTenderEstimate().getTenderHeader().getTenderNo() != null)
            document.add(makePara(
                    pdfLabel.get("tenderNumber")
                            + tenderResponse.getTenderEstimate().getTenderHeader().getTenderNo(),
                    Element.ALIGN_LEFT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getWorksPackage() != null)
            document.add(makePara(
                    pdfLabel.get("tenderFileNo")
                            + tenderResponse.getTenderEstimate().getWorksPackage().getTenderFileNumber(),
                    Element.ALIGN_LEFT));
        document.add(spacer());
        String tenderDate = "";
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getTenderHeader() != null
                && tenderResponse.getTenderEstimate().getTenderHeader().getTenderDate() != null)
            tenderDate = sdf.format(tenderResponse.getTenderEstimate().getTenderHeader().getTenderDate());
        document.add(
                makePara(pdfLabel.get("tenderNegotiationpdf.tenderdate") + tenderDate, Element.ALIGN_RIGHT));
        document.add(spacer());
        PdfPTable contractorTable = null;
        if (tenderResponse != null) {
            contractorTable = createContractorTable(tenderResponse);
            document.add(contractorTable);
        }
        document.add(spacer());

        if (tenderResponse != null
                && tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType)) {
            PdfPTable negotiationTable = null;
            negotiationTable = createNegotiationTable(tenderResponse,
                    tenderResponse.getTenderResponseContractors().get(0).getContractor());
            document.add(negotiationTable);
            document.add(spacer());
            if (negotiationTable != null && negotiationTable.getRows().size() > 8)
                document.newPage();

        } else if (tenderResponse != null
                && !tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType))
            createNegotiationTableForContractors(tenderResponse);

        if (tenderResponse != null && tenderResponse.getNegotiationPreparedBy() != null
                && tenderResponse.getNegotiationPreparedBy().getEmployeeName() != null)
            document.add(makePara(pdfLabel.get("tenderNegotiationpdf.preparedby") + " "
                    + tenderResponse.getNegotiationPreparedBy().getEmployeeName()));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara(pdfLabel.get("tenderNegotiationpdf.checkedby")));
        document.newPage();

        PdfPTable approvaldetailsTable = null;
        if (tenderResponse != null)
            approvaldetailsTable = createApprovalDetailsTable(tenderResponse);

        if (approvaldetailsTable != null && approvaldetailsTable.getRows().size() != 1) {
            document.add(makePara(pdfLabel.get("tenderNegotiationpdf.approvaldetails")));
            document.add(spacer());
            document.add(approvaldetailsTable);
        }
        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(TENDER_PDF_ERROR, e);
    }
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * create negotiation table main table//from   w w w  .j a va  2 s .  c  o m
 *
 * @param tenderResponse
 * @return
 * @throws DocumentException
 * @throws ApplicationException
 */
private PdfPTable createNegotiationTable(final TenderResponse tenderResponse, final Contractor contractor)
        throws DocumentException {
    final PdfPTable negotiationTable = new PdfPTable(13);
    negotiationTable.setWidthPercentage(100);
    negotiationTable.setWidths(
            new float[] { 0.5f, 1f, 3.6f, 1.5f, 1.1f, 0.9f, 1.5f, 1.7f, 1.7f, 1.7f, 1.7f, 1.7f, 1.7f });
    try {
        negotiationTable.getDefaultCell().setPadding(5);
        negotiationTable.getDefaultCell().setBorderWidth(1);
        negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.slno"));
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.scheduleno"));
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.descofwork"));
        negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.quantity"));

        /**
         * start creating tables for Estimate, before negotion, after negotiation and marketRate
         */

        final PdfPTable estimateTable = createAsPerEstimateTable(tenderResponse);
        estimateTable.setWidths(new float[] { 0.45f, 0.37f, 0.62f });
        final PdfPCell estimateCell = new PdfPCell(estimateTable);
        estimateCell.setColspan(3);
        negotiationTable.addCell(estimateCell);

        final PdfPTable beforeNegotiationTable = createBeforeNegotiationTable(tenderResponse);
        final PdfPCell beforeNegotiationCell = new PdfPCell(beforeNegotiationTable);
        beforeNegotiationCell.setColspan(2);
        negotiationTable.addCell(beforeNegotiationCell);

        final PdfPTable afterNegotiationTable = createAfterNegotiationTable(tenderResponse);
        final PdfPCell afterNegotiationCell = new PdfPCell(afterNegotiationTable);
        afterNegotiationCell.setColspan(2);
        negotiationTable.addCell(afterNegotiationCell);
        final PdfPTable marketRateTable = createMarketRateTable(tenderResponse);
        final PdfPCell marketRateCell = new PdfPCell(marketRateTable);
        marketRateCell.setColspan(2);
        negotiationTable.addCell(marketRateCell);
        /**
         * end creating tables for before negotion, after negotiation and marketRate
         */
        if (YES.equalsIgnoreCase(worksPackgeReq))
            createNegotiationTableDataForWp(tenderResponse, negotiationTable, contractor);
        else
            createNegotiationTableData(tenderResponse, negotiationTable, contractor);
        createNegotiationTableFooter(negotiationTable);
        addRowFooter(negotiationTable);
        addTotalQuotedFooter(negotiationTable);
        addFinalRow(negotiationTable, tenderResponse);
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(TENDER_PDF_ERROR, e);
    }
    return negotiationTable;
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * view workpackage pdf//w ww. ja v a  2 s.co  m
 */
public void createNegotiationTableDataForWp(final TenderResponse tenderResponse,
        final PdfPTable negotiationTable, final Contractor contractor) {
    Date asOnDate = null;
    if (tenderResponse.getNegotiationDate() != null)
        asOnDate = tenderResponse.getNegotiationDate();

    int i = 0;
    final Map<String, Integer> exceptionaSorMap = worksService.getExceptionSOR();
    totalBefNegAmt = 0;
    totalAmt = 0;
    totalAftNegAmt = 0;
    totalMarketRateAmt = 0;
    for (final TenderResponseActivity tenderResponseActivity : tenderResponse.getTenderResponseActivities()) {
        String schNo;
        String description;
        Double quantity = 0.0;
        double rate;
        String per;
        double befNegRate = 0.0;
        double befNegAmount;
        double aftNegRate = 0.0;
        double aftNegAmount;
        MarketRate marketRateObj;
        double marketRate = 0.0;
        double marketRateAmount = 0.0;
        double uomFactor = 1;

        if (tenderResponseActivity != null) {
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getCode() != null
                    && exceptionaSorMap.containsKey(tenderResponseActivity.getActivity().getUom().getUom()))
                uomFactor = exceptionaSorMap.get(tenderResponseActivity.getActivity().getUom().getUom());

            final Map<String, Object> rateQtyMap = processLatestRateAndQtyForLineItem(
                    worksPackage.getActivitiesForEstimate(), tenderResponseActivity.getActivity());
            if (rateQtyMap != null && !rateQtyMap.isEmpty()) {
                negotiationTable.addCell(makePara(++i));
                schNo = (String) rateQtyMap.get("sorcode");
                negotiationTable.addCell(centerPara(schNo));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                description = (String) rateQtyMap.get("desc");
                negotiationTable.addCell(makePara(description, Element.ALIGN_LEFT));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                quantity = (Double) rateQtyMap.get("qty");
                negotiationTable.addCell(centerPara(formatter.format(quantity)));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                rate = (Double) rateQtyMap.get("rate");
                negotiationTable.addCell(rightPara(formatter.format(rate)));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                per = (String) rateQtyMap.get("per");
                negotiationTable.addCell(centerPara(per));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                final double amount = (Double) rateQtyMap.get("amt");
                negotiationTable.addCell(rightPara(formatter.format(amount)));
                totalAmt = totalAmt + amount;
            }

            if (rateQtyMap != null && rateQtyMap.get("slno") != null) {
                /**
                 * before negotiation
                 */
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                for (final TenderResponseQuotes tenderResponseQuotes : tenderResponseActivity
                        .getTenderResponseQuotes())
                    if (tenderResponseQuotes.getContractor().getId() == contractor.getId()) {
                        if (tenderResponseQuotes.getQuotedRate() != 0.0)
                            befNegRate = tenderResponseQuotes.getQuotedRate();
                        negotiationTable.addCell(rightPara(formatter.format(befNegRate)));

                        befNegAmount = quantity * befNegRate / uomFactor;
                        totalBefNegAmt = totalBefNegAmt + befNegAmount;
                        negotiationTable.addCell(rightPara(formatter.format(befNegAmount)));
                    }
                if (tenderResponseActivity.getNegotiatedRate() != 0.0)
                    aftNegRate = tenderResponseActivity.getNegotiatedRate();
                negotiationTable.addCell(rightPara(formatter.format(aftNegRate)));

                aftNegAmount = quantity * aftNegRate / uomFactor;
                totalAftNegAmt = totalAftNegAmt + aftNegAmount;
                negotiationTable.addCell(rightPara(formatter.format(aftNegAmount)));

                if (tenderResponseActivity.getActivity() != null
                        && tenderResponseActivity.getActivity().getSchedule() != null && asOnDate != null
                        && tenderResponseActivity.getActivity().getSchedule().hasValidMarketRateFor(asOnDate)) {
                    marketRateObj = tenderResponseActivity.getActivity().getSchedule()
                            .getMarketRateOn(asOnDate);
                    marketRate = marketRateObj.getMarketRate().getValue();
                    marketRateAmount = quantity * marketRate / uomFactor;
                }

                if (tenderResponseActivity.getActivity() != null
                        && tenderResponseActivity.getActivity().getSchedule() != null && asOnDate != null
                        && !tenderResponseActivity.getActivity().getSchedule()
                                .hasValidMarketRateFor(asOnDate)) {
                    marketRate = tenderResponseActivity.getActivity().getRate();
                    marketRateAmount = quantity * marketRate;
                }

                if (tenderResponseActivity.getActivity() != null
                        && tenderResponseActivity.getActivity().getNonSor() != null) {
                    marketRate = tenderResponseActivity.getActivity().getRate();
                    final double marketQty = tenderResponseActivity.getActivity().getQuantity();
                    marketRateAmount = marketQty * marketRate;
                }
                negotiationTable.addCell(rightPara(formatter.format(marketRate)));
                totalMarketRateAmt = totalMarketRateAmt + marketRateAmount;
                negotiationTable.addCell(rightPara(formatter.format(marketRateAmount)));
            }

        }
    }
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * view estimate pdf// w w  w  . jav  a 2  s.  c  o  m
 */
public void createNegotiationTableData(final TenderResponse tenderResponse, final PdfPTable negotiationTable,
        final Contractor contractor) {

    Date asOnDate = null;
    if (tenderResponse.getNegotiationDate() != null)
        asOnDate = tenderResponse.getNegotiationDate();
    int i = 0;
    final Map<String, Integer> exceptionaSorMap = worksService.getExceptionSOR();

    for (final TenderResponseActivity tenderResponseActivity : tenderResponse.getTenderResponseActivities()) {
        String schNo = "";
        String description = "";
        Double quantity = 0.0;
        double rate = 0.0;
        String per = "";
        double befNegRate = 0.0;
        double befNegAmount;
        double aftNegRate = 0.0;
        double aftNegAmount;
        MarketRate marketRateObj;
        double marketRate = 0.0;
        double marketRateAmount = 0.0;
        negotiationTable.addCell(makePara(++i));
        double uomFactor = 1;

        if (tenderResponseActivity != null) {
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getCode() != null
                    && exceptionaSorMap.containsKey(tenderResponseActivity.getActivity().getUom().getUom()))
                uomFactor = exceptionaSorMap.get(tenderResponseActivity.getActivity().getUom().getUom());

            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getCode() != null)
                schNo = tenderResponseActivity.getActivity().getSchedule().getCode();
            negotiationTable.addCell(centerPara(schNo));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getDescription() != null)
                description = tenderResponseActivity.getActivity().getSchedule().getDescription();
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getNonSor() != null
                    && tenderResponseActivity.getActivity().getNonSor().getDescription() != null)
                description = tenderResponseActivity.getActivity().getNonSor().getDescription();
            negotiationTable.addCell(makePara(description, Element.ALIGN_LEFT));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getQuantity() != 0)
                quantity = tenderResponseActivity.getActivity().getQuantity();
            negotiationTable.addCell(centerPara(quantity));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getRate() != 0
                    && tenderResponseActivity.getActivity().getSORCurrentRate() != null)
                rate = tenderResponseActivity.getActivity().getSORCurrentRate().getValue();
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getNonSor() != null
                    && tenderResponseActivity.getActivity().getRate() != 0)
                rate = tenderResponseActivity.getActivity().getRate();
            negotiationTable.addCell(rightPara(formatter.format(rate)));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            if (tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getUom() != null
                    && tenderResponseActivity.getActivity().getSchedule().getUom().getUom() != null)
                per = tenderResponseActivity.getActivity().getSchedule().getUom().getUom();
            if (tenderResponseActivity.getActivity().getNonSor() != null
                    && tenderResponseActivity.getActivity().getNonSor().getUom() != null
                    && tenderResponseActivity.getActivity().getNonSor().getUom().getUom() != null)
                per = tenderResponseActivity.getActivity().getNonSor().getUom().getUom();
            negotiationTable.addCell(centerPara(per));
            final double amount = quantity * rate / uomFactor;
            totalAmt = totalAmt + amount;
            negotiationTable.addCell(rightPara(formatter.format(amount)));
            /** before negotiation */
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            for (final TenderResponseQuotes tenderResponseQuotes : tenderResponseActivity
                    .getTenderResponseQuotes())
                if (tenderResponseQuotes.getContractor().getId() == contractor.getId()) {
                    if (tenderResponseQuotes.getQuotedRate() != 0.0)
                        befNegRate = tenderResponseQuotes.getQuotedRate();
                    final double quotedQty = tenderResponseQuotes.getQuotedQuantity();
                    negotiationTable.addCell(rightPara(formatter.format(befNegRate)));
                    befNegAmount = quotedQty * befNegRate / uomFactor;
                    totalBefNegAmt = totalBefNegAmt + befNegAmount;
                    negotiationTable.addCell(rightPara(formatter.format(befNegAmount)));

                }
            if (tenderResponseActivity.getNegotiatedRate() != 0.0)
                aftNegRate = tenderResponseActivity.getNegotiatedRate();
            final double negotiatedQty = tenderResponseActivity.getNegotiatedQuantity();
            negotiationTable.addCell(rightPara(formatter.format(aftNegRate)));
            aftNegAmount = negotiatedQty * aftNegRate / uomFactor;
            totalAftNegAmt = totalAftNegAmt + aftNegAmount;
            negotiationTable.addCell(rightPara(formatter.format(aftNegAmount)));
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null && asOnDate != null
                    && tenderResponseActivity.getActivity().getSchedule().hasValidMarketRateFor(asOnDate)) {
                marketRateObj = tenderResponseActivity.getActivity().getSchedule().getMarketRateOn(asOnDate);
                marketRate = marketRateObj.getMarketRate().getValue();
                marketRateAmount = quantity * marketRate / uomFactor;
            } else if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null) {
                marketRate = tenderResponseActivity.getActivity().getSORCurrentRate().getValue();
                final double marketQty = tenderResponseActivity.getActivity().getQuantity();
                marketRateAmount = marketQty * marketRate / uomFactor;
            } else if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getNonSor() != null) {
                marketRate = tenderResponseActivity.getActivity().getRate();
                final double marketQty = tenderResponseActivity.getActivity().getQuantity();
                marketRateAmount = marketQty * marketRate;
            }
            negotiationTable.addCell(rightPara(formatter.format(marketRate)));
            totalMarketRateAmt = totalMarketRateAmt + marketRateAmount;
            negotiationTable.addCell(rightPara(formatter.format(marketRateAmount)));
        }
    }
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * start for first footer row/*  w  w w. j a v a  2 s  . c om*/
 */
public PdfPTable createTenderTotalTable() {
    final PdfPTable tenderTotalTable = new PdfPTable(3);
    tenderTotalTable.getDefaultCell().setBorderWidth(1);
    tenderTotalTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tenderTotalTable.getDefaultCell().setColspan(3);
    tenderTotalTable.addCell(pdfLabel.get("tenderNegotiationpdf.tendertotal"));
    return tenderTotalTable;
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public PdfPTable createAsPerEstimateTable(final TenderResponse tenderResponse) {
    final PdfPTable estimateTable = new PdfPTable(3);
    estimateTable.getDefaultCell().setBorderWidth(1);
    estimateTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    estimateTable.getDefaultCell().setColspan(3);
    estimateTable.addCell(pdfLabel.get("tenderNegotiationpdf.asPerEstimate"));
    estimateTable.getDefaultCell().setColspan(1);
    estimateTable.addCell(pdfLabel.get(TENDERNEGOTIATION_RATE));
    estimateTable.addCell(pdfLabel.get("tenderNegotiationpdf.Per"));
    estimateTable.addCell(pdfLabel.get(TENDERNEGOTIATION_AMOUNT));
    return estimateTable;
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * creating tables for before negotion//from  w  w  w  .  j a v  a2s  .  c om
 */
public PdfPTable createBeforeNegotiationTable(final TenderResponse tenderResponse) {
    final PdfPTable beforeNegotiationTable = new PdfPTable(2);
    beforeNegotiationTable.getDefaultCell().setBorderWidth(1);
    beforeNegotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    beforeNegotiationTable.getDefaultCell().setColspan(2);
    beforeNegotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.asPerTender"));
    beforeNegotiationTable.getDefaultCell().setColspan(1);
    beforeNegotiationTable.addCell(pdfLabel.get(TENDERNEGOTIATION_RATE));
    beforeNegotiationTable.addCell(pdfLabel.get(TENDERNEGOTIATION_AMOUNT));
    return beforeNegotiationTable;
}