diff --git a/Villa y Corte/Villa_y_Corte_v1.html b/Villa y Corte/Villa_y_Corte_v1.html
index 0bab8920d1..71302ff960 100644
--- a/Villa y Corte/Villa_y_Corte_v1.html
+++ b/Villa y Corte/Villa_y_Corte_v1.html
@@ -270,7 +270,7 @@
-
+
@@ -282,7 +282,7 @@
-
+
@@ -307,7 +307,7 @@
-
+
@@ -373,7 +373,8 @@
-
+
+
@@ -5406,40 +5407,60 @@
-
DINERO
+
+
DINERO
+
+
Escudos de oro:
-
+
Reales de plata:
-
+
Marvedís de cobre:
-
+
-
@@ -5662,7 +5685,7 @@
-
+
@@ -5674,7 +5697,7 @@
-
+
@@ -7249,7 +7272,7 @@ on("change:percepcion change:comunicacion change:cultura", function() {
suertemax = Math.max(-100, Math.min(100, suertemax));
setAttrs({
- suertemax: suertemax
+ suerte: suertemax
});
});
});
@@ -8272,6 +8295,68 @@ on(
}
);
+// CAMBIO MONETARIO CASTILLA BIDIRECCIONAL (DECIMALES SOLO SI NECESARIOS)
+on(
+ "change:monedamanocastellana change:monedacambiadacastellana change:monedacambiocastellana sheet:opened",
+ function (event) {
+
+ getAttrs(
+ [
+ "monedamanocastellana",
+ "monedacambiadacastellana",
+ "monedacambiocastellana"
+ ],
+ function (values) {
+
+ const cantidad = parseFloat(values.monedamanocastellana) || 0;
+ const resultado = parseFloat(values.monedacambiadacastellana) || 0;
+ const cambio = parseFloat(values.monedacambiocastellana) || 0;
+
+ let updates = {};
+
+ // Si el cambio es 0 → resultado 0
+ if (cambio === 0) {
+ updates.monedacambiadacastellana = 0;
+ setAttrs(updates);
+ return;
+ }
+
+ // Función de redondeo limpio a 2 decimales
+ const redondear = (num) => Math.round(num * 100) / 100;
+
+ // Si cambia la cantidad original
+ if (event.sourceAttribute === "monedamanocastellana") {
+
+ updates.monedacambiadacastellana =
+ redondear(cantidad * cambio);
+
+ }
+
+ // Si cambia la cantidad convertida
+ if (event.sourceAttribute === "monedacambiadacastellana") {
+
+ updates.monedamanocastellana =
+ redondear(resultado / cambio);
+
+ }
+
+ // Si cambia el tipo de cambio o se abre la hoja
+ if (
+ event.sourceAttribute === "monedacambiocastellana" ||
+ event.sourceType === "sheet"
+ ) {
+
+ updates.monedacambiadacastellana =
+ redondear(cantidad * cambio);
+
+ }
+
+ setAttrs(updates);
+
+ }
+ );
+ }
+);
// ENSALMOS DIARIOS TOTALES SEGÚN TEMPLANZA