Skip to content

Commit b322fcb

Browse files
committed
Merge branch 'desarrollo' into produccion
2 parents 9e1c606 + 311ffd9 commit b322fcb

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

API (SpringBoot)/Proyecto/src/main/java/com/example/Proyecto/service/Ingredientes/IngredientesService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public List<IngredienteListadoDTO> obtenerIngredientesParaListado() {
9999
}
100100

101101
public void crearIngrediente(Ingredientes ingrediente) {
102-
// Eliminada la coma después de CANTIDAD_INGREDIENTE y los NULL sobrantes
103102
String sql = "INSERT INTO ingredientes (" +
104103
"ID_PROVEEDOR, " +
105104
"ID_CATEGORIA, " +
@@ -109,15 +108,18 @@ public void crearIngrediente(Ingredientes ingrediente) {
109108
"CANTIDAD_INGREDIENTE" +
110109
") VALUES (?, ?, ?, ?, ?, ?)";
111110

112-
BigDecimal cantidadInicial = BigDecimal.ZERO;
111+
// Aseguramos que la cantidad nunca sea nula al insertar
112+
BigDecimal cantidad = (ingrediente.getCantidadIngrediente() != null)
113+
? ingrediente.getCantidadIngrediente()
114+
: BigDecimal.ZERO;
113115

114116
jdbcTemplate.update(sql,
115117
ingrediente.getIdProveedor(),
116118
ingrediente.getIdCategoria(),
117119
ingrediente.getIdUnidadMedida(),
118120
ingrediente.getNombreIngrediente(),
119121
ingrediente.getReferenciaIngrediente(),
120-
cantidadInicial
122+
cantidad
121123
);
122124
}
123125

0 commit comments

Comments
 (0)