Example usage for java.lang Double intValue

List of usage examples for java.lang Double intValue

Introduction

In this page you can find the example usage for java.lang Double intValue.

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Double as an int after a narrowing primitive conversion.

Usage

From source file:net.cbtltd.rest.nextpax.A_Handler.java

@Override
public synchronized void readSchedule() {
    LOG.debug("NextPax readSchedule() key: " + this.getApikey() + "_started");
    Scanner sc = null;/*w w  w.jav a2 s.  c  om*/
    Date version = new Date();
    String line = "";
    String message = "readSchedule";
    String altid;
    String periodid;
    String startdate;
    String enddate;
    Double length;
    String lastminute;
    String rentprice;
    String bookingcosts;
    String discount;
    String othercosts;
    String totalprice;
    String discountcode;
    String recordhash;
    String[] houseinformation;

    Product product = null;

    String partyId = getAltpartyid();

    boolean firsttime = true;
    long startTime = System.currentTimeMillis();

    LOG.debug(message);
    final SqlSession sqlSession = RazorServer.openSession();
    String filename = "paxgenerator_available_bookingnet_" + getApikey() + ".csv";
    try {
        // RelationService.load(sqlSession, Downloaded.PRODUCT_DOWNLOAD_DATE, getAltpartyid(), new Date().toString());

        long startTimeForCSVRead = System.currentTimeMillis();
        sc = new Scanner(ftp(filename));
        // sc = new Scanner(new BufferedReader(new InputStreamReader(
        // new FileInputStream(System.getProperty("user.home")
        // + File.separator
        // + "PMS"
        // + File.separator
        // + "nextpax"
        // + File.separator
        // + getApikey()
        // + File.separator
        // + filename)
        // )));
        long endTimeForCSVRead = System.currentTimeMillis();
        LOG.debug("Time taken to read csv: " + (endTimeForCSVRead - startTimeForCSVRead));

        SortedSet<DateTime> availableDates = new TreeSet<DateTime>();
        List<Price> prices = new ArrayList<Price>();
        long startTimeForProductProcessing = 0;
        int i = 0;

        // remove header information.
        line = sc.nextLine();
        String currenthouse = "";
        while (sc.hasNext()) {
            line = sc.nextLine();
            if (line.isEmpty()) {
                continue;
            }
            houseinformation = line.split("\\|");

            if (firsttime) {
                currenthouse = houseinformation[0];
                product = sqlSession.getMapper(ProductMapper.class).altread(new NameId(partyId, currenthouse));
                if (product == null) {
                    continue;
                }
                firsttime = false;
                // product = PartnerService.getProduct(sqlSession, partyId, currenthouse); // check for null
                startTimeForProductProcessing = System.currentTimeMillis();
            }

            altid = houseinformation[0];
            periodid = houseinformation[1];
            startdate = houseinformation[2];
            enddate = houseinformation[3];
            length = Double.valueOf(houseinformation[4]);
            lastminute = houseinformation[5];
            rentprice = houseinformation[6];
            bookingcosts = houseinformation[7];
            discount = houseinformation[8];
            othercosts = houseinformation[9];
            totalprice = houseinformation[10];
            discountcode = houseinformation[11];
            recordhash = houseinformation[12];

            // price table
            Price price = new Price();
            price.setAltid(periodid);
            price.setPartyid(getAltpartyid());
            price.setEntitytype(NameId.Type.Product.name());
            price.setEntityid(product.getId());
            price.setCurrency(Currency.Code.EUR.name());
            price.setQuantity(length);
            price.setUnit(Unit.DAY);
            price.setName(Price.RACK_RATE);
            price.setType(NameId.Type.Reservation.name());
            price.setDate(DF.parse(startdate));
            price.setTodate(DF.parse(enddate));

            net.cbtltd.shared.Price exists = sqlSession.getMapper(PriceMapper.class).existsAltID(price);

            price.setFactor(1.0);
            price.setOrganizationid(getAltpartyid());
            price.setRule(getDayOfWeek(DF.parse(startdate)));
            price.setAvailable(1);
            price.setState(Price.CREATED);
            double unitprice = Double.valueOf(totalprice) / length; // what is this ?
            price.setValue(NameId.round(Double.valueOf(totalprice) / length));
            price.setMinimum(Double.valueOf(totalprice));
            price.setMinStay(length.intValue());
            price.setVersion(version);

            price.setEntityid(product.getId());
            if (exists != null) {
                //add price into array and update it after
                // sqlSession.getMapper(PriceMapper.class).create(price);

                // check if there is reservation for this price.
                // if reservation is created and we still get the price,
                // we need to cancel the reservation
                Reservation action = new Reservation();
                action.setProductid(product.getId());
                action.setFromdate(price.getDate());
                action.setTodate(price.getTodate());
                action = sqlSession.getMapper(ReservationMapper.class).collides(action);
                if (action != null && StringUtils.isNotBlank(action.getAltid())) {
                    // cancel this reservation
                    PartnerService.cancelReservation(sqlSession, action);
                }
                price.setId(exists.getId());
                // sqlSession.getMapper(PriceMapper.class).update(price);
            }
            prices.add(price);

            // when we come across a new house will create reservations for
            // the blocked dates for the previous house.
            // create a map of available dates
            // iterate through prices and check off the dates from the
            // collection of month dates and use the rest of the dates
            // to create the reservation
            if (currenthouse.compareTo(altid) != 0 || !sc.hasNext()) {
                if (!sc.hasNext()) {
                    addToAvailableDates(availableDates, startdate, enddate);
                }

                createSchedule(availableDates, product, version, sqlSession);
                // insert list of prices
                sqlSession.getMapper(PriceMapper.class).insertList(prices);
                // clear list
                prices.clear();
                sqlSession.commit();

                LOG.debug("Time taken for Product Process " + currenthouse + " : "
                        + (System.currentTimeMillis() - startTimeForProductProcessing));

                // now cancel price for existing property that we did not process in this run.
                sqlSession.getMapper(PriceMapper.class).cancelversion(price);

                // reset fields
                // create a new set for the next home
                currenthouse = altid;
                availableDates = new TreeSet<DateTime>();
                // product = PartnerService.getProduct(sqlSession, partyId, currenthouse);
                product = sqlSession.getMapper(ProductMapper.class).altread(new NameId(partyId, currenthouse));
                startTimeForProductProcessing = System.currentTimeMillis();
            }

            if (sc.hasNext()) {
                addToAvailableDates(availableDates, startdate, enddate);
            }

            /*            i++;
                        if (i > 0 && i % IsPartner.PRICE_BATCH_SIZE == 0) {
                           LOG.debug("Smart flush for price: " + i);
                           sqlSession.commit();
                        }*/
        }
        sqlSession.commit();

        // Cancel old reservations.
        resetStartTime();
        cancelOldReservations(sqlSession, version);
        LOG.debug("Canceled old reservations: " + (System.currentTimeMillis() - getStartTime()));
        // sqlSession.commit(); // why duplicate?

    } catch (Throwable x) {
        sqlSession.rollback();
        LOG.error(x.getMessage());
    } finally {
        if (sc != null) {
            try {
                sc.close();
                delete(filename);
                sqlSession.close();
            } catch (Exception e) {
                LOG.error(e.getMessage());
            }
        }
    }
    long endTime = System.currentTimeMillis();
    LOG.debug("NextPax readSchedule() for key: " + this.getApikey() + " done." + " Time: "
            + (endTime - startTime));
    MonitorService.monitor(message, version);
}

From source file:com.nec.harvest.service.impl.ProfitByShopServiceImpl.java

/**
 * //ww w  .j av  a 2s  .c  o m
 * @param jiseki
 * @param mapPreviousYearBudget
 * @param mapCurrentYearBudget
 * @param inventoryPricePreviousMonth
 * @param inventoryPriceCurrentMonth
 * @param mode
 * @param taxRate
 * @param restDay
 * @param daysInMonth
 * @return
 */
private ProfitMonthlyBean calculateProfitMonthly(VJiseki jiseki,
        Map<String, BudgetPerformance> mapPreviousYearBudget,
        Map<String, BudgetPerformance> mapCurrentYearBudget, Double inventoryPricePreviousMonth,
        Double inventoryPriceCurrentMonth, boolean mode, double taxRate, int restDay, int daysInMonth) {

    final int HUNDRED = 100;
    final int THOUSAND = 1000;

    ProfitMonthlyBean profitMonthlyBean = new ProfitMonthlyBean();
    if (jiseki == null && mapPreviousYearBudget == null && mapCurrentYearBudget == null
            && inventoryPricePreviousMonth == null && inventoryPriceCurrentMonth == null) {
        return profitMonthlyBean;
    }

    //
    Double tmp = null;

    //      // No10 (No6)
    //      if (!mode && jiseki != null) {
    //         Double uriSkKG = jiseki.getUriSkKG();
    //         if (uriSkKG != null) {
    //            tmp = Math.floor((uriSkKG - Math
    //                  .floor((uriSkKG / (HUNDRED + taxRate)) * taxRate))
    //                  / THOUSAND); // integer
    //            tmp = (tmp == 0.0d ? null : tmp);
    //         }
    //      }
    //      profitMonthlyBean.setCurrentFoodIncome(tmp);

    // Modified by SONDN: Update SPEC 20141222
    // No10 (No6)
    if (!mode && jiseki != null) {
        Double uriSkKG = jiseki.getUriSkKG();
        Double ktSkKG = jiseki.getKtSkKG();
        Double idoSkKGU = jiseki.getIdoSkKGU();
        Double idoSkKGH = jiseki.getIdoSkKGH();
        if (uriSkKG != null || ktSkKG != null || idoSkKGU != null || idoSkKGH != null) {
            double step1 = uriSkKG == null ? 0
                    : uriSkKG - Math.floor((uriSkKG / (HUNDRED + taxRate)) * taxRate);
            double step2 = ktSkKG == null ? 0 : ktSkKG;
            if (restDay != -1) {
                step2 = (step2 / daysInMonth) * restDay;
            }
            double step3 = idoSkKGU == null ? 0 : idoSkKGU;
            double step4 = idoSkKGH == null ? 0 : idoSkKGH;

            tmp = Math.floor((step1 + step2 + step3 - step4) / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setCurrentFoodIncome(tmp);

    // No11 (No7)
    tmp = null;
    if (!mode && jiseki != null) {
        Double uriKrKG = jiseki.getUriKrKG();
        Double ktKrKG = jiseki.getKtKrKG();
        if (uriKrKG != null || ktKrKG != null) {
            double step1 = uriKrKG == null ? 0
                    : uriKrKG - Math.floor((uriKrKG / (HUNDRED + taxRate)) * taxRate);
            double step2 = ktKrKG == null ? 0 : ktKrKG;

            if (restDay != -1) {
                step1 = (step1 / daysInMonth) * restDay;
                step2 = (step2 / daysInMonth) * restDay;
            }

            tmp = Math.floor((step1 + step2) / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setCurrentManageIncome(tmp);

    // No12 (No8)
    tmp = null;
    if (mapPreviousYearBudget != null && mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7111) != null) {
        tmp = mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7111).getJisekiKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setPreviousYearIncomeTotal(tmp);

    // No13 (No9)
    tmp = null;
    if (mapCurrentYearBudget != null && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7111) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7111).getYosanKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setExpectedYearIncomeTotal(tmp);

    // No14 (No10)
    tmp = null;
    if (mode && mapCurrentYearBudget != null
            && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7111) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7111).getJisekiKingaku();
        if (tmp != null) {
            Math.floor(tmp = tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    } else if (profitMonthlyBean.getCurrentFoodIncome() != null
            || profitMonthlyBean.getCurrentManageIncome() != null) { // check
        // No10
        // or
        // No11
        // not
        // null
        // No10 + No11;
        tmp = (profitMonthlyBean.getCurrentFoodIncome() == null ? 0 : profitMonthlyBean.getCurrentFoodIncome())
                + (profitMonthlyBean.getCurrentManageIncome() == null ? 0
                        : profitMonthlyBean.getCurrentManageIncome());
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentYearIncomeTotal(tmp);

    // No15 (No11)
    tmp = null;
    if (profitMonthlyBean.getCurrentYearIncomeTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != 0) { // check
        // No12
        // not
        // null
        // or
        // dif
        // 0
        // No14 / No12;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentYearIncomeTotal() / profitMonthlyBean.getPreviousYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalPreviousYearIncomeRatio(tmp);

    // No16 (No12)
    tmp = null;
    if (profitMonthlyBean.getCurrentYearIncomeTotal() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != 0) { // check
        // No13
        // not
        // null
        // or
        // dif
        // 0
        // No14 / No13;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentYearIncomeTotal() / profitMonthlyBean.getExpectedYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalExpectedYearIncomeRatio(tmp);

    // No18 (No14) = No27
    tmp = null;
    if (mapPreviousYearBudget != null && mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7521) != null) {
        tmp = mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7521).getJisekiKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setPreviousYearCostPrice(tmp);
    profitMonthlyBean.setPreviousYearCostPriceTotal(tmp); // No27

    // No19 (No15)
    tmp = null;
    profitMonthlyBean.setPreviousYearCostPriceRatio(tmp);

    // No20 (No16) = No29
    tmp = null;
    if (mapCurrentYearBudget != null && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7521) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7521).getYosanKingaku();
        tmp = (tmp == 0.0d ? null : tmp);
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setExpectedCostPrice(tmp);
    profitMonthlyBean.setExpectedCostPriceTotal(tmp); // No29

    // No21 (No17)
    tmp = null;
    profitMonthlyBean.setExpectedCostPriceRatio(tmp);

    // No22 (No18)
    tmp = null;
    if (mode && mapCurrentYearBudget != null
            && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7521) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K7521).getJisekiKingaku();
        tmp = (tmp == null ? 0 : Math.floor(tmp / THOUSAND)); // integer
        tmp = (tmp == 0.0d ? null : tmp);
    } else if (jiseki != null) {
        if (jiseki.getKtSrKG() != null || jiseki.getKgcSrKG() != null || jiseki.getKgcSrKG() != null
                || jiseki.getKnSrKG() != null || jiseki.getIdoSrKGU() != null || jiseki.getIdoSrKGH() != null) {
            double step1 = (jiseki.getKtSrKG() == null ? 0 : jiseki.getKtSrKG());
            if (restDay != -1) {
                step1 = (step1 / daysInMonth) * restDay;
            }

            double step2 = (jiseki.getKgcSrKG() == null ? 0
                    : (jiseki.getKgcSrKG()
                            - Math.floor((jiseki.getKgcSrKG() / (HUNDRED + taxRate)) * taxRate)));

            tmp = Math.floor(((jiseki.getKnSrKG() == null ? 0 : jiseki.getKnSrKG()) + step1 + step2
                    + (jiseki.getIdoSrKGU() == null ? 0 : jiseki.getIdoSrKGU())
                    - (jiseki.getIdoSrKGH() == null ? 0 : jiseki.getIdoSrKGH())) / THOUSAND); // Integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setCurrentCostPrice(tmp);

    // No23 (No19)
    tmp = null;
    if (!mode && profitMonthlyBean.getCurrentCostPrice() != null
            && profitMonthlyBean.getCurrentFoodIncome() != null
            && profitMonthlyBean.getCurrentFoodIncome() != 0) { // check
        // No14 not
        // null or
        // dif 0
        // No22 / No10;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentCostPrice() / profitMonthlyBean.getCurrentFoodIncome()) * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentCostPriceRatio(tmp);

    // No24 (No20)
    tmp = null;
    if (profitMonthlyBean.getCurrentCostPrice() != null
            && profitMonthlyBean.getPreviousYearCostPriceTotal() != null
            && profitMonthlyBean.getPreviousYearCostPriceTotal() != 0) { // check
        // No27
        // not
        // null
        // or
        // dif
        // 0
        // No22 / No27;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentCostPrice() / profitMonthlyBean.getPreviousYearCostPriceTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setPreviousCostPriceRatioTotal(tmp);

    // No25 (No21)
    tmp = null;
    if ((profitMonthlyBean.getCurrentCostPrice() != null)
            && ((profitMonthlyBean.getExpectedCostPriceTotal() != null)
                    && (profitMonthlyBean.getExpectedCostPriceTotal() != 0))) { // check No29 not
        // null or dif 0
        // No22 / No29;
        tmp = RoundNumericUtil
                .round((profitMonthlyBean.getCurrentCostPrice() / profitMonthlyBean.getExpectedCostPriceTotal())
                        * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalExpectedCostPriceRatio(tmp);

    // No26 (No22)
    tmp = null;
    if (!mode && inventoryPriceCurrentMonth != null) {
        tmp = inventoryPriceCurrentMonth / THOUSAND; // integer
        tmp = (tmp == 0.0d ? null : Double.parseDouble(String.valueOf(tmp.intValue())));
    }
    profitMonthlyBean.setCurrentInventoryCost(tmp);

    // No17 (No13)
    tmp = null;
    if (mode || profitMonthlyBean.getCurrentInventoryCost() == null || inventoryPricePreviousMonth == null) {
        tmp = null;
    } else {
        // update SPEC 01/09/2014
        if (restDay != -1 && (inventoryPriceCurrentMonth != null && inventoryPriceCurrentMonth == 0.0d)) {
            tmp = null;
        } else {
            tmp = inventoryPricePreviousMonth / 1000;
            tmp = (tmp == 0.0d ? null : Double.parseDouble(String.valueOf(tmp.intValue())));
        } // end

    }
    profitMonthlyBean.setPreviousInventoryCost(tmp);

    // No28 (No24)
    tmp = null;
    if (profitMonthlyBean.getPreviousYearCostPriceTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != 0) { // check
        // No12
        // not
        // null
        // or
        // dif
        // 0
        // No27 / No12;
        tmp = RoundNumericUtil.round((profitMonthlyBean.getPreviousYearCostPriceTotal()
                / profitMonthlyBean.getPreviousYearIncomeTotal()) * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setPreviousYearCostPriceRatioTotal(tmp);

    // No30 (No26)
    tmp = null;
    if ((profitMonthlyBean.getExpectedCostPriceTotal() != null)
            && ((profitMonthlyBean.getExpectedYearIncomeTotal() != null)
                    && (profitMonthlyBean.getExpectedYearIncomeTotal() != 0))) { // check No13
        // not null or
        // dif 0
        // No29 / No13;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getExpectedCostPriceTotal() / profitMonthlyBean.getExpectedYearIncomeTotal())
                        * HUNDRED,
                1);

        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setExpectedCostPriceRatioTotal(tmp);

    // No31 (No27) = No17 + No22 - No26
    tmp = null;
    if (profitMonthlyBean.getPreviousInventoryCost() != null || profitMonthlyBean.getCurrentCostPrice() != null
            || profitMonthlyBean.getCurrentInventoryCost() != null) {
        tmp = (profitMonthlyBean.getPreviousInventoryCost() == null ? 0
                : profitMonthlyBean.getPreviousInventoryCost())
                + (profitMonthlyBean.getCurrentCostPrice() == null ? 0
                        : profitMonthlyBean.getCurrentCostPrice())
                - (profitMonthlyBean.getCurrentInventoryCost() == null ? 0
                        : profitMonthlyBean.getCurrentInventoryCost());
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentCostPriceTotal(tmp);

    // No32 (No28)
    tmp = null;
    if (profitMonthlyBean.getCurrentCostPriceTotal() != null
            && profitMonthlyBean.getCurrentYearIncomeTotal() != null
            && profitMonthlyBean.getCurrentYearIncomeTotal() != 0) { // check
        // No14
        // not
        // null
        // or
        // dif
        // 0
        // No31 / No14;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentCostPriceTotal() / profitMonthlyBean.getCurrentYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentCostPriceRatioTotal(tmp);

    // No33 (No29)
    tmp = null;
    if (profitMonthlyBean.getCurrentCostPriceTotal() != null
            && profitMonthlyBean.getPreviousYearCostPriceTotal() != null
            && profitMonthlyBean.getPreviousYearCostPriceTotal() != 0) { // check
        // No27
        // not
        // null
        // or
        // dif
        // 0
        // No31 / No27;
        tmp = RoundNumericUtil.round((profitMonthlyBean.getCurrentCostPriceTotal()
                / profitMonthlyBean.getPreviousYearCostPriceTotal()) * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalCostPriceRatio(tmp);

    // No34 (No30)
    tmp = null;
    if (profitMonthlyBean.getCurrentCostPriceTotal() != null
            && profitMonthlyBean.getExpectedCostPriceTotal() != null
            && profitMonthlyBean.getExpectedCostPriceTotal() != 0) { // check
        // No27
        // not
        // null
        // or
        // dif
        // 0
        // No31 / No29;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentCostPriceTotal() / profitMonthlyBean.getExpectedCostPriceTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalExpCostPriceRatio(tmp);

    // No35 (No31)
    tmp = null;
    if (mapPreviousYearBudget != null && mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8110) != null) {
        tmp = mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8110).getJisekiKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setPreviousYearHumanCost(tmp);

    // No36 (No32)
    tmp = null;
    if (profitMonthlyBean.getPreviousYearHumanCost() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != 0) { // check
        // No12
        // not
        // null
        // or
        // dif
        // 0
        // No35 / No12;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getPreviousYearHumanCost() / profitMonthlyBean.getPreviousYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setPreviousYearHumanCostRatio(tmp);

    // No37 (No33)
    tmp = null;
    if (mapCurrentYearBudget != null && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8110) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8110).getYosanKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setExpectedHumanCost(tmp);

    // No38 (No34)
    tmp = null;
    if (profitMonthlyBean.getExpectedHumanCost() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != 0) { // check
        // No13
        // not
        // null
        // or
        // dif
        // 0
        // No37 / No13;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getExpectedHumanCost() / profitMonthlyBean.getExpectedYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setExpectedHumanCostRatio(tmp);

    // No39 (No35)
    tmp = null;
    if (mode && mapCurrentYearBudget != null
            && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8110) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8110).getJisekiKingaku();
        if (tmp != null) {
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    } else if (jiseki != null) {
        if (jiseki.getKtJkKG() != null || jiseki.getKgcJkKG() != null || jiseki.getJkJkKG() != null
                || jiseki.getIdoJkKGU() != null || jiseki.getIdoJkKGH() != null || jiseki.getHelpJkKGU() != null
                || jiseki.getHelpJkKGH() != null) {
            double step1 = (jiseki.getKtJkKG() == null ? 0 : jiseki.getKtJkKG());
            if (restDay != -1) {
                step1 = (step1 / daysInMonth) * restDay;
            }

            double step2 = (jiseki.getKgcJkKG() == null ? 0
                    : (jiseki.getKgcJkKG()
                            - Math.floor((jiseki.getKgcJkKG() / (HUNDRED + taxRate)) * taxRate)));

            tmp = Math.floor(((jiseki.getJkJkKG() == null ? 0 : jiseki.getJkJkKG()) + step1 + step2
                    + (jiseki.getIdoJkKGU() == null ? 0 : jiseki.getIdoJkKGU())
                    - (jiseki.getIdoJkKGH() == null ? 0 : jiseki.getIdoJkKGH())
                    + (jiseki.getHelpJkKGU() == null ? 0 : jiseki.getHelpJkKGU())
                    - (jiseki.getHelpJkKGH() == null ? 0 : jiseki.getHelpJkKGH())) / THOUSAND); // Integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setCurrentHumanCost(tmp);

    // No40 (No36)
    tmp = null;
    if (profitMonthlyBean.getCurrentHumanCost() != null && profitMonthlyBean.getCurrentYearIncomeTotal() != null
            && profitMonthlyBean.getCurrentYearIncomeTotal() != 0) { // check
        // No14
        // not
        // null
        // or
        // dif
        // 0
        // No39 / No14;
        tmp = RoundNumericUtil
                .round((profitMonthlyBean.getCurrentHumanCost() / profitMonthlyBean.getCurrentYearIncomeTotal())
                        * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentHumanCostRatio(tmp);

    // No41 (No37)
    tmp = null;
    if (profitMonthlyBean.getCurrentHumanCost() != null && profitMonthlyBean.getPreviousYearHumanCost() != null
            && profitMonthlyBean.getPreviousYearHumanCost() != 0) { // check
        // No35
        // not
        // null
        // or
        // dif 0
        // No39 / No35;
        tmp = RoundNumericUtil
                .round((profitMonthlyBean.getCurrentHumanCost() / profitMonthlyBean.getPreviousYearHumanCost())
                        * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalPreviousYearHumanCostRatio(tmp);

    // No42 (No38)
    tmp = null;
    if (profitMonthlyBean.getCurrentHumanCost() != null && profitMonthlyBean.getExpectedHumanCost() != null
            && profitMonthlyBean.getExpectedHumanCost() != 0) { // check
        // No37 not
        // null or
        // dif 0
        // No39 / No37;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentHumanCost() / profitMonthlyBean.getExpectedHumanCost()) * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalExpectedYearHumanCostRatio(tmp);

    // No43 (No39)
    tmp = null;
    if (mapPreviousYearBudget != null && mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8210) != null) {
        tmp = mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8210).getJisekiKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setPreviousYearBudget(tmp);

    // No44 (No40)
    tmp = null;
    if (profitMonthlyBean.getPreviousYearBudget() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != 0) { // check
        // No12
        // not
        // null
        // or
        // dif
        // 0
        // No43 / No12;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getPreviousYearBudget() / profitMonthlyBean.getPreviousYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setPreviousYearBudgetRatio(tmp);

    // No45 (No41)
    tmp = null;
    if (mapCurrentYearBudget != null && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8210) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8210).getYosanKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer            
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setExptectedBudget(tmp);

    // No46 (No42)
    tmp = null;
    if (profitMonthlyBean.getExptectedBudget() != null && profitMonthlyBean.getExpectedYearIncomeTotal() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != 0) { // check
        // No13
        // not
        // null
        // or
        // dif
        // 0
        // No45 / No13;
        tmp = RoundNumericUtil
                .round((profitMonthlyBean.getExptectedBudget() / profitMonthlyBean.getExpectedYearIncomeTotal())
                        * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setExptectedBudgetRatio(tmp);

    // No47 (No43)
    tmp = null;
    if (mode && mapCurrentYearBudget != null
            && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8210) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8210).getJisekiKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND);
            tmp = (tmp == 0.0d ? null : tmp);
        }
    } else if (jiseki != null) {
        if (jiseki.getKtKhKG() != null || jiseki.getKgcKhKG() != null || jiseki.getUriKhKG() != null
                || jiseki.getKnKhKG() != null || jiseki.getIdoKhKGH() != null || jiseki.getIdoKhKGU() != null) {
            double step1 = (jiseki.getKtKhKG() == null ? 0 : jiseki.getKtKhKG());

            double step2 = (jiseki.getKgcKhKG() == null ? 0
                    : (jiseki.getKgcKhKG()
                            - Math.floor((jiseki.getKgcKhKG() / (HUNDRED + taxRate)) * taxRate)));

            double step3 = (jiseki.getUriKhKG() == null ? 0
                    : (jiseki.getUriKhKG()
                            - Math.floor((jiseki.getUriKhKG() / (HUNDRED + taxRate)) * taxRate)));

            if (restDay != -1) {
                step1 = (step1 / daysInMonth) * restDay;
                step3 = (step3 / daysInMonth) * restDay;
            }

            tmp = Math.floor((step1 + (jiseki.getKnKhKG() == null ? 0 : jiseki.getKnKhKG()) + step2 + step3
                    + (jiseki.getIdoKhKGU() == null ? 0 : jiseki.getIdoKhKGU())
                    - (jiseki.getIdoKhKGH() == null ? 0 : jiseki.getIdoKhKGH())) / THOUSAND);
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setCurrentBudget(tmp);

    // No 48 (No44)
    tmp = null;
    if (profitMonthlyBean.getCurrentBudget() != null && profitMonthlyBean.getCurrentYearIncomeTotal() != null
            && profitMonthlyBean.getCurrentYearIncomeTotal() != 0) { // check
        // No14
        // not
        // null
        // or
        // dif
        // 0
        // No47 / No14;
        tmp = RoundNumericUtil
                .round((profitMonthlyBean.getCurrentBudget() / profitMonthlyBean.getCurrentYearIncomeTotal())
                        * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentBudgetRatio(tmp);

    // No49 (No45)
    tmp = null;
    if ((profitMonthlyBean.getCurrentBudget() != null) && ((profitMonthlyBean.getPreviousYearBudget() != null)
            && (profitMonthlyBean.getPreviousYearBudget() != 0))) { // check No43 not
        // null or dif 0
        // No47 / No43;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentBudget() / profitMonthlyBean.getPreviousYearBudget()) * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalPreviousYearBudgetRatio(tmp);

    // No50 (No46)
    tmp = null;
    if (profitMonthlyBean.getCurrentBudget() != null && profitMonthlyBean.getExptectedBudget() != null
            && profitMonthlyBean.getExptectedBudget() != 0) { // check No45
        // not null
        // or dif 0
        // No47 / No45;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentBudget() / profitMonthlyBean.getExptectedBudget()) * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalExpectedBudgetRatio(tmp);

    // No51 (No47)
    tmp = null;
    if (mapPreviousYearBudget != null && mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8310) != null) {
        tmp = mapPreviousYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8310).getJisekiKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setPreviousYearPersonnelProfit(tmp);

    // No52 (No48)
    tmp = null;
    if (profitMonthlyBean.getPreviousYearPersonnelProfit() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != null
            && profitMonthlyBean.getPreviousYearIncomeTotal() != 0) { // check
        // No12
        // not
        // null
        // or
        // dif
        // 0
        // No51 / No12;
        tmp = RoundNumericUtil.round((profitMonthlyBean.getPreviousYearPersonnelProfit()
                / profitMonthlyBean.getPreviousYearIncomeTotal()) * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setPreviousYearPersonnelProfitRatio(tmp);

    // No53 (No49)
    tmp = null;
    if (mapCurrentYearBudget != null && mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8310) != null) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8310).getYosanKingaku();
        if (tmp != null) {
            // hungpd: amount tighten equals business day
            if (restDay != -1) {
                tmp = (tmp / daysInMonth) * restDay;
            }
            // hungpd: end
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    }
    profitMonthlyBean.setExpectedPersonnelProfit(tmp);

    // No54 (No50)
    tmp = null;
    if (profitMonthlyBean.getExpectedPersonnelProfit() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != null
            && profitMonthlyBean.getExpectedYearIncomeTotal() != 0) { // check
        // No13
        // not
        // null
        // or
        // dif
        // 0
        // No53 / No13;
        tmp = RoundNumericUtil.round((profitMonthlyBean.getExpectedPersonnelProfit()
                / profitMonthlyBean.getExpectedYearIncomeTotal()) * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setExpectedPersonnelProfitRatio(tmp);

    // No55 (No51)
    tmp = null;
    if ((mode) && (mapCurrentYearBudget != null)
            && (mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8310) != null)) {
        tmp = mapCurrentYearBudget.get(Constants.DEFAULT_KMKCODEJ_K8310).getJisekiKingaku();
        if (tmp != null) {
            tmp = Math.floor(tmp / THOUSAND); // integer
            tmp = (tmp == 0.0d ? null : tmp);
        }
    } else {
        // No55 = No14 - No31 - No39 - No47
        if (profitMonthlyBean.getCurrentYearIncomeTotal() != null
                || profitMonthlyBean.getCurrentCostPriceTotal() != null
                || profitMonthlyBean.getCurrentHumanCost() != null
                || profitMonthlyBean.getCurrentBudget() != null) {

            tmp = (profitMonthlyBean.getCurrentYearIncomeTotal() == null ? 0
                    : profitMonthlyBean.getCurrentYearIncomeTotal())
                    - (profitMonthlyBean.getCurrentCostPriceTotal() == null ? 0
                            : profitMonthlyBean.getCurrentCostPriceTotal())
                    - (profitMonthlyBean.getCurrentHumanCost() == null ? 0
                            : profitMonthlyBean.getCurrentHumanCost())
                    - (profitMonthlyBean.getCurrentBudget() == null ? 0 : profitMonthlyBean.getCurrentBudget());
            tmp = (tmp == 0.0d ? null : tmp);
        }

    }
    profitMonthlyBean.setCurrentPersonnelProfit(tmp);

    // No56 (No52)
    tmp = null;
    if (profitMonthlyBean.getCurrentPersonnelProfit() != null
            && profitMonthlyBean.getCurrentYearIncomeTotal() != null
            && profitMonthlyBean.getCurrentYearIncomeTotal() != 0) {
        // No55 / No14;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentPersonnelProfit() / profitMonthlyBean.getCurrentYearIncomeTotal())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setCurrentPersonnelProfitRatio(tmp);

    // No57 (No53)
    tmp = null;
    if (profitMonthlyBean.getCurrentPersonnelProfit() != null
            && profitMonthlyBean.getPreviousYearPersonnelProfit() != null
            && profitMonthlyBean.getPreviousYearPersonnelProfit() != 0) {
        // No55 / No51;
        tmp = RoundNumericUtil.round((profitMonthlyBean.getCurrentPersonnelProfit()
                / profitMonthlyBean.getPreviousYearPersonnelProfit()) * HUNDRED, 1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalPreviousYearPersonnelProfitRatio(tmp);

    // No58 (No54)
    tmp = null;
    if (profitMonthlyBean.getCurrentPersonnelProfit() != null
            && profitMonthlyBean.getExpectedPersonnelProfit() != null
            && profitMonthlyBean.getExpectedPersonnelProfit() != 0) {
        // No55 / No53;
        tmp = RoundNumericUtil.round(
                (profitMonthlyBean.getCurrentPersonnelProfit() / profitMonthlyBean.getExpectedPersonnelProfit())
                        * HUNDRED,
                1);
        tmp = (tmp == 0.0d ? null : tmp);
    }
    profitMonthlyBean.setTotalExpectedPersonnelProfitRatio(tmp);
    return profitMonthlyBean;
}