Example usage for java.math BigDecimal ZERO

List of usage examples for java.math BigDecimal ZERO

Introduction

In this page you can find the example usage for java.math BigDecimal ZERO.

Prototype

BigDecimal ZERO

To view the source code for java.math BigDecimal ZERO.

Click Source Link

Document

The value 0, with a scale of 0.

Usage

From source file:com.ssbusy.controller.checkout.CheckoutController.java

private String saveSingleShip0(HttpServletRequest request, HttpServletResponse response, Model model,
        OrderInfoForm orderInfoForm, MyBillingInfoForm billingForm, MyShippingInfoForm shippingForm,
        BindingResult result, boolean ajax)
        throws PricingException, ServiceException, CheckoutException, ParseException {
    MyCustomer myCustomer = (MyCustomer) CustomerState.getCustomer();
    Region region = myCustomer.getRegion();
    Boolean w_flag = (Boolean) request.getSession().getAttribute("w_flag");
    if (region == null) {
        if (w_flag != null && w_flag) {
            return "redirect:/weixin/region";
        } else//  ww w. ja va  2  s. c  om
            return REDIRECT_REGION_SELECT;
    }

    MyAddress myAddress = processShippingForm(shippingForm, result);
    if (result.hasErrors()) {
        putFulfillmentOptionsAndEstimationOnModel(model);
        populateModelWithShippingReferenceData(request, model);
        model.addAttribute("states", stateService.findStates());
        model.addAttribute("countries", countryService.findCountries());
        model.addAttribute("expirationMonths", populateExpirationMonths());
        model.addAttribute("expirationYears", populateExpirationYears());
        model.addAttribute("validShipping", false);
        if (w_flag != null && w_flag) {
            return "weixin/cart/w_checkout";
        } else
            return checkoutAddress;
    }

    billingForm.setPaymentMethod(shippingForm.getPaymentMethod());
    billingForm.setBp_pay(shippingForm.getBp_pay());
    billingForm.setAlipay(shippingForm.getAlipay());
    if (shippingForm.getBp_pay() == null || shippingForm.getBp_pay().doubleValue() < 0)
        billingForm.setBp_pay(BigDecimal.ZERO);
    if (shippingForm.getAlipay() == null || shippingForm.getAlipay().doubleValue() < 0)
        billingForm.setAlipay(BigDecimal.ZERO);
    billingForm.setMyAddress(myAddress);
    prepopulateCheckoutForms(CartState.getCart(), orderInfoForm, null, billingForm);

    String assign = request.getParameter("assign");
    MyOrder cart = (MyOrder) CartState.getCart();

    Date dStart = null, dEnd = null;
    Date nowDay = Calendar.getInstance().getTime();
    if (nowDay.after(myDate1) && nowDay.before(myDate2)) {
        dStart = myDate1;
        dEnd = myDate2;
    } else if (nowDay.after(myDate2) && nowDay.before(myDate3)) {
        dStart = myDate2;
        dEnd = myDate3;
    } else if (nowDay.after(myDate3) && nowDay.before(myDate4)) {
        dStart = myDate3;
        dEnd = myDate4;
    }
    if (dStart != null) {
        List<Order> orders = myorderService.getAllSubmittedInTime(myCustomer.getId(), dStart, dEnd);
        boolean contain = ifCanAdd(orders);
        if (contain) {
            if (w_flag != null && w_flag) {
                return "redirect:/weixin/checkout";
            } else
                return "redirect:/checkout/checkout-step-2?error=%E4%B8%8D%E8%A6%81%E5%A4%AA%E8%B4%AA%E5%BF%83%EF%BC%8C%E5%8F%AA%E8%83%BD%E6%8A%A21%E6%AC%A1%E5%93%A6";
        }
    }

    String a1;
    Date a2;
    if ("2".equals(assign)) {
        String date = request.getParameter("date");
        String detaildate = request.getParameter("detaildate");
        int deta = 0;
        try {
            deta = Integer.parseInt(detaildate);
        } catch (Exception e) {
            // ignore
        }

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, deta);
        if ("1".equals(date)) {
            calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1);
        } else if ("2".equals(date)) {
            calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 2);
        }
        SimpleDateFormat dateformat1 = new SimpleDateFormat("HH:mm");
        a2 = calendar.getTime();
        a1 = dateformat1.format(a2);
    } else {
        SimpleDateFormat dateformat1 = new SimpleDateFormat("HH:mm");
        a2 = new Date();
        a1 = dateformat1.format(a2);
    }
    cart.setDelieverDate(a2);

    FulfillmentGroup fulfillmentGroup = cart.getFulfillmentGroups().get(0);

    fulfillmentGroup.setAddress(shippingForm.getMyAddress());
    fulfillmentGroup.setPersonalMessage(shippingForm.getPersonalMessage());
    fulfillmentGroup.setDeliveryInstruction(shippingForm.getDeliveryMessage());

    cart = (MyOrder) orderService.save(cart, true);
    CartState.setCart(cart);
    CustomerAddress defaultAddress = customerAddressService
            .findDefaultCustomerAddress(CustomerState.getCustomer().getId());
    if (defaultAddress == null) {
        MyAddress address = (MyAddress) addressService.saveAddress(shippingForm.getMyAddress());
        CustomerAddress customerAddress = customerAddressService.create();
        customerAddress.setAddress(address);
        customerAddress.setCustomer(CustomerState.getCustomer());
        customerAddress = customerAddressService.saveCustomerAddress(customerAddress);
        customerAddressService.makeCustomerAddressDefault(customerAddress.getId(),
                customerAddress.getCustomer().getId());
    }

    // ????
    if (false) {// if("no".equals(request.getParameter("forcedSubmit"))){
        String[] times = region.getShipping_time().split(";");
        boolean isOutDeliveryDateRange = true;
        for (String time : times) {
            String[] shipping_time = time.split("-");
            if ((a1.compareTo(shipping_time[0]) > 0) && (a1.compareTo(shipping_time[1]) < 0))
                isOutDeliveryDateRange = false;
        }
        if (isOutDeliveryDateRange) {
            return "redirect:/checkout/checkout-step-2?flag=1";
        }
    }

    try {
        if ("alipay_pay".equals(billingForm.getPaymentMethod())) {
            String description = "";
            for (OrderItem ot : cart.getOrderItems()) {
                description = description + ot.getName() + "";
                if (description.length() > 50) {
                    description = description + "....";
                    break;
                }
            }
            // TODO ?location
            FulfillmentLocation loc = null;
            List<FulfillmentGroup> fgroups = cart.getFulfillmentGroups();
            if (fgroups == null || fgroups.size() == 0) {
                Customer customer = CustomerState.getCustomer();
                if (customer instanceof MyCustomer)
                    loc = ((MyCustomer) customer).getRegion().getFulfillmentLocations().get(0);
            } else {
                Address addr = fgroups.get(0).getAddress();
                if (addr instanceof MyAddress) {
                    loc = ((MyAddress) addr).getDormitory().getAreaAddress().getRegion()
                            .getFulfillmentLocations().get(0);
                }
            }
            // TODO path??alipay
            String path = "/alipay/direct_pay?tradeNo="
                    + (new SimpleDateFormat("yyyyMMddHHmm").format(SystemTime.asDate()) + cart.getId())
                    + "&subject= " + (loc == null ? "" : loc.getId())
                    + (new Date().getTime() % 1000000) + cart.getId() + " ??&description=" + description
                    + "&tradeUrl=http://www.onxiao.com/customer/orders";
            if (billingForm.getAlipay().compareTo(cart.getTotal().getAmount()) >= 0) {
                // ?
                path = path + "&totalFee=" + cart.getTotal();
                return "forward:" + path;

            } else {
                if (billingForm.getAlipay().doubleValue() == 0) {
                    return completeCodCheckout(request, response, model, billingForm, result);
                } else {
                    // ?
                    path = path + "&totalFee=" + billingForm.getAlipay();
                    return "forward:" + path;
                }
            }
        } else if ("balance_pay".equals(billingForm.getPaymentMethod())) {
            if (billingForm.getBp_pay().compareTo(cart.getTotal().getAmount()) >= 0) {
                return completeBpCheckout(request, response, model, billingForm, result);
            } else {
                if (billingForm.getAlipay().doubleValue() <= 0) {
                    return completeCodCheckout(request, response, model, billingForm, result);
                } else {
                    return complexCheckout(request, response, model, billingForm, result,
                            MyPaymentInfoType.Payment_Bp, cart.getId());
                }
            }

        } else if ("integral_pay".equals(billingForm.getPaymentMethod())) {
            return completeIntegrlCheckout(request, response, model, billingForm, result);
        } else {
            return completeCodCheckout(request, response, model, billingForm, result);
        }
    } catch (CheckoutException e) {
        if (ajax)
            throw e;
        if (e.getCause() instanceof InventoryUnavailableException) {
            try {
                if (w_flag != null && w_flag) {
                    return "redirect:/weixin/checkout";
                } else
                    return "redirect:/checkout/checkout-step-2?inventoryError=1&errorMessage=" + URLEncoder
                            .encode(((InventoryUnavailableException) e.getCause()).getMessage(), "utf-8");
            } catch (UnsupportedEncodingException e1) {
                if (w_flag != null && w_flag) {
                    return "redirect:/weixin/checkout";
                } else
                    return "redirect:/checkout/checkout-step-2?inventoryError=1&errorMessage="
                            + ((InventoryUnavailableException) e.getCause()).getMessage();
            }
        } else if (e.getCause() instanceof InsufficientFundsException) {
            if (w_flag != null && w_flag) {
                return "redirect:/weixin/checkout";
            } else
                return "redirect:/checkout/checkout-step-2?error=%E7%A7%AF%E5%88%86%E6%88%96%E8%80%85%E4%BD%99%E9%A2%9D%E4%B8%8D%E8%B6%B3";
        } else {
            throw e;
        }
    }
}

From source file:com.sunchenbin.store.feilong.core.lang.NumberUtil.java

/**
 * ?(null)./*from  w w  w . j  a  va 2  s .  c  o m*/
 *
 * @param numbers
 *            the numbers
 * @return the  value
 * @since 1.2.1
 */
public static BigDecimal getAddValue(Number... numbers) {
    BigDecimal returnValue = BigDecimal.ZERO;
    for (Number number : numbers) {
        if (Validator.isNotNullOrEmpty(number)) {
            BigDecimal bigDecimal = ConvertUtil.toBigDecimal(number);
            returnValue = returnValue.add(bigDecimal);
        }
    }
    return returnValue;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398ModularBudgetV1_0Generator.java

/**
 * /*from  ww  w  .  j  a v a 2  s  .com*/
 * This method is used to get 1st BudgetPeriod for Modular Budget form
 * 
 * @param budgetPeriod
 *            budget period 1.
 * @return Periods object containing modular budget details for the
 *         corresponding budget period.
 */
private Periods getPeriods(BudgetPeriodContract budgetPeriod) {
    Periods periods = Periods.Factory.newInstance();
    DirectCost directCost = DirectCost.Factory.newInstance();
    IndirectCost indirectCost = IndirectCost.Factory.newInstance();

    ScaleTwoDecimal consortiumFandA = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal directCostLessConsortiumFandA = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalDirectCosts = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdTotalIndirectCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdBaseCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdRate = ScaleTwoDecimal.ZERO;
    String costType = null;

    // BudgetPeriod
    periods.setBudgetPeriod(1);

    // StartDate and EndDate

    if (budgetPeriod.getStartDate() != null) {
        periods.setBudgetPeriodStartDate(s2SDateTimeService.convertDateToCalendar(budgetPeriod.getStartDate()));
    }
    if (budgetPeriod.getEndDate() != null) {
        periods.setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(budgetPeriod.getEndDate()));
    }

    // Set dfault values for mandatory fields.
    directCost.setDirectCostLessConsortiumFandA(BigDecimal.ZERO);
    directCost.setTotalFundsRequestedDirectCosts(BigDecimal.ZERO);
    periods.setTotalFundsRequestedDirectIndirectCosts(BigDecimal.ZERO);

    // TotalDirectAndIndirectCost
    BudgetModularContract budgetModular = budgetPeriod.getBudgetModular();
    if (budgetModular != null) {
        ScaleTwoDecimal totalCost = getTotalCost(budgetModular);
        periods.setTotalFundsRequestedDirectIndirectCosts(totalCost.bigDecimalValue());
        cumulativeTotalFundsRequestedDirectIndirectCosts = cumulativeTotalFundsRequestedDirectIndirectCosts
                .add(totalCost);
        // DirectCosts
        if (budgetModular.getConsortiumFna() != null) {
            consortiumFandA = budgetModular.getConsortiumFna();
            directCost.setConsortiumFandA(consortiumFandA.bigDecimalValue());
            cumulativeConsortiumFandA = cumulativeConsortiumFandA.add(consortiumFandA);
        }
        if (budgetModular.getDirectCostLessConsortiumFna() != null) {
            directCostLessConsortiumFandA = budgetModular.getDirectCostLessConsortiumFna();
            directCost.setDirectCostLessConsortiumFandA(directCostLessConsortiumFandA.bigDecimalValue());
            cumulativeDirectCostLessConsortiumFandA = cumulativeDirectCostLessConsortiumFandA
                    .add(directCostLessConsortiumFandA);
        }
        if (budgetModular.getTotalDirectCost() != null) {
            totalDirectCosts = budgetModular.getTotalDirectCost();
            directCost.setTotalFundsRequestedDirectCosts(totalDirectCosts.bigDecimalValue());
            cumulativeTotalFundsRequestedDirectCosts = cumulativeTotalFundsRequestedDirectCosts
                    .add(totalDirectCosts);
        }

        List<IndirectCostItems> indirectCostItemsList = new ArrayList<>();
        for (BudgetModularIdcContract budgetModularIdc : budgetModular.getBudgetModularIdcs()) {
            IndirectCostItems indirectCostItems = IndirectCostItems.Factory.newInstance();
            if (budgetModularIdc.getFundsRequested() != null) {
                bdCost = budgetModularIdc.getFundsRequested();
                indirectCostItems.setIndirectCostFundsRequested(bdCost.bigDecimalValue());
                bdTotalIndirectCost = bdTotalIndirectCost.add(bdCost);
            }
            if (budgetModularIdc.getIdcBase() != null) {
                bdBaseCost = budgetModularIdc.getIdcBase();
                indirectCostItems.setIndirectCostBase(bdBaseCost.bigDecimalValue());
            }
            if (budgetModularIdc.getIdcRate() != null) {
                bdRate = budgetModularIdc.getIdcRate();
                indirectCostItems.setIndirectCostRate(bdRate.bigDecimalValue());
            }
            if (budgetModularIdc.getDescription() != null) {
                costType = budgetModularIdc.getDescription();
                indirectCostItems.setIndirectCostTypeDescription(costType);
            }
            indirectCostItemsList.add(indirectCostItems);
        }
        IndirectCostItems[] indirectCostItemsArray = new IndirectCostItems[0];
        indirectCostItemsArray = indirectCostItemsList.toArray(indirectCostItemsArray);
        indirectCost.setIndirectCostItemsArray(indirectCostItemsArray);
    }
    periods.setDirectCost(directCost);

    // CognizantFederalAgency
    OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization();
    if (organization != null) {
        if (organization.getCognizantAuditor() != null) {
            RolodexContract rolodex = rolodexService.getRolodex(organization.getCognizantAuditor());
            if (rolodex != null) {
                indirectCost.setCognizantFederalAgency(getCognizantFederalAgency(rolodex));
            }
        }

        if (organization.getIndirectCostRateAgreement() != null) {
            indirectCost.setIndirectCostAgreementDate(s2SDateTimeService
                    .convertDateStringToCalendar(organization.getIndirectCostRateAgreement()));
        }
    }

    // TotalFundsRequestedIndirectCost
    indirectCost.setTotalFundsRequestedIndirectCost(bdTotalIndirectCost.bigDecimalValue());
    cumulativeTotalFundsRequestedIndirectCost = cumulativeTotalFundsRequestedIndirectCost
            .add(bdTotalIndirectCost);
    periods.setIndirectCost(indirectCost);
    return periods;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398ModularBudgetV1_1Generator.java

/**
 * //  w  w w . j a va 2s  . com
 * This method is used to get 1st BudgetPeriod for Modular Budget form
 * 
 * @param budgetPeriod
 *            budget period 1.
 * @return Periods object containing modular budget details for the
 *         corresponding budget period.
 */
private Periods getPeriods(BudgetPeriodContract budgetPeriod) {

    Periods periods = Periods.Factory.newInstance();
    DirectCost directCost = DirectCost.Factory.newInstance();
    IndirectCost indirectCost = IndirectCost.Factory.newInstance();

    ScaleTwoDecimal consortiumFandA = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal directCostLessConsortiumFandA = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalDirectCosts = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdTotalIndirectCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdBaseCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal bdRate = ScaleTwoDecimal.ZERO;
    String costType = null;

    // BudgetPeriod
    periods.setBudgetPeriod(1);

    // StartDate And EndDate
    if (budgetPeriod.getStartDate() != null) {
        periods.setBudgetPeriodStartDate(s2SDateTimeService.convertDateToCalendar(budgetPeriod.getStartDate()));
    }
    if (budgetPeriod.getEndDate() != null) {
        periods.setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(budgetPeriod.getEndDate()));
    }

    // Set dfault values for mandatory fields.
    directCost.setDirectCostLessConsortiumFandA(BigDecimal.ZERO);
    directCost.setTotalFundsRequestedDirectCosts(BigDecimal.ZERO);
    periods.setTotalFundsRequestedDirectIndirectCosts(BigDecimal.ZERO);

    // TotalDirectAndIndirectCost
    BudgetModularContract budgetModular = budgetPeriod.getBudgetModular();
    if (budgetModular != null) {
        ScaleTwoDecimal totalCost = getTotalCost(budgetModular);
        periods.setTotalFundsRequestedDirectIndirectCosts(totalCost.bigDecimalValue());
        cumulativeTotalFundsRequestedDirectIndirectCosts = cumulativeTotalFundsRequestedDirectIndirectCosts
                .add(totalCost);
        // DirectCosts
        if (budgetModular.getConsortiumFna() != null) {
            consortiumFandA = budgetModular.getConsortiumFna();
            directCost.setConsortiumFandA(consortiumFandA.bigDecimalValue());
            cumulativeConsortiumFandA = cumulativeConsortiumFandA.add(consortiumFandA);
        }
        if (budgetModular.getDirectCostLessConsortiumFna() != null) {
            directCostLessConsortiumFandA = budgetModular.getDirectCostLessConsortiumFna();
            directCost.setDirectCostLessConsortiumFandA(directCostLessConsortiumFandA.bigDecimalValue());
            cumulativeDirectCostLessConsortiumFandA = cumulativeDirectCostLessConsortiumFandA
                    .add(directCostLessConsortiumFandA);
        }
        if (budgetModular.getTotalDirectCost() != null) {
            totalDirectCosts = budgetModular.getTotalDirectCost();
            directCost.setTotalFundsRequestedDirectCosts(totalDirectCosts.bigDecimalValue());
            cumulativeTotalFundsRequestedDirectCosts = cumulativeTotalFundsRequestedDirectCosts
                    .add(totalDirectCosts);
        }

        List<IndirectCostItems> indirectCostItemsList = new ArrayList<>();
        for (BudgetModularIdcContract budgetModularIdc : budgetModular.getBudgetModularIdcs()) {
            IndirectCostItems indirectCostItems = IndirectCostItems.Factory.newInstance();
            if (budgetModularIdc.getFundsRequested() != null) {
                bdCost = budgetModularIdc.getFundsRequested();
                indirectCostItems.setIndirectCostFundsRequested(bdCost.bigDecimalValue());
                bdTotalIndirectCost = bdTotalIndirectCost.add(bdCost);
            }
            if (budgetModularIdc.getIdcBase() != null) {
                bdBaseCost = budgetModularIdc.getIdcBase();
                indirectCostItems.setIndirectCostBase(bdBaseCost.bigDecimalValue());
            }
            if (budgetModularIdc.getIdcRate() != null) {
                bdRate = budgetModularIdc.getIdcRate();
                indirectCostItems.setIndirectCostRate(bdRate.bigDecimalValue());
            }
            if (budgetModularIdc.getDescription() != null) {
                if (budgetModularIdc.getRateClass() != null) {

                    costType = budgetModularIdc.getRateClass().getDescription();
                } else {
                    costType = budgetModularIdc.getDescription();
                }

                indirectCostItems.setIndirectCostTypeDescription(costType);
            }
            indirectCostItemsList.add(indirectCostItems);
        }
        IndirectCostItems[] indirectCostItemsArray = new IndirectCostItems[0];
        indirectCostItemsArray = indirectCostItemsList.toArray(indirectCostItemsArray);
        indirectCost.setIndirectCostItemsArray(indirectCostItemsArray);
    }
    periods.setDirectCost(directCost);

    // CognizantFederalAgency
    OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization();
    if (organization != null) {
        if (organization.getCognizantAuditor() != null) {
            RolodexContract rolodex = rolodexService.getRolodex(organization.getCognizantAuditor());
            if (rolodex != null) {
                indirectCost.setCognizantFederalAgency(getCognizantFederalAgency(rolodex));
            }
        }

        if (organization.getIndirectCostRateAgreement() != null) {
            indirectCost.setIndirectCostAgreementDate(s2SDateTimeService
                    .convertDateStringToCalendar(organization.getIndirectCostRateAgreement()));
        }

    }
    // TotalFundsRequestedIndirectCost
    indirectCost.setTotalFundsRequestedIndirectCost(bdTotalIndirectCost.bigDecimalValue());
    cumulativeTotalFundsRequestedIndirectCost = cumulativeTotalFundsRequestedIndirectCost
            .add(bdTotalIndirectCost);
    periods.setIndirectCost(indirectCost);
    return periods;
}

From source file:pe.gob.mef.gescon.web.ui.AlertaMB.java

public void desactivar(ActionEvent event) {
    try {/*from   w  ww  . j  ava 2 s. c  om*/
        if (event != null) {
            if (this.getSelectedAlerta() != null) {
                LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB");
                User user = loginMB.getUser();
                AlertaService service = (AlertaService) ServiceFinder.findBean("AlertaService");
                this.getSelectedAlerta().setNactivo(BigDecimal.ZERO);
                this.getSelectedAlerta().setDfechamodificacion(new Date());
                this.getSelectedAlerta().setVusuariomodificacion(user.getVlogin());
                service.saveOrUpdate(this.getSelectedAlerta());
                this.setListaAlerta(service.getAlertas());
            } else {
                FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA,
                        "Debe seleccionar la alerta a desactivar.");
                FacesContext.getCurrentInstance().addMessage(null, message);
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRBudgetV1_1Generator.java

/**
 * This method gets BudgetSummary details such as
 * CumulativeTotalFundsRequestedSeniorKeyPerson,CumulativeTotalFundsRequestedOtherPersonnel
 * CumulativeTotalNoOtherPersonnel,CumulativeTotalFundsRequestedPersonnel,CumulativeEquipments,CumulativeTravels
 * CumulativeTrainee,CumulativeOtherDirect,CumulativeTotalFundsRequestedDirectCosts,CumulativeTotalFundsRequestedIndirectCost
 * CumulativeTotalFundsRequestedDirectIndirectCosts and CumulativeFee based
 * on BudgetSummaryInfo for the RRBudget.
 * //ww w  . java 2  s  .c  o m
 * @param budgetSummaryData
 *            (BudgetSummaryInfo) budget summary entry.
 * @return BudgetSummary details corresponding to the BudgetSummaryInfo
 *         object.
 */
private BudgetSummary getBudgetSummary(BudgetSummaryDto budgetSummaryData) {

    BudgetSummary budgetSummary = BudgetSummary.Factory.newInstance();
    // Set default values for mandatory fields
    budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson(BigDecimal.ZERO);
    budgetSummary.setCumulativeTotalFundsRequestedPersonnel(BigDecimal.ZERO);
    budgetSummary.setCumulativeTotalFundsRequestedDirectCosts(BigDecimal.ZERO);

    if (budgetSummaryData.getCumTotalFundsForSrPersonnel() != null) {
        budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson(
                budgetSummaryData.getCumTotalFundsForSrPersonnel().bigDecimalValue());
    }
    if (budgetSummaryData.getCumTotalFundsForOtherPersonnel() != null) {
        budgetSummary.setCumulativeTotalFundsRequestedOtherPersonnel(
                budgetSummaryData.getCumTotalFundsForOtherPersonnel().bigDecimalValue());
    }
    if (budgetSummaryData.getCumNumOtherPersonnel() != null) {
        budgetSummary
                .setCumulativeTotalNoOtherPersonnel(budgetSummaryData.getCumNumOtherPersonnel().intValue());
    }
    if (budgetSummaryData.getCumTotalFundsForPersonnel() != null) {
        budgetSummary.setCumulativeTotalFundsRequestedPersonnel(
                budgetSummaryData.getCumTotalFundsForPersonnel().bigDecimalValue());
    }
    budgetSummary.setCumulativeEquipments(getCumulativeEquipments(budgetSummaryData));
    budgetSummary.setCumulativeTravels(getCumulativeTravels(budgetSummaryData));
    budgetSummary.setCumulativeTrainee(getCumulativeTrainee(budgetSummaryData));
    budgetSummary.setCumulativeOtherDirect(getCumulativeOtherDirect(budgetSummaryData));
    budgetSummary.setCumulativeTotalFundsRequestedDirectCosts(
            budgetSummaryData.getCumTotalDirectCosts().bigDecimalValue());
    budgetSummary.setCumulativeTotalFundsRequestedIndirectCost(
            budgetSummaryData.getCumTotalIndirectCosts().bigDecimalValue());
    budgetSummary.setCumulativeTotalFundsRequestedDirectIndirectCosts(
            budgetSummaryData.getCumTotalCosts().bigDecimalValue());
    if (budgetSummaryData.getCumFee() != null) {
        budgetSummary.setCumulativeFee(budgetSummaryData.getCumFee().bigDecimalValue());
    }
    return budgetSummary;
}

From source file:com.gst.portfolio.savings.service.SavingsAccountWritePlatformServiceJpaRepositoryImpl.java

@Override
public void processPostActiveActions(final SavingsAccount account, final DateTimeFormatter fmt,
        final Set<Long> existingTransactionIds, final Set<Long> existingReversedTransactionIds) {

    AppUser user = getAppUserIfPresent();

    final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
            .isSavingsInterestPostingAtCurrentPeriodEnd();
    final Integer financialYearBeginningMonth = this.configurationDomainService
            .retrieveFinancialYearBeginningMonth();

    Money amountForDeposit = account.activateWithBalance();
    boolean isRegularTransaction = false;
    if (amountForDeposit.isGreaterThanZero()) {
        boolean isAccountTransfer = false;
        this.savingsAccountDomainService.handleDeposit(account, fmt, account.getActivationLocalDate(),
                amountForDeposit.getAmount(), null, isAccountTransfer, isRegularTransaction);
        updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
    }//from   w  w w .  ja v  a  2 s  . c o  m
    account.processAccountUponActivation(isSavingsInterestPostingAtCurrentPeriodEnd,
            financialYearBeginningMonth, user);
    List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
    if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) {
        depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
                .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
    }
    account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name(),
            depositAccountOnHoldTransactions);
}

From source file:de.hybris.platform.ordermanagementfacade.returns.impl.DefaultOmsReturnFacade.java

/**
 * Creates {@link ReturnRequestModel} in the {@link ImpersonationContext}
 *
 * @param order/*from  w  w  w.  jav  a2 s .com*/
 *       the {@link OrderModel} for which returnRequest needs to be created
 * @param returnRequestData
 *       the {@link ReturnRequestData} containing required data to create {@link ReturnRequestModel}
 * @return the newly created {@link ReturnRequestModel}
 */
protected ReturnRequestModel createReturnRequestInContext(final OrderModel order,
        final ReturnRequestData returnRequestData) {
    final ReturnRequestModel returnRequest = getReturnService().createReturnRequest(order);
    /*
     * Start for Daimler POC START ::::
     */
    returnRequest.setStatus(returnRequestData.getStatus());
    returnRequest.setRMA(returnRequestData.getRma());
    /*
     * Start for Daimler POC END ::::
     */

    returnRequest.setRefundDeliveryCost(
            canRefundDeliveryCost(order.getCode(), returnRequestData.getRefundDeliveryCost()));
    getModelService().save(returnRequest);

    returnRequestData.getEntries().forEach(returnEntryData -> {
        final AbstractOrderEntryModel orderEntry = getOrderService().getEntryForNumber(order,
                returnEntryData.getOrderEntry().getEntryNumber());
        Assert.notNull(orderEntry,
                Localization.getLocalizedString("ordermanagementfacade.returns.validation.null.orderentry"));

        final RefundEntryModel refundEntryToBeCreated = getReturnService().createRefund(returnRequest,
                orderEntry, returnEntryData.getNotes(), returnEntryData.getExpectedQuantity(),
                returnEntryData.getAction(), returnEntryData.getRefundReason());
        refundEntryToBeCreated.setAmount(returnEntryData.getRefundAmount() != null
                ? returnEntryData.getRefundAmount().getValue()
                : calculateRefundEntryAmount(orderEntry.getBasePrice(), returnEntryData.getExpectedQuantity()));
        getModelService().save(refundEntryToBeCreated);
    });

    // Recalculate the subTotal after updating a refund amount
    returnRequest.setSubtotal(returnRequest.getReturnEntries().stream()
            .filter(returnEntry -> returnEntry instanceof RefundEntryModel)
            .map(refundEntry -> ((RefundEntryModel) refundEntry).getAmount())
            .reduce(BigDecimal.ZERO, BigDecimal::add));
    getModelService().save(returnRequest);

    try {
        getRefundService().apply(returnRequest.getOrder(), returnRequest);
    } catch (final OrderReturnRecordsHandlerException e) //NOSONAR
    {
        LOGGER.info("Return record already in progress for Order: " + order.getCode()); //NOSONAR
    } catch (final IllegalStateException ise) //NOSONAR
    {
        LOGGER.info("Order " + order.getCode() + " Return record already in progress"); //NOSONAR
    }
    final CreateReturnEvent createReturnEvent = new CreateReturnEvent();
    createReturnEvent.setReturnRequest(returnRequest);
    getEventService().publishEvent(createReturnEvent);

    return returnRequest;
}

From source file:com.ugam.collage.plus.service.people_count.impl.PeopleAccountingServiceImpl.java

@Override
public PCValidationSummaryVo validateEmployeeSummary(Integer yearId, Integer monthId, String costCentreId) {

    List<EmployeeSummaryCssplit> employeeSummaryCssplitList = employeeSummaryCssplitDao
            .findByYearIdMonthIdConstCentreId(yearId, monthId, costCentreId);
    if (employeeSummaryCssplitList == null || employeeSummaryCssplitList.isEmpty()) {
        return null;
    }/*w w  w . ja  va2s  .c om*/
    List<EmployeeSummaryTotal> employeeSummaryTotalList = employeeSummaryTotalDao.findByYeadIdAndMonthId(yearId,
            monthId);

    if (employeeSummaryTotalList == null || employeeSummaryTotalList.isEmpty()) {
        return null;
    }
    List<EmployeeMonthlyAssignment> openCountList = employeeMonthlyAssignmentDao.findByOpeningCount(yearId,
            monthId, costCentreId);

    List<EmployeeMonthlyAssignment> closingCountList = employeeMonthlyAssignmentDao.findByClosingCount(yearId,
            monthId, costCentreId);

    PCValidationSummaryVo pcValidationSummaryVo = new PCValidationSummaryVo();
    Boolean summaryCountMatch = false;
    Boolean masterOpeningCount = false;
    Boolean masterCloseCount = false;

    EmployeeSummaryCssplit employeeSummaryCssplit = employeeSummaryCssplitList.get(0);
    EmployeeSummaryTotal employeeSummaryTotal = employeeSummaryTotalList.get(0);

    if (employeeSummaryCssplit == null || employeeSummaryTotal == null) {
        return null;
    }

    // TODO: check the below condition after putiing the data

    if (openCountList == null || openCountList.isEmpty() || closingCountList == null
            || closingCountList.isEmpty()) {
        return null;
    }

    // Get Count Match Summary

    List<IdNameValueVo<String>> countMatchSummaryList = new ArrayList<IdNameValueVo<String>>();

    if (employeeSummaryCssplit.getOpeningCnt() == employeeSummaryTotal.getOpeningCnt()
            && employeeSummaryCssplit.getClosingCnt() == employeeSummaryTotal.getClosingCnt()
            && employeeSummaryCssplit.getAverageCnt() == employeeSummaryTotal.getAverageCnt()) {

        summaryCountMatch = true;
        IdNameValueVo<String> countMatchSummary = new IdNameValueVo<String>(1, "Overall Count", COUNT_MATCH,
                " ");
        countMatchSummaryList.add(countMatchSummary);
        // logger.debug("{Overall Count}===>{COUNT_MATCH}:" +
        // summaryCountMatch);
    } else {
        IdNameValueVo<String> countMatchSummary = new IdNameValueVo<String>(1, "Overall Count",
                COUNT_NOT_MATCHED, " ");
        countMatchSummaryList.add(countMatchSummary);
        // logger.debug("{Overall Count}===>{COUNT_NOT_MATCHED}:" +
        // summaryCountMatch);
    }

    if (openCountList.size() == employeeSummaryCssplit.getOpeningCnt()) {
        masterOpeningCount = true;
        IdNameValueVo<String> countMatchSummary = new IdNameValueVo<String>(2, "Opening Count", COUNT_MATCH,
                UI_DISPLAY_GROUP_FOR_SELECTED_COST_CENTER);
        countMatchSummaryList.add(countMatchSummary);
        // logger.debug("{Opening Count}===>{COUNT_MATCH}:" +
        // masterOpeningCount);
    } else {
        IdNameValueVo<String> countMatchSummary = new IdNameValueVo<String>(2, "Opening Count",
                COUNT_NOT_MATCHED, UI_DISPLAY_GROUP_FOR_SELECTED_COST_CENTER);
        countMatchSummaryList.add(countMatchSummary);
        // logger.debug("{Opening Count}===>{COUNT_NOT_MATCHED}:" +
        // masterOpeningCount);
    }
    if (closingCountList.size() == employeeSummaryCssplit.getClosingCnt()) {
        masterCloseCount = true;
        IdNameValueVo<String> countMatchSummary = new IdNameValueVo<String>(3, "Clossing Count", COUNT_MATCH,
                UI_DISPLAY_GROUP_FOR_SELECTED_COST_CENTER);
        countMatchSummaryList.add(countMatchSummary);
        // logger.debug("{Clossing Count}===>{COUNT_MATCH}:" +
        // masterCloseCount);
    } else {
        IdNameValueVo<String> countMatchSummary = new IdNameValueVo<String>(3, "Clossing Count",
                COUNT_NOT_MATCHED, UI_DISPLAY_GROUP_FOR_SELECTED_COST_CENTER);
        countMatchSummaryList.add(countMatchSummary);
        // logger.debug("{Clossing Count}===>{COUNT_NOT_MATCHED}:" +
        // masterCloseCount);
    }

    pcValidationSummaryVo.setCountMatchSummary(countMatchSummaryList);

    // Get UnAllocated Data

    List<IdTextVo> unPickedPeopleDataList = new ArrayList<IdTextVo>();

    List<EmployeeMonthlyAssignment> allUnPickedPeopleDataList = employeeMonthlyAssignmentDao
            .findUnPickedPeopleData(yearId, monthId, costCentreId);
    logger.debug("{People who have not been picked by anyone}===>{allUnPickedPeopleDataList.size()}:"
            + allUnPickedPeopleDataList.size());
    if (unPickedPeopleDataList != null && !unPickedPeopleDataList.isEmpty()) {

        for (EmployeeMonthlyAssignment allUnPickedPeopleData : allUnPickedPeopleDataList) {
            EmployeeMaster employee = allUnPickedPeopleData.getEmployeeMaster();
            IdTextVo idTextVo = new IdTextVo(employee.getEmployeeId(), employee.getEmployeeName());
            unPickedPeopleDataList.add(idTextVo);
        }
    }

    pcValidationSummaryVo.setUnPickedPeopleData(unPickedPeopleDataList);

    // Get UnAllocated People Data
    List<IdTextVo> unAllocatedPeopleDataList = new ArrayList<IdTextVo>();

    List<EmployeeMonthlyAssignment> allUnAllocatedPeopleDataList = employeeMonthlyAssignmentDao
            .findUnAllocatedPeopleData(yearId, monthId, costCentreId);
    logger.debug(
            "{People who are not part of any client-project team-structure}===>{allUnAllocatedPeopleDataList.size()}:"
                    + allUnAllocatedPeopleDataList.size());
    if (allUnAllocatedPeopleDataList != null && !allUnAllocatedPeopleDataList.isEmpty()) {
        for (EmployeeMonthlyAssignment allUnAllocatedPeopleData : allUnAllocatedPeopleDataList) {
            EmployeeMaster employee = allUnAllocatedPeopleData.getEmployeeMaster();
            IdTextVo idTextVo = new IdTextVo(employee.getEmployeeId(), employee.getEmployeeName());
            unAllocatedPeopleDataList.add(idTextVo);
        }
    }
    pcValidationSummaryVo.setUnAllocatedPeopleData(unAllocatedPeopleDataList);

    // Get client project summary
    boolean isFalse = false;
    List<ClientProjectStatusVo> clientProjectSummaryList = new ArrayList<ClientProjectStatusVo>();
    // executionDataDao for type one
    List<ExecutionData> executionDataListTypeOne = executionDataDao.findByTypeOne(yearId, monthId,
            costCentreId);
    if (executionDataListTypeOne != null && !executionDataListTypeOne.isEmpty()) {
        for (ExecutionData executionData : executionDataListTypeOne) {
            ClientProjectStatusVo clientProjectStatusVo = new ClientProjectStatusVo(
                    executionData.getProjectMaster().getProjectId(), executionData.getProjectName(),
                    executionData.getCompanyMaster().getCompanyId(), executionData.getCompanyName(), isFalse,
                    BigDecimal.ZERO);
            clientProjectSummaryList.add(clientProjectStatusVo);
        }

    }

    List<ExecutionData> executionDataListTypeTwo = executionDataDao.findByTypeTwo(yearId, monthId,
            costCentreId);
    if (executionDataListTypeTwo != null && !executionDataListTypeTwo.isEmpty()) {
        BigDecimal revenue = BigDecimal.ZERO;
        for (ExecutionData executionData : executionDataListTypeTwo) {
            // collageProjectRevenueDao for type 2
            List<CollageProjectRevenue> collageProjectRevenueList = collageProjectRevenueDao
                    .findByYearIdMonthIdPrjectIdZohoId(yearId, monthId,
                            executionData.getProjectMaster().getProjectId(),
                            executionData.getZohoMaster().getZohoId());
            // logger.debug("{Project revenue }===>{collageProjectRevenueList.size()}:"
            // + collageProjectRevenueList.size());
            if (collageProjectRevenueList != null & !collageProjectRevenueList.isEmpty()) {
                revenue = collageProjectRevenueList.get(0).getRevenueValue();
            }
            ClientProjectStatusVo clientProjectStatusVo = new ClientProjectStatusVo(
                    executionData.getProjectMaster().getProjectId(), executionData.getProjectName(),
                    executionData.getCompanyMaster().getCompanyId(), executionData.getCompanyName(), isFalse,
                    revenue);
            clientProjectSummaryList.add(clientProjectStatusVo);
        }
    }

    pcValidationSummaryVo.setClientProjectSummary(clientProjectSummaryList);

    return pcValidationSummaryVo;
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractSubscriptionController.java

@RequestMapping(value = "/taxable_amount", method = RequestMethod.GET)
@ResponseBody/*ww w . j  a v  a  2  s.c o  m*/
public String getTaxableAmount(@RequestParam("amount") final String amount) {
    logger.debug("getTaxableAmount method starting...");
    BigDecimal taxableAmount = BigDecimal.ZERO;
    try {
        if (amount != null) {
            taxableAmount = billingAdminService.getTaxableAmount(new BigDecimal(amount));
        }
    } catch (Exception e) {
        logger.error("Failed to get taxable amount", e);
    }
    logger.debug("getTaxableAmount method end");
    return taxableAmount.toString();
}