Ejemplo n.º 1
0
 private void setAttributesFromDB(Sale sale, Sale saleFromDB) {
   sale.setStatus(saleFromDB.getStatus());
   sale.setRecalculatedTotal(saleFromDB.getRecalculatedTotal());
   sale.setTotalBeforeTax(saleFromDB.getTotalBeforeTax());
   sale.setTotalAfterTax(saleFromDB.getTotalAfterTax());
   sale.setTotalNoTax(saleFromDB.getTotalNoTax());
 }
Ejemplo n.º 2
0
 private Sale checkIfQuote(Sale sale) {
   if (sale.getSaleQuoteId() != null) {
     Sale saleQuote = saleDAO.findById(Long.parseLong(sale.getSaleQuoteId()));
     if (saleQuote != null && saleQuote.isQuote()) {
       saleQuote.setSaleQuoteId(
           sale.getStatus() == FinancialStatusSale._0_draft
               ? "_draft_" + sale.getId()
               : sale.getId() + "");
       saleQuote.setStatus(FinancialStatusSale._2_quote_transformed);
     } else {
       sale.setSaleQuoteId(null);
     }
     saleDAO.merge(saleQuote);
     return saleQuote;
   }
   return null;
 }
Ejemplo n.º 3
0
  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  public Sale duplicate(Sale sale)
      throws IabakoUniqueConstraintException, IabakoPackageForbiddenException,
          IabakoActionForbiddenException, IabakoStockException {
    // get ProdSer from DB
    sale.setProductsServices(saleDAO.getProductServiceList(sale));

    if (sale.getInstallmentsDefinition() != null
        && sale.getInstallmentsDefinition().getInstallmentsFrequency()
            == InstallmentsFrequency.custom
        && GenericTools.isEmpty(sale.getInstallmentsDefinition().getInstallments())) {
      // initialize empty relation coming from GWT world before clone() call
      sale.getInstallmentsDefinition()
          .setInstallments(saleDAO.getCustomInstallmentsDefinition(sale));
    }
    Sale newSale = sale.customClone();

    newSale.setDate(new Date());
    newSale.setDateString(GenericTools.formatDateToString(newSale.getDate()));

    newSale.setClient(sale.getClient());
    if (sale.getStatus() != FinancialStatusSale._0_draft) {
      newSale.setSaleStep(SaleStep.confirmation);
    }

    newSale.getPayments().clear();
    newSale.getInstallments().clear();

    List<Installment> installments =
        newSale.getInstallmentsDefinition() != null
            ? newSale.getInstallmentsDefinition().getInstallments()
            : null;

    return save(
        true, newSale, newSale.getProductsServices(), newSale.getExpenses(), null, installments);
  }