Ejemplo n.º 1
0
  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);
  }
Ejemplo n.º 2
0
  @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());
  }