mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
modificado iva dependiendo de si es reducido o no y del lugar de la entrega
This commit is contained in:
@ -35,7 +35,9 @@ public class HomeController {
|
|||||||
"presupuesto.plantilla-cubierta",
|
"presupuesto.plantilla-cubierta",
|
||||||
"presupuesto.plantilla-cubierta-text",
|
"presupuesto.plantilla-cubierta-text",
|
||||||
"presupuesto.impresion-cubierta",
|
"presupuesto.impresion-cubierta",
|
||||||
"presupuesto.impresion-cubierta-help");
|
"presupuesto.impresion-cubierta-help",
|
||||||
|
"presupuesto.iva-reducido",
|
||||||
|
"presupuesto.iva-reducido-descripcion");
|
||||||
|
|
||||||
Map<String, String> translations = translationService.getTranslations(locale, keys);
|
Map<String, String> translations = translationService.getTranslations(locale, keys);
|
||||||
model.addAttribute("languageBundle", translations);
|
model.addAttribute("languageBundle", translations);
|
||||||
|
|||||||
@ -533,7 +533,9 @@ public class PresupuestoController {
|
|||||||
"presupuesto.impresion-cubierta",
|
"presupuesto.impresion-cubierta",
|
||||||
"presupuesto.impresion-cubierta-help",
|
"presupuesto.impresion-cubierta-help",
|
||||||
"presupuesto.exito.guardado",
|
"presupuesto.exito.guardado",
|
||||||
"presupuesto.add.error.save.title");
|
"presupuesto.add.error.save.title",
|
||||||
|
"presupuesto.iva-reducido",
|
||||||
|
"presupuesto.iva-reducido-descripcion");
|
||||||
|
|
||||||
Map<String, String> translations = translationService.getTranslations(locale, keys);
|
Map<String, String> translations = translationService.getTranslations(locale, keys);
|
||||||
model.addAttribute("languageBundle", translations);
|
model.addAttribute("languageBundle", translations);
|
||||||
@ -734,13 +736,13 @@ public class PresupuestoController {
|
|||||||
|
|
||||||
Map<String, Object> saveResult = presupuestoService.guardarPresupuesto(
|
Map<String, Object> saveResult = presupuestoService.guardarPresupuesto(
|
||||||
presupuesto,
|
presupuesto,
|
||||||
serviciosList,
|
serviciosList,
|
||||||
datosMaquetacion,
|
datosMaquetacion,
|
||||||
datosMarcapaginas,
|
datosMarcapaginas,
|
||||||
mode,
|
mode,
|
||||||
cliente_id,
|
cliente_id,
|
||||||
id,
|
id,
|
||||||
request,
|
request,
|
||||||
locale);
|
locale);
|
||||||
|
|
||||||
return ResponseEntity.ok(Map.of("id", saveResult.get("presupuesto_id"),
|
return ResponseEntity.ok(Map.of("id", saveResult.get("presupuesto_id"),
|
||||||
|
|||||||
@ -105,6 +105,20 @@ public class Presupuesto extends AbstractAuditedEntity implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Entrega{
|
||||||
|
peninsula("presupuesto.entrega.peninsula"),
|
||||||
|
canarias("presupuesto.entrega.canarias"),
|
||||||
|
paises_ue("presupuesto.entrega.paises-ue");
|
||||||
|
|
||||||
|
private final String messageKey;
|
||||||
|
Entrega(String messageKey) {
|
||||||
|
this.messageKey = messageKey;
|
||||||
|
}
|
||||||
|
public String getMessageKey() {
|
||||||
|
return messageKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Presupuesto clone() {
|
public Presupuesto clone() {
|
||||||
try {
|
try {
|
||||||
@ -165,11 +179,18 @@ public class Presupuesto extends AbstractAuditedEntity implements Cloneable {
|
|||||||
@Column(name = "base_imponible", precision = 12, scale = 2)
|
@Column(name = "base_imponible", precision = 12, scale = 2)
|
||||||
private BigDecimal baseImponible;
|
private BigDecimal baseImponible;
|
||||||
|
|
||||||
@Column(name = "iva_tipo", precision = 5, scale = 2)
|
@Column(name = "iva_reducido")
|
||||||
private BigDecimal ivaTipo;
|
private Boolean ivaReducido;
|
||||||
|
|
||||||
@Column(name = "iva_importe", precision = 12, scale = 2)
|
@Column(name = "entrega_tipo")
|
||||||
private BigDecimal ivaImporte;
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Entrega entregaTipo;
|
||||||
|
|
||||||
|
@Column(name = "iva_importe_4", precision = 12, scale = 2)
|
||||||
|
private BigDecimal ivaImporte4;
|
||||||
|
|
||||||
|
@Column(name = "iva_importe_21", precision = 12, scale = 2)
|
||||||
|
private BigDecimal ivaImporte21;
|
||||||
|
|
||||||
@Column(name = "total_con_iva", precision = 12, scale = 2)
|
@Column(name = "total_con_iva", precision = 12, scale = 2)
|
||||||
private BigDecimal totalConIva;
|
private BigDecimal totalConIva;
|
||||||
@ -481,20 +502,36 @@ public class Presupuesto extends AbstractAuditedEntity implements Cloneable {
|
|||||||
this.baseImponible = baseImponible;
|
this.baseImponible = baseImponible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getIvaTipo() {
|
public Boolean getIvaReducido() {
|
||||||
return ivaTipo;
|
return ivaReducido;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIvaTipo(BigDecimal ivaTipo) {
|
public void setIvaReducido(Boolean ivaReducido) {
|
||||||
this.ivaTipo = ivaTipo;
|
this.ivaReducido = ivaReducido;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getIvaImporte() {
|
public Entrega getEntregaTipo() {
|
||||||
return ivaImporte;
|
return entregaTipo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIvaImporte(BigDecimal ivaImporte) {
|
public void setEntregaTipo(Entrega entregaTipo) {
|
||||||
this.ivaImporte = ivaImporte;
|
this.entregaTipo = entregaTipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getIvaImporte4() {
|
||||||
|
return ivaImporte4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIvaImporte4(BigDecimal ivaImporte4) {
|
||||||
|
this.ivaImporte4 = ivaImporte4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getIvaImporte21() {
|
||||||
|
return ivaImporte21;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIvaImporte21(BigDecimal ivaImporte21) {
|
||||||
|
this.ivaImporte21 = ivaImporte21;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getTotalConIva() {
|
public BigDecimal getTotalConIva() {
|
||||||
@ -881,7 +918,4 @@ public class Presupuesto extends AbstractAuditedEntity implements Cloneable {
|
|||||||
public void setId(Long id){
|
public void setId(Long id){
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,11 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.imprimelibros.erp.presupuesto.dto.Presupuesto;
|
import com.imprimelibros.erp.presupuesto.dto.Presupuesto;
|
||||||
|
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder.In;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PresupuestoFormDataMapper {
|
public class PresupuestoFormDataMapper {
|
||||||
@ -39,6 +37,8 @@ public class PresupuestoFormDataMapper {
|
|||||||
public String paginasColor = "";
|
public String paginasColor = "";
|
||||||
public String posicionPaginasColor = "";
|
public String posicionPaginasColor = "";
|
||||||
public String tipoEncuadernacion = "fresado"; // enum name
|
public String tipoEncuadernacion = "fresado"; // enum name
|
||||||
|
public String entregaTipo = "peninsula"; // enum name
|
||||||
|
public boolean ivaReducido = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== Interior =====
|
// ===== Interior =====
|
||||||
@ -157,6 +157,9 @@ public class PresupuestoFormDataMapper {
|
|||||||
|
|
||||||
vm.datosGenerales.tipoEncuadernacion = enumName(p.getTipoEncuadernacion(), "fresado");
|
vm.datosGenerales.tipoEncuadernacion = enumName(p.getTipoEncuadernacion(), "fresado");
|
||||||
|
|
||||||
|
vm.datosGenerales.entregaTipo = enumName(p.getEntregaTipo(), "peninsula");
|
||||||
|
vm.datosGenerales.ivaReducido = Boolean.TRUE.equals(p.getIvaReducido());
|
||||||
|
|
||||||
// ===== Interior
|
// ===== Interior
|
||||||
vm.interior.tipoImpresion = enumName(p.getTipoImpresion(), "negro");
|
vm.interior.tipoImpresion = enumName(p.getTipoImpresion(), "negro");
|
||||||
vm.interior.papelInteriorId = nz(p.getPapelInteriorId(), 3);
|
vm.interior.papelInteriorId = nz(p.getPapelInteriorId(), 3);
|
||||||
|
|||||||
@ -453,9 +453,9 @@ public class PresupuestoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String obtenerPrecioRetractilado(Integer tirada) {
|
private String obtenerPrecioRetractilado(Integer tirada) {
|
||||||
|
|
||||||
Map<String, Object> requestBody = new HashMap<>();
|
Map<String, Object> requestBody = new HashMap<>();
|
||||||
requestBody.put("tirada",tirada != null ? tirada : 0);
|
requestBody.put("tirada", tirada != null ? tirada : 0);
|
||||||
Double precio_retractilado = apiClient.getRetractilado(requestBody);
|
Double precio_retractilado = apiClient.getRetractilado(requestBody);
|
||||||
return precio_retractilado != null
|
return precio_retractilado != null
|
||||||
? String.valueOf(Math.round(precio_retractilado * 100.0) / 100.0)
|
? String.valueOf(Math.round(precio_retractilado * 100.0) / 100.0)
|
||||||
@ -878,8 +878,8 @@ public class PresupuestoService {
|
|||||||
resumen.put("precio_total_tirada", presupuesto.getPrecioTotalTirada());
|
resumen.put("precio_total_tirada", presupuesto.getPrecioTotalTirada());
|
||||||
resumen.put("servicios_total", presupuesto.getServiciosTotal());
|
resumen.put("servicios_total", presupuesto.getServiciosTotal());
|
||||||
resumen.put("base_imponible", presupuesto.getBaseImponible());
|
resumen.put("base_imponible", presupuesto.getBaseImponible());
|
||||||
resumen.put("iva_tipo", presupuesto.getIvaTipo());
|
resumen.put("iva_importe_4", presupuesto.getIvaImporte4());
|
||||||
resumen.put("iva_importe", presupuesto.getIvaImporte());
|
resumen.put("iva_importe_21", presupuesto.getIvaImporte21());
|
||||||
resumen.put("total_con_iva", presupuesto.getTotalConIva());
|
resumen.put("total_con_iva", presupuesto.getTotalConIva());
|
||||||
|
|
||||||
return resumen;
|
return resumen;
|
||||||
@ -925,6 +925,12 @@ public class PresupuestoService {
|
|||||||
List<Double> precios = (List<Double>) data.getOrDefault("precios", List.of());
|
List<Double> precios = (List<Double>) data.getOrDefault("precios", List.of());
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Double> pesos = (List<Double>) data.getOrDefault("peso", List.of());
|
List<Double> pesos = (List<Double>) data.getOrDefault("peso", List.of());
|
||||||
|
|
||||||
|
boolean hayDepositoLegal = servicios != null && servicios.stream()
|
||||||
|
.map(m -> java.util.Objects.toString(m.get("id"), ""))
|
||||||
|
.map(String::trim)
|
||||||
|
.anyMatch("deposito-legal"::equals);
|
||||||
|
|
||||||
if (precios.isEmpty()) {
|
if (precios.isEmpty()) {
|
||||||
var preciosCalc = this.calcularPresupuesto(presupuesto, locale);
|
var preciosCalc = this.calcularPresupuesto(presupuesto, locale);
|
||||||
precios = (List<Double>) ((Map<String, Object>) preciosCalc.get("data")).getOrDefault("precios", List.of());
|
precios = (List<Double>) ((Map<String, Object>) preciosCalc.get("data")).getOrDefault("precios", List.of());
|
||||||
@ -956,19 +962,42 @@ public class PresupuestoService {
|
|||||||
BigDecimal precioTotalTirada = BigDecimal.valueOf(precioUnit)
|
BigDecimal precioTotalTirada = BigDecimal.valueOf(precioUnit)
|
||||||
.multiply(BigDecimal.valueOf(cantidad))
|
.multiply(BigDecimal.valueOf(cantidad))
|
||||||
.setScale(2, RoundingMode.HALF_UP);
|
.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
if( hayDepositoLegal ){
|
||||||
|
precioTotalTirada = precioTotalTirada.add(BigDecimal.valueOf(precioUnit).multiply(BigDecimal.valueOf(4)));
|
||||||
|
}
|
||||||
|
|
||||||
// servicios_total
|
// servicios_total
|
||||||
|
BigDecimal serviciosIva4 = BigDecimal.ZERO;
|
||||||
BigDecimal serviciosTotal = BigDecimal.ZERO;
|
BigDecimal serviciosTotal = BigDecimal.ZERO;
|
||||||
if (servicios != null) {
|
if (servicios != null) {
|
||||||
for (Map<String, Object> s : servicios) {
|
for (Map<String, Object> s : servicios) {
|
||||||
try {
|
try {
|
||||||
// retractilado o ejemplar-prueba: recalcular precio
|
// retractilado: recalcular precio
|
||||||
if (s.get("id").equals("retractilado")) {
|
if (s.get("id").equals("retractilado")) {
|
||||||
double precio_retractilado = obtenerPrecioRetractilado(cantidad) != null
|
double precio_retractilado = obtenerPrecioRetractilado(cantidad) != null
|
||||||
? Double.parseDouble(obtenerPrecioRetractilado(cantidad))
|
? Double.parseDouble(obtenerPrecioRetractilado(cantidad))
|
||||||
: 0.0;
|
: 0.0;
|
||||||
s.put("price", precio_retractilado);
|
s.put("price", precio_retractilado);
|
||||||
}
|
}
|
||||||
|
// si tiene protitipo, guardamos el valor para el IVA al 4%
|
||||||
|
else if (s.get("id").equals("ejemplar-prueba")) {
|
||||||
|
serviciosIva4 = BigDecimal.valueOf(
|
||||||
|
s.get("price") != null ? Double.parseDouble(String.valueOf(s.get("price"))) : 0.0);
|
||||||
|
} else if (s.get("id").equals("marcapaginas")) {
|
||||||
|
PresupuestoMarcapaginas pm = presupuesto.getDatosMarcapaginasJson() != null
|
||||||
|
? new ObjectMapper().readValue(presupuesto.getDatosMarcapaginasJson(),
|
||||||
|
PresupuestoMarcapaginas.class)
|
||||||
|
: null;
|
||||||
|
Map<String, Object> precio_marcapaginas = this.getPrecioMarcapaginas(pm, locale);
|
||||||
|
s.put("price", precio_marcapaginas.getOrDefault("precio_total", 0.0));
|
||||||
|
} else if (s.get("id").equals("maquetacion")) {
|
||||||
|
PresupuestoMaquetacion pm = presupuesto.getDatosMaquetacionJson() != null
|
||||||
|
? new ObjectMapper().readValue(presupuesto.getDatosMaquetacionJson(),
|
||||||
|
PresupuestoMaquetacion.class)
|
||||||
|
: null;
|
||||||
|
Map<String, Object> precio_maquetacion = this.getPrecioMaquetacion(pm, locale);
|
||||||
|
s.put("price", precio_maquetacion.getOrDefault("precio", 0.0));
|
||||||
|
}
|
||||||
double unidades = Double.parseDouble(String.valueOf(s.getOrDefault("units", 0)));
|
double unidades = Double.parseDouble(String.valueOf(s.getOrDefault("units", 0)));
|
||||||
double precio = Double.parseDouble(String.valueOf(
|
double precio = Double.parseDouble(String.valueOf(
|
||||||
s.get("id").equals("marcapaginas")
|
s.get("id").equals("marcapaginas")
|
||||||
@ -985,17 +1014,30 @@ public class PresupuestoService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// base imponible, IVA y total (si tienes IVA configurable, úsalo; si no, 0)
|
BigDecimal baseImponible = precioTotalTirada;
|
||||||
BigDecimal baseImponible = precioTotalTirada.add(serviciosTotal);
|
BigDecimal ivaImporte4 = BigDecimal.ZERO;
|
||||||
BigDecimal ivaTipo = BigDecimal.ZERO;
|
BigDecimal ivaImporte21 = BigDecimal.ZERO;
|
||||||
try {
|
|
||||||
double iva = 4.0; // 0..100
|
// Si la entrega es en peninsula, se mira el valor del iva
|
||||||
ivaTipo = BigDecimal.valueOf(iva);
|
// Canarias y paises UE no llevan IVA
|
||||||
} catch (Exception ignore) {
|
if (presupuesto.getEntregaTipo() == Presupuesto.Entrega.peninsula){
|
||||||
}
|
// Si el iva es reducido, el precio de la tirada y el del prototipo llevan IVA
|
||||||
BigDecimal ivaImporte = baseImponible.multiply(ivaTipo).divide(BigDecimal.valueOf(100), 2,
|
// 4%
|
||||||
RoundingMode.HALF_UP);
|
if (presupuesto.getIvaReducido()) {
|
||||||
BigDecimal totalConIva = baseImponible.add(ivaImporte);
|
ivaImporte4 = baseImponible.add(serviciosIva4).multiply(BigDecimal.valueOf(4)).divide(
|
||||||
|
BigDecimal.valueOf(100), 2,
|
||||||
|
RoundingMode.HALF_UP);
|
||||||
|
ivaImporte21 = serviciosTotal.subtract(serviciosIva4).multiply(BigDecimal.valueOf(21)).divide(
|
||||||
|
BigDecimal.valueOf(100), 2,
|
||||||
|
RoundingMode.HALF_UP);
|
||||||
|
} else {
|
||||||
|
ivaImporte21 = baseImponible.add(serviciosTotal).multiply(BigDecimal.valueOf(21)).divide(
|
||||||
|
BigDecimal.valueOf(100), 2,
|
||||||
|
RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseImponible = baseImponible.add(serviciosTotal);
|
||||||
|
BigDecimal totalConIva = baseImponible.add(ivaImporte21).add(ivaImporte4);
|
||||||
|
|
||||||
// precios y totales
|
// precios y totales
|
||||||
if (tirada == (presupuesto.getSelectedTirada() != null ? presupuesto.getSelectedTirada() : 0)) {
|
if (tirada == (presupuesto.getSelectedTirada() != null ? presupuesto.getSelectedTirada() : 0)) {
|
||||||
@ -1003,8 +1045,8 @@ public class PresupuestoService {
|
|||||||
presupuesto.setPrecioTotalTirada(precioTotalTirada);
|
presupuesto.setPrecioTotalTirada(precioTotalTirada);
|
||||||
presupuesto.setServiciosTotal(serviciosTotal);
|
presupuesto.setServiciosTotal(serviciosTotal);
|
||||||
presupuesto.setBaseImponible(baseImponible);
|
presupuesto.setBaseImponible(baseImponible);
|
||||||
presupuesto.setIvaTipo(ivaTipo);
|
presupuesto.setIvaImporte4(ivaImporte4);
|
||||||
presupuesto.setIvaImporte(ivaImporte);
|
presupuesto.setIvaImporte21(ivaImporte21);
|
||||||
presupuesto.setTotalConIva(totalConIva);
|
presupuesto.setTotalConIva(totalConIva);
|
||||||
}
|
}
|
||||||
Map<String, Object> snap = new HashMap<>();
|
Map<String, Object> snap = new HashMap<>();
|
||||||
@ -1012,8 +1054,8 @@ public class PresupuestoService {
|
|||||||
snap.put("precio_total_tirada", precioTotalTirada);
|
snap.put("precio_total_tirada", precioTotalTirada);
|
||||||
snap.put("servicios_total", serviciosTotal);
|
snap.put("servicios_total", serviciosTotal);
|
||||||
snap.put("base_imponible", baseImponible);
|
snap.put("base_imponible", baseImponible);
|
||||||
snap.put("iva_tipo", ivaTipo);
|
snap.put("iva_importe_4", ivaImporte4);
|
||||||
snap.put("iva_importe", ivaImporte);
|
snap.put("iva_importe_21", ivaImporte21);
|
||||||
snap.put("total_con_iva", totalConIva);
|
snap.put("total_con_iva", totalConIva);
|
||||||
snap.put("peso", (index >= 0 && index < pesos.size()) ? pesos.get(index) : 0.0);
|
snap.put("peso", (index >= 0 && index < pesos.size()) ? pesos.get(index) : 0.0);
|
||||||
|
|
||||||
@ -1189,8 +1231,10 @@ public class PresupuestoService {
|
|||||||
target.setPrecioTotalTirada(src.getPrecioTotalTirada());
|
target.setPrecioTotalTirada(src.getPrecioTotalTirada());
|
||||||
target.setServiciosTotal(src.getServiciosTotal());
|
target.setServiciosTotal(src.getServiciosTotal());
|
||||||
target.setBaseImponible(src.getBaseImponible());
|
target.setBaseImponible(src.getBaseImponible());
|
||||||
target.setIvaTipo(src.getIvaTipo());
|
target.setIvaReducido(src.getIvaReducido());
|
||||||
target.setIvaImporte(src.getIvaImporte());
|
target.setEntregaTipo(src.getEntregaTipo());
|
||||||
|
target.setIvaImporte4(src.getIvaImporte4());
|
||||||
|
target.setIvaImporte21(src.getIvaImporte21());
|
||||||
target.setTotalConIva(src.getTotalConIva());
|
target.setTotalConIva(src.getTotalConIva());
|
||||||
target.setCreatedBy(target.getCreatedBy() == null ? src.getCreatedBy() : target.getCreatedBy()); // no pisar si
|
target.setCreatedBy(target.getCreatedBy() == null ? src.getCreatedBy() : target.getCreatedBy()); // no pisar si
|
||||||
// ya existe
|
// ya existe
|
||||||
|
|||||||
@ -206,7 +206,8 @@ presupuesto.resumen.tabla.cantidad=Cantidad
|
|||||||
presupuesto.resumen.tabla.precio-unidad=Precio/unidad
|
presupuesto.resumen.tabla.precio-unidad=Precio/unidad
|
||||||
presupuesto.resumen.tabla.precio-total=Precio total
|
presupuesto.resumen.tabla.precio-total=Precio total
|
||||||
presupuesto.resumen.tabla.base=Base
|
presupuesto.resumen.tabla.base=Base
|
||||||
presupuesto.resumen.tabla.iva=I.V.A. (4%)
|
presupuesto.resumen.tabla.iva4=I.V.A. (4%)
|
||||||
|
presupuesto.resumen.tabla.iva21=I.V.A. (21%)
|
||||||
presupuesto.resumen.tabla.total=Total presupuesto
|
presupuesto.resumen.tabla.total=Total presupuesto
|
||||||
presupuesto.resumen-texto=Impresion de {0} unidades encuadernadas en {1} en {2} con {3} páginas en formato {4} x {5} mm. \
|
presupuesto.resumen-texto=Impresion de {0} unidades encuadernadas en {1} en {2} con {3} páginas en formato {4} x {5} mm. \
|
||||||
<ul> \
|
<ul> \
|
||||||
|
|||||||
@ -33,6 +33,8 @@ export default class PresupuestoWizard {
|
|||||||
paginasColor: 0,
|
paginasColor: 0,
|
||||||
posicionPaginasColor: '',
|
posicionPaginasColor: '',
|
||||||
tipoEncuadernacion: 'fresado',
|
tipoEncuadernacion: 'fresado',
|
||||||
|
entregaTipo: 'peninsula',
|
||||||
|
ivaReducido: true,
|
||||||
},
|
},
|
||||||
interior: {
|
interior: {
|
||||||
tipoImpresion: 'negro',
|
tipoImpresion: 'negro',
|
||||||
@ -122,6 +124,9 @@ export default class PresupuestoWizard {
|
|||||||
this.divPosicionPaginasColor = $('#div-posicion-paginas-color');
|
this.divPosicionPaginasColor = $('#div-posicion-paginas-color');
|
||||||
this.posicionPaginasColor = $('#posicionPaginasColor');
|
this.posicionPaginasColor = $('#posicionPaginasColor');
|
||||||
this.paginas = $('#paginas');
|
this.paginas = $('#paginas');
|
||||||
|
this.entregaTipo = $('#entregaTipo');
|
||||||
|
this.ivaReducido = $('#iva-reducido');
|
||||||
|
this.btnIvaReducidoDetail = $('#btn-iva-reducido-detail');
|
||||||
this.btn_next_datos_generales = $('#next-datos-generales');
|
this.btn_next_datos_generales = $('#next-datos-generales');
|
||||||
this.datos_generales_alert = $('#datos-generales-alert');
|
this.datos_generales_alert = $('#datos-generales-alert');
|
||||||
|
|
||||||
@ -393,6 +398,27 @@ export default class PresupuestoWizard {
|
|||||||
******************************/
|
******************************/
|
||||||
#initDatosGenerales() {
|
#initDatosGenerales() {
|
||||||
|
|
||||||
|
this.btnIvaReducidoDetail.on('click', () => {
|
||||||
|
Swal.fire({
|
||||||
|
position: 'top-end',
|
||||||
|
icon: 'info',
|
||||||
|
title: window.languageBundle.get('presupuesto.iva-reducido'),
|
||||||
|
html: `
|
||||||
|
<div class="acitivity-timeline p-4">
|
||||||
|
${window.languageBundle.get('presupuesto.iva-reducido-descripcion')}
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
confirmButtonClass: 'btn btn-primary w-xs mt-2',
|
||||||
|
showConfirmButton: false,
|
||||||
|
showCloseButton: true,
|
||||||
|
buttonsStyling: false,
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-secondary me-2', // clases para el botón confirmar
|
||||||
|
cancelButton: 'btn btn-light' // clases para cancelar
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$('.datos-generales-data').on('change', () => {
|
$('.datos-generales-data').on('change', () => {
|
||||||
const dataToStore = this.#getDatosGeneralesData();
|
const dataToStore = this.#getDatosGeneralesData();
|
||||||
this.#updateDatosGeneralesData(dataToStore);
|
this.#updateDatosGeneralesData(dataToStore);
|
||||||
@ -537,6 +563,8 @@ export default class PresupuestoWizard {
|
|||||||
paginasColor: this.paginasColor.val(),
|
paginasColor: this.paginasColor.val(),
|
||||||
posicionPaginasColor: this.posicionPaginasColor.val(),
|
posicionPaginasColor: this.posicionPaginasColor.val(),
|
||||||
tipoEncuadernacion: $('.tipo-libro input:checked').val() || 'fresado',
|
tipoEncuadernacion: $('.tipo-libro input:checked').val() || 'fresado',
|
||||||
|
entregaTipo: this.entregaTipo.val(),
|
||||||
|
ivaReducido: this.ivaReducido.is(':checked'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,6 +585,8 @@ export default class PresupuestoWizard {
|
|||||||
paginasColor: data.paginasColor,
|
paginasColor: data.paginasColor,
|
||||||
posicionPaginasColor: data.posicionPaginasColor,
|
posicionPaginasColor: data.posicionPaginasColor,
|
||||||
tipoEncuadernacion: data.tipoEncuadernacion,
|
tipoEncuadernacion: data.tipoEncuadernacion,
|
||||||
|
entregaTipo: data.entregaTipo,
|
||||||
|
ivaReducido: data.ivaReducido,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,6 +632,9 @@ export default class PresupuestoWizard {
|
|||||||
this.formato.val(option.val()).trigger('change');
|
this.formato.val(option.val()).trigger('change');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.entregaTipo.val(this.formData.datosGenerales.entregaTipo);
|
||||||
|
this.ivaReducido.prop('checked', this.formData.datosGenerales.ivaReducido);
|
||||||
}
|
}
|
||||||
|
|
||||||
#getTamanio() {
|
#getTamanio() {
|
||||||
@ -1752,8 +1785,6 @@ export default class PresupuestoWizard {
|
|||||||
});
|
});
|
||||||
const servicios = data.servicios || [];
|
const servicios = data.servicios || [];
|
||||||
|
|
||||||
let total = 0;
|
|
||||||
|
|
||||||
const locale = document.documentElement.lang || 'es-ES';
|
const locale = document.documentElement.lang || 'es-ES';
|
||||||
|
|
||||||
for (const l of lineas) {
|
for (const l of lineas) {
|
||||||
@ -1766,7 +1797,6 @@ export default class PresupuestoWizard {
|
|||||||
<td class="text-end">${formateaMoneda(data[l].precio_total, 2, locale)}</td>
|
<td class="text-end">${formateaMoneda(data[l].precio_total, 2, locale)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
total += data[l].precio_total;
|
|
||||||
this.tablaResumen.find('tbody').append(row);
|
this.tablaResumen.find('tbody').append(row);
|
||||||
}
|
}
|
||||||
for (const s of servicios) {
|
for (const s of servicios) {
|
||||||
@ -1779,13 +1809,26 @@ export default class PresupuestoWizard {
|
|||||||
<td class="text-end">${s.id === "marcapaginas" ? formateaMoneda(s.precio * s.unidades, 2, locale) : formateaMoneda(s.precio, 2, locale)}</td>
|
<td class="text-end">${s.id === "marcapaginas" ? formateaMoneda(s.precio * s.unidades, 2, locale) : formateaMoneda(s.precio, 2, locale)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
total += s.precio;
|
|
||||||
this.tablaResumen.find('tbody').append(row);
|
this.tablaResumen.find('tbody').append(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#resumen-base').text(formateaMoneda(total, 2, locale));
|
$('#resumen-base').text(formateaMoneda(data.base_imponible, 2, locale));
|
||||||
$('#resumen-iva').text(formateaMoneda(total * 0.04, 2, locale));
|
if(data.iva_importe_4 > 0) {
|
||||||
$('#resumen-total').text(formateaMoneda(total * 1.04, 2, locale));
|
$('#tr-resumen-iva4').removeClass('d-none');
|
||||||
|
$('#resumen-iva4').text(formateaMoneda(data.iva_importe_4, 2, locale));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#tr-resumen-iva4').addClass('d-none');
|
||||||
|
$('#resumen-iva4').text(formateaMoneda(0, 2, locale));
|
||||||
|
}
|
||||||
|
if(data.iva_importe_21 > 0) {
|
||||||
|
$('#tr-resumen-iva21').removeClass('d-none');
|
||||||
|
$('#resumen-iva21').text(formateaMoneda(data.iva_importe_21, 2, locale));
|
||||||
|
} else {
|
||||||
|
$('#tr-resumen-iva21').addClass('d-none');
|
||||||
|
$('#resumen-iva21').text(formateaMoneda(0, 2, locale));
|
||||||
|
}
|
||||||
|
$('#resumen-total').text(formateaMoneda(data.total_con_iva, 2, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
|||||||
@ -270,7 +270,7 @@
|
|||||||
<div
|
<div
|
||||||
class="form-check form-switch form-switch-custom form-switch-presupuesto mb-3 d-flex align-items-center">
|
class="form-check form-switch form-switch-custom form-switch-presupuesto mb-3 d-flex align-items-center">
|
||||||
<input type="checkbox" class="form-check-input datos-generales-data me-2" id="iva-reducido"
|
<input type="checkbox" class="form-check-input datos-generales-data me-2" id="iva-reducido"
|
||||||
name="iva-reducido">
|
name="iva-reducido" checked/>
|
||||||
<label for="iva-reducido" class="form-label d-flex align-items-center mb-0">
|
<label for="iva-reducido" class="form-label d-flex align-items-center mb-0">
|
||||||
<span th:text="#{presupuesto.iva-reducido}" class="me-2">I.V. reducido</span>
|
<span th:text="#{presupuesto.iva-reducido}" class="me-2">I.V. reducido</span>
|
||||||
<button type="button" id="btn-iva-reducido-detail"
|
<button type="button" id="btn-iva-reducido-detail"
|
||||||
@ -282,8 +282,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row justify-content-center mb-2">
|
<div class="row justify-content-center mb-2">
|
||||||
<div class="col-sm-3 justify-content-center">
|
<div class="col-sm-3 justify-content-center">
|
||||||
<label for="entrega" class="form-label mt-2" th:text="#{presupuesto.entrega}">Entrega</label>
|
<label for="entregaTipo" class="form-label mt-2" th:text="#{presupuesto.entrega}">Entrega</label>
|
||||||
<select class="form-select select2 datos-generales-data" id="entrega" name="entrega">
|
<select class="form-select select2 datos-generales-data" id="entregaTipo" name="entregaTipo">
|
||||||
<option selected value="peninsula" th:text="#{presupuesto.entrega.peninsula}">Península
|
<option selected value="peninsula" th:text="#{presupuesto.entrega.peninsula}">Península
|
||||||
y
|
y
|
||||||
Baleares</option>
|
Baleares</option>
|
||||||
|
|||||||
@ -34,9 +34,13 @@
|
|||||||
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.base}">Total</th>
|
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.base}">Total</th>
|
||||||
<th class="text-end" id="resumen-base">0,00 €</th>
|
<th class="text-end" id="resumen-base">0,00 €</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="table-active">
|
<tr id="tr-resumen-iva4" class="table-active">
|
||||||
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.iva}">IVA (4%)</th>
|
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.iva4}">IVA (4%)</th>
|
||||||
<th class="text-end" id="resumen-iva">0,00 €</th>
|
<th class="text-end" id="resumen-iva4">0,00 €</th>
|
||||||
|
</tr>
|
||||||
|
<tr id="tr-resumen-iva21" class="table-active">
|
||||||
|
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.iva21}">IVA (21%)</th>
|
||||||
|
<th class="text-end" id="resumen-iva21">0,00 €</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="table-active">
|
<tr class="table-active">
|
||||||
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.total}">Total con IVA</th>
|
<th colspan="4" class="text-end" th:text="#{presupuesto.resumen.tabla.total}">Total con IVA</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user