|
@@ -175,54 +175,19 @@
|
|
|
<table class="table tablesaw tableHead tablesaw-stack table--lista_entrate tableHead" id="tablesaw-350" width="100%">
|
|
<table class="table tablesaw tableHead tablesaw-stack table--lista_entrate tableHead" id="tablesaw-350" width="100%">
|
|
|
<thead>
|
|
<thead>
|
|
|
<tr>
|
|
<tr>
|
|
|
- <!--<th scope="col"></th>-->
|
|
|
|
|
<th scope="col">Data</th>
|
|
<th scope="col">Data</th>
|
|
|
<th scope="col">Importo</th>
|
|
<th scope="col">Importo</th>
|
|
|
<th scope="col">Fornitore</th>
|
|
<th scope="col">Fornitore</th>
|
|
|
<th scope="col">Causale</th>
|
|
<th scope="col">Causale</th>
|
|
|
<th scope="col">Pagamento</th>
|
|
<th scope="col">Pagamento</th>
|
|
|
|
|
+ <th scope="col">Stato</th>
|
|
|
<th scope="col">...</th>
|
|
<th scope="col">...</th>
|
|
|
</tr>
|
|
</tr>
|
|
|
</thead>
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody id="checkall-target">
|
|
<tbody id="checkall-target">
|
|
|
</tbody>
|
|
</tbody>
|
|
|
- <!--
|
|
|
|
|
- <tfoot>
|
|
|
|
|
- <tr id="tfooter">
|
|
|
|
|
- <td colspan="6"><span class="total"></span></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </tfoot>
|
|
|
|
|
- -->
|
|
|
|
|
</table>
|
|
</table>
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- <!--
|
|
|
|
|
- <div class="paginator d-flex justify-content-center">
|
|
|
|
|
- <nav aria-label="Page navigation example">
|
|
|
|
|
- <ul class="pagination">
|
|
|
|
|
- <li class="page-item">
|
|
|
|
|
- <a class="page-link" href="#" aria-label="Previous">
|
|
|
|
|
- <span aria-hidden="true"></span>
|
|
|
|
|
- </a>
|
|
|
|
|
- </li>
|
|
|
|
|
- <li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
|
|
|
- <li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
|
|
|
- <li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
|
|
|
- <li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
|
|
|
-
|
|
|
|
|
- <li class="page-item"><span class="more-page">...</span></li>
|
|
|
|
|
-
|
|
|
|
|
- <li class="page-item">
|
|
|
|
|
- <a class="page-link" href="#" aria-label="Next">
|
|
|
|
|
- <span aria-hidden="true"></span>
|
|
|
|
|
- </a>
|
|
|
|
|
- </li>
|
|
|
|
|
- </ul>
|
|
|
|
|
- </nav>
|
|
|
|
|
- </div>
|
|
|
|
|
- -->
|
|
|
|
|
-
|
|
|
|
|
<br><b class="totalDiv"></b>
|
|
<br><b class="totalDiv"></b>
|
|
|
|
|
|
|
|
</section>
|
|
</section>
|
|
@@ -275,15 +240,6 @@
|
|
|
<input id="datePagamento" type="date" class="form-control" wire:model="data_pagamento">
|
|
<input id="datePagamento" type="date" class="form-control" wire:model="data_pagamento">
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-{{-- <div class="col-md-6">
|
|
|
|
|
- <span class="title-form d-block w-100">Allegato</span>
|
|
|
|
|
- <div class="input-group mb-3">
|
|
|
|
|
- <input type="file" class="form-control form-control-lg" wire:model="attachment">
|
|
|
|
|
- </div>
|
|
|
|
|
- </div> --}}
|
|
|
|
|
-
|
|
|
|
|
<div class="col-12">
|
|
<div class="col-12">
|
|
|
<span class="title-form d-block w-100">Fornitore</span>
|
|
<span class="title-form d-block w-100">Fornitore</span>
|
|
|
|
|
|
|
@@ -569,9 +525,6 @@
|
|
|
<div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
|
|
<div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
|
|
|
<span class="amount_p"><strong>Importo</strong></span><span class="amount_data"><strong>{{$amount}}</strong></span>
|
|
<span class="amount_p"><strong>Importo</strong></span><span class="amount_data"><strong>{{$amount}}</strong></span>
|
|
|
</div>
|
|
</div>
|
|
|
- <!--<div class="total--wrapper_tax d-flex align-items-center justify-content-between w-100 mb-2 pb-3">
|
|
|
|
|
- <span class="taxt_p">IVA (22%):</span><span class="tax_data">€ 22,00</span>
|
|
|
|
|
- </div>-->
|
|
|
|
|
<div class="total--wrapper_netprice d-flex align-items-center justify-content-between w-100">
|
|
<div class="total--wrapper_netprice d-flex align-items-center justify-content-between w-100">
|
|
|
<span class="netprice_p"><strong>Totale Netto</strong></span><span class="netprice_data"><strong>{{$amount}}</strong></span>
|
|
<span class="netprice_p"><strong>Totale Netto</strong></span><span class="netprice_data"><strong>{{$amount}}</strong></span>
|
|
|
</div>
|
|
</div>
|
|
@@ -672,9 +625,7 @@
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
$('.supplierClass').select2({
|
|
$('.supplierClass').select2({
|
|
|
- /*matcher: function(params, data) {
|
|
|
|
|
- return matchStart(params, data);
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
$('.paymentClass').select2({
|
|
$('.paymentClass').select2({
|
|
|
matcher: function(params, data) {
|
|
matcher: function(params, data) {
|
|
@@ -699,16 +650,6 @@
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
Livewire.on('load-select', () => {
|
|
Livewire.on('load-select', () => {
|
|
|
- /*$('.causalClass').select2({
|
|
|
|
|
- matcher: function(params, data) {
|
|
|
|
|
- return matchStart(params, data);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- $('.causalClass').on('change', function (e) {
|
|
|
|
|
- var data = $('.causalClass').select2("val");
|
|
|
|
|
- @this.set('causal_id', data);
|
|
|
|
|
- });
|
|
|
|
|
- */
|
|
|
|
|
$('.causalClass').each(function(i, obj) {
|
|
$('.causalClass').each(function(i, obj) {
|
|
|
$(obj).select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$(obj).select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$(obj).on('change', function (e) {
|
|
$(obj).on('change', function (e) {
|
|
@@ -718,9 +659,7 @@
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
$('.supplierClass').select2({
|
|
$('.supplierClass').select2({
|
|
|
- /*matcher: function(params, data) {
|
|
|
|
|
- return matchStart(params, data);
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
$('.supplierClass').on('change', function (e) {
|
|
$('.supplierClass').on('change', function (e) {
|
|
|
var data = $('.supplierClass').select2("val");
|
|
var data = $('.supplierClass').select2("val");
|
|
@@ -738,40 +677,31 @@
|
|
|
|
|
|
|
|
$('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$('.filterSupplier').on('change', function (e) {
|
|
$('.filterSupplier').on('change', function (e) {
|
|
|
- //var data = $('.filterSupplier').select2("val");
|
|
|
|
|
- //@this.set('filterSupplier', data);
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
$('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$('.filterPaymentMethod').on('change', function (e) {
|
|
$('.filterPaymentMethod').on('change', function (e) {
|
|
|
- //var data = $('.filterPaymentMethod').select2("val");
|
|
|
|
|
- //@this.set('filterPaymentMethod', data);
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
$('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$('.filterCausals').on('change', function (e) {
|
|
$('.filterCausals').on('change', function (e) {
|
|
|
- //var data = $('.filterCausals').select2("val");
|
|
|
|
|
- //@this.set('filterCausals', data);
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
Livewire.on('hide-search', () => {
|
|
Livewire.on('hide-search', () => {
|
|
|
- //pcsh2();
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$('.filterSupplier').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$('.filterSupplier').on('change', function (e) {
|
|
$('.filterSupplier').on('change', function (e) {
|
|
|
- //var data = $('.filterSupplier').select2("val");
|
|
|
|
|
- //@this.set('filterSupplier', data);
|
|
|
|
|
});
|
|
});
|
|
|
$('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$('.filterPaymentMethod').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$('.filterPaymentMethod').on('change', function (e) {
|
|
$('.filterPaymentMethod').on('change', function (e) {
|
|
|
- //var data = $('.filterPaymentMethod').select2("val");
|
|
|
|
|
- //@this.set('filterPaymentMethod', data);
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
$('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
$('.filterCausals').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
|
|
|
$('.filterCausals').on('change', function (e) {
|
|
$('.filterCausals').on('change', function (e) {
|
|
|
- //var data = $('.filterCausals').select2("val");
|
|
|
|
|
- //@this.set('filterCausals', data);
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
function onlyNumberAmount(input) {
|
|
function onlyNumberAmount(input) {
|
|
@@ -846,7 +776,6 @@
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$(document).on("select2:open",".filterCausals",function() {
|
|
$(document).on("select2:open",".filterCausals",function() {
|
|
|
- //$('.filterCausals').on('select2:open', function (e) {
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
$(".select2-results__option").each(function(){
|
|
$(".select2-results__option").each(function(){
|
|
|
var txt = $(this).html();
|
|
var txt = $(this).html();
|
|
@@ -956,14 +885,22 @@
|
|
|
{ data: 'supplier' },
|
|
{ data: 'supplier' },
|
|
|
{ data: 'causals' },
|
|
{ data: 'causals' },
|
|
|
{ data: 'payment' },
|
|
{ data: 'payment' },
|
|
|
|
|
+ {
|
|
|
|
|
+ data: 'is_paid',
|
|
|
|
|
+ render: function (data) {
|
|
|
|
|
+ if (data === true || data === 'true' || data === 1 || data === '1' || data === 'Pagato') {
|
|
|
|
|
+ return '<span class="badge bg-success">Pagato</span>';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return '<span class="badge bg-danger">Non Pagato</span>';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
data: "action",
|
|
data: "action",
|
|
|
render: function (data){
|
|
render: function (data){
|
|
|
if (data == "")
|
|
if (data == "")
|
|
|
return "";
|
|
return "";
|
|
|
const j = data.split("|");
|
|
const j = data.split("|");
|
|
|
- //$(".totalDiv").html('Totale : <b>' + j[1] + '</b>');
|
|
|
|
|
- //$(".total").html('Totale : <b>' + j[1] + '</b>');
|
|
|
|
|
var ret = '<button type="button" class="btn" onclick="editData(' + j[0] + ')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button> ';
|
|
var ret = '<button type="button" class="btn" onclick="editData(' + j[0] + ')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button> ';
|
|
|
ret += '<button type="button" class="btn" onclick="deleteData(' + j[0] + ')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>';
|
|
ret += '<button type="button" class="btn" onclick="deleteData(' + j[0] + ')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>';
|
|
|
return ret;
|
|
return ret;
|
|
@@ -1089,7 +1026,6 @@
|
|
|
modalInstance.show();
|
|
modalInstance.show();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Re-initialize table if needed after Livewire updates
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
|
|
if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
|
|
|
loadDataTable();
|
|
loadDataTable();
|
|
@@ -1133,7 +1069,6 @@
|
|
|
setTimeout(function() {
|
|
setTimeout(function() {
|
|
|
initImportCausalSelect();
|
|
initImportCausalSelect();
|
|
|
|
|
|
|
|
- // Ensure the table is reloaded when modal is shown
|
|
|
|
|
if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
|
|
if (!$.fn.DataTable.isDataTable('#tablesaw-350')) {
|
|
|
loadDataTable();
|
|
loadDataTable();
|
|
|
if (tableState) {
|
|
if (tableState) {
|
|
@@ -1213,12 +1148,11 @@
|
|
|
closeButton.setAttribute('aria-label', 'Close');
|
|
closeButton.setAttribute('aria-label', 'Close');
|
|
|
alert.appendChild(closeButton);
|
|
alert.appendChild(closeButton);
|
|
|
|
|
|
|
|
- const accountingExit = document.getElementById('accountingExit'); // Or any other suitable container
|
|
|
|
|
|
|
+ const accountingExit = document.getElementById('accountingExit');
|
|
|
if (accountingExit) {
|
|
if (accountingExit) {
|
|
|
accountingExit.prepend(alert);
|
|
accountingExit.prepend(alert);
|
|
|
} else {
|
|
} else {
|
|
|
- // If accountingExit is not found, prepend to the main container
|
|
|
|
|
- const mainContainer = document.querySelector('.col.card--ui'); // Adjust selector as needed
|
|
|
|
|
|
|
+ const mainContainer = document.querySelector('.col.card--ui');
|
|
|
if (mainContainer) {
|
|
if (mainContainer) {
|
|
|
mainContainer.prepend(alert);
|
|
mainContainer.prepend(alert);
|
|
|
} else {
|
|
} else {
|
|
@@ -1228,7 +1162,7 @@
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
alert.remove();
|
|
alert.remove();
|
|
|
- }, 5000); // Remove after 5 seconds
|
|
|
|
|
|
|
+ }, 5000);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
function closeImportModal() {
|
|
function closeImportModal() {
|
|
@@ -1236,19 +1170,15 @@
|
|
|
if (importModal) {
|
|
if (importModal) {
|
|
|
importModal.hide();
|
|
importModal.hide();
|
|
|
}
|
|
}
|
|
|
- // We no longer need to reload the page here, as this will happen after the result modal is closed
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Update the existing emit handler for import-started
|
|
|
|
|
Livewire.on('import-started', () => {
|
|
Livewire.on('import-started', () => {
|
|
|
- // Disable the close button and submit button during import
|
|
|
|
|
const closeButton = document.querySelector('#importModal .btn-close');
|
|
const closeButton = document.querySelector('#importModal .btn-close');
|
|
|
const submitButton = document.querySelector('#importModal button[type="submit"]');
|
|
const submitButton = document.querySelector('#importModal button[type="submit"]');
|
|
|
if (closeButton) closeButton.disabled = true;
|
|
if (closeButton) closeButton.disabled = true;
|
|
|
if (submitButton) submitButton.disabled = true;
|
|
if (submitButton) submitButton.disabled = true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // Add listener for close-import-modal event
|
|
|
|
|
Livewire.on('close-import-modal', () => {
|
|
Livewire.on('close-import-modal', () => {
|
|
|
const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
|
|
const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
|
|
|
if (importModal) {
|
|
if (importModal) {
|
|
@@ -1258,9 +1188,7 @@
|
|
|
|
|
|
|
|
let transitioningToResultModal = false;
|
|
let transitioningToResultModal = false;
|
|
|
|
|
|
|
|
- // Listener per evento di chiusura della modale di import
|
|
|
|
|
document.getElementById('importModal').addEventListener('hidden.bs.modal', function () {
|
|
document.getElementById('importModal').addEventListener('hidden.bs.modal', function () {
|
|
|
- // Ricarica la pagina solo se non stiamo passando alla modale di risultato
|
|
|
|
|
if (!transitioningToResultModal) {
|
|
if (!transitioningToResultModal) {
|
|
|
console.log("Modal import chiusa dall'utente: ricarica la pagina");
|
|
console.log("Modal import chiusa dall'utente: ricarica la pagina");
|
|
|
setTimeout(function() {
|
|
setTimeout(function() {
|
|
@@ -1268,7 +1196,6 @@
|
|
|
}, 500);
|
|
}, 500);
|
|
|
} else {
|
|
} else {
|
|
|
console.log("Transizione da importModal a resultModal: non ricaricare");
|
|
console.log("Transizione da importModal a resultModal: non ricaricare");
|
|
|
- // Reset della variabile dopo la transizione
|
|
|
|
|
transitioningToResultModal = false;
|
|
transitioningToResultModal = false;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -1277,16 +1204,13 @@
|
|
|
Livewire.on('show-import-result', data => {
|
|
Livewire.on('show-import-result', data => {
|
|
|
transitioningToResultModal = true;
|
|
transitioningToResultModal = true;
|
|
|
|
|
|
|
|
- // Prepara il contenuto della modale di risultato
|
|
|
|
|
const resultDiv = document.getElementById('importResultMessage');
|
|
const resultDiv = document.getElementById('importResultMessage');
|
|
|
resultDiv.innerHTML = data.message;
|
|
resultDiv.innerHTML = data.message;
|
|
|
- // Chiudi la modale di importazione
|
|
|
|
|
const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
|
|
const importModal = bootstrap.Modal.getInstance(document.getElementById('importModal'));
|
|
|
if (importModal) {
|
|
if (importModal) {
|
|
|
importModal.hide();
|
|
importModal.hide();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Mostra la modale dei risultati dopo un breve ritardo
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
const resultModal = new bootstrap.Modal(document.getElementById('importResultModal'));
|
|
const resultModal = new bootstrap.Modal(document.getElementById('importResultModal'));
|
|
|
resultModal.show();
|
|
resultModal.show();
|
|
@@ -1299,68 +1223,57 @@
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
- // Function to calculate and update the amount field
|
|
|
|
|
- function calculateAmount(rowIndex) {
|
|
|
|
|
- const imponibileField = document.getElementById(`rows.${rowIndex}.imponibile`);
|
|
|
|
|
- const aliquotaField = document.getElementById(`rows.${rowIndex}.aliquota_iva`);
|
|
|
|
|
- const amountField = document.getElementById(`rows.${rowIndex}.amount`);
|
|
|
|
|
-
|
|
|
|
|
- if (imponibileField && aliquotaField && amountField) {
|
|
|
|
|
- // Get imponibile value (remove formatting)
|
|
|
|
|
- let imponibile = imponibileField.value.replace('€', '').replace(/\./g, '').replace(',', '.').trim();
|
|
|
|
|
- imponibile = parseFloat(imponibile) || 0;
|
|
|
|
|
-
|
|
|
|
|
- // Get aliquota value (remove % sign)
|
|
|
|
|
- let aliquota = aliquotaField.value.replace('%', '').trim();
|
|
|
|
|
- aliquota = parseFloat(aliquota) || 0;
|
|
|
|
|
-
|
|
|
|
|
- // Calculate amount: imponibile + (imponibile * aliquota / 100)
|
|
|
|
|
- const imposta = imponibile * (aliquota / 100);
|
|
|
|
|
- const totalAmount = imponibile + imposta;
|
|
|
|
|
-
|
|
|
|
|
- // Format and set the amount value
|
|
|
|
|
- let formattedAmount = "€ " + totalAmount.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
|
|
|
- amountField.value = formattedAmount;
|
|
|
|
|
-
|
|
|
|
|
- // Trigger the Livewire update to sync with backend
|
|
|
|
|
- // This uses the Livewire.find method to access component methods
|
|
|
|
|
- const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
|
|
|
|
|
- if (component) {
|
|
|
|
|
- component.set(`rows.${rowIndex}.amount`, formattedAmount);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function calculateAmount(rowIndex) {
|
|
|
|
|
+ const imponibileField = document.getElementById(`rows.${rowIndex}.imponibile`);
|
|
|
|
|
+ const aliquotaField = document.getElementById(`rows.${rowIndex}.aliquota_iva`);
|
|
|
|
|
+ const amountField = document.getElementById(`rows.${rowIndex}.amount`);
|
|
|
|
|
+
|
|
|
|
|
+ if (imponibileField && aliquotaField && amountField) {
|
|
|
|
|
+ let imponibile = imponibileField.value.replace('€', '').replace(/\./g, '').replace(',', '.').trim();
|
|
|
|
|
+ imponibile = parseFloat(imponibile) || 0;
|
|
|
|
|
+
|
|
|
|
|
+ let aliquota = aliquotaField.value.replace('%', '').trim();
|
|
|
|
|
+ aliquota = parseFloat(aliquota) || 0;
|
|
|
|
|
+
|
|
|
|
|
+ const imposta = imponibile * (aliquota / 100);
|
|
|
|
|
+ const totalAmount = imponibile + imposta;
|
|
|
|
|
+
|
|
|
|
|
+ let formattedAmount = "€ " + totalAmount.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
|
|
|
+ amountField.value = formattedAmount;
|
|
|
|
|
+
|
|
|
|
|
+ const component = Livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id'));
|
|
|
|
|
+ if (component) {
|
|
|
|
|
+ component.set(`rows.${rowIndex}.amount`, formattedAmount);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- // Attach event listeners to imponibile and aliquota fields
|
|
|
|
|
- function setupCalculationListeners() {
|
|
|
|
|
- const rows = document.querySelectorAll('input[id^="rows."][id$=".imponibile"], input[id^="rows."][id$=".aliquota_iva"]');
|
|
|
|
|
|
|
+ function setupCalculationListeners() {
|
|
|
|
|
+ const rows = document.querySelectorAll('input[id^="rows."][id$=".imponibile"], input[id^="rows."][id$=".aliquota_iva"]');
|
|
|
|
|
|
|
|
- rows.forEach(field => {
|
|
|
|
|
- field.addEventListener('blur', function() {
|
|
|
|
|
- // Extract row index from the field ID
|
|
|
|
|
- const rowIndex = this.id.match(/rows\.(\d+)\./)[1];
|
|
|
|
|
- calculateAmount(rowIndex);
|
|
|
|
|
|
|
+ rows.forEach(field => {
|
|
|
|
|
+ field.addEventListener('blur', function() {
|
|
|
|
|
+ const rowIndex = this.id.match(/rows\.(\d+)\./)[1];
|
|
|
|
|
+ calculateAmount(rowIndex);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Initial setup
|
|
|
|
|
- setupCalculationListeners();
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // Re-attach listeners after Livewire updates
|
|
|
|
|
- document.addEventListener('livewire:load', function() {
|
|
|
|
|
setupCalculationListeners();
|
|
setupCalculationListeners();
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
- document.addEventListener('livewire:update', function() {
|
|
|
|
|
- setupCalculationListeners();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ document.addEventListener('livewire:load', function() {
|
|
|
|
|
+ setupCalculationListeners();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ document.addEventListener('livewire:update', function() {
|
|
|
|
|
+ setupCalculationListeners();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // Also attach to rows added dynamically
|
|
|
|
|
- Livewire.on('load-select', function() {
|
|
|
|
|
- setTimeout(setupCalculationListeners, 300); // Give time for DOM to update
|
|
|
|
|
|
|
+ Livewire.on('load-select', function() {
|
|
|
|
|
+ setTimeout(setupCalculationListeners, 300);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
-});
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
@endpush
|
|
@endpush
|