@Override
  protected SupervisorPayrollItemDto doTransform(SupervisorPayrollItem e, int depth) {

    SupervisorPayrollItemDto d = new SupervisorPayrollItemDto();
    d.setId(e.getId());
    for (SupervisorConciliationItem supervisorConciliationItem :
        e.getSupervisorConciliationItems()) {
      SupervisorConciliationItemDto i = new SupervisorConciliationItemDto();
      i.setBonusAmount(NumberUtils.toString(supervisorConciliationItem.getBonusAmount()));
      i.setCreditAmount(NumberUtils.toString(supervisorConciliationItem.getCreditAmount()));
      i.setDevAmount(NumberUtils.toString(supervisorConciliationItem.getDevAmount()));
      i.setReductionAmount(NumberUtils.toString(supervisorConciliationItem.getReductionAmount()));
      i.setTotalTrader(NumberUtils.toString(supervisorConciliationItem.getTotalTrader()));
      i.setTraderName(supervisorConciliationItem.getTrader().getName());

      d.addSupervisorConciliationItem(i);
    }
    d.setSupervisorName(e.getSupervisor().getName());
    d.setTotalAmount(NumberUtils.toString(e.getTotalAmount()));
    if (e.getBonusItem() != null) {
      d.setTotalBonusAmount(NumberUtils.toString(e.getBonusItem().getCollectAmount()));
    } else {
      d.setTotalBonusAmount(NumberUtils.toString(BigDecimal.ZERO));
    }
    d.setTotalCreditAmount(NumberUtils.toString(e.getSubtotalCollect()));
    d.setTotalBonusAmount(NumberUtils.toString(e.getSubtotalBonus()));
    d.setTotalDevAmount(NumberUtils.toString(e.getSubtotalDev()));
    d.setTotalReductionAmount(NumberUtils.toString(e.getSubtotalReduction()));
    d.setDateFrom(DateUtils.toDate(e.getPayroll().getDateFrom()));
    d.setDateTo(DateUtils.toDate(e.getPayroll().getDateTo()));

    return d;
  }
Ejemplo n.º 2
0
  @Override
  public BillDetailDto searchDetail(Long billId) {
    BillDetailDto d = new BillDetailDto();

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

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

    d.setClientAddress(bill.getClient().getCompanyAddress());
    d.setClientName(bill.getClient().getName());
    d.setCreditAmount(NumberUtils.toString(bill.getTotalAmount()));
    d.setCreditDate(DateUtils.toDate(bill.getStartDate()));

    BigDecimal firstPayment = BigDecimal.ZERO;
    if (bill.getPayments() != null && bill.getPayments().size() > 0) {
      firstPayment = bill.getPayments().get(0).getAmount();
    }

    d.setFirstInstallmentAmount(NumberUtils.toString(firstPayment));
    d.setInstallmentAmount(NumberUtils.toString(bill.getTotalDailyInstallment()));

    d.setWeekAmount(
        NumberUtils.toString(
            NumberUtils.multiply(bill.getTotalDailyInstallment(), new BigDecimal(7))));

    d.setCurrentAmount(
        NumberUtils.toString(
            NumberUtils.subtract(bill.getTotalAmount(), bill.getRemainingAmount())));

    d.setRemainingAmount(NumberUtils.toString(bill.getRemainingAmount()));
    d.setTraderName(bill.getTrader().getName());
    d.setCreditNumber(StringUtils.toString(bill.getCreditNumber()));
    d.setCompletedDate(
        (bill.getCompletedDate() != null)
            ? DateUtils.toDate(bill.getCompletedDate())
            : StringUtils.EMPTY);
    d.setStatus(bill.getStatus().name());
    d.setCollectorId(bill.getCollector().getId());
    d.setCollectorDescription(
        String.valueOf(bill.getCollector().getZone())
            + " / "
            + bill.getCollector().getDescription());
    d.setCustomerCompanyType(
        (StringUtils.isNotBlank(bill.getClient().getCompanyType()))
            ? bill.getClient().getCompanyType()
            : StringUtils.EMPTY);

    for (Payment p : bill.getPayments()) {
      BillDetailPaymentDto r = new BillDetailPaymentDto();
      r.setAmount(NumberUtils.toString(p.getAmount()));
      r.setCollector(
          String.valueOf(
              (p.getCollector() != null)
                  ? p.getCollector().getZone() + " / " + p.getCollector().getDescription()
                  : StringUtils.EMPTY));
      r.setDate(DateUtils.toDate(p.getDate()));
      r.setId(p.getId());
      r.setTraderPayment(p.isTraderPayment() ? "SI" : " - ");

      d.getPayments().add(r);
    }

    for (Dev p : bill.getDevList()) {
      BillDetailDevolutionDto r = new BillDetailDevolutionDto();
      r.setAmount(NumberUtils.toString(p.getAmount()));
      r.setDate(DateUtils.toDate(p.getDate()));
      r.setInstallmentAmount(NumberUtils.toString(p.getInstallmentAmount()));
      r.setProductDescription(p.getProduct().getDescription());
      r.setObservations(p.getObservations());
      r.setCount(p.getProductCount());

      d.getDevolutions().add(r);
    }
    for (BillProduct p : bill.getBillProducts()) {
      BillProductDetailDto r = new BillProductDetailDto();
      r.setCount((p.getCount() != null) ? String.valueOf(p.getCount()) : "0");
      r.setCodProducto(p.getProduct().getCode());
      r.setDescription(
          p.getProduct().getDescription()
              + " / "
              + NumberUtils.toString(p.getProduct().getPrice()));
      r.setInstallmentAmount(NumberUtils.toString(p.getDailyInstallment()));
      r.setTotalAmount(NumberUtils.toString(p.getAmount()));

      d.getProducts().add(r);
    }
    for (Discount e : bill.getDiscounts()) {
      BillDetailDiscountDto r = new BillDetailDiscountDto();
      r.setAmount(NumberUtils.toString(e.getAmount()));
      r.setDate(DateUtils.toDate(e.getDate()));
      r.setObservations(e.getObservations());

      d.getDiscounts().add(r);
    }
    for (ProductReduction e : bill.getProductReductionList()) {
      BillDetailReductionDto r = new BillDetailReductionDto();
      r.setId(e.getId());
      r.setAmount(NumberUtils.toString(e.getAmount()));
      r.setDate(DateUtils.toDate(e.getDate()));
      r.setObservations(e.getObservations());

      d.getReductions().add(r);
    }

    return d;
  }