コード例 #1
0
 @Action(
     value = "payments",
     results = {@Result(name = "success", type = "tiles", location = "/payment-list.tiles")})
 @SkipValidation
 public String list() {
   this.paymentList = paymentService.findAll();
   return SUCCESS;
 }
コード例 #2
0
 @Action(
     value = "savePayment",
     results = {
       @Result(
           name = "success",
           location = "spPayment",
           type = "redirectAction",
           params = {"model.id", "${id}"}),
       @Result(name = "input", type = "tiles", location = "/payment.tiles")
     })
 public String save() {
   if (payment != null && payment.hashCode() != paymentHash) {
     if (doctorID != null && doctorID.equals("")) {
       addFieldError("doctorID", Messages.getString("DoctorSessionAction.CheckDoctor"));
       return INPUT;
     }
     if (!payment.getPaymentMethod().equals(PaymentMethod.MONEY_BACK) && payment.getValue() <= 0) {
       addFieldError("value", Messages.getString("PaymentAction.WrongValue"));
       return INPUT;
     }
     if (Messages.getCustomer("customer").trim().equals(Customer.degfim.toString().trim())
         && getDoctors() != null) {
       if (!payment.getPaymentMethod().equals(PaymentMethod.MONEY_BACK)) {
         if (payment.getValue() > checkVal()) {
           addFieldError("value", "Мөнгөн дүн " + checkVal() + " -аас дээш байж болохгүй");
           return INPUT;
         }
       } else {
         if (payment.getValue() > getDoctorSessionValue()) {
           addFieldError(
               "value", "Мөнгөн дүн " + getDoctorSessionValue() + " -аас дээш байж болохгүй");
           return INPUT;
         }
       }
     }
     if (numberService.findAll().size() == 0)
       numberService.saveOrUpdate(new PaymentNumberCounter());
     PaymentMethod method = payment.getPaymentMethod();
     List<Patient> patientList = patientService.searchById(id);
     payment.setPatient(patientList.get(0));
     if (method.equals(PaymentMethod.MONEY_BACK) && payment.getValue() > 0) {
       payment.setValue(payment.getValue() * (-1));
     }
     if (doctorID != null) payment.setDoctor(doctorService.get(Long.parseLong(doctorID)));
     payment.setPaymentNumber(numberService.getNextPaymentNumber(method));
     payment.setId(null);
     paymentService.saveOrUpdate(payment);
     ssm.logInfo(payment);
     return SUCCESS;
   }
   return INPUT;
 }
コード例 #3
0
 public int checkVal() {
   Doctor doctor = doctorService.get(Long.parseLong(doctorID));
   SessionPayment sp = spService.getSpExistPatient(id);
   int sessionVal = 0;
   for (DoctorSession ds : sp.getListOfSession()) {
     if (ds.getDoctor().getId() == doctor.getId()) {
       sessionVal += ds.getSum();
     }
   }
   int paymentVal = 0;
   for (Payment p : sp.getListOfPayment()) {
     Doctor doctor1 = paymentService.get(p.getId()).getDoctor();
     if (doctor1 != null)
       if (doctor1.getId() == doctor.getId()) {
         paymentVal += p.getValue();
       }
   }
   return sessionVal - paymentVal;
 }
コード例 #4
0
 @Action(
     value = "editPayment",
     results = {
       @Result(
           name = "success",
           location = "spPaymentEdit",
           type = "redirectAction",
           params = {"model.id", "${id,patient.id}"}),
       @Result(name = "input", type = "tiles", location = "/paymentEdit.tiles")
     })
 public String edit() {
   if (payment != null && payment.hashCode() != paymentHash) {
     PaymentMethod method = payment.getPaymentMethod();
     List<Patient> paymentList = patientService.searchById(payment.getPatient().getId());
     payment.setPatient(paymentList.get(0));
     payment.setPaymentNumber(numberService.getNextPaymentNumber(method));
     paymentService.update(payment);
     ssm.logInfo(payment);
     return SUCCESS;
   }
   return INPUT;
 }
コード例 #5
0
 public void prepare() throws Exception {
   if ((payment != null) && payment.getId() != null) {
     this.payment = paymentService.get(payment.getId());
     this.paymentHash = payment.hashCode();
   }
 }