Example usage for com.lowagie.text.pdf PdfPTable setWidthPercentage

List of usage examples for com.lowagie.text.pdf PdfPTable setWidthPercentage

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPTable setWidthPercentage.

Prototype

public void setWidthPercentage(float widthPercentage) 

Source Link

Document

Sets the width percentage that the table will occupy in the page.

Usage

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

License:Open Source License

private PdfPTable createApprovalDetailsTable(final ContractorBillRegister egBillRegister)
        throws DocumentException {
    try {//  w w  w  .  ja v  a2  s . c  o  m
        final PdfPTable approvaldetailsTable = new PdfPTable(5);
        approvaldetailsTable.setWidthPercentage(100);
        approvaldetailsTable.setWidths(new float[] { 2f, 1f, 1f, 1.5f, 2f });
        addRow(approvaldetailsTable, true, makePara("Approval Step"), centerPara("Name"),
                centerPara("Designation"), centerPara("Approved on"), centerPara("Remarks"));

        List<StateHistory<Position>> history = null;
        if (egBillRegister != null && egBillRegister.getCurrentState() != null
                && egBillRegister.getCurrentState().getHistory() != null)
            history = egBillRegister.getStateHistory();

        if (history != null) {
            Collections.reverse(history);
            for (final StateHistory ad : history)
                displayHistory(ad, approvaldetailsTable);
        }
        return approvaldetailsTable;
    } catch (final Exception e) {
        throw new ApplicationRuntimeException("Exception occured while getting approval details " + e);
    }
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createMultiYearTable(final AbstractEstimate estimate) throws DocumentException {
    final PdfPTable multiyearTable = new PdfPTable(3);
    multiyearTable.setWidthPercentage(100);
    multiyearTable.setWidths(new float[] { 1f, 2f, 2f });
    addRow(multiyearTable, true, makePara("Sl No"), centerPara("Year"), centerPara("Percentage"));
    int i = 0;//from w  ww . j  av a  2 s .  c  o m
    for (final MultiYearEstimate year : estimate.getMultiYearEstimates())
        addRow(multiyearTable, true, makePara(++i),
                makePara(year.getFinancialYear().getFinYearRange(), Element.ALIGN_CENTER),
                rightPara(year.getPercentage()));
    return multiyearTable;
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createOverheadsTable(final AbstractEstimate estimate) throws DocumentException {
    final PdfPTable overheadsTable = new PdfPTable(3);
    overheadsTable.setWidthPercentage(100);
    overheadsTable.setWidths(new float[] { 1f, 4f, 2f });
    addRow(overheadsTable, true, makePara("Sl No"), centerPara("Description"), centerPara("Amount"));
    addRow(overheadsTable, true, makePara("1"), makePara("Work Value"),
            rightPara(toCurrency(estimate.getWorkValue())));
    int i = 1;/*from www . j a v a  2  s  .  c om*/
    for (final OverheadValue oh : estimate.getOverheadValues())
        addRow(overheadsTable, true, makePara(++i), makePara(getOverheadDescription(oh)),
                rightPara(toCurrency(oh.getAmount())));
    addRow(overheadsTable, true, centerPara(""), makePara("TOTAL"),
            rightPara(toCurrency(estimate.getTotalAmount())));
    return overheadsTable;
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createDepositAppropriationTable(final AbstractEstimate estimate,
        final String appropriationNumber) throws DocumentException {
    int isReject = -1;
    depositWorksUsageService = abstractEstimateService.getDepositWorksUsageService();
    BigDecimal totalUtilizedAmt;//  www. j  av a  2s.c o m
    BigDecimal amtAppropriatedsofar;
    BigDecimal totalDepositAmt;
    BigDecimal balOnHand;
    BigDecimal balanceAvailable;
    BigDecimal amtAppropriated;
    final Accountdetailtype accountdetailtype = worksService.getAccountdetailtypeByName("DEPOSITCODE");
    estimateAppropriationService = abstractEstimateService.getEstimateAppropriationService();
    abstractEstimateAppropriationList = estimateAppropriationService.findAllBy(
            "from AbstractEstimateAppropriation aea where aea.abstractEstimate.id=? and aea.depositWorksUsage.id is not null order by id, aea.depositWorksUsage.financialYearId asc",
            estimate.getId());
    final PdfPTable depositWorksAppropriationTable = new PdfPTable(2);
    depositWorksAppropriationTable.setWidthPercentage(100);
    depositWorksAppropriationTable.setWidths(new float[] { 2f, 8f });

    if (appropriationNumber != null && appropriationNumber.toUpperCase().contains("BC"))
        isReject = 1;

    if (appropriationNumber != null && estimate.getTotalAmount() != null && isReject == -1) {
        addRow(depositWorksAppropriationTable, true, centerPara("Deposit Code"),
                centerPara(estimate.getDepositCode().getCode()));
        addRow(depositWorksAppropriationTable, true, centerPara("Account Code"),
                centerPara(estimate.getFinancialDetails().get(0).getCoa().getGlcode() + "-"
                        + estimate.getFinancialDetails().get(0).getCoa().getName()));
        addRow(depositWorksAppropriationTable, true, makePara("Function Center"),
                centerPara(estimate.getFinancialDetails().get(0).getFunction().getName()));
        addRow(depositWorksAppropriationTable, true, makePara("Department"),
                centerPara(estimate.getUserDepartment().getName()));
        addRow(depositWorksAppropriationTable, true, makePara("Amount of the Estimate "),
                rightPara(toCurrency(estimate.getTotalAmount())));
        final PdfPTable appropriationDetailTable = new PdfPTable(6);
        addRow(appropriationDetailTable, true, makePara(7f, "Appropriation Number"),
                makePara(7f, "Total Deposit Amount"), makePara(7f, "Amount Appropriated so far"),
                makePara(7f, "Amount Appropriated"), makePara(7f, "Balance on Hand"),
                makePara(7f, "Balance After Appropriation"));
        for (final AbstractEstimateAppropriation abstractEstimateAppropriation : abstractEstimateAppropriationList)
            if (abstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount().doubleValue() != 0) {
                totalDepositAmt = depositWorksUsageService.getTotalDepositWorksAmount(
                        estimate.getDepositCode().getFund(),
                        abstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails().get(0)
                                .getCoa(),
                        accountdetailtype, estimate.getDepositCode().getId(),
                        abstractEstimateAppropriation.getDepositWorksUsage().getAppropriationDate());
                totalUtilizedAmt = depositWorksUsageService.getTotalUtilizedAmountForDepositWorks(
                        abstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails().get(0),
                        abstractEstimateAppropriation.getDepositWorksUsage().getCreatedDate());
                if (totalUtilizedAmt == null)
                    totalUtilizedAmt = BigDecimal.ZERO;
                amtAppropriatedsofar = totalUtilizedAmt
                        .subtract(abstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount());
                balOnHand = totalDepositAmt.subtract(amtAppropriatedsofar);
                amtAppropriated = abstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount();
                balanceAvailable = BigDecimal
                        .valueOf(totalDepositAmt.doubleValue() - totalUtilizedAmt.doubleValue());
                addRow(appropriationDetailTable, true,
                        makePara(7f,
                                abstractEstimateAppropriation.getDepositWorksUsage().getAppropriationNumber()),
                        rightPara(7f, toCurrency(totalDepositAmt.doubleValue())),
                        rightPara(7f, toCurrency(amtAppropriatedsofar.doubleValue())),
                        rightPara(7f, toCurrency(amtAppropriated.doubleValue())),
                        rightPara(7f, toCurrency(balOnHand.doubleValue())),
                        rightPara(7f, toCurrency(balanceAvailable.doubleValue())));
            }

        final PdfPCell appDetailpdfCell = new PdfPCell(appropriationDetailTable);
        appDetailpdfCell.setBorderWidth(0);

        final PdfPCell appDetailRightHeader = new PdfPCell(
                makePara("Financail Year Wise Appropriation Details"));
        appDetailRightHeader.setVerticalAlignment(Element.ALIGN_MIDDLE);

        depositWorksAppropriationTable.addCell(appDetailRightHeader);
        appropriationDetailTable.setWidthPercentage(100);
        depositWorksAppropriationTable.addCell(appDetailpdfCell);
    }
    return depositWorksAppropriationTable;
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createBudgetaryAppropriationTable(final AbstractEstimate estimate,
        final String appropriationNumber) throws DocumentException {
    int isReject = -1;
    final List<FinancialDetail> financialdetails = estimate.getFinancialDetails();
    BigDecimal totalGrant;/*  w w  w. j  a  v a 2s  .c om*/
    BigDecimal budgetAvailable;
    BigDecimal balOnHand;
    BigDecimal amtAppropriated;
    BigDecimal totGrantafterMultiFactor = BigDecimal.ZERO;

    estimateAppropriationService = abstractEstimateService.getEstimateAppropriationService();
    abstractEstimateAppropriationList = estimateAppropriationService.findAllBy(
            "from AbstractEstimateAppropriation aea where aea.abstractEstimate.id=? and aea.budgetUsage.id is not null order by aea.budgetUsage.id,aea.budgetUsage.financialYearId asc",
            estimate.getId());

    final PdfPTable budgetaryAppropriationTable = new PdfPTable(1);
    budgetaryAppropriationTable.setWidthPercentage(100);
    budgetaryAppropriationTable.setWidths(new float[] { 8f });
    if (appropriationNumber != null && appropriationNumber.toUpperCase().contains("BC"))
        isReject = 1;

    if (appropriationNumber != null && estimate.getTotalAmount() != null && isReject == -1)
        for (final FinancialDetail financialDetail : financialdetails)
            if (financialDetail.getBudgetGroup() != null) {
                addRow(budgetaryAppropriationTable, true, centerPara("Budget Head"),
                        centerPara(financialDetail.getBudgetGroup().getName()));
                addRow(budgetaryAppropriationTable, true, makePara("Function Center"),
                        centerPara(financialDetail.getFunction().getName()));
                addRow(budgetaryAppropriationTable, true, makePara("Amount of the Estimate "),
                        rightPara(toCurrency(estimate.getTotalAmount())));
            }
    final PdfPTable appropriationDetailTable = new PdfPTable(8);
    int count = 0;
    for (final AbstractEstimateAppropriation abstractEstimateAppropriation : abstractEstimateAppropriationList)
        if (abstractEstimateAppropriation.getBudgetUsage().getConsumedAmount() != 0) {
            final Department dept = getDeptFromBudgtAppropriationNo(
                    abstractEstimateAppropriation.getBudgetUsage().getAppropriationnumber());
            totalGrant = abstractEstimateService.getTotalGrantForYearAsOnDate(financialdetails.get(0),
                    abstractEstimateAppropriation.getBudgetUsage().getFinancialYearId().longValue(),
                    Integer.parseInt(dept.getId().toString()),
                    abstractEstimateAppropriation.getBudgetUsage().getUpdatedTime());
            final BigDecimal planningBudgetPerc = abstractEstimateService.getPlanningBudgetPercentage(
                    financialdetails.get(0),
                    abstractEstimateAppropriation.getBudgetUsage().getFinancialYearId().longValue(),
                    Integer.parseInt(dept.getId().toString()));
            if (planningBudgetPerc != null && planningBudgetPerc.compareTo(BigDecimal.ZERO) != 0) {
                totGrantafterMultiFactor = totalGrant.multiply(planningBudgetPerc.divide(new BigDecimal(100)));
                appValue = planningBudgetPerc.divide(new BigDecimal(100)).toString();
            }
            budgetAvailable = abstractEstimateAppropriation.getBalanceAvailable();
            balOnHand = budgetAvailable
                    .add(new BigDecimal(abstractEstimateAppropriation.getBudgetUsage().getConsumedAmount()));
            amtAppropriated = totGrantafterMultiFactor.subtract(balOnHand);
            // Print only for the first time
            if (count == 0) {
                addRow(budgetaryAppropriationTable, false, makePara(""),
                        centerPara("Financial Year Wise Appropriation Details "));
                addRow(appropriationDetailTable, true, makePara(8f, "Department"),
                        makePara(8f, "Appropriation Number"), makePara(8f, "Total Grant"),
                        makePara(8f, appValue + " Times Total Grant"),
                        makePara(8f, "Amount Appropriated so far"), makePara(8f, "Amount Appropriated"),
                        makePara(8f, "Balance on Hand"), makePara(8f, "Balance After Appropriation"));
            }
            addRow(appropriationDetailTable, true, rightPara(8f, dept.getName()),
                    makePara(8f, abstractEstimateAppropriation.getBudgetUsage().getAppropriationnumber()),
                    rightPara(8f, toCurrency(totalGrant.doubleValue())),
                    rightPara(8f, toCurrency(totGrantafterMultiFactor.doubleValue())),
                    rightPara(8f, toCurrency(amtAppropriated.doubleValue())),
                    rightPara(8f,
                            toCurrency(abstractEstimateAppropriation.getBudgetUsage().getConsumedAmount())),
                    rightPara(8f, toCurrency(balOnHand.doubleValue())),
                    rightPara(8f, toCurrency(budgetAvailable.doubleValue())));
            count++;
        }

    final PdfPCell appDetailpdfCell = new PdfPCell(appropriationDetailTable);
    appropriationDetailTable.setWidthPercentage(100);
    budgetaryAppropriationTable.addCell(appDetailpdfCell);
    return budgetaryAppropriationTable;
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createApprovalDetailsTable(final AbstractEstimate estimate) throws DocumentException {
    try {/*from   w  w  w .j a va2 s.  c om*/
        PdfPTable approvaldetailsTable = null;
        if (shouldShowApprovalNumber) {
            approvaldetailsTable = new PdfPTable(6);
            approvaldetailsTable.setWidths(new float[] { 2f, 1f, 1f, 1f, 1.5f, 2f });
        } else {
            approvaldetailsTable = new PdfPTable(5);
            approvaldetailsTable.setWidths(new float[] { 2f, 1.5f, 1.5f, 1.5f, 2f });
        }
        approvaldetailsTable.setWidthPercentage(100);
        addRow(approvaldetailsTable, true, makePara("Approval Step"), centerPara("Name"),
                centerPara("Designation"), centerPara("Approved on"), centerPara("Remarks"));

        if (estimate != null && estimate.getCurrentState() != null) {
            history = new LinkedList<>();
            if (estimate.getCurrentState().getHistory() != null)
                history.addAll(estimate.getCurrentState().getHistory());
            history.add(new StateHistory(estimate.getCurrentState()));
        }

        if (history != null)
            for (final StateHistory stateHistory : history)
                displayHistory(stateHistory, approvaldetailsTable);
        return approvaldetailsTable;
    } catch (final Exception e) {
        throw new ApplicationRuntimeException("Exception occured while getting approval details " + e);
    }
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createEstimateDetailsTable1(final AbstractEstimate estimate) throws DocumentException {
    try {//from ww w  .  j  a  va2s .  co  m
        final PdfPTable estimateDetailsTable1 = new PdfPTable(2);
        estimateDetailsTable1.setWidthPercentage(75);
        estimateDetailsTable1.setWidths(new float[] { 0.6f, 1f });

        addRow(estimateDetailsTable1, true, centerPara("Department"),
                centerPara(estimate.getExecutingDepartment().getName()));
        addRow(estimateDetailsTable1, true, centerPara("Name of the Work"), centerPara(estimate.getName()));
        addRow(estimateDetailsTable1, true, centerPara("Estimate Number"),
                centerPara(estimate.getEstimateNumber()));

        return estimateDetailsTable1;
    } catch (final Exception e) {
        throw new ApplicationRuntimeException("Exception occured while estimate details method1 " + e);
    }
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createBudgetDetailsForEstimateTable(final AbstractEstimate estimate)
        throws DocumentException {
    try {/*  w ww.  j  av  a  2s. com*/

        final PdfPTable estBudgetDetailsTable = new PdfPTable(4);
        estBudgetDetailsTable.setWidthPercentage(75);
        estBudgetDetailsTable.setWidths(new float[] { 0.6f, 1f, 0.5f, 1f });

        BigDecimal totalGrant;
        BigDecimal budgetAvailable;
        BigDecimal balOnHand;
        BigDecimal amtAppropriated = BigDecimal.ZERO;
        BigDecimal totGrantafterMultiFactor = BigDecimal.ZERO;

        BigDecimal totalUtilizedAmt;
        BigDecimal amtAppropriatedsofar = BigDecimal.ZERO;
        worksService.getAccountdetailtypeByName("DEPOSITCODE");
        AbstractEstimateAppropriation latestAbstractEstimateAppropriation;

        if (abstractEstimateAppropriationList != null && !abstractEstimateAppropriationList.isEmpty()) {
            latestAbstractEstimateAppropriation = abstractEstimateAppropriationList
                    .get(abstractEstimateAppropriationList.size() - 1);

            if (latestAbstractEstimateAppropriation != null)
                if (estimate.getDepositCode() == null) {
                    if (latestAbstractEstimateAppropriation.getBudgetUsage().getConsumedAmount() != 0) {
                        final Department dept = getDeptFromBudgtAppropriationNo(
                                latestAbstractEstimateAppropriation.getBudgetUsage().getAppropriationnumber());
                        totalGrant = abstractEstimateService.getTotalGrantForYearAsOnDate(
                                estimate.getFinancialDetails().get(0),
                                latestAbstractEstimateAppropriation.getBudgetUsage().getFinancialYearId()
                                        .longValue(),
                                Integer.parseInt(dept.getId().toString()),
                                latestAbstractEstimateAppropriation.getBudgetUsage().getUpdatedTime());
                        final BigDecimal planningBudgetPerc = abstractEstimateService
                                .getPlanningBudgetPercentage(estimate.getFinancialDetails().get(0),
                                        latestAbstractEstimateAppropriation.getBudgetUsage()
                                                .getFinancialYearId().longValue(),
                                        Integer.parseInt(dept.getId().toString()));
                        if (planningBudgetPerc != null && planningBudgetPerc.compareTo(BigDecimal.ZERO) != 0) {
                            totGrantafterMultiFactor = totalGrant
                                    .multiply(planningBudgetPerc.divide(new BigDecimal(100)));
                            appValue = planningBudgetPerc.divide(new BigDecimal(100)).toString();
                        }

                        budgetAvailable = latestAbstractEstimateAppropriation.getBalanceAvailable();
                        balOnHand = budgetAvailable.add(new BigDecimal(
                                latestAbstractEstimateAppropriation.getBudgetUsage().getConsumedAmount()));
                        amtAppropriated = totGrantafterMultiFactor.subtract(balOnHand);
                    }
                } else if (latestAbstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount()
                        .doubleValue() != 0) {
                    totalUtilizedAmt = depositWorksUsageService.getTotalUtilizedAmountForDepositWorks(
                            latestAbstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails()
                                    .get(0),
                            latestAbstractEstimateAppropriation.getDepositWorksUsage().getCreatedDate());
                    if (totalUtilizedAmt == null)
                        totalUtilizedAmt = BigDecimal.ZERO;
                    amtAppropriatedsofar = totalUtilizedAmt.subtract(
                            latestAbstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount());
                }
        }
        addRow(estBudgetDetailsTable, true, centerPara("Estimate Date"),
                centerPara(DateUtils.getFormattedDate(estimate.getEstimateDate(), "dd/MM/yyyy")),
                centerPara("Fund"), centerPara(estimate.getFinancialDetails().isEmpty() ? ""
                        : estimate.getFinancialDetails().get(0).getFund().getName()));
        if (estimate.getDepositCode() == null) {
            addRow(estBudgetDetailsTable, true, centerPara("Function "),
                    centerPara(estimate.getFinancialDetails().isEmpty() ? ""
                            : estimate.getFinancialDetails().get(0).getFunction().getName()),
                    centerPara("Budget Head"), centerPara(estimate.getFinancialDetails().isEmpty() ? ""
                            : estimate.getFinancialDetails().get(0).getBudgetGroup().getName()));
            addRow(estBudgetDetailsTable, true, centerPara("Amount Appropriated so far"),
                    centerPara(amtAppropriated == null ? "" : toCurrency(amtAppropriated.doubleValue())),
                    centerPara("Estimate Amount"),
                    centerPara(toCurrency(estimate.getTotalAmount().getValue())));
        } else {
            addRow(estBudgetDetailsTable, true, centerPara("Function "),
                    centerPara(estimate.getFinancialDetails().isEmpty() ? ""
                            : estimate.getFinancialDetails().get(0).getFunction().getName()),
                    centerPara("Deposit COA/Deposit Code"),
                    centerPara(estimate.getFinancialDetails().isEmpty() ? ""
                            : estimate.getFinancialDetails().get(0).getCoa().getGlcode().concat("-")
                                    .concat(estimate.getFinancialDetails().get(0).getCoa().getName())
                                    .concat(" / ").concat(estimate.getDepositCode().getCode())));
            addRow(estBudgetDetailsTable, true, centerPara("Amount Appropriated so far"),
                    centerPara(
                            amtAppropriatedsofar == null ? "" : toCurrency(amtAppropriatedsofar.doubleValue())),
                    centerPara("Estimate Amount"),
                    makePara(toCurrency(estimate.getTotalAmount().getValue()), Element.ALIGN_RIGHT));
        }

        return estBudgetDetailsTable;
    } catch (final Exception e) {
        throw new ApplicationRuntimeException("Exception occured while estimate details method 2 " + e);
    }
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createBalanceAmtCalculationTable(final AbstractEstimate estimate) throws DocumentException {
    try {//from  w  w  w  .j av a2s.co m

        final PdfPTable estimateDetailsTable2 = new PdfPTable(2);
        estimateDetailsTable2.setWidthPercentage(75);
        estimateDetailsTable2.setWidths(new float[] { 0.6f, 1f });

        BigDecimal budgetAvailable = BigDecimal.ZERO;
        BigDecimal totalUtilizedAmt;
        BigDecimal totalDepositAmt;
        BigDecimal balanceAvailable = BigDecimal.ZERO;

        final Accountdetailtype accountdetailtype = worksService.getAccountdetailtypeByName("DEPOSITCODE");

        if (abstractEstimateAppropriationList != null && !abstractEstimateAppropriationList.isEmpty()) {
            final AbstractEstimateAppropriation latestAbstractEstimateAppropriation = abstractEstimateAppropriationList
                    .get(abstractEstimateAppropriationList.size() - 1);
            if (latestAbstractEstimateAppropriation != null)
                if (estimate.getDepositCode() == null) {
                    if (latestAbstractEstimateAppropriation.getBudgetUsage().getConsumedAmount() != 0)
                        budgetAvailable = latestAbstractEstimateAppropriation.getBalanceAvailable();
                } else if (latestAbstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount()
                        .doubleValue() != 0) {
                    totalDepositAmt = depositWorksUsageService.getTotalDepositWorksAmount(
                            estimate.getDepositCode().getFund(),
                            latestAbstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails()
                                    .get(0).getCoa(),
                            accountdetailtype, estimate.getDepositCode().getId(),
                            latestAbstractEstimateAppropriation.getDepositWorksUsage().getAppropriationDate());
                    totalUtilizedAmt = depositWorksUsageService.getTotalUtilizedAmountForDepositWorks(
                            latestAbstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails()
                                    .get(0),
                            latestAbstractEstimateAppropriation.getDepositWorksUsage().getCreatedDate());
                    if (totalUtilizedAmt == null)
                        totalUtilizedAmt = BigDecimal.ZERO;
                    balanceAvailable = BigDecimal
                            .valueOf(totalDepositAmt.doubleValue() - totalUtilizedAmt.doubleValue());
                }
        }
        if (estimate.getDepositCode() == null)
            addRow(estimateDetailsTable2, true, centerPara("Balance Amount Available"),
                    centerPara(budgetAvailable == null ? "" : toCurrency(budgetAvailable.doubleValue())));
        else
            addRow(estimateDetailsTable2, true, centerPara("Balance Amount Available"),
                    centerPara(balanceAvailable == null ? "" : toCurrency(balanceAvailable.doubleValue())));
        addRow(estimateDetailsTable2, true, centerPara("Reference"), centerPara(space1));
        addRow(estimateDetailsTable2, true, centerPara("Any Other Remarks"), centerPara(space1 + "\n\n"));

        return estimateDetailsTable2;
    } catch (final Exception e) {
        throw new ApplicationRuntimeException(
                "Exception occured while estimate and budget details method 3" + e);
    }
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private PdfPTable createActivitiesTable(final AbstractEstimate estimate) throws DocumentException {
    final PdfPTable activitiesTable = new PdfPTable(7);
    activitiesTable.setWidthPercentage(100);
    activitiesTable.setWidths(new float[] { 0.5f, 1f, 3.1f, 1.2f, 0.8f, 1.1f, 1.5f });
    addRow(activitiesTable, true, makePara("Sl No"), centerPara("Quantity"), centerPara("Description"),
            centerPara("Sch. No"), centerPara("Unit"), centerPara("Rate"), centerPara("Amount"));
    Collection<Activity> activities = estimate.getSORActivities();
    int index = 1;
    for (final Activity activity : activities) {
        String estimateUom = "";
        if (activity.getUom() == null)
            estimateUom = activity.getSchedule().getUom().getUom();
        else/*from  ww w.jav a  2 s .  co  m*/
            estimateUom = activity.getUom().getUom();
        addRow(activitiesTable, true, makePara(index++), rightPara(activity.getQuantity()),
                makePara(activity.getSchedule().getDescription()), centerPara(activity.getSchedule().getCode()),
                centerPara(estimateUom), rightPara(toCurrency(activity.getSORCurrentRate())),
                rightPara(toCurrency(activity.getAmount())));
    }
    activities = estimate.getNonSORActivities();
    for (final Activity activity : activities)
        addRow(activitiesTable, true, makePara(index++), rightPara(activity.getQuantity()),
                makePara(activity.getNonSor().getDescription()), centerPara(""),
                centerPara(activity.getNonSor().getUom().getUom()), rightPara(toCurrency(activity.getRate())),
                rightPara(toCurrency(activity.getAmount())));
    addRow(activitiesTable, true, centerPara(""), centerPara(""), makePara(""), rightPara(""), centerPara(""),
            centerPara("TOTAL"), rightPara(toCurrency(estimate.getWorkValue())));
    addRow(activitiesTable, true, centerPara(""), centerPara(""), makePara(""), rightPara(""), centerPara(""),
            centerPara("WORK VALUE"), rightPara(toCurrency(estimate.getWorkValueIncludingTaxes())));

    return activitiesTable;
}