doc_name ?? '')); $doctorLabel = $doctorName !== '' ? (preg_match('/^dr\.?\s*/i', $doctorName) ? $doctorName : 'Dr. ' . $doctorName) : '-'; $items = $items ?? []; $rowCount = count($items); $baseGrossTotal = 0.0; $baseDiscountTotal = 0.0; if (! empty($items)) { foreach ($items as $printItem) { $baseGrossTotal += (float) ($printItem->amount ?? 0); $baseDiscountTotal += (float) ($printItem->disc_amount ?? 0); } } $invoiceDiscountTotal = (float) (($invoice->discount_amount ?? 0) + ($invoice->disc_amount ?? 0) + ($invoice->item_discount_amount ?? 0)); $extraInvoiceDiscountTotal = max(0.0, $invoiceDiscountTotal - $baseDiscountTotal); $allocatedExtraDiscountTotal = 0.0; ?>
| Phone: | GSTIN:
Medical Invoice No: inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?>
Date: inv_date ?? '-') ?>
Patient: inv_name ?? '-') ?>
Patient Code: patient_code ?? '-') ?>
Refer By:
Phone: inv_phone_number ?? ($patient->mphone1 ?? '-')) ?>
Type: ipd_credit ?? 0) === 1) ? 'Credit' : 'Cash' ?>
$item): ?> amount ?? 0); $baseRowDisc = (float) ($item->disc_amount ?? 0); $baseRowNet = (float) ($item->twdisc_amount ?? $item->tamount ?? ($item->net_amount ?? 0)); $remainingExtraDiscount = max(0.0, $extraInvoiceDiscountTotal - $allocatedExtraDiscountTotal); $allocExtraDisc = 0.0; if ($remainingExtraDiscount > 0 && $baseGrossTotal > 0) { if ((int) $idx === $rowCount - 1) { $allocExtraDisc = $remainingExtraDiscount; } else { $allocExtraDisc = round($extraInvoiceDiscountTotal * ($rowGross / $baseGrossTotal), 2); if ($allocExtraDisc > $remainingExtraDiscount) { $allocExtraDisc = $remainingExtraDiscount; } } } $allocatedExtraDiscountTotal += $allocExtraDisc; $rowDisc = $baseRowDisc + $allocExtraDisc; $rowNet = max(0.0, $baseRowNet - $allocExtraDisc); $gross += $rowGross; $discount += $rowDisc; $net += $rowNet; ?> gross_amount ?? $gross); $printDiscountTotal = (float) (($invoice->discount_amount ?? 0) + ($invoice->disc_amount ?? 0) + ($invoice->item_discount_amount ?? 0)); $printDiscountTotal = $printDiscountTotal > 0 ? $printDiscountTotal : $discount; $printNetTotal = $printGrossTotal - $printDiscountTotal; if ($printNetTotal < 0) { $printNetTotal = 0.0; } ?>
# Item Batch Qty Rate Discount Amount Net
item_Name ?? '-') ?>formulation) ? ' / ' . esc($item->formulation) : '' ?> batch_no ?? '-') ?> qty ?? 0), 2)) ?> price ?? 0), 2)) ?>
No items found.
Gross
Discount
Net Amount
Prepared By: _____________________
Authorized Sign: _____________________