fixes bug#11299
dev:gleimar qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@82473 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
4b53fabd67
commit
5e278c3fb2
|
@ -1,6 +1,7 @@
|
||||||
package com.rjconsultores.ventaboletos.web.gui.controladores.comissao;
|
package com.rjconsultores.ventaboletos.web.gui.controladores.comissao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.zkoss.util.resource.Labels;
|
import org.zkoss.util.resource.Labels;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
import org.zkoss.zk.ui.WrongValueException;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zul.Combobox;
|
import org.zkoss.zul.Combobox;
|
||||||
import org.zkoss.zul.Datebox;
|
import org.zkoss.zul.Datebox;
|
||||||
|
@ -21,9 +23,12 @@ import com.rjconsultores.ventaboletos.constantes.Constantes;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Constante;
|
import com.rjconsultores.ventaboletos.entidad.Constante;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
import com.rjconsultores.ventaboletos.exception.ComissaoException;
|
import com.rjconsultores.ventaboletos.exception.ComissaoException;
|
||||||
import com.rjconsultores.ventaboletos.service.CalculoComissaoService;
|
import com.rjconsultores.ventaboletos.service.CalculoComissaoService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.ComissaoService;
|
||||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.PuntoVentaService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta;
|
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta;
|
||||||
|
@ -42,6 +47,9 @@ public class BusquedaRetencaoDiariaComissaoController extends MyGenericForwardCo
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConstanteService constanteService;
|
private ConstanteService constanteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ComissaoService comissaoService;
|
||||||
|
|
||||||
private Combobox cmbEmpresa;
|
private Combobox cmbEmpresa;
|
||||||
private List<Empresa> lsEmpresas;
|
private List<Empresa> lsEmpresas;
|
||||||
private List<PuntoVenta> lsPuntoVenta;
|
private List<PuntoVenta> lsPuntoVenta;
|
||||||
|
@ -121,9 +129,7 @@ public class BusquedaRetencaoDiariaComissaoController extends MyGenericForwardCo
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(verificarCampos()) {
|
if(verificarCampos()) {
|
||||||
PuntoVenta puntoVenta = (PuntoVenta) (cmbPuntoVenta.getSelectedItem() != null ? cmbPuntoVenta.getSelectedItem().getValue() : null);
|
processarRecalculoComissao();
|
||||||
Empresa empresa = (Empresa) (cmbEmpresa.getSelectedItem() != null ? cmbEmpresa.getSelectedItem().getValue() : null);
|
|
||||||
calculoComissaoService.registrarCalculoComissao(puntoVenta, empresa, dataInicial.getValue(), dataFinal.getValue(), UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
||||||
|
|
||||||
Messagebox.show(
|
Messagebox.show(
|
||||||
Labels.getLabel("busquedaRetencaoDiariaComissaoController.info.comissao"),
|
Labels.getLabel("busquedaRetencaoDiariaComissaoController.info.comissao"),
|
||||||
|
@ -142,6 +148,30 @@ public class BusquedaRetencaoDiariaComissaoController extends MyGenericForwardCo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processarRecalculoComissao() throws WrongValueException, ComissaoException, BusinessException {
|
||||||
|
PuntoVenta puntoVenta = (PuntoVenta) (cmbPuntoVenta.getSelectedItem() != null ? cmbPuntoVenta.getSelectedItem().getValue() : null);
|
||||||
|
Empresa empresa = (Empresa) (cmbEmpresa.getSelectedItem() != null ? cmbEmpresa.getSelectedItem().getValue() : null);
|
||||||
|
|
||||||
|
List<PuntoVenta> puntoventas = null;
|
||||||
|
if(puntoVenta == null || puntoVenta.getPuntoventaId() == -1) {
|
||||||
|
puntoventas = comissaoService.buscaPuntoVentasEmpresaComComissaoParametrizada(empresa.getEmpresaId());
|
||||||
|
} else {
|
||||||
|
puntoventas = Arrays.asList(new PuntoVenta[] {puntoVenta});
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar cDataAtual = Calendar.getInstance();
|
||||||
|
cDataAtual.setTime(dataInicial.getValue());
|
||||||
|
while(DateUtil.compareOnlyDate(cDataAtual.getTime(), dataFinal.getValue()) <= 0) {
|
||||||
|
for (PuntoVenta pv : puntoventas) {
|
||||||
|
log.info("Inicio Recalculo Comissao Agencia: " + pv.getNombpuntoventa());
|
||||||
|
log.info("Data: " + DateUtil.getStringDate(cDataAtual.getTime()));
|
||||||
|
calculoComissaoService.registrarCalculoComissao(pv, empresa, cDataAtual.getTime(), cDataAtual.getTime(), UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
log.info("Fim Recalculo Comissao Agencia: " + pv.getNombpuntoventa());
|
||||||
|
}
|
||||||
|
cDataAtual.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Combobox getCmbEmpresa() {
|
public Combobox getCmbEmpresa() {
|
||||||
return cmbEmpresa;
|
return cmbEmpresa;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue