@if ($appointment->patientEncounter == null)
{{ optional($appointment->clinicservice)->name }}
{{ optional($appointment->clinicservice)->description ?? ' ' }}
@php
if (
optional($appointment->appointmenttransaction)->discount_type ===
'percentage'
) {
$payable_Amount =
$appointment->service_price -
$appointment->service_price *
(optional($appointment->appointmenttransaction)->discount_value /
100) ;
} else {
$payable_Amount =
$appointment->service_price -
optional($appointment->appointmenttransaction)->discount_value ;
}
$total_tax = 0;
$sub_total = $payable_Amount + $appointment->appointmenttransaction->inclusive_tax_price;
$inclusive_tax_data = json_decode($appointment->appointmenttransaction->inclusive_tax, true); // decode tax details
@endphp
@if (optional($appointment->appointmenttransaction)->discount_value > 0)
{{ Currency::format($sub_total) }} @if (optional($appointment->appointmenttransaction)->discount_type === 'percentage')
({{ optional($appointment->appointmenttransaction)->discount_value ?? '--' }}%
off)
@else
({{ Currency::format(optional($appointment->appointmenttransaction)->discount_value) ?? '--' }}
off)
@endif
{{ Currency::format($appointment->service_price ) }}
@else
{{ Currency::format($appointment->service_amount ) }}
@endif
@if($appointment->appointmenttransaction->inclusive_tax_price != null && $appointment->patientEncounter == null)
{{ __('messages.lbl_with_inclusive_tax') }}
@endif
@endif
@if (
$appointment->patientEncounter !== null &&
optional(optional($appointment->patientEncounter)->billingrecord)->billingItem != null)
@foreach (optional(optional($appointment->patientEncounter)->billingrecord)->billingItem as $billingItem)
{{ optional($billingItem->clinicservice)->name }}
{{ optional($billingItem->clinicservice)->description ?? ' ' }}
@php
if ($billingItem->discount_type === 'percentage') {
$payable_Amount =
$billingItem->service_amount -
$billingItem->service_amount * ($billingItem->discount_value / 100);
} else {
$payable_Amount =
$billingItem->service_amount - $billingItem->discount_value;
}
@endphp
@if ($billingItem->discount_value > 0)
{{ Currency::format($billingItem->total_amount) }} *
{{ $billingItem->quantity }} =
{{ Currency::format($billingItem->total_amount * $billingItem->quantity) }} @if ($billingItem->discount_type === 'percentage')
({{ $billingItem->discount_value ?? '--' }}% off)
@else
({{ Currency::format($billingItem->discount_value) ?? '--' }}
off)
@endif
@if($billingItem->inclusive_tax_amount > 0)
{{ __('messages.lbl_with_inclusive_tax') }}
@endif
{{ Currency::format($billingItem->service_amount * $billingItem->quantity ) }}
@else
{{ Currency::format($billingItem->total_amount ) }}
*
{{ $billingItem->quantity }} =
{{ Currency::format($billingItem->total_amount * $billingItem->quantity) }}
@if($billingItem->inclusive_tax_amount > 0)
{{ __('messages.lbl_with_inclusive_tax') }}
@endif
@endif
{{-- @if (!empty($billingItem->clinicservice->inclusive_tax_price))
@php
$quantity = $billingItem->quantity;
$inclusive_tax_price_per_unit = $billingItem->clinicservice->inclusive_tax_price;
$inclusive_tax_price = $inclusive_tax_price_per_unit * $quantity;
$inclusive_tax_data = json_decode($billingItem->clinicservice->inclusive_tax, true);
$service_total = $payable_Amount * $quantity;
$item_subtotal = ($payable_Amount + $inclusive_tax_price_per_unit) * $quantity;
// dd($inclusive_tax_price_per_unit);
$total_item_tax = 0;
@endphp
-
{{ __('appointment.service_price') }}
{{ Currency::format($service_total) }}
@if (!empty($inclusive_tax_data))
@foreach ($inclusive_tax_data as $t)
@if ($t['type'] == 'percent')
@php
$tax_per_unit = $payable_Amount * $t['value'] / 100 ;
$tax_total = $tax_per_unit * $quantity;
$total_item_tax += $tax_total;
@endphp
-
{{ $t['title'] }} ({{ $t['value'] }}% of {{ Currency::format($payable_Amount) }} × {{ $quantity }})
{{ Currency::format($tax_total) }}
@elseif ($t['type'] == 'fixed')
@php
$tax_total = $t['value'] * $quantity;
$total_item_tax += $tax_total;
@endphp
-
{{ $t['title'] }} ({{ Currency::format($t['value']) }} × {{ $quantity }})
{{ Currency::format($tax_total) }}
@endif
@endforeach
-
{{ __('appointment.sub_total') }}
{{ Currency::format($item_subtotal) }}
@endif
@endif --}}
@endforeach
@endif
@php
$service_total_amount = 0; // Initialize outside the loop
$total_tax = 0;
@endphp
@if ($appointment->patientEncounter !== null)
{{-- @php
dd($appointment->patientEncounter->billingrecord->billingItem);
@endphp --}}
@foreach (optional(optional($appointment->patientEncounter)->billingrecord)->billingItem as $item)
@php
$quantity = $item->quantity ?? 1;
// if (isset($item->inclusive_tax_amount) && $item->inclusive_tax_amount > 0) {
// $service_total_amount += $item->inclusive_tax_amount * $quantity;
// }
// if (!empty($item->discount_type)) {
// if ($item->discount_type === 'fixed') {
// $service_total_amount -= $item->discount_value * $quantity;
// } elseif ($item->discount_type === 'percentage') {
// $service_total_amount -= ($item->total_amount * $item->discount_value / 100);
// }
// }
$service_total_amount += $item->total_amount;
@endphp
@endforeach
@endif
{{-- @if(optional($appointment->appointmenttransaction)->inclusive_tax_price != null && $appointment->patientEncounter == null)
@php
$sub_total = $payable_Amount + $appointment->appointmenttransaction->inclusive_tax_price;
$inclusive_tax_data = json_decode($appointment->appointmenttransaction->inclusive_tax, true); // decode tax details
@endphp
{{ __('appointment.service_price') }}
{{ Currency::format($payable_Amount) }}
@if(!empty($inclusive_tax_data))
@foreach ($inclusive_tax_data as $t)
@if ($t['type'] == 'percent')
@php
$tax_amount = $payable_Amount * $t['value'] / 100 ; // for inclusive, this is reverse calculated
$total_tax += $tax_amount;
@endphp
{{ $t['title'] }} ({{ $t['value'] }}%)
{{ Currency::format($tax_amount) }}
@elseif($t['type'] == 'fixed')
@php
$tax_amount = $t['value'];
$total_tax += $tax_amount;
@endphp
{{ $t['title'] }}
{{ Currency::format($tax_amount) }}
@endif
@endforeach
{{ __('appointment.sub_total') }}
{{ Currency::format($sub_total) }}
@endif
@endif --}}