From d4b4c95cbc2ca5a20a3d1000ee97b342da4d571d Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Sun, 14 Jun 2026 14:34:33 +0530 Subject: [PATCH] Fix IPD discharge and bill print issues --- app/Views/billing/ipd/bill_print.php | 44 ++++++++++++++++++++++- app/Views/billing/ipd/panel_discharge.php | 16 ++++++--- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/app/Views/billing/ipd/bill_print.php b/app/Views/billing/ipd/bill_print.php index ba1688c..85f5dfd 100644 --- a/app/Views/billing/ipd/bill_print.php +++ b/app/Views/billing/ipd/bill_print.php @@ -6,7 +6,8 @@ $ipdItems = $ipd_invoice_items ?? []; $showItems = $showinvoice ?? []; $medicalItems = $inv_med_list ?? []; $payments = $ipd_payment ?? []; -$billTotals = is_array($bill_totals ?? null) ? $bill_totals : []; +$rawBillTotals = $bill_totals ?? []; +$billTotals = is_array($rawBillTotals) ? $rawBillTotals : []; $hasGrossTotal = array_key_exists('gross', $billTotals); $hasNetTotal = array_key_exists('net', $billTotals); $hasPaidTotal = array_key_exists('paid', $billTotals); @@ -91,6 +92,32 @@ if (! $hasBalanceTotal && $balanceAmount === 0.0 && $ipd) { $balanceAmount = (float) ($ipd->balance_amount ?? 0); } +$printAdjustments = []; +foreach ([1, 2, 3] as $slot) { + $amountField = $slot === 1 ? 'Discount' : 'Discount' . $slot; + $remarkField = $slot === 1 ? 'Discount_Remark' : 'Discount_Remark' . $slot; + $amount = (float) ($ipd->{$amountField} ?? 0); + if ($amount > 0) { + $printAdjustments[] = [ + 'label' => 'Deduction', + 'remark' => (string) ($ipd->{$remarkField} ?? ''), + 'amount' => $amount, + ]; + } +} +foreach ([1, 2] as $slot) { + $amountField = 'chargeamount' . $slot; + $remarkField = 'charge' . $slot; + $amount = (float) ($ipd->{$amountField} ?? 0); + if ($amount > 0) { + $printAdjustments[] = [ + 'label' => 'Charge', + 'remark' => (string) ($ipd->{$remarkField} ?? ''), + 'amount' => $amount, + ]; + } +} + $patientAddress = trim((string) (($person->add1 ?? '') . ' ' . ($person->add2 ?? '') . ' ' . ($person->city ?? '') . ' ' . ($person->state ?? ''))); $patientAddress = preg_replace('/\s+/', ' ', $patientAddress ?? ''); @@ -298,6 +325,21 @@ $billHeadingText = $isDischargeFinal + + + + + + Remark :
+ + + + + + + + + Net Amount diff --git a/app/Views/billing/ipd/panel_discharge.php b/app/Views/billing/ipd/panel_discharge.php index a848ecf..47cb56a 100644 --- a/app/Views/billing/ipd/panel_discharge.php +++ b/app/Views/billing/ipd/panel_discharge.php @@ -193,7 +193,9 @@ $canManageIpdStatus = auth()->user()?->can('billing.ipd.status.manage') ?? false }); } - $(document).on('click', '#tab_discharge_content .js-update-discount', function() { + $(document) + .off('click', '#tab_discharge_content .js-update-discount') + .on('click.ipdDischargeProcess', '#tab_discharge_content .js-update-discount', function() { var slot = Number($(this).data('slot') || 0); if (slot < 1 || slot > 3) { return; @@ -208,7 +210,9 @@ $canManageIpdStatus = auth()->user()?->can('billing.ipd.status.manage') ?? false }); }); - $(document).on('click', '#tab_discharge_content .js-update-charge', function() { + $(document) + .off('click', '#tab_discharge_content .js-update-charge') + .on('click.ipdDischargeProcess', '#tab_discharge_content .js-update-charge', function() { var slot = Number($(this).data('slot') || 0); if (slot < 1 || slot > 2) { return; @@ -223,7 +227,9 @@ $canManageIpdStatus = auth()->user()?->can('billing.ipd.status.manage') ?? false }); }); - $(document).on('click', '#tab_discharge_content #btn-update-discharge-process', function() { + $(document) + .off('click', '#tab_discharge_content #btn-update-discharge-process') + .on('click.ipdDischargeProcess', '#tab_discharge_content #btn-update-discharge-process', function() { var status = Number($('#discharge_status').val() || 0); var disTime = String($('#discharge_time').val() || '').trim(); if (status === 0) { @@ -248,7 +254,9 @@ $canManageIpdStatus = auth()->user()?->can('billing.ipd.status.manage') ?? false }); }); - $(document).on('click', '#tab_discharge_content .js-toggle-ipd-status', function() { + $(document) + .off('click', '#tab_discharge_content .js-toggle-ipd-status') + .on('click.ipdDischargeProcess', '#tab_discharge_content .js-toggle-ipd-status', function() { var currentStatus = Number($(this).data('current') || 0); var newStatus = currentStatus === 0 ? 1 : 0; var action = newStatus === 1 ? 'lock bills (set discharged)' : 'unlock bills (set active)';