fix: use computed item totals for IPD gross/net in bill views

This commit is contained in:
DevSoftTech Server 2026-04-10 21:03:17 +05:30
parent a850e3229a
commit 6782aee1a4
2 changed files with 19 additions and 18 deletions

View File

@ -66,14 +66,14 @@ if ($dischargeTimeText !== '') {
$dischargeDateText = trim($dischargeDateText . ' ' . substr($dischargeTimeText, 0, 5));
}
$grossAmount = (float) ($ipd->gross_amount ?? 0);
if ($grossAmount <= 0) {
$grossAmount = (float) ($billTotals['gross'] ?? 0);
$grossAmount = (float) ($billTotals['gross'] ?? 0);
if ($grossAmount <= 0 && $ipd) {
$grossAmount = (float) ($ipd->gross_amount ?? 0);
}
$netAmount = (float) ($ipd->net_amount ?? 0);
if ($netAmount <= 0) {
$netAmount = (float) ($billTotals['net'] ?? 0);
$netAmount = (float) ($billTotals['net'] ?? 0);
if ($netAmount <= 0 && $ipd) {
$netAmount = (float) ($ipd->net_amount ?? 0);
}
$paidAmount = (float) ($billTotals['paid'] ?? 0);
@ -81,9 +81,9 @@ if ($paidAmount <= 0) {
$paidAmount = (float) ($ipd->total_paid_amount ?? 0);
}
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
if ($balanceAmount <= 0) {
$balanceAmount = (float) ($billTotals['balance'] ?? 0);
$balanceAmount = (float) ($billTotals['balance'] ?? 0);
if ($balanceAmount === 0.0 && $ipd) {
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
}
$patientAddress = trim((string) (($person->add1 ?? '') . ' ' . ($person->add2 ?? '') . ' ' . ($person->city ?? '') . ' ' . ($person->state ?? '')));

View File

@ -18,17 +18,18 @@ $balanceTotal = (float) ($billTotals['balance'] ?? 0);
$showPrintActions = (bool) ($show_print_actions ?? true);
$canPrintBill = (bool) ($can_print_bill ?? false);
$showPaymentDetails = (bool) ($show_payment_details ?? true);
$grossAmount = (float) ($ipd->gross_amount ?? 0);
$netAmount = (float) ($ipd->net_amount ?? 0);
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
if ($grossAmount <= 0) {
$grossAmount = (float) ($billTotals['gross'] ?? 0);
$grossAmount = (float) ($billTotals['gross'] ?? 0);
$netAmount = (float) ($billTotals['net'] ?? 0);
$balanceAmount = $balanceTotal;
if ($grossAmount <= 0 && $ipd) {
$grossAmount = (float) ($ipd->gross_amount ?? 0);
}
if ($netAmount <= 0) {
$netAmount = (float) ($billTotals['net'] ?? 0);
if ($netAmount <= 0 && $ipd) {
$netAmount = (float) ($ipd->net_amount ?? 0);
}
if ($balanceAmount <= 0) {
$balanceAmount = $balanceTotal;
if ($balanceAmount === 0.0 && $ipd) {
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
}
$isDischargeFinal = (int) ($ipd->discarge_patient_status ?? 0) > 0;
$billHeaderTitle = $isDischargeFinal ? 'Bill No. : ' . (string) ($ipd->ipd_code ?? '') : 'IPD Invoice';