Example usage for org.joda.time LocalDate dayOfMonth

List of usage examples for org.joda.time LocalDate dayOfMonth

Introduction

In this page you can find the example usage for org.joda.time LocalDate dayOfMonth.

Prototype

public Property dayOfMonth() 

Source Link

Document

Get the day of month property which provides access to advanced functionality.

Usage

From source file:ru.codemine.ccms.sales.domino.DominoSalesLoader.java

License:Open Source License

@Override
public void processSales(List<Shop> shops) {
    emailExtractor.saveAllAttachment();//  w w w.  j  a v a  2  s  . c  om

    Map<LocalDate, Map<String, Sales>> processMap = getSalesMap();

    if (!processMap.isEmpty()) {
        for (Entry<LocalDate, Map<String, Sales>> entry : processMap.entrySet()) {
            LocalDate date = entry.getKey();
            Map<String, Sales> valuesMap = entry.getValue();

            for (Shop shop : shops) {
                Sales saleFromMap = valuesMap.get(shop.getDominoName());
                if (saleFromMap != null) {
                    SalesMeta sm = salesService.getByShopAndDate(shop, date.withDayOfMonth(1),
                            date.dayOfMonth().withMaximumValue());
                    Sales sales = sm.getByDate(date);
                    sales.setValue(saleFromMap.getValue());
                    sales.setCashback(saleFromMap.getCashback());
                    sales.setChequeCount(saleFromMap.getChequeCount());
                    salesService.update(sm);
                } else {
                    log.warn("?  ?    "
                            + shop.getName() + ",    " + date.toString("dd.MM.YYYY"));
                    //log.warn("? : " + shop.getDominoName());
                }
            }
        }

        log.info("??   ");
    } else {
        log.info("?   ? ");
    }

}

From source file:ru.codemine.ccms.utils.Utils.java

License:Open Source License

/**
 *   -   /*from www  .  j  ava  2  s .c o  m*/
 * @param dateMonth
 *  ??
 * @param dateYear
 *  
 * @return
 */
public Map<Shop, SalesMeta> getShopSalesMap(String dateMonth, String dateYear) {
    LocalDate selectedStartDate;
    LocalDate selectedEndDate;
    DateTimeFormatter formatter = DateTimeFormat.forPattern("dd MMMM YYYY");
    if (dateMonth != null && dateYear != null) //  
    {
        selectedStartDate = formatter.parseLocalDate("01 " + dateMonth + " " + dateYear);
        selectedEndDate = selectedStartDate.dayOfMonth().withMaximumValue();
    } else // -  ??,  
    {
        selectedStartDate = LocalDate.now().withDayOfMonth(1);
        selectedEndDate = selectedStartDate.dayOfMonth().withMaximumValue();
    }

    List<Shop> shopList = shopService.getAllOpen();
    Map<Shop, SalesMeta> salesMap = new LinkedHashMap();
    for (Shop shop : shopList) {
        SalesMeta sm = salesService.getByShopAndDate(shop, selectedStartDate, selectedEndDate);

        if (shop.isCountersEnabled()) {
            for (Sales sales : sm.getSales()) {
                Counter counter = counterService.getByShopAndDate(shop,
                        sales.getDate().toDateTime(LocalTime.MIDNIGHT));
                sales.setPassability(counter == null ? 0 : counter.getIn());
            }
        }
        salesMap.put(shop, sm);
    }

    return salesMap;
}