fix: Corregir cálculo de excedente para casas con consumo_only

- Agregar método getExpectedAmountWithDiscount() que retorna el monto sin descuento de 00
- El excedente ahora se calcula contra el monto original configurado, no contra el monto con descuento
- Casas que pagan exactamente el monto por casa aparecen al corriente (/bin/bash.00)
- Casas que pagan más del monto por casa muestran excedente
This commit is contained in:
2026-01-16 17:18:18 -06:00
parent c82cf3de89
commit 8f2f04951f
3 changed files with 29 additions and 3 deletions

View File

@@ -68,6 +68,7 @@
foreach ($houses as $house):
$total = 0;
$totalExpected = 0;
$totalExpectedOriginal = 0;
?>
<tr data-house-id="<?= $house['id'] ?>" data-house-number="<?= $house['number'] ?>" data-status="<?= $house['status'] ?>">
<td><strong><?= $house['number'] ?></strong></td>
@@ -85,8 +86,10 @@
$monthTotals[$month] += $amount; // Accumulate monthly total
$expected = Payment::getExpectedAmount($house, $year, $month);
$expectedOriginal = Payment::getExpectedAmountWithDiscount($house, $year, $month);
$total += $amount;
$totalExpected += $expected;
$totalExpectedOriginal += $expectedOriginal;
$cellClass = 'pending';
$cellText = '-';
@@ -124,7 +127,7 @@
</td>
<?php endforeach; ?>
<?php
$difference = $total - $totalExpected;
$difference = $total - $totalExpectedOriginal;
$diffClass = $difference < 0 ? 'text-danger' : 'text-success';
$diffText = $difference == 0 ? '$0.00' : '$' . number_format($difference, 2);
$grandTotal += $total;
@@ -200,6 +203,7 @@
<?php foreach ($houses as $house):
$total = 0;
$totalExpected = 0;
$totalExpectedOriginal = 0;
?>
<tr>
<td><strong><?= $house['number'] ?></strong></td>
@@ -208,8 +212,10 @@
$payment = $payments[$month][$house['id']] ?? null;
$amount = $payment['amount'] ?? 0;
$expected = Payment::getExpectedAmount($house, $year, $month);
$expectedOriginal = Payment::getExpectedAmountWithDiscount($house, $year, $month);
$total += $amount;
$totalExpected += $expected;
$totalExpectedOriginal += $expectedOriginal;
$bg = '#f8d7da';
if ($amount > 0) {
@@ -223,7 +229,7 @@
</td>
<?php endforeach; ?>
<?php
$difference = $total - $totalExpected;
$difference = $total - $totalExpectedOriginal;
$diffColor = $difference < 0 ? 'red' : 'green';
$diffText = $difference == 0 ? '$0.00' : '$' . number_format($difference, 2);
?>