示例#1
0
 private int getDoctorSessionValue() {
   int sessionVal = 0;
   Doctor doctor = doctorService.get(Long.parseLong(doctorID));
   SessionPayment sp = spService.getSpExistPatient(id);
   for (DoctorSession ds : sp.getListOfSession()) {
     if (ds.getDoctor().getId() == doctor.getId()) {
       sessionVal += ds.getSum();
     }
   }
   return sessionVal;
 }
示例#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
 public List<Doctor> getAllDoctors() {
   return doctorService.findAll();
 }