List of usage examples for java.math BigDecimal add
public BigDecimal add(BigDecimal augend)
From source file:org.openmrs.module.billing.web.controller.main.BillableServiceBillAddForBDController.java
@RequestMapping(method = RequestMethod.POST) public String onSubmit(Model model, Object command, BindingResult bindingResult, HttpServletRequest request, @RequestParam("cons") Integer[] cons, @RequestParam("patientId") Integer patientId, @RequestParam(value = "comment", required = false) String comment, @RequestParam(value = "billType", required = false) String billType) { validate(cons, bindingResult, request); if (bindingResult.hasErrors()) { model.addAttribute("errors", bindingResult.getAllErrors()); return "module/billing/main/billableServiceBillEdit"; }//from ww w . ja v a2s .c om BillingService billingService = Context.getService(BillingService.class); PatientService patientService = Context.getPatientService(); // Get the BillCalculator to calculate the rate of bill item the patient has to pay Patient patient = patientService.getPatient(patientId); Map<String, String> attributes = PatientUtils.getAttributes(patient); BillCalculatorForBDService calculator = new BillCalculatorForBDService(); PatientServiceBill bill = new PatientServiceBill(); bill.setCreatedDate(new Date()); bill.setPatient(patient); bill.setCreator(Context.getAuthenticatedUser()); PatientServiceBillItem item; int quantity = 0; Money itemAmount; Money mUnitPrice; Money totalAmount = new Money(BigDecimal.ZERO); BigDecimal totalActualAmount = new BigDecimal(0); BigDecimal unitPrice; String name; BillableService service; for (int conceptId : cons) { unitPrice = NumberUtils.createBigDecimal(request.getParameter(conceptId + "_unitPrice")); quantity = NumberUtils.createInteger(request.getParameter(conceptId + "_qty")); name = request.getParameter(conceptId + "_name"); service = billingService.getServiceByConceptId(conceptId); mUnitPrice = new Money(unitPrice); itemAmount = mUnitPrice.times(quantity); totalAmount = totalAmount.plus(itemAmount); item = new PatientServiceBillItem(); item.setCreatedDate(new Date()); item.setName(name); item.setPatientServiceBill(bill); item.setQuantity(quantity); item.setService(service); item.setUnitPrice(unitPrice); item.setAmount(itemAmount.getAmount()); // Get the ratio for each bill item Map<String, Object> parameters = HospitalCoreUtils.buildParameters("patient", patient, "attributes", attributes, "billItem", item, "request", request); BigDecimal rate = calculator.getRate(parameters, billType); item.setActualAmount(item.getAmount().multiply(rate)); totalActualAmount = totalActualAmount.add(item.getActualAmount()); bill.addBillItem(item); } bill.setAmount(totalAmount.getAmount()); bill.setActualAmount(totalActualAmount); bill.setComment(comment); bill.setFreeBill(calculator.isFreeBill(billType)); logger.info("Is free bill: " + bill.getFreeBill()); bill.setReceipt(billingService.createReceipt()); bill = billingService.savePatientServiceBill(bill); return "redirect:/module/billing/patientServiceBillForBD.list?patientId=" + patientId + "&billId=" + bill.getPatientServiceBillId() + "&billType=" + billType; }
From source file:org.openmrs.module.billing.web.controller.main.BillableServiceBillEditController.java
@RequestMapping(method = RequestMethod.POST) public String onSubmit(Model model, Object command, BindingResult bindingResult, HttpServletRequest request, @RequestParam("cons") Integer[] cons, @RequestParam("patientId") Integer patientId, @RequestParam("billId") Integer billId, @RequestParam("action") String action, @RequestParam(value = "description", required = false) String description) { validate(cons, bindingResult, request); if (bindingResult.hasErrors()) { model.addAttribute("errors", bindingResult.getAllErrors()); return "module/billing/main/patientServiceBillEdit"; }/* w w w . ja v a2 s. c o m*/ BillingService billingService = Context.getService(BillingService.class); PatientServiceBill bill = billingService.getPatientServiceBillById(billId); // Get the BillCalculator to calculate the rate of bill item the patient // has to pay Patient patient = Context.getPatientService().getPatient(patientId); Map<String, String> attributes = PatientUtils.getAttributes(patient); BillCalculatorService calculator = new BillCalculatorService(); if (!"".equals(description)) bill.setDescription(description); if ("void".equalsIgnoreCase(action)) { bill.setVoided(true); bill.setVoidedDate(new Date()); for (PatientServiceBillItem item : bill.getBillItems()) { item.setVoided(true); item.setVoidedDate(new Date()); /*ghanshyam 7-sept-2012 these 5 lines of code written only due to voided item is being updated in "billing_patient_service_bill_item" table but not being updated in "orders" table */ Order ord = item.getOrder(); if (ord != null) { ord.setVoided(true); ord.setDateVoided(new Date()); } item.setOrder(ord); } billingService.savePatientServiceBill(bill); //ghanshyam 7-sept-2012 Support #343 [Billing][3.2.7-SNAPSHOT]No Queue to be generated from Old bill return "redirect:/module/billing/patientServiceBillEdit.list?patientId=" + patientId; } // void old items and reset amount Map<Integer, PatientServiceBillItem> mapOldItems = new HashMap<Integer, PatientServiceBillItem>(); for (PatientServiceBillItem item : bill.getBillItems()) { item.setVoided(true); item.setVoidedDate(new Date()); //ghanshyam-kesav 16-08-2012 Bug #323 [BILLING] When a bill with a lab\radiology order is edited the order is re-sent Order ord = item.getOrder(); /*ghanshyam 18-08-2012 [Billing - Bug #337] [3.2.7 snap shot][billing(DDU,DDU SDMX,Tanda,mohali)]error in edit bill. the problem was while we are editing the bill of other than lab and radiology. */ if (ord != null) { ord.setVoided(true); ord.setDateVoided(new Date()); } item.setOrder(ord); mapOldItems.put(item.getPatientServiceBillItemId(), item); } bill.setAmount(BigDecimal.ZERO); bill.setPrinted(false); PatientServiceBillItem item; int quantity = 0; Money itemAmount; Money mUnitPrice; Money totalAmount = new Money(BigDecimal.ZERO); BigDecimal totalActualAmount = new BigDecimal(0); BigDecimal unitPrice; String name; BillableService service; for (int conceptId : cons) { unitPrice = NumberUtils.createBigDecimal(request.getParameter(conceptId + "_unitPrice")); quantity = NumberUtils.createInteger(request.getParameter(conceptId + "_qty")); name = request.getParameter(conceptId + "_name"); service = billingService.getServiceByConceptId(conceptId); mUnitPrice = new Money(unitPrice); itemAmount = mUnitPrice.times(quantity); totalAmount = totalAmount.plus(itemAmount); String sItemId = request.getParameter(conceptId + "_itemId"); if (sItemId == null) { item = new PatientServiceBillItem(); // Get the ratio for each bill item Map<String, Object> parameters = HospitalCoreUtils.buildParameters("patient", patient, "attributes", attributes, "billItem", item); BigDecimal rate = calculator.getRate(parameters); item.setAmount(itemAmount.getAmount()); item.setActualAmount(item.getAmount().multiply(rate)); totalActualAmount = totalActualAmount.add(item.getActualAmount()); item.setCreatedDate(new Date()); item.setName(name); item.setPatientServiceBill(bill); item.setQuantity(quantity); item.setService(service); item.setUnitPrice(unitPrice); bill.addBillItem(item); } else { item = mapOldItems.get(Integer.parseInt(sItemId)); // Get the ratio for each bill item Map<String, Object> parameters = HospitalCoreUtils.buildParameters("patient", patient, "attributes", attributes, "billItem", item); BigDecimal rate = calculator.getRate(parameters); //ghanshyam 5-oct-2012 [Billing - Support #344] [Billing] Edited Quantity and Amount information is lost in database if (quantity != item.getQuantity()) { item.setVoided(true); item.setVoidedDate(new Date()); } else { item.setVoided(false); item.setVoidedDate(null); } // ghanshyam-kesav 16-08-2012 Bug #323 [BILLING] When a bill with a lab\radiology order is edited the order is re-sent Order ord = item.getOrder(); if (ord != null) { ord.setVoided(false); ord.setDateVoided(null); } item.setOrder(ord); //ghanshyam 5-oct-2012 [Billing - Support #344] [Billing] Edited Quantity and Amount information is lost in database if (quantity != item.getQuantity()) { item = new PatientServiceBillItem(); item.setService(service); item.setUnitPrice(unitPrice); item.setQuantity(quantity); item.setName(name); item.setCreatedDate(new Date()); item.setOrder(ord); bill.addBillItem(item); } item.setAmount(itemAmount.getAmount()); item.setActualAmount(item.getAmount().multiply(rate)); totalActualAmount = totalActualAmount.add(item.getActualAmount()); } } bill.setAmount(totalAmount.getAmount()); bill.setActualAmount(totalActualAmount); // Determine whether the bill is free or not bill.setFreeBill(calculator.isFreeBill(HospitalCoreUtils.buildParameters("attributes", attributes))); logger.info("Is free bill: " + bill.getFreeBill()); bill = billingService.savePatientServiceBill(bill); //ghanshyam 7-sept-2012 Support #343 [Billing][3.2.7-SNAPSHOT]No Queue to be generated from Old bill return "redirect:/module/billing/patientServiceBillEdit.list?patientId=" + patientId + "&billId=" + billId; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRBudgetV1_0Generator.java
/** * This method gets BudgetYearDataType details like * BudgetPeriodStartDate,BudgetPeriodEndDate,BudgetPeriod * KeyPersons,OtherPersonnel,TotalCompensation,Equipment,ParticipantTraineeSupportCosts,Travel,OtherDirectCosts * DirectCosts,IndirectCosts,CognizantFederalAgency,TotalCosts based on * BudgetPeriodInfo for the RRBudget./*from w w w . j av a 2 s. c om*/ * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return BudgetYearDataType corresponding to the BudgetPeriodInfo entry. */ private BudgetYearDataType getBudgetYearDataType(BudgetPeriodDto periodInfo) { BudgetYearDataType budgetYear = BudgetYearDataType.Factory.newInstance(); if (periodInfo != null) { if (periodInfo.getStartDate() != null) { budgetYear.setBudgetPeriodStartDate( s2SDateTimeService.convertDateToCalendar(periodInfo.getStartDate())); } if (periodInfo.getEndDate() != null) { budgetYear .setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getEndDate())); } BudgetPeriod.Enum budgetPeriod = BudgetPeriod.Enum.forInt(periodInfo.getBudgetPeriod()); budgetYear.setBudgetPeriod(budgetPeriod); budgetYear.setKeyPersons(getKeyPersons(periodInfo)); budgetYear.setOtherPersonnel(getOtherPersonnel(periodInfo)); if (periodInfo.getTotalCompensation() != null) { budgetYear.setTotalCompensation(periodInfo.getTotalCompensation().bigDecimalValue()); } budgetYear.setEquipment(getEquipment(periodInfo)); budgetYear.setTravel(getTravel(periodInfo)); budgetYear.setParticipantTraineeSupportCosts(getParticipantTraineeSupportCosts(periodInfo)); budgetYear.setOtherDirectCosts(getOtherDirectCosts(periodInfo)); BigDecimal directCosts = null; if (periodInfo.getDirectCostsTotal() != null) { directCosts = periodInfo.getDirectCostsTotal().bigDecimalValue(); budgetYear.setDirectCosts(directCosts); } IndirectCosts indirectCosts = getIndirectCosts(periodInfo); budgetYear.setIndirectCosts(indirectCosts); budgetYear.setCognizantFederalAgency(periodInfo.getCognizantFedAgency()); if (indirectCosts != null && directCosts != null) { budgetYear.setTotalCosts(directCosts.add(indirectCosts.getTotalIndirectCosts())); } else { budgetYear.setTotalCosts(periodInfo.getTotalCosts().bigDecimalValue()); } } return budgetYear; }
From source file:com.gst.portfolio.shareaccounts.serialization.ShareAccountDataSerializer.java
private void handleRedeemSharesChargeTransactions(final ShareAccount account, final ShareAccountTransaction transaction) { Set<ShareAccountCharge> charges = account.getCharges(); BigDecimal totalChargeAmount = BigDecimal.ZERO; for (ShareAccountCharge charge : charges) { if (charge.isActive() && charge.isSharesRedeemCharge()) { BigDecimal amount = charge.updateChargeDetailsForAdditionalSharesRequest(transaction.amount(), account.getCurrency()); ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(transaction, charge, amount); transaction.addShareAccountChargePaidBy(paidBy); totalChargeAmount = totalChargeAmount.add(amount); }/*from ww w .j a v a2 s . c om*/ } transaction.deductChargesFromTotalAmount(totalChargeAmount); Set<ShareAccountChargePaidBy> paidBySet = transaction.getChargesPaidBy(); if (paidBySet != null && !paidBySet.isEmpty()) { for (ShareAccountChargePaidBy chargePaidBy : paidBySet) { ShareAccountCharge charge = chargePaidBy.getCharge(); if (charge.isActive() && charge.isSharesRedeemCharge()) { Money money = Money.of(account.getCurrency(), chargePaidBy.getAmount()); charge.updatePaidAmountBy(money); } } } transaction.addAmountPaid(transaction.chargeAmount()); }
From source file:com.gst.portfolio.shareaccounts.serialization.ShareAccountDataSerializer.java
private void handleAdditionalSharesChargeTransactions(final ShareAccount account, final ShareAccountTransaction purchaseTransaction) { Set<ShareAccountCharge> charges = account.getCharges(); BigDecimal totalChargeAmount = BigDecimal.ZERO; for (ShareAccountCharge charge : charges) { if (charge.isActive() && charge.isSharesPurchaseCharge()) { BigDecimal amount = charge.updateChargeDetailsForAdditionalSharesRequest( purchaseTransaction.amount(), account.getCurrency()); ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(purchaseTransaction, charge, amount); purchaseTransaction.addShareAccountChargePaidBy(paidBy); totalChargeAmount = totalChargeAmount.add(amount); }/*from ww w .j a va 2 s .c o m*/ } purchaseTransaction.updateChargeAmount(totalChargeAmount); }
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.GanttDiagramTagLib.java
private StringBuilder generateGanttDiagramInTimeMode(BigDecimal tableWidth) throws JspException { StringBuilder builder = new StringBuilder(); if (!getEvents().isEmpty()) { if (isShowPeriod() && isShowObservations()) { builder.append("<table style=\"width:") .append(tableWidth.add(BigDecimal.valueOf(FIXED_COLUMNS_SIZE_EM))) .append("em;\" class=\"tcalendar thlight\">"); } else {// w w w . j ava2s.c om builder.append("<table class=\"tcalendar thlight\">"); } generateHeaders(builder); int numberOfUnits = getNumberOfUnits(); String selectedEvent = getRequest().getParameter(getEventParameter()); Object selectedEventObject = getRequest().getAttribute(getEventParameter()); for (GanttDiagramEvent event : getEvents()) { String eventUrl = getRequest().getContextPath() + getEventUrl() + "&" + getEventParameter() + "=" + event.getGanttDiagramEventIdentifier(); if (event.getGanttDiagramEventUrlAddOns() != null) { eventUrl = eventUrl.concat(event.getGanttDiagramEventUrlAddOns()); } final MultiLanguageString diagramEventName = event.getGanttDiagramEventName(); String eventName = diagramEventName == null ? "" : diagramEventName.getContent(); String paddingStyle = "padding-left:" + event.getGanttDiagramEventOffset() * PADDING_LEFT_MULTIPLIER + "px"; if (event.getGanttDiagramEventIdentifier().equals(selectedEvent) || (selectedEventObject != null && event.getGanttDiagramEventIdentifier().equals(selectedEventObject.toString()))) { builder.append("<tr class=\"selected\">"); } else { builder.append("<tr>"); } if (getViewTypeEnum() == ViewType.YEAR_DAILY) { builder.append("<td class=\"padded\">").append("<div class=\"nowrap\">"); builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName) .append("\">"); builder.append("<a href=\"").append(eventUrl).append("&month=") .append(Month.values()[event.getGanttDiagramEventMonth() - 1].toString()).append("\">") .append(eventName); } else { builder.append("<td class=\"padded\">") .append("<div style=\"overflow:hidden; width: 14.5em;\" class=\"nowrap\">"); builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName) .append("\">"); builder.append("<a href=\"").append(eventUrl).append("\">").append(eventName); } builder.append("</a></span></div></td>"); for (DateTime day : getGanttDiagramObject().getDays()) { int startIndex = 0, endIndex = 0; int dayOfMonth = day.getDayOfMonth(); int monthOfYear = day.getMonthOfYear(); if (getViewTypeEnum() == ViewType.YEAR_DAILY) { monthOfYear = event.getGanttDiagramEventMonth(); } int year = day.getYear(); YearMonthDay yearMonthDay = new YearMonthDay(year, monthOfYear, 1); isEventToMarkWeekendsAndHolidays = event.isGanttDiagramEventToMarkWeekendsAndHolidays(); if (!isEventToMarkWeekendsAndHolidays) { builder.append("<td style=\"width: ").append(convertToEm(numberOfUnits)) .append("em;\"><div style=\"position: relative;\">"); } if (getViewTypeEnum() == ViewType.YEAR_DAILY) { if (dayOfMonth > yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) { addEmptyDiv(builder); builder.append("</div></td>"); continue; } } specialDiv = false; for (Interval interval : event.getGanttDiagramEventSortedIntervals()) { toWrite = null; toMark = true; LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate(); if ((event.getGanttDiagramEventDayType(interval) == DayType.SPECIFIC_DAYS) || (event.getGanttDiagramEventDayType(interval) == DayType.WORKDAY)) { if ((localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) || (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) || (Holiday.isHoliday(localDate))) { toMark = false; } } if (isEventToMarkWeekendsAndHolidays) { if (Holiday.isHoliday(localDate)) { toWrite = F; } else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) { toWrite = S; } else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) { toWrite = D; } } if (interval.getStart().getYear() <= year && interval.getEnd().getYear() >= year) { if (interval.getStart().getYear() < year && interval.getEnd().getYear() > year) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } // Started in same year and Ended after else if (interval.getStart().getYear() == year && interval.getEnd().getYear() > year) { if (interval.getStart().getMonthOfYear() < monthOfYear) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } else if (interval.getStart().getMonthOfYear() == monthOfYear) { if (interval.getStart().getDayOfMonth() == dayOfMonth) { startIndex = calculateTimeOfDay(interval.getStart()); addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)), convertToEm(startIndex - 1)); } else if (interval.getStart().getDayOfMonth() < dayOfMonth) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } } } // Ended in same year and started before else if (interval.getStart().getYear() < year && interval.getEnd().getYear() == year) { if (interval.getEnd().getMonthOfYear() > monthOfYear) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } else if (interval.getEnd().getMonthOfYear() == monthOfYear) { if (interval.getEnd().getDayOfMonth() > dayOfMonth) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } else if (interval.getEnd().getDayOfMonth() == dayOfMonth) { endIndex = calculateTimeOfDay(interval.getEnd()); addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT); } } } // Ended and Started In Same Year else if (interval.getStart().getYear() == year && interval.getEnd().getYear() == year) { if (interval.getStart().getMonthOfYear() <= monthOfYear && interval.getEnd().getMonthOfYear() >= monthOfYear) { if (interval.getStart().getMonthOfYear() == monthOfYear && interval.getEnd().getMonthOfYear() > monthOfYear) { if (interval.getStart().getDayOfMonth() == dayOfMonth) { startIndex = calculateTimeOfDay(interval.getStart()); addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)), convertToEm(startIndex - 1)); } else if (interval.getStart().getDayOfMonth() < dayOfMonth) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } } else if (interval.getStart().getMonthOfYear() < monthOfYear && interval.getEnd().getMonthOfYear() == monthOfYear) { if (interval.getEnd().getDayOfMonth() > dayOfMonth) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } else if (interval.getEnd().getDayOfMonth() == dayOfMonth) { endIndex = calculateTimeOfDay(interval.getEnd()); addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT); } } else if (interval.getStart().getMonthOfYear() < monthOfYear && interval.getEnd().getMonthOfYear() > monthOfYear) { addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT); } else if (interval.getStart().getMonthOfYear() == monthOfYear && interval.getEnd().getMonthOfYear() == monthOfYear) { if (interval.getStart().getDayOfMonth() <= dayOfMonth && interval.getEnd().getDayOfMonth() >= dayOfMonth) { if (event.isGanttDiagramEventIntervalsLongerThanOneDay() && (interval.getStart().getDayOfMonth() == dayOfMonth || interval.getEnd().getDayOfMonth() > dayOfMonth)) { startIndex = calculateTimeOfDay(interval.getStart()); addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)), convertToEm(startIndex - 1)); } else if (interval.getStart().getDayOfMonth() == dayOfMonth && interval.getEnd().getDayOfMonth() > dayOfMonth) { startIndex = calculateTimeOfDay(interval.getStart()); addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)), convertToEm(startIndex - 1)); } else if (interval.getStart().getDayOfMonth() < dayOfMonth && interval.getEnd().getDayOfMonth() == dayOfMonth) { endIndex = calculateTimeOfDay(interval.getEnd()); addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT); } else if (interval.getStart().getDayOfMonth() == dayOfMonth && interval.getEnd().getDayOfMonth() == dayOfMonth) { startIndex = calculateTimeOfDay(interval.getStart()); endIndex = calculateTimeOfDay(interval.getEnd()); if (startIndex == endIndex) { addSpecialDiv(builder, convertToEm(1), convertToEm(startIndex - 1)); } else { addSpecialDiv(builder, convertToEm((endIndex - startIndex) + 1), convertToEm(startIndex - 1)); } } } } } } } } if (!isEventToMarkWeekendsAndHolidays) { builder.append("</div></td>"); } else if (!specialDiv) { builder.append("<td class=\"tdnomark\">"); if (dayOfMonth <= yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) { LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate(); if (Holiday.isHoliday(localDate)) { builder.append(F); } else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) { builder.append("S"); } else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) { builder.append("D"); } } builder.append("</td>"); } } if (isShowPeriod()) { builder.append("<td class=\"padded smalltxt\" title=\"") .append(event.getGanttDiagramEventPeriod()) .append("\"><div style=\"overflow:hidden;\" class=\"nowrap\">") .append(event.getGanttDiagramEventPeriod()).append("</div></td>"); } if (isShowObservations()) { builder.append("<td class=\"padded smalltxt\">") .append(event.getGanttDiagramEventObservations()).append("</td>"); } builder.append("</tr>"); } insertNextAndBeforeLinks(builder); builder.append("</table>"); } return builder; }
From source file:alfio.manager.TicketReservationManager.java
private static TotalPrice totalReservationCostWithVAT(PromoCodeDiscount promoCodeDiscount, Event event, PriceContainer.VatStatus reservationVatStatus, List<Ticket> tickets, Stream<Pair<AdditionalService, List<AdditionalServiceItem>>> additionalServiceItems) { List<TicketPriceContainer> ticketPrices = tickets.stream() .map(t -> TicketPriceContainer.from(t, reservationVatStatus, event, promoCodeDiscount)) .collect(toList());// w w w . j a va2 s . c o m BigDecimal totalVAT = ticketPrices.stream().map(TicketPriceContainer::getVAT).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal totalDiscount = ticketPrices.stream().map(TicketPriceContainer::getAppliedDiscount) .reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal totalNET = ticketPrices.stream().map(TicketPriceContainer::getFinalPrice).reduce(BigDecimal.ZERO, BigDecimal::add); int discountedTickets = (int) ticketPrices.stream() .filter(t -> t.getAppliedDiscount().compareTo(BigDecimal.ZERO) > 0).count(); int discountAppliedCount = discountedTickets <= 1 || promoCodeDiscount.getDiscountType() == DiscountType.FIXED_AMOUNT ? discountedTickets : 1; List<AdditionalServiceItemPriceContainer> asPrices = additionalServiceItems .flatMap(generateASIPriceContainers(event, null)).collect(toList()); BigDecimal asTotalVAT = asPrices.stream().map(AdditionalServiceItemPriceContainer::getVAT) .reduce(BigDecimal.ZERO, BigDecimal::add); //FIXME discount is not applied to donations, as it wouldn't make sense. Must be implemented for #111 BigDecimal asTotalNET = asPrices.stream().map(AdditionalServiceItemPriceContainer::getFinalPrice) .reduce(BigDecimal.ZERO, BigDecimal::add); return new TotalPrice(unitToCents(totalNET.add(asTotalNET)), unitToCents(totalVAT.add(asTotalVAT)), -(MonetaryUtil.unitToCents(totalDiscount)), discountAppliedCount); }
From source file:com.marcosanta.service.impl.KalturaServiceImpl.java
@Override public ReporteGeneralGranulado topTen(Date fechaInicio, Date fechaFin, String valorUnitarioTam, String valorUnitarioTiempoVisto, int novistos) { BigDecimal total = new BigDecimal(0); ReporteGeneralGranulado rpg = new ReporteGeneralGranulado(); List<SistemaSubReporte> ssr; List<CatReporteXls> ssrCompleta = new ArrayList<>(); CatReporteXls top[] = new CatReporteXls[11]; for (int i = 0; i < 11; i++) { top[i] = new CatReporteXls(); }/*w w w. j a va 2s .co m*/ for (KalturaCuenta kc : consultasBDService.findAllCuenta()) { for (KalturaUnidad ku : kc.getListaUnidad()) { for (KalturaFabrica kf : ku.getListaFabricas()) { if (fechaInicio != null && fechaFin != null) { ssr = consultasBDService.findSubReportByFechaCorteNivelPrograma(fechaInicio, fechaFin, "programa", kc.getNombre(), kf.getNombre(), novistos); } else { ssr = consultasBDService.findReportNivelPrograma("programa", kc.getNombre(), kf.getNombre(), novistos); } for (SistemaSubReporte subReporte : ssr) { total = total.add(new BigDecimal(subReporte.getTiempoVisto())); if (ssrCompleta.contains(new CatReporteXls(subReporte.getNombre()))) { CatReporteXls caRepTmp = ssrCompleta .get(ssrCompleta.indexOf(new CatReporteXls(subReporte.getNombre()))); if (caRepTmp.getNombreFabrica().equals(kf.getNombre()) && caRepTmp.getNombreUnidad().equals(ku.getNombre())) { caRepTmp.setMinVistos( caRepTmp.getMinVistos().add(new BigDecimal(subReporte.getTiempoVisto()))); caRepTmp.setMinVisUni( caRepTmp.getMinVisUni().add(new BigDecimal((subReporte.getTiempoVisto() * Double.parseDouble(valorUnitarioTiempoVisto))))); } else { ssrCompleta.add(new CatReporteXls(subReporte.getNombre(), new BigDecimal(subReporte.getTiempoVisto()), new BigDecimal(subReporte.getTiempoVisto() * Double.parseDouble(valorUnitarioTiempoVisto)), subReporte.getUnidad(), subReporte.getFabrica())); } } else { ssrCompleta.add(new CatReporteXls(subReporte.getNombre(), new BigDecimal(subReporte.getTiempoVisto()), new BigDecimal(subReporte.getTiempoVisto() * Double.parseDouble(valorUnitarioTiempoVisto)), subReporte.getUnidad(), subReporte.getFabrica())); } } } } } for (CatReporteXls crx : ssrCompleta) { for (int i = 0; i < 10; i++) { if (crx.getMinVistos().compareTo(top[i].getMinVistos()) == 1) { if (i < 9 && top[i + 1].getMinVistos().compareTo(crx.getMinVistos()) == -1) { } else { top[i] = crx; break; } } } } List<CatReporteXls> ssrCompletas = new ArrayList<>(); for (int i = 9; i >= 0; i--) { top[i].setPorciento( top[i].getMinVistos().multiply(new BigDecimal(100).divide(total, MathContext.DECIMAL128))); ssrCompletas.add(top[i]); System.out.println(top[i].getNombre() + " " + top[i].getMinVistos() + " " + top[i].getMinVisUni() + " " + top[i].getPorciento()); } rpg.setTabla(ssrCompletas); return rpg; }
From source file:com.autentia.tnt.bean.billing.BillBean.java
private void calcTotals(List<Bill> res) { BigDecimal totals = new BigDecimal(0); BigDecimal totalsNoTaxes = new BigDecimal(0); BigDecimal totalsUnpaid = new BigDecimal(0); for (Bill elem : res) { totals = totals.add(elem.getTotal()); totalsNoTaxes = totalsNoTaxes.add(elem.getTotalNoTaxes()); totalsUnpaid = totalsUnpaid.add(elem.getUnpaid()); }/*from w ww . j a v a 2 s.c o m*/ setTotals(totals); setTotalsNoTaxes(totalsNoTaxes); setTotalsTaxes(totals.subtract(totalsNoTaxes)); setTotalsUnpaid(totalsUnpaid); }
From source file:com.t2tierp.controller.nfe.NfeCabecalhoController.java
private void atualizaTotais() { BigDecimal totalProdutos = BigDecimal.ZERO; BigDecimal valorFrete = BigDecimal.ZERO; BigDecimal valorSeguro = BigDecimal.ZERO; BigDecimal valorOutrasDespesas = BigDecimal.ZERO; BigDecimal desconto = BigDecimal.ZERO; BigDecimal baseCalculoIcms = BigDecimal.ZERO; BigDecimal valorIcms = BigDecimal.ZERO; BigDecimal baseCalculoIcmsSt = BigDecimal.ZERO; BigDecimal valorIcmsSt = BigDecimal.ZERO; BigDecimal valorIpi = BigDecimal.ZERO; BigDecimal valorPis = BigDecimal.ZERO; BigDecimal valorCofins = BigDecimal.ZERO; BigDecimal valorNotaFiscal = BigDecimal.ZERO; BigDecimal totalServicos = BigDecimal.ZERO; BigDecimal baseCalculoIssqn = BigDecimal.ZERO; BigDecimal valorIssqn = BigDecimal.ZERO; BigDecimal valorPisIssqn = BigDecimal.ZERO; BigDecimal valorCofinsIssqn = BigDecimal.ZERO; // Se houver CFOP cadastrado na Operao Fiscal, a nota de servios if (getObjeto().getTributOperacaoFiscal().getCfop() != null) { for (NfeDetalhe itensNfe : getObjeto().getListaNfeDetalhe()) { totalServicos = totalServicos.add(itensNfe.getValorTotal()); valorFrete = valorFrete.add(itensNfe.getValorFrete()); valorSeguro = valorSeguro.add(itensNfe.getValorSeguro()); valorOutrasDespesas = valorOutrasDespesas.add(itensNfe.getValorOutrasDespesas()); desconto = desconto.add(itensNfe.getValorDesconto()); baseCalculoIssqn = baseCalculoIssqn.add(itensNfe.getNfeDetalheImpostoIssqn().getBaseCalculoIssqn()); valorIssqn = valorIssqn.add(itensNfe.getNfeDetalheImpostoIssqn().getValorIssqn()); valorPisIssqn = valorPisIssqn.add(itensNfe.getNfeDetalheImpostoPis().getValorPis()); valorCofinsIssqn = valorCofinsIssqn.add(itensNfe.getNfeDetalheImpostoCofins().getValorCofins()); }/*from ww w . jav a2s.c o m*/ // valorNotaFiscal = // totalServicos.add(valorPis).add(valorCofins).add(valorOutrasDespesas).subtract(desconto); valorNotaFiscal = totalServicos.add(valorOutrasDespesas).subtract(desconto); } else { for (NfeDetalhe itensNfe : getObjeto().getListaNfeDetalhe()) { totalProdutos = totalProdutos.add(itensNfe.getValorTotal()); valorFrete = valorFrete.add(itensNfe.getValorFrete()); valorSeguro = valorSeguro.add(itensNfe.getValorSeguro()); valorOutrasDespesas = valorOutrasDespesas.add(itensNfe.getValorOutrasDespesas()); desconto = desconto.add(itensNfe.getValorDesconto()); if (itensNfe.getNfeDetalheImpostoIcms().getBaseCalculoIcms() != null) { baseCalculoIcms = baseCalculoIcms.add(itensNfe.getNfeDetalheImpostoIcms().getBaseCalculoIcms()); } if (itensNfe.getNfeDetalheImpostoIcms().getValorIcms() != null) { valorIcms = valorIcms.add(itensNfe.getNfeDetalheImpostoIcms().getValorIcms()); } if (itensNfe.getNfeDetalheImpostoIcms().getValorBaseCalculoIcmsSt() != null) { baseCalculoIcmsSt = baseCalculoIcmsSt .add(itensNfe.getNfeDetalheImpostoIcms().getValorBaseCalculoIcmsSt()); } if (itensNfe.getNfeDetalheImpostoIcms().getValorIcmsSt() != null) { valorIcmsSt = valorIcmsSt.add(itensNfe.getNfeDetalheImpostoIcms().getValorIcmsSt()); } if (itensNfe.getNfeDetalheImpostoIpi().getValorIpi() != null) { valorIpi = valorIpi.add(itensNfe.getNfeDetalheImpostoIpi().getValorIpi()); } if (itensNfe.getNfeDetalheImpostoPis().getValorPis() != null) { valorPis = valorPis.add(itensNfe.getNfeDetalheImpostoPis().getValorPis()); } if (itensNfe.getNfeDetalheImpostoCofins().getValorCofins() != null) { valorCofins = valorCofins.add(itensNfe.getNfeDetalheImpostoCofins().getValorCofins()); } } // valorNotaFiscal = // totalProdutos.add(valorIcmsSt).add(valorPis).add(valorCofins).add(valorIpi).add(valorOutrasDespesas).subtract(desconto); valorNotaFiscal = totalProdutos.add(valorIpi).add(valorOutrasDespesas).subtract(desconto); } getObjeto().setValorFrete(valorFrete); getObjeto().setValorDespesasAcessorias(valorOutrasDespesas); getObjeto().setValorSeguro(valorSeguro); getObjeto().setValorDesconto(desconto); getObjeto().setValorServicos(totalServicos); getObjeto().setBaseCalculoIssqn(baseCalculoIssqn); getObjeto().setValorIssqn(valorIssqn); getObjeto().setValorPisIssqn(valorPisIssqn); getObjeto().setValorCofinsIssqn(valorCofinsIssqn); getObjeto().setValorTotalProdutos(totalProdutos); getObjeto().setBaseCalculoIcms(baseCalculoIcms); getObjeto().setValorIcms(valorIcms); getObjeto().setBaseCalculoIcmsSt(baseCalculoIcmsSt); getObjeto().setValorIcmsSt(valorIcmsSt); getObjeto().setValorIpi(valorIpi); getObjeto().setValorPis(valorPis); getObjeto().setValorCofins(valorCofins); getObjeto().setValorTotal(valorNotaFiscal); }