@Test public void updateAmount_ok() { Long customerNumber = 455L; String checkNumber = "IR662429"; BigDecimal a1 = new BigDecimal("32239.47"); Integer u1 = paymentService.updateAmount(customerNumber, checkNumber, a1); assertThat(u1, is(1)); Payment p1 = paymentService.findByPk(customerNumber, checkNumber); assertThat(p1, notNullValue()); assertThat(p1.getAmount(), is(a1)); System.out.println(p1.toString()); BigDecimal a2 = new BigDecimal("77777.88"); Integer u2 = paymentService.updateAmount(customerNumber, checkNumber, a2); assertThat(u2, is(1)); Payment p2 = paymentService.findByPk(customerNumber, checkNumber); assertThat(p2, notNullValue()); assertThat(p2.getAmount(), is(a2)); System.out.println(p2.toString()); }
@RequestMapping(value = "/delete/{pid}", method = RequestMethod.GET) public String deletePayment(ModelMap modelMap, @PathVariable int pid) { Payment payment = paymentService.getPaymentById(pid); logService.addLog( new Log( sessionBean.getUserName(), "delete", "payment delete", "удален платеж на сумму: " + payment.getCredit() + "/ " + payment.getDebt() + " для клиента " + payment.getClientP().getName() + " " + payment.getClientP().getContractInfo() + " " + payment.getReason())); if (payment.getInvoiceP() != null || payment.getWaybill() != null) { modelMap.addAttribute("message", "unable to remove this type of payment!"); return "/auth/message"; } String message = "payment with id " + payment.getId() + " has been deleted"; paymentService.deletePayment(payment); System.out.println("deleting!!"); modelMap.addAttribute("message", message); return "/auth/message"; }
@Test public void save_ok() { Payment result = paymentService.save(payment1); assertThat(result, notNullValue()); Payment actual = paymentService.findById(result.getId()); assertThat(actual, is(result)); payment1.setId(actual.getId()); }
@Test public void saveAll_ok() { List<Payment> payments = paymentService.saveAll(Arrays.asList(payment2, payment3)); assertThat(payments, notNullValue()); Payment actual2 = paymentService.findById(payments.get(0).getId()); Payment actual3 = paymentService.findById(payments.get(1).getId()); assertThat(actual2, is(payments.get(0))); assertThat(actual3, is(payments.get(1))); payment2.setId(actual2.getId()); payment3.setId(actual3.getId()); }
@RequestMapping(value = "/get/{type}", method = RequestMethod.GET) public String getPaymentsSpecific( ModelMap model, @PathVariable String type, @RequestParam(required = false, defaultValue = "") String dateFrom, @RequestParam(required = false, defaultValue = "") String dateTo, @RequestParam(required = false, defaultValue = "") String clientStr) { List<Payment> payments = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyy-MM-dd"); Date d1 = new Date(); Date d2 = new Date(); model .addAttribute("dateFrom", dateFrom) .addAttribute("dateTo", dateTo) .addAttribute("clientStr", clientStr); if (type.equals("in")) { if (!dateFrom.equals("") && !dateTo.equals("")) { try { d1 = sdf.parse(dateFrom); d2 = sdf.parse(dateTo); } catch (ParseException e) { e.printStackTrace(); } payments = paymentService.listPayments(clientStr, d1, d2); } if (dateFrom.equals("") && dateTo.equals("") && !clientStr.equals("")) { try { d1 = sdf.parse("1971-01-01"); d2 = sdf.parse("2025-01-01"); } catch (ParseException e) { e.printStackTrace(); } payments = paymentService.listPayments(clientStr, d1, d2); } if (dateFrom.equals("") && dateTo.equals("") && clientStr.equals("")) { payments = paymentService.listPayments(); } model.addAttribute("payments", payments); return "/auth/payment/paymentgetin"; } // model.addAttribute("payments", paymentService.listPayments()); return "/auth/payment/paymentget"; }
@RequestMapping(value = "/roundall", method = RequestMethod.GET) public String roundPaymentTable(ModelMap modelMap) { paymentService.roundAllBalances(); System.out.println("rounding!!!"); return "redirect:/"; }
@RequestMapping(value = "/recalc", method = RequestMethod.GET) public String recalcPaymentTable(ModelMap modelMap) { paymentService.recalcPaymentTable(); modelMap.addAttribute("message", "recalc is done"); System.out.println("recalcing!!!"); return "/auth/message"; }
@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()); }
public void verifyAndRegisterPayment(Payment payment) { verifyPaymentServiceIsInitialized(); if (payment != null) { paymentService.registerPayment(payment); } }
@Test public void testCreateWithPayment() { PaymentService srvPayment = Paymill.getService(PaymentService.class); Payment payment = srvPayment.create(getToken()); PreauthorizationService svrTx = Paymill.getService(PreauthorizationService.class); Preauthorization preauthorizationParams = new Preauthorization(); preauthorizationParams.setPayment(payment); preauthorizationParams.setAmount(100); preauthorizationParams.setCurrency("EUR"); Preauthorization tx = svrTx.create(preauthorizationParams); assertNotNull(tx); assertNotNull(tx.getId()); assertEquals((int) tx.getAmount(), 100); assertNotNull(tx.getPayment()); assertEquals(payment.getId(), tx.getPayment().getId()); }
@Test public void testPay() { GenericCreditCardService creditCardService = Mockito.mock(GenericCreditCardService.class); Purchase p = BillingCalculator.calculateTotalPurchase(customer, "EL-001,FU-002"); // Mocking external service behavior Mockito.when(creditCardService.pay("xxxx111xxxx", p.getTotalPrice())).thenReturn(true); paymentService.pay(customer, p, "xxxx111xxxx", creditCardService); }
@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()); }
@RequestMapping(value = "/credit/{cid}", method = RequestMethod.POST) public String chargeBalanceP( ModelMap modelMap, @ModelAttribute Payment payment, @PathVariable int cid, @RequestParam(required = true) String type, RedirectAttributes redirectAttributes) { Client client = clientService.getClientById(cid); payment.setPaymentType(type); paymentService.increaseCredit(payment, client, "username"); redirectAttributes.addFlashAttribute("message", Messages.success); redirectAttributes.addFlashAttribute("client", client); redirectAttributes.addFlashAttribute("payment", payment); return "redirect:/auth/payment/credit/" + client.getId(); }
@RequestMapping(value = "/get", method = RequestMethod.GET) public String getPaymentsAll(ModelMap model) { model.addAttribute("payments", paymentService.listPayments()); return "/auth/payment/paymentget"; }
private void clear() { paymentService.removeAll(Arrays.asList(payment1, payment2, payment3)); }