Example usage for org.joda.time DateTime getYear

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

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

License:Open Source License

/**
 * Creates the advance bill details//from   w  w w .  j  a v a 2  s . co 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 .  ja  v  a 2  s.  c o  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.model.PropertyBillInfo.java

License:Open Source License

public String getFinancialYear() {
    DateTime fromDate = new DateTime(currentInstallment.getFromDate());
    DateTime toDate = new DateTime(currentInstallment.getToDate());
    return fromDate.getYear() + "-" + toDate.getYear();
}

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 av a 2  s  . c  o  m*/

    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 o m*/
    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.jav a  2 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.ptis.domain.service.notice.RecoveryNoticeService.java

License:Open Source License

private ReportRequest generateInventoryNotice(final BasicProperty basicProperty,
        final Map<String, Object> reportParams, final City city, final SimpleDateFormat formatter) {
    ReportRequest reportInput;//from w  w  w .  ja  v a 2 s . c o m
    final Installment currentInstall = propertyTaxCommonUtils.getCurrentPeriodInstallment();
    final DateTime dateTime = new DateTime();
    final DateTime currInstToDate = new DateTime(currentInstall.getToDate());
    reportParams.put(TOTAL_TAX_DUE, String.valueOf(getTotalPropertyTaxDue(basicProperty)));
    reportParams.put(REPORT_DATE, propertyTaxCommonUtils.getDateWithSufix(dateTime.getDayOfMonth()));
    reportParams.put(REPORT_MON_YEAR, dateTime.monthOfYear().getAsShortText() + "," + dateTime.getYear());

    final String cityGrade = city.getGrade();
    if (StringUtils.isNotBlank(cityGrade)
            && cityGrade.equalsIgnoreCase(PropertyTaxConstants.CITY_GRADE_CORPORATION)) {
        reportParams.put(INST_LAST_DATE,
                propertyTaxCommonUtils.getDateWithSufix(currInstToDate.getDayOfMonth()));
        reportParams.put(INST_MON_YEAR,
                currInstToDate.monthOfYear().getAsShortText() + "," + currInstToDate.getYear());
        reportInput = new ReportRequest(REPORT_INVENTORY_NOTICE_CORPORATION, reportParams, reportParams);
    } else {
        reportParams.put(INST_LAST_DATE, formatter.format(currentInstall.getToDate()));
        reportInput = new ReportRequest(REPORT_INVENTORY_NOTICE_MUNICIPALITY, reportParams, reportParams);
    }
    return reportInput;
}

From source file:org.egov.wtms.application.service.collection.ConnectionBillService.java

License:Open Source License

public Map<String, Integer> generateOrderForDemandDetails(Set<EgDemandDetails> demandDetails, Billable billable,
        List<Installment> advanceInstallments, Map<String, Installment> currInstallments) {

    Map<Date, String> instReasonMap = new TreeMap<>();
    HashMap<String, Integer> orderMap = new HashMap<>();
    Date key;/* w w w.j  av a2 s .  c  o m*/
    DateTime dateTime;
    for (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);
    }
    int order = 1;
    Map<String, Map<String, String>> installmentAndReason = new LinkedHashMap<>();

    for (Map.Entry<Date, String> entry : instReasonMap.entrySet()) {
        String[] split = entry.getValue().split("-");
        if (installmentAndReason.get(split[0]) == null) {
            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 (String installmentYear : installmentAndReason.keySet())
        for (String reasonCode : 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.emonocot.job.dwc.write.ArchiveMetadataWriter.java

License:Open Source License

private Eml getEml() {
    Eml eml = new Eml();
    if (citationString != null) {
        DateTime now = new DateTime();
        Integer year = new Integer(now.getYear());
        citationString = citationString.replace("{0}", year.toString()).replace("{1}",
                dateTimeFormatter.print(now));
    }/*from   ww w  .  j  ava2  s .  c  om*/
    eml.setCitation(citationString, identifier);
    Agent resourceCreator = new Agent();
    resourceCreator.setEmail(creatorEmail);
    resourceCreator.setFirstName(creatorName);
    eml.setResourceCreator(resourceCreator);
    eml.setDescription(description);
    eml.setHomepageUrl(homepageUrl);
    eml.setLogoUrl(logoUrl);
    eml.setTitle(title);
    eml.setSubject(subject);
    eml.setPublished(new Date());
    Agent metadataProvider = new Agent();
    metadataProvider.setEmail(publisherEmail);
    metadataProvider.setFirstName(publisherName);
    eml.setMetadataProvider(metadataProvider);
    eml.setIntellectualRights(rights);
    return eml;
}

From source file:org.encuestame.mvc.view.FrontEndRssFeedView.java

License:Apache License

@Override
protected Channel newFeed() {
    final Channel channel = new Channel("rss_2.0");
    channel.setPubDate(new Date());
    channel.setDescription("Last Items Published");
    channel.setTitle("Last Items Published");
    final DateTime time = new DateTime();
    channel.setCopyright(String.valueOf(time.getYear()));
    channel.setPubDate(time.toDate());/*from ww w  . ja v  a 2  s  .c o m*/
    channel.setLink("");
    return channel;
}