Compare commits
3 Commits
a1e67a8a0b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f2f04951f | |||
| c82cf3de89 | |||
| 6f4bf30e72 |
@@ -51,6 +51,23 @@ class Payment {
|
||||
return round($monto_base, 2);
|
||||
}
|
||||
|
||||
public static function getExpectedAmountWithDiscount($house, $year, $month) {
|
||||
$db = Database::getInstance();
|
||||
|
||||
$bill = $db->fetchOne(
|
||||
"SELECT * FROM monthly_bills WHERE year = ? AND month = ?",
|
||||
[$year, $month]
|
||||
);
|
||||
|
||||
if (!$bill) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$monto_base = $bill['amount_per_house'];
|
||||
|
||||
return round($monto_base, 2);
|
||||
}
|
||||
|
||||
public static function update($houseId, $year, $month, $amount, $userId, $notes = null, $paymentMethod = null) {
|
||||
$db = Database::getInstance();
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<?php endif; ?>
|
||||
<?php if (Auth::isAdmin()): ?>
|
||||
<li><span class="dropdown-item text-muted small"><i class="bi bi-server"></i> <?= DB_HOST ?>:<?= DB_PORT ?></span></li>
|
||||
<li><span class="dropdown-item text-muted small"><i class="bi bi-database"></i> DB: <?= DB_NAME ?></span></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -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);
|
||||
?>
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
foreach ($houses as $house):
|
||||
$total = 0;
|
||||
$totalExpected = 0;
|
||||
$totalExpectedOriginal = 0;
|
||||
?>
|
||||
<tr>
|
||||
<td><strong><?= $house['number'] ?></strong></td>
|
||||
@@ -68,8 +69,10 @@
|
||||
$monthTotals[$month] += $amount;
|
||||
|
||||
$expected = Payment::getExpectedAmount($house, $year, $month);
|
||||
$expectedOriginal = Payment::getExpectedAmountWithDiscount($house, $year, $month);
|
||||
$total += $amount;
|
||||
$totalExpected += $expected;
|
||||
$totalExpectedOriginal += $expectedOriginal;
|
||||
|
||||
$bg_color = '#FFFFFF'; // Default white
|
||||
if ($house['status'] == 'deshabitada') {
|
||||
@@ -89,7 +92,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);
|
||||
$grandTotal += $total;
|
||||
|
||||
@@ -423,7 +423,7 @@ function exportConceptDebtorsPDF() {
|
||||
});
|
||||
}
|
||||
|
||||
console.log('DEBUG - Final URL:', url);
|
||||
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user