224 lines
6.5 KiB
Plaintext
Executable File
224 lines
6.5 KiB
Plaintext
Executable File
package com.fp.frontend.controller.pgeneral.gene;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ViewScoped;
|
|
|
|
import org.primefaces.event.SelectEvent;
|
|
|
|
import com.fp.dto.Request;
|
|
import com.fp.dto.Response;
|
|
import com.fp.dto.query.DtoQuery;
|
|
import com.fp.dto.save.DtoSave;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.pgeneral.acco.AccountStatusController;
|
|
import com.fp.frontend.controller.pgeneral.lov.BalanceTypeLovController;
|
|
import com.fp.frontend.controller.pgeneral.product.ModuleController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.pgeneral.acco.TgeneAccountStatus;
|
|
import com.fp.persistence.pgeneral.charge.TgeneChargesGroup;
|
|
import com.fp.persistence.pgeneral.gene.TgeneBalanceType;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCurrency;
|
|
import com.fp.persistence.pgeneral.product.TgeneModule;
|
|
|
|
/**
|
|
* Clase controladora del bean TgeneChargesGroup.
|
|
*
|
|
* @author Jorge Vaca.
|
|
* @version 2.1
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ChargesGroupController extends AbstractController<TgeneChargesGroup> {
|
|
|
|
private List<TgeneModule> lmodules;
|
|
private List<TgeneCatalogDetail> lgroups;
|
|
/**
|
|
* Lista de estatus de cuentas asociados a un modulo.
|
|
*/
|
|
private List<TgeneAccountStatus> laccountstatus;
|
|
|
|
private List<TgeneCurrency> lcurrency;
|
|
|
|
public ChargesGroupController() throws Exception {
|
|
super(TgeneChargesGroup.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
// Inicializa autoconsulta
|
|
super.startQuery();
|
|
}
|
|
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
this.recperpage = 15; // Cambiar al # reg a mirar.
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "CHARGESGROUP";
|
|
lgroups = CatalogDetailController.find("CHARGES");
|
|
lmodules = ModuleController.find();
|
|
lmodules = ModuleController.find();
|
|
lcurrency = CurrencyController.find();
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Crea una instancia de TgeneTransactionProcess y marca el registro como nuevo.
|
|
*
|
|
* @throws Exception
|
|
*/
|
|
@Override
|
|
public void create() throws Exception {
|
|
String modulecode = super.getMfilters().get("pk.modulecode");
|
|
if (modulecode == null) {
|
|
MessageHelper.setMessageError("msg_modulerequird");
|
|
return;
|
|
}
|
|
super.create();
|
|
this.record.getPk().setModulecode( modulecode );
|
|
this.record.getPk().setCompanycode(super.getLoginController().getRequest().getCompany());
|
|
this.record.getPk().setChargecatalogcode("CHARGES");
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
Request request = this.callerhelper.getRequest();
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("t.pk.balancetype, t.pk.balancegroup"); // En en string van todos los campos de orden ("t.pk, t.nombre, t.cpais").
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
request.setQueryTables(mtables);
|
|
|
|
Response resp = this.callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
this.lrecord = new ArrayList<TgeneChargesGroup>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
this.lrecord = (List<TgeneChargesGroup>) resp.get(this.beanalias);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void save(){
|
|
try {
|
|
Request request = this.callerhelper.getRequest();
|
|
DtoSave dtosave = super.getDtoSave();
|
|
if(!dtosave.pendingProcess()){
|
|
return;
|
|
}
|
|
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
|
msave.put(this.beanalias, dtosave); // adicionar metadata de mantenimiento para cada tabla.
|
|
dtosave.setReturnpk(true);
|
|
request.setSaveTables(msave);
|
|
Response resp = this.callerhelper.executeSave(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
this.postCommit(resp);
|
|
MessageHelper.setMessageInfo(resp);
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void postCommit(Response response) throws Exception {
|
|
super.postCommitGeneric(response, this.beanalias);
|
|
}
|
|
|
|
/**
|
|
* Lov de tipos de saldo.
|
|
*/
|
|
public void openBalancetypeLov() {
|
|
Map<String, List<String>> params = new HashMap<>();
|
|
List<String> l = new ArrayList<>();
|
|
l.add(super.getMfilters().get("pk.modulecode").toString());
|
|
|
|
params.put("modulecode", l);
|
|
List<String> lcat = new ArrayList<>();
|
|
lcat.add("CHARGES");
|
|
params.put("category", lcat);
|
|
BalanceTypeLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Fija datos del tipo de saldo al cerrar el lov.
|
|
* @param event
|
|
* @throws Exception
|
|
*/
|
|
public void onReturnBalancetypeLov(SelectEvent event) throws Exception {
|
|
TgeneBalanceType t = (TgeneBalanceType) event.getObject();
|
|
this.record.getPk().setBalancetype(t.getPk().getBalancetype());
|
|
this.record.getPk().setBalancegroup(t.getPk().getBalancegroup());
|
|
}
|
|
|
|
/**
|
|
* Actualzia el campo modulecode en cada controlador que esta inyectado. La actualizacion se realiza cuando cambia el modulo en la pantalla.
|
|
* @throws Exception
|
|
*/
|
|
public void updatemodule() throws Exception {
|
|
String modulecode = super.getMfilters().get("pk.modulecode");
|
|
laccountstatus = AccountStatusController.find(modulecode);
|
|
|
|
}
|
|
|
|
/**
|
|
* Entrega el valor de: lmodules
|
|
* @return List<TgeneModule>
|
|
*/
|
|
public List<TgeneModule> getLmodules() {
|
|
return lmodules;
|
|
}
|
|
|
|
/**
|
|
* Entrega el valor de: lgroups
|
|
* @return List<TgeneCatalogDetail>
|
|
*/
|
|
public List<TgeneCatalogDetail> getLgroups() {
|
|
return lgroups;
|
|
}
|
|
|
|
/**
|
|
* Entrega el valor de: laccountstatus
|
|
* @return List<TgeneAccountStatus>
|
|
*/
|
|
public List<TgeneAccountStatus> getLaccountstatus() {
|
|
return laccountstatus;
|
|
}
|
|
|
|
/**
|
|
* Entrega el valor de: lcurrency
|
|
* @return List<TgeneCurrency>
|
|
*/
|
|
public List<TgeneCurrency> getLcurrency() {
|
|
return lcurrency;
|
|
}
|
|
|
|
|
|
}
|