コード例 #1
0
  @RequestMapping(method = RequestMethod.GET)
  public String displayForm(
      @ModelAttribute("command") Object command,
      @RequestParam("billId") Integer billId,
      HttpServletRequest request,
      Model model) {

    BillingService billingService = (BillingService) Context.getService(BillingService.class);

    List<MiscellaneousService> listMiscellaneousService =
        billingService.getAllMiscellaneousService();

    if (listMiscellaneousService == null || listMiscellaneousService.size() == 0) {
      request
          .getSession()
          .setAttribute(WebConstants.OPENMRS_MSG_ATTR, "No MiscellaneousService found.");
    } else {
      model.addAttribute("listMiscellaneousService", listMiscellaneousService);
    }

    MiscellaneousServiceBill bill = billingService.getMiscellaneousServiceBillById(billId);
    model.addAttribute("bill", bill);

    return "module/billing/main/miscellaneousServiceBillEdit";
  }
コード例 #2
0
  @RequestMapping(method = RequestMethod.POST)
  public String onSubmit(
      Model model,
      @RequestParam(value = "serviceId") Integer miscellaneousServiceId,
      @RequestParam("billId") Integer billId,
      @RequestParam("name") String name,
      @RequestParam("action") String action,
      Object command,
      BindingResult binding,
      HttpServletRequest request) {

    BillingService billingService = (BillingService) Context.getService(BillingService.class);
    MiscellaneousServiceBill miscellaneousServiceBill =
        billingService.getMiscellaneousServiceBillById(billId);

    // if action is void
    if ("void".equalsIgnoreCase(action)) {
      miscellaneousServiceBill.setVoided(true);
      billingService.saveMiscellaneousServiceBill(miscellaneousServiceBill);
      return "redirect:/module/billing/miscellaneousServiceBill.list";
    }

    // 07/07/2012:kesavulu: New Requirement #306 Add field quantity in Miscellaneous Services Bill

    MiscellaneousService miscellaneousService = null;
    int quantity = 0;
    Money itemAmount;
    Money totalAmount = new Money(BigDecimal.ZERO);

    miscellaneousService = billingService.getMiscellaneousServiceById(miscellaneousServiceId);
    quantity = Integer.parseInt(request.getParameter(miscellaneousServiceId + "_qty"));
    itemAmount =
        new Money(new BigDecimal(request.getParameter(miscellaneousServiceId + "_amount")));

    itemAmount = itemAmount.times(quantity);
    totalAmount = totalAmount.plus(itemAmount);
    miscellaneousServiceBill.setLiableName(name);

    miscellaneousService = billingService.getMiscellaneousServiceById(miscellaneousServiceId);
    miscellaneousServiceBill.setAmount(totalAmount.getAmount());
    miscellaneousServiceBill.setService(miscellaneousService);
    miscellaneousServiceBill.setQuantity(quantity);
    miscellaneousServiceBill =
        billingService.saveMiscellaneousServiceBill(miscellaneousServiceBill);

    return "redirect:/module/billing/miscellaneousServiceBill.list?serviceId="
        + miscellaneousServiceId
        + "&billId="
        + miscellaneousServiceBill.getId();
  }