@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void installmentToPayment(Installment installment) throws IabakoPackageForbiddenException { Installment installmentFromDB = (Installment) installmentService.getById(installment.getId()); if (installmentFromDB == null) { log.warn("No installment found with id :" + installment.getId()); return; } Payment payment = new Payment(); payment.setDate(GenericTools.getDateFromString(installment.getDateString())); payment.setScheduleDate(GenericTools.getDateFromString(installment.getScheduleDateString())); payment.setAmount(installment.getAmount()); payment.setSale(installment.getSale()); payment.setComment(installment.getComment()); payment.setPaymentMethod(installment.getPaymentMethod()); payment.setRequestDetails(installment.getRequestDetails()); payment.setRequestBeforeDateSent(installment.isRequestBeforeDateSent()); payment.setRequestAfterDateSent(installment.isRequestAfterDateSent()); installmentService.remove(installmentFromDB, true); paymentService.save(payment, true); trackingService.addTrackingToUserSession( TrackingType.installmentToPaymentReceived, installment.getSale()); }
private void addPaymentsInstallments( Sale sale, List<Payment> payments, List<Installment> installments) { if (installments != null) { for (Installment i : installments) { i.setDate(GenericTools.getDateFromString(i.getDateString())); i.setAmount(ServerTools.round(i.getAmount())); } if (sale.getClient() != null) { // Client must be enabled if he has future or pending installments sale.getClient().setDisabled(false); } } if (payments != null) { for (Payment p : payments) { p.setDate(GenericTools.getDateFromString(p.getDateString())); p.setScheduleDate(GenericTools.getDateFromString(p.getScheduleDateString())); p.setAmount(ServerTools.round(p.getAmount())); p.setPaymentMethod(sale.getPaymentMethod()); } } sale.setInstallments(installments); sale.setPayments(payments); }
@RequestMapping(value = "/admin/index.html", method = RequestMethod.GET) public ModelAndView index() { ModelAndView modelAndView = new ModelAndView(index); ModelMap modelMap = modelAndView.getModelMap(); List<User> users = userService.findAllUsers(); Account account = accountService.findLatestRecord(); int totalIncome = incomeService.getTotal(); List<Food> dishes = foodService.findAllFoods(); Payment todayPayment = paymentService.getPaymentOfToday(); List<FoodType> catagorys = foodTypeService.findAllFoodTypes(); Map<String, List<Food>> map = new HashMap<String, List<Food>>(); for (FoodType type : catagorys) { List<Food> foods = foodService.findFoodByType(type.getGuid()); if (foods.size() > 0) { map.put(type.getName(), foods); } } modelMap.put(USERS, users); if (account != null) { modelMap.put(REMAINDER, account.getRemainder()); } modelMap.put(INCOMETOTAL, totalIncome); modelMap.put(DISHES, dishes); modelMap.put(CATAGORYS, map); if (todayPayment != null) { modelMap.put(TODAYCONSUME, todayPayment.getAmount()); } List<String> contentPages = new ArrayList<String>(); contentPages.add(dashboard + JSPSUFFIX); contentPages.add(userManage + JSPSUFFIX); contentPages.add(dishManage + JSPSUFFIX); modelMap.put(CONTENTPAGE, contentPages); List<StepBean> emptyStepBean = Collections.emptyList(); modelMap.put(STEPS, emptyStepBean); return modelAndView; }
public BigDecimal getFinalPayment() { /*if (this.paymentSchedule == null) { this.paymentSchedule = loanCalculator.calculatePaymentSchedule(); }*/ Iterator payments = this.paymentSchedule.getPayments(); Payment payment = null; while (payments.hasNext()) { payment = (Payment) payments.next(); } BigDecimal finalPayment = payment.getPrincipal().add(payment.getInterest()); ; finalPayment = finalPayment.setScale(2, BigDecimal.ROUND_HALF_UP); return finalPayment; }
public BigDecimal getMonthlyPayment() { /*if (this.paymentSchedule == null) { this.paymentSchedule = loanCalculator.calculatePaymentSchedule(); }*/ Iterator payments = this.paymentSchedule.getPayments(); BigDecimal monthlyPayment = null; if (payments.hasNext()) { Payment payment = (Payment) payments.next(); monthlyPayment = payment.getPrincipal().add(payment.getInterest()); monthlyPayment = monthlyPayment.setScale(2, BigDecimal.ROUND_HALF_UP); } return monthlyPayment; }
public void paymentTest() { Payment payment = new Payment(); // 取出订单 Order order = orderDAO.getOrderById(8); // 取出订单顾客 Customer customer = order.getCustomer(); // 取出操作员 Worker worker = workerDAO.getWorkerById(7); // 取出银行卡 Bankcard bankcard = customer.getBankcardList().get(0); payment.setPayCustomer(customer); System.out.println("OrderId:" + order.getOrderId()); payment.setPayOrder(order); System.out.println(bankcard); payment.setPayCard(bankcard); payment.setPayPrice(order.getOrderPrice()); payment.setPayType(1); payment.setWorker(worker); paymentDAO.createPayment(payment); }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void paymentToInstallment(Long idPayment) { Payment payment = (Payment) paymentService.getById(idPayment); if (payment == null) { log.warn("No payment found with id :" + idPayment); return; } Installment installment = new Installment(); installment.setDate( payment.getScheduleDate() != null ? payment.getScheduleDate() : payment.getDate()); installment.setAmount(payment.getAmount()); installment.setSale(payment.getSale()); installment.setComment(payment.getComment()); installment.setRequestDetails(payment.getRequestDetails()); installment.setRequestBeforeDateSent(payment.isRequestBeforeDateSent()); installment.setRequestAfterDateSent(payment.isRequestAfterDateSent()); paymentService.remove(payment, true); installmentService.save(installment, true); trackingService.addTrackingToUserSession( TrackingType.paymentReceivedToInstallment, payment.getSale()); }