fix: use computed item totals for IPD gross/net in bill views
This commit is contained in:
parent
a850e3229a
commit
6782aee1a4
|
|
@ -66,14 +66,14 @@ if ($dischargeTimeText !== '') {
|
||||||
$dischargeDateText = trim($dischargeDateText . ' ' . substr($dischargeTimeText, 0, 5));
|
$dischargeDateText = trim($dischargeDateText . ' ' . substr($dischargeTimeText, 0, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
$grossAmount = (float) ($ipd->gross_amount ?? 0);
|
$grossAmount = (float) ($billTotals['gross'] ?? 0);
|
||||||
if ($grossAmount <= 0) {
|
if ($grossAmount <= 0 && $ipd) {
|
||||||
$grossAmount = (float) ($billTotals['gross'] ?? 0);
|
$grossAmount = (float) ($ipd->gross_amount ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$netAmount = (float) ($ipd->net_amount ?? 0);
|
$netAmount = (float) ($billTotals['net'] ?? 0);
|
||||||
if ($netAmount <= 0) {
|
if ($netAmount <= 0 && $ipd) {
|
||||||
$netAmount = (float) ($billTotals['net'] ?? 0);
|
$netAmount = (float) ($ipd->net_amount ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$paidAmount = (float) ($billTotals['paid'] ?? 0);
|
$paidAmount = (float) ($billTotals['paid'] ?? 0);
|
||||||
|
|
@ -81,9 +81,9 @@ if ($paidAmount <= 0) {
|
||||||
$paidAmount = (float) ($ipd->total_paid_amount ?? 0);
|
$paidAmount = (float) ($ipd->total_paid_amount ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
|
$balanceAmount = (float) ($billTotals['balance'] ?? 0);
|
||||||
if ($balanceAmount <= 0) {
|
if ($balanceAmount === 0.0 && $ipd) {
|
||||||
$balanceAmount = (float) ($billTotals['balance'] ?? 0);
|
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$patientAddress = trim((string) (($person->add1 ?? '') . ' ' . ($person->add2 ?? '') . ' ' . ($person->city ?? '') . ' ' . ($person->state ?? '')));
|
$patientAddress = trim((string) (($person->add1 ?? '') . ' ' . ($person->add2 ?? '') . ' ' . ($person->city ?? '') . ' ' . ($person->state ?? '')));
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,18 @@ $balanceTotal = (float) ($billTotals['balance'] ?? 0);
|
||||||
$showPrintActions = (bool) ($show_print_actions ?? true);
|
$showPrintActions = (bool) ($show_print_actions ?? true);
|
||||||
$canPrintBill = (bool) ($can_print_bill ?? false);
|
$canPrintBill = (bool) ($can_print_bill ?? false);
|
||||||
$showPaymentDetails = (bool) ($show_payment_details ?? true);
|
$showPaymentDetails = (bool) ($show_payment_details ?? true);
|
||||||
$grossAmount = (float) ($ipd->gross_amount ?? 0);
|
$grossAmount = (float) ($billTotals['gross'] ?? 0);
|
||||||
$netAmount = (float) ($ipd->net_amount ?? 0);
|
$netAmount = (float) ($billTotals['net'] ?? 0);
|
||||||
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
|
$balanceAmount = $balanceTotal;
|
||||||
if ($grossAmount <= 0) {
|
|
||||||
$grossAmount = (float) ($billTotals['gross'] ?? 0);
|
if ($grossAmount <= 0 && $ipd) {
|
||||||
|
$grossAmount = (float) ($ipd->gross_amount ?? 0);
|
||||||
}
|
}
|
||||||
if ($netAmount <= 0) {
|
if ($netAmount <= 0 && $ipd) {
|
||||||
$netAmount = (float) ($billTotals['net'] ?? 0);
|
$netAmount = (float) ($ipd->net_amount ?? 0);
|
||||||
}
|
}
|
||||||
if ($balanceAmount <= 0) {
|
if ($balanceAmount === 0.0 && $ipd) {
|
||||||
$balanceAmount = $balanceTotal;
|
$balanceAmount = (float) ($ipd->balance_amount ?? 0);
|
||||||
}
|
}
|
||||||
$isDischargeFinal = (int) ($ipd->discarge_patient_status ?? 0) > 0;
|
$isDischargeFinal = (int) ($ipd->discarge_patient_status ?? 0) > 0;
|
||||||
$billHeaderTitle = $isDischargeFinal ? 'Bill No. : ' . (string) ($ipd->ipd_code ?? '') : 'IPD Invoice';
|
$billHeaderTitle = $isDischargeFinal ? 'Bill No. : ' . (string) ($ipd->ipd_code ?? '') : 'IPD Invoice';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user