Example usage for org.joda.time DateTime getMonthOfYear

List of usage examples for org.joda.time DateTime getMonthOfYear

Introduction

In this page you can find the example usage for org.joda.time DateTime getMonthOfYear.

Prototype

public int getMonthOfYear() 

Source Link

Document

Get the month of year field value.

Usage

From source file:org.egov.ptis.client.bill.PTBillServiceImpl.java

License:Open Source License

/**
 * Setting the EgBillDetails to generate XML as a part of Erpcollection
 * Integration/*from   ww w .  jav  a2  s  .c  o  m*/
 *
 * @see org.egov.demand.interfaces.BillServiceInterface
 */
@Override
public List<EgBillDetails> getBilldetails(final Billable billObj) {
    final List<EgBillDetails> billDetails = new ArrayList<>();
    LOGGER.debug("Entered method getBilldetails : " + billObj);
    EgBillDetails billdetail;
    final PropertyTaxBillable billable = (PropertyTaxBillable) billObj;

    if (billable.isMutationFeePayment()) {
        final Installment currInstallment = propertyTaxCommonUtils.getCurrentInstallment();
        billdetail = new EgBillDetails();
        billdetail.setOrderNo(1);
        billdetail.setCreateDate(new Date());
        billdetail.setModifiedDate(new Date());
        billdetail.setCrAmount(billable.getMutationFee());
        billdetail.setDrAmount(BigDecimal.ZERO);
        billdetail.setGlcode(GLCODE_FOR_MUTATION_FEE);
        billdetail.setDescription(MUTATION_FEE_STR);
        billdetail.setAdditionalFlag(Integer.valueOf(0));
        billdetail.setEgInstallmentMaster(currInstallment);
        billdetail.setAdditionalFlag(Integer.valueOf(1));
        billdetail.setPurpose(PURPOSE.OTHERS.toString());
        billdetail.setFunctionCode(financialUtil.getFunctionCode());
        billDetails.add(billdetail);
        return billDetails;
    }

    String key;
    BigDecimal balance;
    BigDecimal earlyPayRebate = BigDecimal.ZERO;
    DateTime installmentDate;
    BillDetailBean billDetailBean;
    EgDemandReason reason;
    Installment installment;
    String reasonMasterCode;
    final BasicProperty basicProperty = billable.getBasicProperty();
    final Property activeProperty = basicProperty.getProperty();
    TreeMap<Installment, PenaltyAndRebate> installmentPenaltyAndRebate = (TreeMap<Installment, PenaltyAndRebate>) billable
            .getCalculatedPenalty();
    Map<String, Installment> currInstallments = propertyTaxUtil.getInstallmentsForCurrYear(new Date());

    Date advanceStartDate = DateUtils.addYears(currInstallments.get(CURRENTYEAR_FIRST_HALF).getFromDate(), 1);
    List<Installment> advanceInstallments = propertyTaxCommonUtils.getAdvanceInstallmentsList(advanceStartDate);

    billable.setInstTaxBean(installmentPenaltyAndRebate);
    if (installmentPenaltyAndRebate.get(currInstallments.get(CURRENTYEAR_FIRST_HALF)) != null) {
        earlyPayRebate = installmentPenaltyAndRebate.get(currInstallments.get(CURRENTYEAR_FIRST_HALF))
                .getRebate();
    }
    final Ptdemand ptDemand = ptDemandDAO.getNonHistoryCurrDmdForProperty(activeProperty);
    final HashMap<String, Integer> orderMap = propertyTaxUtil
            .generateOrderForDemandDetails(ptDemand.getEgDemandDetails(), billable, advanceInstallments);

    for (final EgDemandDetails demandDetail : ptDemand.getEgDemandDetails()) {
        balance = demandDetail.getAmount().subtract(demandDetail.getAmtCollected());
        reason = demandDetail.getEgDemandReason();
        installment = reason.getEgInstallmentMaster();
        reasonMasterCode = reason.getEgDemandReasonMaster().getCode();
        if (balance.compareTo(BigDecimal.ZERO) == 1) {
            installmentDate = new DateTime(installment.getInstallmentYear().getTime());

            if (isNotPenalty(reasonMasterCode)) {
                key = installmentDate.getMonthOfYear() + "/" + installmentDate.getYear() + "-"
                        + reasonMasterCode;
                billDetailBean = new BillDetailBean(installment, orderMap.get(key), key,
                        demandDetail.getAmount().subtract(demandDetail.getAmtCollected()),
                        demandDetail.getEgDemandReason().getGlcodeId().getGlcode(),
                        reason.getEgDemandReasonMaster().getReasonMaster(), Integer.valueOf(1),
                        definePurpose(demandDetail));

                billDetails.add(createBillDet(billDetailBean));
            }
        }
    }
    addBillDetailsForRebate(billDetails, earlyPayRebate, currInstallments, orderMap);

    getPenaltyAndRebateDmd(billDetails, billable, installmentPenaltyAndRebate, ptDemand, orderMap);

    // Get the demand for current year second half and use it in advance
    // collection
    BigDecimal currentInstDemand = BigDecimal.ZERO;
    for (EgDemandDetails dmdDet : ptDemand.getEgDemandDetails()) {
        if (isDmdForCurrYrSecHalf(currInstallments, dmdDet)) {
            currentInstDemand = currentInstDemand.add(dmdDet.getAmount());
        }
    }
    // Advance Bill details only if current tax is greater than zero.
    if (isCurrTaxGrtZero(currentInstDemand)) {
        createAdvanceBillDetails(billDetails, currentInstDemand, orderMap, ptDemand, billable,
                advanceInstallments, currInstallments.get(CURRENTYEAR_SECOND_HALF));
    }

    LOGGER.debug("Exiting method getBilldetails : " + billDetails);
    return billDetails;
}

From source file:org.egov.ptis.client.bill.PTBillServiceImpl.java

License:Open Source License

private void addBillDetailsForRebate(final List<EgBillDetails> billDetails, BigDecimal earlyPayRebate,
        Map<String, Installment> currInstallments, final HashMap<String, Integer> orderMap) {
    String key;/*  w  w w  .j  a  v  a2 s  .c  o  m*/
    DateTime installmentDate;
    BillDetailBean billDetailBean;
    if (isCurrTaxGrtZero(earlyPayRebate)) {
        installmentDate = new DateTime(
                currInstallments.get(CURRENTYEAR_FIRST_HALF).getInstallmentYear().getTime());
        key = installmentDate.getMonthOfYear() + "/" + installmentDate.getYear() + "-" + DEMANDRSN_CODE_REBATE;
        billDetailBean = new BillDetailBean(currInstallments.get(CURRENTYEAR_FIRST_HALF), orderMap.get(key),
                key, earlyPayRebate, PropertyTaxConstants.GLCODE_FOR_TAXREBATE, DEMANDRSN_CODE_REBATE,
                Integer.valueOf(1), PURPOSE.REBATE.toString());
        billDetails.add(createBillDet(billDetailBean));
    }
}

From source file:org.egov.ptis.client.bill.PTBillServiceImpl.java

License:Open Source License

/**
 * Creates the advance bill details/*  ww w.j a va  2s .c o  m*/
 * 
 * @param billDetails
 * @param orderMap
 * @param currentInstallmentDemand
 * @param demandDetail
 * @param reason
 * @param installment
 */
private void createAdvanceBillDetails(List<EgBillDetails> billDetails, BigDecimal currentInstallmentDemand,
        HashMap<String, Integer> orderMap, Ptdemand ptDemand, PropertyTaxBillable billable,
        List<Installment> advanceInstallments, Installment dmdDetInstallment) {

    BillDetailBean billDetailBean = null;
    /*
     * Advance will be created with current year second half installment.
     * While fetching advance collection, we will pass current year second
     * half installment
     */
    BigDecimal advanceCollection = demandGenericDAO.getBalanceByDmdMasterCodeInst(ptDemand,
            DEMANDRSN_CODE_ADVANCE, getModule(), dmdDetInstallment);

    if (advanceCollection.compareTo(BigDecimal.ZERO) < 0) {
        advanceCollection = advanceCollection.abs();
    }

    BigDecimal partiallyCollectedAmount = advanceCollection.remainder(currentInstallmentDemand);

    Integer noOfAdvancesPaid = (advanceCollection.subtract(partiallyCollectedAmount)
            .divide(currentInstallmentDemand)).intValue();

    LOGGER.debug("getBilldetails - advanceCollection = " + advanceCollection + ", noOfAdvancesPaid="
            + noOfAdvancesPaid);

    String key = null;
    DateTime installmentDate = null;
    Installment installment = null;
    if (noOfAdvancesPaid < MAX_ADVANCES_ALLOWED) {
        for (int i = noOfAdvancesPaid; i < advanceInstallments.size(); i++) {
            installment = advanceInstallments.get(i);
            installmentDate = new DateTime(installment.getInstallmentYear().getTime());
            key = installmentDate.getMonthOfYear() + "/" + installmentDate.getYear() + "-"
                    + DEMANDRSN_CODE_ADVANCE;

            billDetailBean = new BillDetailBean(installment, orderMap.get(key), key,
                    i == noOfAdvancesPaid ? currentInstallmentDemand.subtract(partiallyCollectedAmount)
                            : currentInstallmentDemand,
                    GLCODE_FOR_ADVANCE, DEMANDRSN_STR_ADVANCE, Integer.valueOf(0),
                    PURPOSE.ADVANCE_AMOUNT.toString());
            billDetails.add(createBillDet(billDetailBean));
        }
    } else {
        LOGGER.debug("getBillDetails - All advances are paid...");
    }
}

From source file:org.egov.ptis.client.bill.PTBillServiceImpl.java

License:Open Source License

private EgDemandDetails insertPenaltyAndBillDetails(final List<EgBillDetails> billDetails,
        final PropertyTaxBillable billable, final HashMap<String, Integer> orderMap, BigDecimal penalty,
        final Installment installment) {

    LOGGER.info("Entered into prepareDmdAndBillDetails");
    LOGGER.info("preapreDmdAndBillDetails- Installment : " + installment + ", Penalty Amount: " + penalty);
    String key = null;/*from  ww  w.  j  av a2 s  .  co m*/
    final EgDemandDetails penDmdDtls = getPenaltyDmdDtls(billable, installment);
    EgDemandDetails insertPenDmdDetail = null;

    final boolean thereIsPenalty = penalty != null && penalty.compareTo(BigDecimal.ZERO) != 0 ? true : false;
    final DateTime installmentDate = new DateTime(installment.getInstallmentYear().getTime());

    // Checking whether to impose penalty or not
    if (billable.getLevyPenalty()) {
        /* do not create penalty demand details if penalty is zero */
        if (penDmdDtls == null && thereIsPenalty)
            insertPenDmdDetail = insertPenaltyDmdDetail(installment, penalty);
        else if (penDmdDtls != null)
            penalty = penDmdDtls.getAmount().subtract(penDmdDtls.getAmtCollected());
        if (thereIsPenalty) {
            key = installmentDate.getMonthOfYear() + "/" + installmentDate.getYear() + "-"
                    + DEMANDRSN_CODE_PENALTY_FINES;
            final BillDetailBean billDetailBean = new BillDetailBean(installment, orderMap.get(key), key,
                    penalty, GLCODE_FOR_PENALTY, PropertyTaxConstants.DEMANDRSN_STR_PENALTY_FINES,
                    Integer.valueOf(1), definePurpose(penDmdDtls));
            billDetails.add(createBillDet(billDetailBean));
        }
    }
    return insertPenDmdDetail;
}

From source file:org.egov.ptis.client.service.PenaltyCalculationService.java

License:Open Source License

public Map<Installment, BigDecimal> getInstallmentWisePenalty() throws ValidationException {

    LOGGER.debug("Entered into getInstallmentWisePenalty, basicProperty={}", basicProperty);

    Map<Installment, BigDecimal> installmentWisePenalty = new TreeMap<Installment, BigDecimal>();

    Map<Installment, Date> installmentWisePenaltyEffectiveDates = getPenaltyEffectiveDates(basicProperty,
            new ArrayList<Installment>(installmentWiseDemand.keySet()));

    if (installmentWisePenaltyEffectiveDates.isEmpty()) {
        LOGGER.debug("getInstallmentWisePenalty - installmentWisePenaltyEffectiveDates is empty");
        return null;
    }/*from  w  ww. j a  v a 2 s.c om*/

    LOGGER.debug("getInstallmentWisePenalty - installmentWisePenaltyEffectiveDates={}",
            installmentWisePenaltyEffectiveDates);

    Installment installment = null;
    BigDecimal penalty = BigDecimal.ZERO;
    BigDecimal balancePenalty = BigDecimal.ZERO;
    EgDemandDetails penaltyDemandDetail = null;

    Amount balance = null;
    Amount installmentDemand = null;
    Amount installmentCollection = null;

    DateTime installmentLatestCollectionDate = null;
    DateTime today = new DateTime();

    for (Map.Entry<Installment, Date> mapEntry : installmentWisePenaltyEffectiveDates.entrySet()) {

        installment = mapEntry.getKey();
        penalty = BigDecimal.ZERO;
        installmentDemand = new Amount(installmentWiseDemand.get(installment));
        installmentCollection = new Amount(installmentWiseCollection.get(installment));
        installmentLatestCollectionDate = new DateTime(installmentAndLatestCollDate.get(installment));

        if (!installmentWisePenaltyDemandDetail.isEmpty()) {
            penaltyDemandDetail = installmentWisePenaltyDemandDetail.get(installment);
        }

        if (mapEntry.getValue() != null) {

            balance = installmentDemand.minus(installmentWiseCollection.get(installment));

            if (balance.isGreaterThanZero()) {

                /*
                 * if (installmentCollection.isZero()) { penalty =
                 * calculatePenalty(mapEntry.getValue(),
                 * balance.getAmount()); } else {
                 */

                if (penaltyDemandDetail == null || installmentLatestCollectionDate == null) {

                    LOGGER.debug(
                            "getInstallmentWisePenalty - Penalty demand detail / collection date is null for {} ",
                            installment);
                    penalty = calculatePenalty(mapEntry.getValue(), balance.getAmount());

                } else {

                    if (penaltyDemandDetail.getAmtCollected().compareTo(BigDecimal.ZERO) > 0) {
                        balancePenalty = penaltyDemandDetail.getAmount()
                                .subtract(penaltyDemandDetail.getAmtCollected());
                    }

                    if (installmentLatestCollectionDate.getMonthOfYear() == today.getMonthOfYear()
                            && installmentLatestCollectionDate.getYear() == today.getYear()) {

                        penalty = balancePenalty.compareTo(BigDecimal.ZERO) > 0 ? balancePenalty
                                : calculatePenalty(mapEntry.getValue(), balance.getAmount());

                    } else {
                        penalty = calculatePenalty(mapEntry.getValue(), balance.getAmount())
                                .add(balancePenalty);
                    }

                }
                // }
            }
        }

        installmentWisePenalty.put(mapEntry.getKey(), penalty);
    }

    LOGGER.debug("getInstallmentWisePenalty, installmentWisePenalty={}", installmentWisePenalty);
    LOGGER.debug("Exiting from getInstallmentWisePenalty");

    return installmentWisePenalty;
}

From source file:org.egov.ptis.client.util.PropertyTaxUtil.java

License:Open Source License

public HashMap<String, Integer> generateOrderForDemandDetails(final Set<EgDemandDetails> demandDetails,
        final PropertyTaxBillable billable, final List<Installment> advanceInstallments) {

    final Map<Date, String> instReasonMap = new TreeMap<>();
    final HashMap<String, Integer> orderMap = new HashMap<>();
    BigDecimal balance;//from   ww  w  .  j  av a  2  s .c  om
    Date key = null;
    String reasonMasterCode = null;
    final Map<String, Installment> currYearInstMap = getInstallmentsForCurrYear(new Date());

    for (final EgDemandDetails demandDetail : demandDetails) {
        balance = demandDetail.getAmount().subtract(demandDetail.getAmtCollected());

        if (balance.compareTo(BigDecimal.ZERO) > 0) {
            final EgDemandReason reason = demandDetail.getEgDemandReason();
            final Installment installment = reason.getEgInstallmentMaster();
            final DateTime dateTime = new DateTime(installment.getInstallmentYear());
            reasonMasterCode = reason.getEgDemandReasonMaster().getCode();

            LOGGER.info(reasonMasterCode);
            key = getOrder(installment.getInstallmentYear(),
                    DEMAND_REASON_ORDER_MAP.get(reasonMasterCode).intValue());
            instReasonMap.put(key,
                    dateTime.getMonthOfYear() + "/" + dateTime.getYear() + "-" + reasonMasterCode);
        }
    }
    if (rebateService.isEarlyPayRebateActive(
            billable.getReceiptDate() != null ? billable.getReceiptDate() : new Date())) {
        final Installment currFirstHalf = currYearInstMap.get(CURRENTYEAR_FIRST_HALF);
        final DateTime dateTime = new DateTime(currFirstHalf.getInstallmentYear());
        key = getOrder(currFirstHalf.getInstallmentYear(), DEMAND_REASON_ORDER_MAP.get(DEMANDRSN_CODE_REBATE));
        instReasonMap.put(key,
                dateTime.getMonthOfYear() + "/" + dateTime.getYear() + "-" + DEMANDRSN_CODE_REBATE);
    }

    DateTime dateTime = null;
    for (final Installment inst : advanceInstallments) {
        dateTime = new DateTime(inst.getInstallmentYear());

        key = getOrder(inst.getInstallmentYear(), DEMAND_REASON_ORDER_MAP.get(DEMANDRSN_CODE_ADVANCE));

        instReasonMap.put(key,
                dateTime.getMonthOfYear() + "/" + dateTime.getYear() + "-" + DEMANDRSN_CODE_ADVANCE);
    }

    BigDecimal penaltyAmount;
    for (final Map.Entry<Installment, PenaltyAndRebate> mapEntry : billable.getInstTaxBean().entrySet()) {
        penaltyAmount = mapEntry.getValue().getPenalty();
        final boolean thereIsPenalty = penaltyAmount != null && penaltyAmount.compareTo(BigDecimal.ZERO) > 0;
        if (thereIsPenalty) {
            dateTime = new DateTime(mapEntry.getKey().getInstallmentYear());

            key = getOrder(mapEntry.getKey().getInstallmentYear(),
                    DEMAND_REASON_ORDER_MAP.get(DEMANDRSN_CODE_PENALTY_FINES));
            instReasonMap.put(key,
                    dateTime.getMonthOfYear() + "/" + dateTime.getYear() + "-" + DEMANDRSN_CODE_PENALTY_FINES);
        }
    }

    int order = 1;
    final Map<String, Map<String, String>> installmentAndReason = new LinkedHashMap<>();

    for (final Map.Entry<Date, String> entry : instReasonMap.entrySet()) {
        final String[] split = entry.getValue().split("-");
        if (installmentAndReason.get(split[0]) == null) {
            final Map<String, String> reason = new HashMap<>();
            reason.put(split[1], entry.getValue());
            installmentAndReason.put(split[0], reason);
        } else
            installmentAndReason.get(split[0]).put(split[1], entry.getValue());
    }

    for (final String installmentYear : installmentAndReason.keySet())
        for (final String reasonCode : PropertyTaxConstants.ORDERED_DEMAND_RSNS_LIST)
            if (installmentAndReason.get(installmentYear).get(reasonCode) != null)
                orderMap.put(installmentAndReason.get(installmentYear).get(reasonCode), order++);

    return orderMap;
}

From source file:org.egov.ptis.domain.service.notice.RecoveryNoticeService.java

License:Open Source License

private ReportRequest generateDistressNotice(final BasicProperty basicProperty,
        final Map<String, Object> reportParams, final City city, final String noticeNo) {
    ReportRequest reportInput;//from  w  w w.j  ava2 s.c  o  m
    final Address ownerAddress = basicProperty.getAddress();
    reportParams.put(TOTAL_TAX_DUE, getTotalPropertyTaxDueIncludingPenalty(basicProperty));
    final DateTime noticeDate = new DateTime();
    reportParams.put(DOOR_NO,
            StringUtils.isNotBlank(ownerAddress.getHouseNoBldgApt()) ? ownerAddress.getHouseNoBldgApt().trim()
                    : "N/A");
    reportParams.put(CONSUMER_ID, basicProperty.getUpicNo());
    reportParams.put(NOTICE_DAY, propertyTaxCommonUtils.getDateWithSufix(noticeDate.getDayOfMonth()));
    reportParams.put(NOTICE_MONTH, noticeDate.monthOfYear().getAsShortText());
    reportParams.put(NOTICE_YEAR, noticeDate.getYear());
    if (noticeDate.getMonthOfYear() >= 4 && noticeDate.getMonthOfYear() <= 10)
        reportParams.put(FIN_HALF_STRAT_MONTH, "April");
    else
        reportParams.put(FIN_HALF_STRAT_MONTH, "October");
    reportParams.put(DISTRESS_NOTICE_NUMBER, noticeNo);
    reportParams.put(DISTRESS_NOTICE_DATE, DateUtils.getDefaultFormattedDate(new Date()));
    final String cityGrade = city.getGrade();
    if (org.apache.commons.lang.StringUtils.isNotEmpty(cityGrade)
            && cityGrade.equalsIgnoreCase(PropertyTaxConstants.CITY_GRADE_CORPORATION)) {
        reportParams.put(SECTION_ACT, PropertyTaxConstants.CORPORATION_ESD_NOTICE_SECTION_ACT);
        reportInput = new ReportRequest(PropertyTaxConstants.REPORT_DISTRESS_CORPORATION, reportParams,
                reportParams);
    } else {
        reportParams.put(SECTION_ACT, PropertyTaxConstants.MUNICIPALITY_DISTRESS_NOTICE_SECTION_ACT);
        reportInput = new ReportRequest(PropertyTaxConstants.REPORT_DISTRESS_MUNICIPALITY, reportParams,
                reportParams);
    }
    return reportInput;
}

From source file:org.egov.works.web.adaptor.WorksMilestoneIndexJsonAdaptor.java

License:Open Source License

@Override
public JsonElement serialize(final WorksMilestoneIndexResponse response, final Type type,
        final JsonSerializationContext jsc) {
    final JsonObject jsonObject = new JsonObject();
    if (response != null) {
        jsonObject.addProperty(response.getReporttype(), response.getName());
        jsonObject.addProperty("Total no of works", response.getTotalnoofworks());
        jsonObject.addProperty("Total estimated cost in lakhs",
                BigDecimal.valueOf(response.getTotalestimatedcostinlakhs() / 100000)
                        .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        jsonObject.addProperty("Total work order value in lakhs",
                BigDecimal.valueOf(response.getTotalworkordervalueinlakhs() / 100000)
                        .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        jsonObject.addProperty("Total bill amount in lakhs",
                BigDecimal.valueOf(response.getTotalbillamountinlakhs() / 100000)
                        .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        jsonObject.addProperty("Total paid amount in lakhs",
                BigDecimal.valueOf(response.getTotalpaidamountinlakhs() / 100000)
                        .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        jsonObject.addProperty("Milestone not created", response.getMilestonenotcreatedcount());
        final DateTime currentDate = new DateTime();
        switch (currentDate.getMonthOfYear()) {
        case 1:/*from   w  w w.j  a v  a2s.com*/
            worksReportJsonAdaptorHelper.showJanuaryData(response, jsonObject, currentDate);
            break;
        case 2:
            worksReportJsonAdaptorHelper.showFebruaryData(response, jsonObject, currentDate);

            break;
        case 3:
            worksReportJsonAdaptorHelper.showMarchData(response, jsonObject, currentDate);

            break;
        case 4:
            worksReportJsonAdaptorHelper.showAprilData(response, jsonObject, currentDate);
            break;
        case 5:
            worksReportJsonAdaptorHelper.showMayData(response, jsonObject, currentDate);

            break;
        case 6:
            worksReportJsonAdaptorHelper.showJuneData(response, jsonObject, currentDate);
            break;
        case 7:
            worksReportJsonAdaptorHelper.showJulyData(response, jsonObject, currentDate);

            break;
        case 8:
            worksReportJsonAdaptorHelper.showAugustData(response, jsonObject, currentDate);

            break;
        case 9:
            worksReportJsonAdaptorHelper.showSeptemberData(response, jsonObject, currentDate);

            break;
        case 10:
            worksReportJsonAdaptorHelper.showOctoberData(response, jsonObject, currentDate);
            break;
        case 11:
            worksReportJsonAdaptorHelper.showNovemberData(response, jsonObject, currentDate);

            break;
        case 12:
            worksReportJsonAdaptorHelper.showDecemberData(response, jsonObject, currentDate);

            break;
        default:
            break;
        }

        jsonObject.addProperty("Financial progress %", BigDecimal.valueOf(response.getFinancialprogress())
                .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
    }
    return jsonObject;
}

From source file:org.egov.works.web.adaptor.WorksSectorReportJsonAdaptor.java

License:Open Source License

@Override
public JsonElement serialize(final WorksMilestoneIndexResponse response, final Type type,
        final JsonSerializationContext jsc) {
    final JsonObject jsonObject = new JsonObject();
    if (response != null) {

        jsonObject.addProperty("District Name", response.getDistrictname());
        jsonObject.addProperty("ULB Name", response.getUlbname());
        jsonObject.addProperty("Sector", response.getTypeofwork());
        jsonObject.addProperty("Fund", response.getFund());

        if (response.getScheme() != null)
            jsonObject.addProperty("Scheme", response.getScheme());
        else//ww  w .  j  av  a  2 s  .c  o m
            jsonObject.addProperty("Scheme", "NA");
        if (response.getSubscheme() != null)
            jsonObject.addProperty("Sub Scheme", response.getSubscheme());
        else
            jsonObject.addProperty("Sub Scheme", "NA");
        jsonObject.addProperty("Ward", response.getWard());
        jsonObject.addProperty("Estimate Number", response.getEstimatenumber());
        jsonObject.addProperty("Work Identification Number", response.getWin());
        jsonObject.addProperty("Name of the work", response.getNameofthework());
        if (response.getTotalestimatedcostinlakhs() != null)
            jsonObject.addProperty("Estimated cost in lakhs",
                    BigDecimal.valueOf(response.getTotalestimatedcostinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Estimated cost in lakhs", "0.00");
        jsonObject.addProperty("Agreement Number", response.getAgreementnumber());
        jsonObject.addProperty("Agreement Date",
                response.getAgreementdate() != null
                        ? DateUtils.getDefaultFormattedDate(response.getAgreementdate())
                        : "");
        jsonObject.addProperty("Contractor Name and code", response.getContractornamecode());
        jsonObject.addProperty("Contract Period(in days)", response.getContractperiod());
        if (response.getTotalworkordervalueinlakhs() != null)
            jsonObject.addProperty("Work order value in lakhs",
                    BigDecimal.valueOf(response.getTotalworkordervalueinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Work order value in lakhs", "0.00");
        if (response.getTotalbillamountinlakhs() != null)
            jsonObject.addProperty("Total bill amount in lakhs",
                    BigDecimal.valueOf(response.getTotalbillamountinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Total bill amount in lakhs", "0.00");
        if (response.getTotalpaidamountinlakhs() != null)
            jsonObject.addProperty("Total paid amount in lakhs",
                    BigDecimal.valueOf(response.getTotalpaidamountinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Total paid amount in lakhs", "0.00");
        jsonObject.addProperty("Is Milestone created", response.getIsmilestonecreated());
        final DateTime currentDate = new DateTime();
        switch (currentDate.getMonthOfYear()) {
        case 1:
            worksReportJsonAdaptorHelper.showJanuaryData(response, jsonObject, currentDate);
            break;
        case 2:
            worksReportJsonAdaptorHelper.showFebruaryData(response, jsonObject, currentDate);

            break;
        case 3:
            worksReportJsonAdaptorHelper.showMarchData(response, jsonObject, currentDate);

            break;
        case 4:
            worksReportJsonAdaptorHelper.showAprilData(response, jsonObject, currentDate);
            break;
        case 5:
            worksReportJsonAdaptorHelper.showMayData(response, jsonObject, currentDate);

            break;
        case 6:
            worksReportJsonAdaptorHelper.showJuneData(response, jsonObject, currentDate);
            break;
        case 7:
            worksReportJsonAdaptorHelper.showJulyData(response, jsonObject, currentDate);

            break;
        case 8:
            worksReportJsonAdaptorHelper.showAugustData(response, jsonObject, currentDate);

            break;
        case 9:
            worksReportJsonAdaptorHelper.showSeptemberData(response, jsonObject, currentDate);

            break;
        case 10:
            worksReportJsonAdaptorHelper.showOctoberData(response, jsonObject, currentDate);
            break;
        case 11:
            worksReportJsonAdaptorHelper.showNovemberData(response, jsonObject, currentDate);

            break;
        case 12:
            worksReportJsonAdaptorHelper.showDecemberData(response, jsonObject, currentDate);

            break;
        default:
            break;
        }

        jsonObject.addProperty("Financial progress %", BigDecimal.valueOf(response.getFinancialprogress())
                .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        jsonObject.addProperty("Latest updated time stamp", response.getLatestupdatedtimestamp());
    }
    return jsonObject;
}

From source file:org.egov.works.web.adaptor.WorksTransactionIndexJsonAdaptor.java

License:Open Source License

@Override
public JsonElement serialize(final WorksMilestoneIndexResponse response, final Type type,
        final JsonSerializationContext jsc) {
    final JsonObject jsonObject = new JsonObject();
    if (response != null) {
        jsonObject.addProperty("Fund", response.getFund());
        if (response.getScheme() != null)
            jsonObject.addProperty("Scheme", response.getScheme());
        else/* ww w . jav  a2 s  .c  o m*/
            jsonObject.addProperty("Scheme", "NA");
        if (response.getSubscheme() != null)
            jsonObject.addProperty("Sub Scheme", response.getSubscheme());
        else
            jsonObject.addProperty("Sub Scheme", "NA");
        jsonObject.addProperty("Ward", response.getWard());
        jsonObject.addProperty("Estimate Number", response.getEstimatenumber());
        jsonObject.addProperty("Work Identification Number", response.getWin());
        jsonObject.addProperty("Name of the work", response.getNameofthework());
        if (response.getTotalestimatedcostinlakhs() != null)
            jsonObject.addProperty("Estimated cost in lakhs",
                    BigDecimal.valueOf(response.getTotalestimatedcostinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Estimated cost in lakhs", "0.00");
        jsonObject.addProperty("Agreement Number", response.getAgreementnumber());
        jsonObject.addProperty("Agreement Date",
                response.getAgreementdate() != null
                        ? DateUtils.getDefaultFormattedDate(response.getAgreementdate())
                        : "");
        jsonObject.addProperty("Contract Period(in days)", response.getContractperiod());
        if (response.getTotalworkordervalueinlakhs() != null)
            jsonObject.addProperty("Work order value in lakhs",
                    BigDecimal.valueOf(response.getTotalworkordervalueinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Work order value in lakhs", "0.00");
        if (response.getTotalbillamountinlakhs() != null)
            jsonObject.addProperty("Total bill amount in lakhs",
                    BigDecimal.valueOf(response.getTotalbillamountinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Total bill amount in lakhs", "0.00");
        if (response.getTotalpaidamountinlakhs() != null)
            jsonObject.addProperty("Total paid amount in lakhs",
                    BigDecimal.valueOf(response.getTotalpaidamountinlakhs() / 100000)
                            .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
        else
            jsonObject.addProperty("Total paid amount in lakhs", "0.00");

        final DateTime currentDate = new DateTime();
        switch (currentDate.getMonthOfYear()) {
        case 1:
            worksReportJsonAdaptorHelper.showJanuaryData(response, jsonObject, currentDate);
            break;
        case 2:
            worksReportJsonAdaptorHelper.showFebruaryData(response, jsonObject, currentDate);

            break;
        case 3:
            worksReportJsonAdaptorHelper.showMarchData(response, jsonObject, currentDate);

            break;
        case 4:
            worksReportJsonAdaptorHelper.showAprilData(response, jsonObject, currentDate);
            break;
        case 5:
            worksReportJsonAdaptorHelper.showMayData(response, jsonObject, currentDate);

            break;
        case 6:
            worksReportJsonAdaptorHelper.showJuneData(response, jsonObject, currentDate);
            break;
        case 7:
            worksReportJsonAdaptorHelper.showJulyData(response, jsonObject, currentDate);

            break;
        case 8:
            worksReportJsonAdaptorHelper.showAugustData(response, jsonObject, currentDate);

            break;
        case 9:
            worksReportJsonAdaptorHelper.showSeptemberData(response, jsonObject, currentDate);

            break;
        case 10:
            worksReportJsonAdaptorHelper.showOctoberData(response, jsonObject, currentDate);
            break;
        case 11:
            worksReportJsonAdaptorHelper.showNovemberData(response, jsonObject, currentDate);

            break;
        case 12:
            worksReportJsonAdaptorHelper.showDecemberData(response, jsonObject, currentDate);

            break;
        default:
            break;
        }

        jsonObject.addProperty("Financial progress %", BigDecimal.valueOf(response.getFinancialprogress())
                .setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
    }
    return jsonObject;
}