Ejemplo n.º 1
0
  @Override
  public boolean updateOverdueDays(Long billId) {

    Bill bill = this.getDao().findById(billId);

    ErrorTypedConditions.checkArgument(bill != null, ErrorType.BILL_NOT_FOUND);

    Date overdueDaysFlag = bill.getOverdueDaysFlag();
    Date now = DateUtils.now();

    int daysBetween = DateUtils.daysBetween(overdueDaysFlag, now);
    //		if(daysBetween <= 0){
    //			daysBetween = 1;
    //		}
    LOGGER.debug(String.format("dias de atraso calculados: %s", daysBetween));

    if (daysBetween > 0) {
      LOGGER.info(
          String.format("dias de atraso a actualizar: %s, para billId = %s", daysBetween, billId));

      bill.incrementOverdueDays(daysBetween);
      bill.audit();
    }

    return this.getDao().saveOrUpdate(bill);
  }
Ejemplo n.º 2
0
  @Override
  public BillInfoDto setCancelDiscount(Long id) {

    Bill bill = this.getDao().findById(id);
    ErrorTypedConditions.checkArgument(
        bill != null,
        String.format("Factura no encontrada con id: %s", id),
        ErrorType.VALIDATION_ERRORS);

    bill.setStatus(Status.CANCELED_DISCOUNT);
    bill.setUpdatedDate(DateUtils.now());

    BillInfoDto r = new BillInfoDto();
    r.setBillId(id);
    r.setBillStatus(bill.getStatus().name());
    r.setRemainingAmount(NumberUtils.toString(bill.getRemainingAmount()));
    r.setOverdueDays(bill.getOverdueDays());
    r.setInstallmentAmount(NumberUtils.toString(bill.getTotalDailyInstallment()));

    return r;
  }