- REGISTRO DE INGRESOS (MOSTRAR EN COLOR GRIS CLARO LOS REGISTROS DESHABILITADOS)

This commit is contained in:
Brayan.Gonzalez 2025-05-07 18:45:14 -06:00
parent 1fbca6e5ff
commit a266bf4f68
6 changed files with 1794 additions and 1637 deletions

View File

@ -24,6 +24,7 @@ import com.arrebol.taxiservicios.model.stocktaking.ServiceOrderHasProduct;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
@ -145,7 +146,6 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
LocalDate localStartDate = starDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localEndDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
@ -187,7 +187,6 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate searchType = builder.notEqual(root.get("type"), ExpenseType.INICIO);
Predicate pending = builder.equal(root.get("depositStatus"), ExpenseStatusType.PENDING);
Predicate bankCardNotNull = builder.isNotNull(root.get("bankCard"));
@ -195,7 +194,7 @@ public class ExpenseController extends ConnectionManager implements Serializable
Predicate locationPredicate = builder.equal(root.get("location"), location);
query.where(builder.and(
searchType, locationPredicate, pending,bankCardNotNull
searchType, locationPredicate, pending, bankCardNotNull
));
query.orderBy(builder.asc(root.get("createdOn")));
@ -250,6 +249,7 @@ public class ExpenseController extends ConnectionManager implements Serializable
}
return success;
}
public List<Expense> fillExpenseDataTableBetweenDatesAbono(Date starDate, Date endDate, String location) {
logger.info("fillExpenseDataTableBetweenDates");
@ -264,7 +264,6 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate searchType = builder.equal(root.get("type"), ExpenseType.ABONO_FINANCIAMIENTO);
Predicate startDatePredicate = builder.greaterThanOrEqualTo(root.get("createdOn"), starDate);
Predicate endDatePredicate = builder.lessThanOrEqualTo(root.get("createdOn"), endDate);
@ -303,17 +302,15 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"),ExpenseIncomeType.EARNING);
Predicate predicateAffects = builder.equal(root.get("idExpenseType").get("activePaymentCustomer"),BasicType.DISABLED);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.SMALL),builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"), ExpenseIncomeType.EARNING);
Predicate predicateAffects = builder.equal(root.get("idExpenseType").get("activePaymentCustomer"), BasicType.DISABLED);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.SMALL), builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate startDatePredicate = builder.greaterThanOrEqualTo(root.get("createdOn"), starDate);
Predicate endDatePredicate = builder.lessThanOrEqualTo(root.get("createdOn"), endDate);
Predicate locationPredicate = builder.equal(root.get("location").get("id"), location);
query.where(builder.and(
predicateBox,predicateType,predicateAffects, startDatePredicate, endDatePredicate, locationPredicate
predicateBox, predicateType, predicateAffects, startDatePredicate, endDatePredicate, locationPredicate
));
query.orderBy(builder.asc(root.get("createdOn")));
@ -345,15 +342,14 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"),ExpenseIncomeType.EARNING);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.GENERAL),builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"), ExpenseIncomeType.EARNING);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.GENERAL), builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate startDatePredicate = builder.greaterThanOrEqualTo(root.get("createdOn"), starDate);
Predicate endDatePredicate = builder.lessThanOrEqualTo(root.get("createdOn"), endDate);
Predicate locationPredicate = builder.equal(root.get("location").get("id"), location);
query.where(builder.and(
predicateBox,predicateType, startDatePredicate, endDatePredicate, locationPredicate
predicateBox, predicateType, startDatePredicate, endDatePredicate, locationPredicate
));
query.orderBy(builder.asc(root.get("createdOn")));
@ -385,17 +381,15 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"),ExpenseIncomeType.EXPENSE);
Predicate predicateInversion = builder.equal(root.get("idExpenseType").get("expenseCatalogType"),ExpenseCatalogType.EXPENSE);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.SMALL),builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"), ExpenseIncomeType.EXPENSE);
Predicate predicateInversion = builder.equal(root.get("idExpenseType").get("expenseCatalogType"), ExpenseCatalogType.EXPENSE);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.SMALL), builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate startDatePredicate = builder.greaterThanOrEqualTo(root.get("createdOn"), starDate);
Predicate endDatePredicate = builder.lessThanOrEqualTo(root.get("createdOn"), endDate);
Predicate locationPredicate = builder.equal(root.get("location").get("id"), location);
query.where(builder.and(
predicateBox,predicateType,predicateInversion, startDatePredicate, endDatePredicate, locationPredicate
predicateBox, predicateType, predicateInversion, startDatePredicate, endDatePredicate, locationPredicate
));
query.orderBy(builder.asc(root.get("createdOn")));
@ -427,17 +421,15 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"),ExpenseIncomeType.EXPENSE);
Predicate predicateInversion = builder.equal(root.get("idExpenseType").get("expenseCatalogType"),ExpenseCatalogType.INVESTMENT);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.SMALL),builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"), ExpenseIncomeType.EXPENSE);
Predicate predicateInversion = builder.equal(root.get("idExpenseType").get("expenseCatalogType"), ExpenseCatalogType.INVESTMENT);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.SMALL), builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate startDatePredicate = builder.greaterThanOrEqualTo(root.get("createdOn"), starDate);
Predicate endDatePredicate = builder.lessThanOrEqualTo(root.get("createdOn"), endDate);
Predicate locationPredicate = builder.equal(root.get("location").get("id"), location);
query.where(builder.and(
predicateBox,predicateType,predicateInversion, startDatePredicate, endDatePredicate, locationPredicate
predicateBox, predicateType, predicateInversion, startDatePredicate, endDatePredicate, locationPredicate
));
query.orderBy(builder.asc(root.get("createdOn")));
@ -469,15 +461,14 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaQuery<Expense> query = builder.createQuery(Expense.class);
Root<Expense> root = query.from(Expense.class);
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"),ExpenseIncomeType.EXPENSE);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.GENERAL),builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate predicateType = builder.equal(root.get("idExpenseType").get("expenseIncomeCatalogType"), ExpenseIncomeType.EXPENSE);
Predicate predicateBox = builder.or(builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.GENERAL), builder.equal(root.get("idExpenseType").get("activeBox"), BoxType.BOTH));
Predicate startDatePredicate = builder.greaterThanOrEqualTo(root.get("createdOn"), starDate);
Predicate endDatePredicate = builder.lessThanOrEqualTo(root.get("createdOn"), endDate);
Predicate locationPredicate = builder.equal(root.get("location").get("id"), location);
query.where(builder.and(
predicateBox,predicateType, startDatePredicate, endDatePredicate, locationPredicate
predicateBox, predicateType, startDatePredicate, endDatePredicate, locationPredicate
));
query.orderBy(builder.asc(root.get("createdOn")));
@ -542,7 +533,7 @@ public class ExpenseController extends ConnectionManager implements Serializable
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
transaction = session.beginTransaction();
String query = "SELECT exp FROM Expense exp WHERE exp.type = 'INICIO' AND exp.location.id = '"+idLocation+"' ORDER BY exp.createdOn DESC";
String query = "SELECT exp FROM Expense exp WHERE exp.type = 'INICIO' AND exp.location.id = '" + idLocation + "' ORDER BY exp.createdOn DESC";
result = session.createQuery(query).getResultList();
@ -601,7 +592,7 @@ public class ExpenseController extends ConnectionManager implements Serializable
String query = "SELECT usr FROM User usr "
+ " WHERE "
+ " usr.userStatusType = 'ENABLED' "
+ " AND usr.active = true AND usr.location.id = '"+location.getId()+"' "
+ " AND usr.active = true AND usr.location.id = '" + location.getId() + "' "
+ " ORDER BY usr.createdOn DESC";
result = session.createQuery(query, User.class).getResultList();
@ -683,7 +674,7 @@ public class ExpenseController extends ConnectionManager implements Serializable
expense.setDriver(idDriver);
}
if(null != taxiId) {
if (null != taxiId) {
expense.setTaxi(new Taxi(taxiId));
}
session.save(expense);
@ -742,7 +733,6 @@ public class ExpenseController extends ConnectionManager implements Serializable
public void updateAdeudoTaxi(Taxi taxi) {
logger.info("deleteById");
Transaction transaction = null;
try {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
@ -754,16 +744,14 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaUpdate<Taxi> update = builder.createCriteriaUpdate(Taxi.class);
Root<Taxi> root = update.from(Taxi.class);
update.set("adeudo",taxi.getAdeudo());
update.set("adeudo", taxi.getAdeudo());
update.where(builder.equal(root.get("id"), taxi.getId()));
session.createQuery(update).executeUpdate();
transaction.commit();
logger.info("Adeudo actualizado");
} catch (HibernateException e) {
@ -776,11 +764,9 @@ public class ExpenseController extends ConnectionManager implements Serializable
}
public void returnServiceOrder(Expense expense, User user) {
logger.info("deleteById");
Transaction transaction = null;
try {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
@ -792,9 +778,9 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaUpdate<ServiceOrder> update = builder.createCriteriaUpdate(ServiceOrder.class);
Root<ServiceOrder> root = update.from(ServiceOrder.class);
update.set("serviceOrderType",ServiceOrderType.FINISHED);
update.set("payUser",null);
update.set("payDate",null);
update.set("serviceOrderType", ServiceOrderType.FINISHED);
update.set("payUser", null);
update.set("payDate", null);
update.set("lastUpdatedBy", user);
update.set("lastUpdatedOn", new Date());
@ -802,10 +788,8 @@ public class ExpenseController extends ConnectionManager implements Serializable
session.createQuery(update).executeUpdate();
transaction.commit();
logger.info("ServiceOrder actualizado");
} catch (HibernateException e) {
@ -821,7 +805,6 @@ public class ExpenseController extends ConnectionManager implements Serializable
public void returnServiceOrderHasProduct(Expense expense, User user) {
logger.info("deleteById");
Transaction transaction = null;
try {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
@ -833,8 +816,7 @@ public class ExpenseController extends ConnectionManager implements Serializable
CriteriaUpdate<ServiceOrderHasProduct> update = builder.createCriteriaUpdate(ServiceOrderHasProduct.class);
Root<ServiceOrderHasProduct> root = update.from(ServiceOrderHasProduct.class);
update.set("cobrado",BasicType.DISABLED);
update.set("cobrado", BasicType.DISABLED);
update.where(builder.equal(root.get("serviceOrder").get("id"), expense.getServiceOrder().getId()));
@ -843,10 +825,8 @@ public class ExpenseController extends ConnectionManager implements Serializable
session.createQuery(update).executeUpdate();
transaction.commit();
logger.info("ServiceOrder actualizado");
} catch (HibernateException e) {
@ -893,6 +873,29 @@ public class ExpenseController extends ConnectionManager implements Serializable
return success;
}
public boolean disabledExpense(Expense expense, User user) {
logger.info("disabledExpense");
boolean success = false;
Transaction transaction = null;
try {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
transaction = session.beginTransaction();
expense.setStatus(ExpenseStatusType.DISABLED);
expense.setLastUpdatedBy(user);
expense.setLastUpdatedOn(correcciónDeHr(new Date(), -7));
session.update(expense);
transaction.commit();
success = true;
} catch (HibernateException e) {
logger.error("Can not disabled expense", e);
rollback(transaction);
} catch (Exception e) {
logger.error("Method disabledExpense()", e);
rollback(transaction);
}
return success;
}
public boolean autorizarExpenseById(String expenseId) {
logger.info("autorizarExpenseById");
@ -931,6 +934,14 @@ public class ExpenseController extends ConnectionManager implements Serializable
return success;
}
private Date correcciónDeHr(Date fecha, int horas) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(fecha);
calendar.add(Calendar.HOUR_OF_DAY, horas);
Date nuevaFecha = calendar.getTime();
return nuevaFecha;
}
private static final long serialVersionUID = -4436342523608482137L;
final Logger logger = LogManager.getLogger(ExpenseController.class);

View File

@ -15,6 +15,11 @@ public enum ExpenseStatusType {
public String toString() {
return "AUTHORIZED";
}
}, DISABLED("Deshabilitada") {
@Override
public String toString() {
return "DISABLED";
}
};
private final String status;

View File

@ -672,7 +672,14 @@ public class AddClosingDayBean extends TaxiGenericBean implements Serializable {
private final String sub_query_to_find_previously_closing_day = "(SELECT DATE(cd.created_on) FROM closing_day cd WHERE DATE(cd.created_on) <= CURDATE() AND cd.user_id = :userID AND cd.active_status = 'ENEBLED' order by cd.created_on DESC LIMIT 1)";
private final String query_total_inicio_expenses = "SELECT IF(ISNULL(SUM(payment)),0, SUM(payment)) AS total_expenses FROM expense LEFT JOIN expense_income_catalog ON expense.id_expense_type = expense_income_catalog.id WHERE DATE(expense.created_on) > " + sub_query_to_find_previously_closing_day + " AND expense_status_type = 'AUTHORIZED' AND expense.created_by = :userID AND (expense_type IN ('INICIO','ABONO_FINANCIAMIENTO','PAGO_ORDEN_SERVICIO') OR (expense_income_catalog.type = 'EARNING')) AND id_bank_card is null";
private final String query_total_expenses = "SELECT IF(ISNULL(SUM(payment)),0, SUM(payment)) AS total_expenses FROM expense INNER JOIN expense_income_catalog ON expense.id_expense_type = expense_income_catalog.id WHERE DATE(expense.created_on)> " + sub_query_to_find_previously_closing_day + " AND expense_status_type = 'AUTHORIZED' AND expense.created_by = :userID AND expense_income_catalog.type = 'EXPENSE' AND id_bank_card is null";
private final String query_total_expenses = "SELECT IF(ISNULL(SUM(payment)),0, SUM(payment)) AS total_expenses "
+ "FROM expense "
+ "INNER JOIN expense_income_catalog ON expense.id_expense_type = expense_income_catalog.id "
+ "WHERE DATE(expense.created_on)> " + sub_query_to_find_previously_closing_day + " "
+ "AND expense_status_type = 'AUTHORIZED' "
+ "AND expense.created_by = :userID "
+ "AND expense_income_catalog.type = 'EXPENSE' "
+ "AND id_bank_card is null";
private final String query_total_transfer_send = "SELECT IF(ISNULL(SUM(amount_to_transfer)),0, SUM(amount_to_transfer)) AS total_transfer_send FROM transfer_car_driver WHERE DATE(created_on) > " + sub_query_to_find_previously_closing_day + " AND action_status = 'APPROVED' AND active_status = 'ENEBLED' AND id_user_transmitter = :userID";
private final String query_total_transfer_receiver = "SELECT IF(ISNULL(SUM(amount_to_transfer)),0, SUM(amount_to_transfer)) AS total_transfer_receiver FROM transfer_car_driver WHERE DATE(created_on) > " + sub_query_to_find_previously_closing_day + " AND action_status = 'APPROVED' AND active_status = 'ENEBLED' AND id_user_receiver = :userID";

View File

@ -8,6 +8,7 @@ package com.arrebol.taxiservicios.beans.admin.expense;
import com.arrebol.taxiservicios.beans.Datatable;
import com.arrebol.taxiservicios.beans.TaxiGenericBean;
import com.arrebol.taxiservicios.controller.admin.BitacoraController;
import com.arrebol.taxiservicios.controller.admin.ClosingDayServiceImpl;
import com.arrebol.taxiservicios.controller.admin.ExpenseController;
import com.arrebol.taxiservicios.controller.admin.GenericValidationController;
import com.arrebol.taxiservicios.controller.admin.TaxiController;
@ -125,11 +126,10 @@ public class ManagerExpense extends TaxiGenericBean implements Serializable, Dat
getAddExpense().setDepositStatus(ExpenseStatusType.PENDING);
getAddExpense().setBankCard(new BankCard(getBankCardId()));
}else{
} else {
getAddExpense().setDepositStatus(ExpenseStatusType.AUTHORIZED);
}
boolean success = getController().addExpense(
getAddExpense(),
getLoggedUser().getId(),
@ -231,12 +231,11 @@ public class ManagerExpense extends TaxiGenericBean implements Serializable, Dat
logger.info("deleteRow in Expense");
try {
if (getGenericController().existClosingDayByCreatedOn(new Date(), getLoggedUser())) {
showMessage(FacesMessage.SEVERITY_WARN,
"Error",
"No se puede hacer ninguna acción si existe un corte del día");
if (new ClosingDayServiceImpl().existClosingDayByCreatedOn(correcciónDeHr(new Date(), -7), getSelectedExpense().getCreatedBy())) {
showMessage(FacesMessage.SEVERITY_WARN, "Error", "El usuario al que afectará la eliminación ya realizó su corte del día");
return;
}
if (getGenericController().existStableSmallBoxByCurdate(getLoggedUser())) {
showMessage(FacesMessage.SEVERITY_WARN,
"Dia cerrado",
@ -298,6 +297,54 @@ public class ManagerExpense extends TaxiGenericBean implements Serializable, Dat
}
}
public void disableRow() {
logger.info("disableRow in Expense");
try {
if (new ClosingDayServiceImpl().existClosingDayByCreatedOn(correcciónDeHr(new Date(), -7), getSelectedExpense().getCreatedBy())) {
showMessage(FacesMessage.SEVERITY_WARN, "Error", "El usuario al que afectará la devolución ya realizó su corte del día");
return;
}
if (getGenericController().existStableSmallBoxByCurdate(getLoggedUser())) {
showMessage(FacesMessage.SEVERITY_WARN,
"Dia cerrado",
"No se puede hacer ninguna acción porque ya existe un cuadre de caja chica del día");
return;
}
if (getSelectedExpense().getType().equals(ExpenseType.ABONO_FINANCIAMIENTO)) {
Taxi taxi = getSelectedExpense().getTaxi();
taxi.setAdeudo((float) (taxi.getAdeudo() + getSelectedExpense().getPayment()));
getController().updateAdeudoTaxi(taxi);
}
if (getSelectedExpense().getType().equals(ExpenseType.PAGO_ORDEN_SERVICIO)) {
getController().returnServiceOrder(getSelectedExpense(), getLoggedUser());
getController().returnServiceOrderHasProduct(getSelectedExpense(), getLoggedUser());
}
boolean success = getController().disabledExpense(getSelectedExpense(), getLoggedUser());
if (success) {
if (null == getCommentsBitacora() || getCommentsBitacora().trim().equals("")) {
setCommentsBitacora("El usuario " + getLoggedUser().getUserName() + " no agrego comentarios a la hora de deshabilitar el Ingreso/Egreso");
}
String actionBitacora = "Deshabilitar Ingreso/Egreso";
String descBitacora = "Se deshabilito el Ingreso/Egreso, con el folio " + getSelectedExpense().getFolio()
+ ", costo " + currencyFormatNumber(getSelectedExpense().getPayment())
+ ", tipo " + getSelectedExpense().getType().getType()
+ ", estatus " + getSelectedExpense().getStatus().getStatus()
+ " y fecha " + getSelectedExpense().getPaymentDate();
getBitacoraController().saveNewRecordInBitacora(createNewRecordInBitacora(UUID.randomUUID().toString(), actionBitacora, getCommentsBitacora(), descBitacora), getLoggedUser().getLocation().getId());
fillExpenseDataTableBetweenDates();
setSelectedExpense(null);
setCommentsBitacora("");
showMessage(FacesMessage.SEVERITY_INFO, getBundlePropertyFile().getString("expense.disable.title"), getBundlePropertyFile().getString("expense.disable.success.desc"));
} else {
logger.error("Expense " + getSelectedExpense() + "was not disabled");
showMessage(FacesMessage.SEVERITY_ERROR, getBundlePropertyFile().getString("expense.disable.title"), getBundlePropertyFile().getString("expense.disable.fail.desc"));
}
} catch (Exception e) {
logger.error("disableRow: " + e);
showMessage(FacesMessage.SEVERITY_FATAL, getBundlePropertyFile().getString("expense.disable.title"), getBundlePropertyFile().getString("expense.disable.exception.desc"));
}
}
public void autorizarPendingExpense() {
logger.info("autorizarPendingExpense");
@ -499,6 +546,25 @@ public class ManagerExpense extends TaxiGenericBean implements Serializable, Dat
}
}
public String validarColorPagoPoliza(String estatus) {
switch (estatus) {
case "DISABLED":
return "bgGray";
case "PENDING":
return "datatableRowLittle";
default:
return "bgWhite";
}
}
private Date correcciónDeHr(Date fecha, int horas) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(fecha);
calendar.add(Calendar.HOUR_OF_DAY, horas);
Date nuevaFecha = calendar.getTime();
return nuevaFecha;
}
public ExpenseController getController() {
return controller;
}

View File

@ -273,6 +273,12 @@ expense.delete.title=Eliminaci\u00f3n de gasto
expense.delete.success.desc=Se elimin\u00f3 el gasto correctamente.
expense.delete.fail.desc=No se pudo eliminar el gasto.
expense.delete.exception.desc=Ocurrio un error al eliminar el gasto.
expense.disable.title=Deshabilitar de gasto
expense.disable.success.desc=Se deshabilito el gasto correctamente.
expense.disable.fail.desc=No se pudo deshabilitar el gasto.
expense.disable.exception.desc=Ocurrio un error al deshabilitar el gasto.
expense.autorizar.title=Autorizar gasto
expense.autorizar.success.desc=Se autoriz\u00f3 el gasto correctamente.
expense.autorizar.fail.desc=No se pudo autorizar el gasto.

View File

@ -10,6 +10,17 @@
<h:outputScript library="js" name="admin/expense.js" />
<h:outputScript library="js" name="bitacora/bitacora.js" />
<h:outputScript library="js" name="bitacora/bitacora.de.ventas.gastos.e.inicios.js" />
<style>
.bgGray {
background-color: gray !important;
color: black;
}
.bgWhite {
background-color:white !important;
color: black;
}
</style>
</ui:define>
<ui:define name="title">#{i18n.project} - #{grant['admin.sale.name']}</ui:define>
@ -69,11 +80,11 @@
rowsPerPageTemplate="5,10,25,50,100"
emptyMessage="#{i18n['menu.admin.expense.datatable.empty']}"
rowKey="#{expense.id}"
rowStyleClass="#{expense.status eq 'PENDING' ? 'datatableRowLittle' : null}"
selection="#{managerExpense.selectedExpense}"
editable="true" selectionMode="single"
paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowStyleClass="#{managerExpense.validarColorPagoPoliza(expense.status)}">
<f:facet name="header">
<div style="float:right;padding-top: 5px;display: block;">
@ -117,6 +128,11 @@
filterBy="#{expense.idExpenseType != null and not empty expense.idExpenseType ? expense.idExpenseType.name : ''}">
<h:outputText value="#{expense.idExpenseType != null and not empty expense.idExpenseType ? expense.idExpenseType.name : ''}" />
</p:column>
<p:column headerText="Estatus" sortBy="#{expense.status.status}" filterBy="#{expense.status.status}">
<h:outputText value="#{expense.status.status}" />
</p:column>
<p:column headerText="#{i18n['menu.admin.expense.column.description']}" sortBy="#{expense.description}" filterBy="#{expense.description}">
<h:outputText value="#{expense.description}" />
</p:column>
@ -130,14 +146,31 @@
class="ui-button-icon-only red-btn"
title="Eliminar"
id="ctxMenuItem3"
rendered="#{loginBean.isUserInRole('admin.income.expenses.delete') and expense.getAction(managerExpense.lastStableSmallBox) and !managerExpense.hayCuadreSmall}"
rendered="#{loginBean.isUserInRole('admin.income.expenses.delete') and expense.getAction(managerExpense.lastStableSmallBox)
and !managerExpense.hayCuadreSmall
and expense.status eq 'AUTHORIZED'}"
update="confirmForm:globalConfirmMsg"
onclick="PF('deleteEventBitacoraIngresoEgreso').show();">
<f:setPropertyActionListener value="#{expense}" target="#{managerExpense.selectedExpense}" />
<p:confirm message="¿Estas seguro de querer borrar el ingreso/egreso?"
header="Eliminar Ingreso/Egreso"
icon="ui-icon-delete"/>
</p:commandButton>
<p:commandButton
icon="ui-icon-minusthick"
class="ui-button-icon-only red-btn"
title="Deshabilitar"
id="ctxMenuItem4"
rendered="#{loginBean.isUserInRole('admin.income.expenses.delete') and expense.getAction(managerExpense.lastStableSmallBox)
and !managerExpense.hayCuadreSmall
and expense.status eq 'AUTHORIZED'}"
update="confirmForm:globalConfirmMsg"
onclick="PF('disabledEventBitacoraIngresoEgreso').show();">
<f:setPropertyActionListener value="#{expense}" target="#{managerExpense.selectedExpense}" />
<p:confirm message="¿Estas seguro de querer deshabilitar el ingreso/egreso?"
header="Deshabilitar Ingreso/Egreso"
icon="ui-icon-delete"/>
</p:commandButton>
</p:column>
@ -175,6 +208,35 @@
</p:dialog>
</h:form>
<h:form id="bitacoraFormDisableIngresoEgreso" rendered="#{loginBean.isUserInRole('admin.income.expenses.delete')}">
<p:growl id="msgsDialogBitacoraDisableIngresoEgreso" showDetail="true"/>
<p:dialog widgetVar="disabledEventBitacoraIngresoEgreso" width="30%"
id="disabledEventBitacoraIngresoEgreso"
header="Deshabilitar Ingreso/Egreso"
modal="true" responsive="true"
showEffect="clip" hideEffect="clip">
<br></br>
<h:panelGroup styleClass="md-inputfield" >
<p:inputText id="commentsBitacora"
value="#{managerExpense.commentsBitacora}"
autocomplete="off" style="width: 100%;">
</p:inputText>
<label>Comentarios</label>
<p:message for="commentsBitacora" display="text"/>
</h:panelGroup>
<br></br>
<div class="ui-g-12">
<p:commandButton id="addButtonBitacora"
value="#{i18n['button.save']}"
actionListener="#{managerExpense.disableRow()}"
oncomplete="disabledEventBitacoraIngresoEgreso(xhr, status, args)"
update="formExpense:dtExpenseDtb
msgsDialogBitacoraDisableIngresoEgreso
disabledEventBitacoraIngresoEgreso"/>
</div>
</p:dialog>
</h:form>
<h:form id="expenseForm" rendered="#{loginBean.isUserInRole('admin.income.expenses.add')}">
<p:growl id="msgsDialog" showDetail="true"/>
<p:dialog widgetVar="expenseDialogPopup" width="30%" id="expenseDialogPopup"