@if(isset($invoiceSettings->client_first_name))
@if( isset( $invoiceSettings ) && $invoiceSettings->logo == 1 ) @if( isset( $invoiceSettings->business_logo ) && $invoiceSettings->business_logo != "" && File::exists(public_path($invoiceSettings->business_logo))) @endif @elseif( isset( $invoiceSettings ) && $invoiceSettings->logo == 0 ) @else @if( isset($invoiceSettings->business_logo) && $invoiceSettings->business_logo != "" && File::exists(public_path($invoiceSettings->business_logo))) @endif @endif

{{$invoiceSettings->practitioner_first_name ?? ""}} {{$invoiceSettings->practitioner_last_name ?? ""}}

@if( isset( $invoiceSettings ) && $invoiceSettings->profession == 1 ) {{-- --}} @endif
@if( isset( $invoiceSettings ) && $invoiceSettings->practitioner_provider_number==1 ) @if($invoiceSettings->registartion_number)

Registration number: {{$invoiceSettings->registartion_number ?? ""}}

@endif @elseif( isset( $invoiceSettings ) && $invoiceSettings->practitioner_provider_number==0 ) @else @if($invoiceSettings->registartion_number)

Registration number: {{$invoiceSettings->registartion_number ?? ""}}

@endif @endif @if($display == 1 && isset($phf) && isset($chf))

{{$invoiceSettings->provider_name ?? ""}} {{$invoiceSettings->provider_number ?? ""}}

@endif @if($invoice->bill_to =='company' && $invoiceSettings->claim_bill_to == 1 && $invoiceSettings->claim_number !="" && $invoiceSettings->claim_number != NULL)

Claim no: {{$invoiceSettings->claim_number ?? ""}}

@endif
@if( !empty( $invoiceSettings->abn_number ) ) @endif
@php $title = isset( $is_gst_flag ) && $is_gst_flag == 'on' ? 'Tax Invoice' : 'Invoice'; @endphp

{{$title}}

ABN: {{$invoiceSettings->abn_number?? ""}}

@if( isset($invoiceSettings) && $invoiceSettings->company_name==1 )

{{$invoiceSettings->business_name ?? ""}}

@elseif( isset($invoiceSettings) && $invoiceSettings->company_name==0 ) @else

{{$invoiceSettings->business_name ?? ""}}

@endif
@if( isset( $invoiceSettings ) && $invoiceSettings->is_replace_business_address == 1 )

{{ $invoiceSettings->address1 }}

@if(!empty($invoiceSettings->address2))

{{ $invoiceSettings->address2 }}

@endif

{{ $invoiceSettings->suburb.' '.$invoiceSettings->state.' '.$invoiceSettings->postcode }}

{{ $invoiceSettings->country }}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->address == 1 )

{{ $invoiceSettings->business_address }}

@if(!empty($invoiceSettings->business_address_2))

{{ $invoiceSettings->business_address_2 }}

@endif

{{ $invoiceSettings->business_suburb.' '.$invoiceSettings->business_state.' '.$invoiceSettings->business_postcode }}

{{ $invoiceSettings->business_country }}

@endif
@if( isset($invoiceSettings) && $invoiceSettings->phone_number==1 )

{{$invoiceSettings->business_office_phone ?? ""}}

@elseif( isset($invoiceSettings) && $invoiceSettings->phone_number==0 ) @else

{{$invoiceSettings->business_office_phone ?? ""}}

@endif

@if( isset( $invoiceSettings ) && $invoiceSettings->email == 1 )

{{$invoiceSettings->business_email ?? ""}}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->email == 0 ) @else

{{$invoiceSettings->business_email ?? ""}}

@endif

@if( isset( $invoiceSettings ) && $invoiceSettings->website == 1 )

{{$invoiceSettings->business_website ?? ""}}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->website == 0 ) @else

{{$invoiceSettings->business_website ?? ""}}

@endif
@php $header_discount = 0; @endphp @if($pii) @foreach( $pii as $tid ) @php $header_discount += $tid->item_discount; @endphp @endforeach @endif @if($pip1) @foreach( $pip1 as $prod ) @php $header_discount += $prod->product_discount; @endphp @endforeach @endif @if($packagesData) @foreach( $packagesData as $package ) @php $header_discount += $package->package_discount; @endphp @endforeach @endif @if($courseData) @php $header_discount += $courseData->discount; @endphp @endif @if($paymentPlanData) @php $header_discount += $paymentPlanData->discount; @endphp @endif @if($invoiceSettings->claim_bill_to == 1 && $invoice->bill_to =='company') @endif

{{$invoiceSettings->client_first_name ?? ""}} {{$invoiceSettings->client_middle_name ?? ""}} {{$invoiceSettings->client_last_name ?? ""}}

@if( isset( $invoiceSettings ) && $invoiceSettings->client_name == 1 )

{{$invoiceSettings->client_email_text ?? ""}}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->client_name == 0 ) @else

{{$invoiceSettings->client_email_text ?? ""}}

@endif
@if( isset( $invoiceSettings ) && $invoiceSettings->client_address == 1 )

{{ ucwords( $invoiceSettings->client_address1 ) ?? ""}}

{{ ucwords( $invoiceSettings->client_address2 ) ?? ""}}

{{ ucwords( $invoiceSettings->client_suburb ) ?? ""}} {{ ucwords( $invoiceSettings->client_city ) ?? ""}} {{ ucwords( $invoiceSettings->client_postcode ) ?? ""}}

{{ ucwords( $invoiceSettings->client_country ) ?? ""}}

@elseif( isset($invoiceSettings) && $invoiceSettings->client_address==0 ) @else

{{ ucwords( $client->address ) ?? ""}}

@endif
@if( isset( $invoiceSettings ) && $invoiceSettings->client_dob == 1 )

@if(isset($invoiceSettings->client_date_of_birth)) DOB: {{\Carbon\Carbon::parse($invoiceSettings->client_date_of_birth)->format('d/m/Y')}} @else {{""}} @endif

@elseif( isset( $invoiceSettings ) && $invoiceSettings->client_dob == 0 ) @else

@if(isset($invoiceSettings->client_date_of_birth)) DOB: {{\Carbon\Carbon::parse($invoiceSettings->client_date_of_birth)->format('d/m/Y')}} @else {{""}} @endif

@endif

Bill to:

{{ $invoiceSettings->claim_company_name ?? "" }}

{{ ucwords( $invoiceSettings->claim_owner_first_name) ?? ""}} {{ ucwords( $invoiceSettings->claim_owner_last_name) ?? ""}}

{{ $invoiceSettings->claim_owner_email ?? ""}}

Invoice number: {{$invoice->invoice_number ?? ""}}
Invoice date: {{\Carbon\Carbon::parse($invoice->date)->format('d/m/y')}}
{{-- @if( isset($isDisplay) && ( count($pii) > 0 ) ) @if($isDisplay == 1) @else @endif @else @endif --}} @if($header_discount > 0) @endif {{-- @if( isset( $status ) && $status ) @endif --}} @php $total=0; $totals=0; $maintotal=0; $totalgst = 0; $totalgst1 = 0; $totalgstItem = 0; $totalgst1Item = 0; $appPrice=0; $productPrice=0; $gst_total1 = 0; $gst_total2 = 0; $gst_total3 = 0; $item_discount = 0; $gst = 0; @endphp @if( $pii ) @foreach( $pii as $tid ) @if( $tid->appointment_type ) @php $quantity = isset($tid->item_qty) ? $tid->item_qty : 1; $tid->app_cost = $tid->app_cost; $total += preg_replace("/[^0-9.]/", "", $tid->app_cost * $tid->item_qty ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $tid->app_cost * $tid->item_qty ?? 0.00); @endphp @if( $tid->is_gst == 'on' ) @php $totalgst += preg_replace("/[^0-9.]/", "", $tid->app_cost - $tid->item_discount ?? 0.00); @endphp {{-- GST FOR MULTIPLE QTY --}} @if( $tid->item_qty == 1 ) @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->app_cost ?? 0.00); @endphp @else @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->app_cost ?? 0.00)/ preg_replace("/[^0-9.]/", "", $tid->item_qty ?? 1); @endphp @endif @for( $i=1; $i<=$tid->item_qty; $i++ ) @php $totalgstItem += number_format((($appPrice - $tid->item_discount)/11),2); @endphp @endfor @else @endif @if($tid->item_discount > 0) @else @if($header_discount > 0) @endif @endif @if($tid->is_gst == "on") @php $gst_total1 += ($tid->app_cost * $quantity) - $tid->item_discount; $item_discount += $tid->item_discount; @endphp @else @php $item_discount += $tid->item_discount; @endphp @endif @endif @endforeach @endif @isset( $pip1 ) @foreach( $pip1 as $prod ) @if( $prod->product_iteams ) @php $total += preg_replace("/[^0-9.]/", "", $prod->product_cost * $prod->deduct_quantity); $totals += preg_replace("/[^0-9.]/", "", $prod->product_cost * $prod->deduct_quantity); @endphp @if( $prod->is_gst == 'on' ) @php $totalgst1 += preg_replace("/[^0-9.]/", "",$prod->product_cost - $prod->product_discount); @endphp {{-- GST FOR MULTIPLE QTY --}} @for( $i=1; $i<=$prod->deduct_quantity; $i++ ) @php $totalgst1Item += ( preg_replace("/[^0-9.]/", "",($prod->product_cost - $prod->product_discount))/11); @endphp @endfor @else @endif @if($prod->product_discount > 0) @else @if($header_discount > 0) @endif @endif @if($prod->is_gst == "on") @php $gst_total2 += ($prod->deduct_quantity * $prod->product_cost) - $prod->product_discount; $item_discount += $prod->product_discount; @endphp @else @php $item_discount += $prod->product_discount; @endphp @endif @endif @endforeach @endisset @if($packagesData) @foreach( $packagesData as $tid ) @if( $tid->package_id ) @php $quantity = isset($tid->package_quantity) ? $tid->package_quantity : 1; $tid->package_cost = $tid->package_cost; $total += preg_replace("/[^0-9.]/", "", $tid->package_cost * $tid->package_quantity ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $tid->package_cost * $tid->package_quantity ?? 0.00); @endphp @if( $tid->is_gst == 'on' ) @php $totalgst += preg_replace("/[^0-9.]/", "", $tid->package_cost - $tid->package_discount ?? 0.00); @endphp {{-- GST FOR MULTIPLE QTY --}} @if( $tid->package_quantity == 1 ) @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->package_cost ?? 0.00); @endphp @else @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->package_cost ?? 0.00)/ preg_replace("/[^0-9.]/", "", $tid->package_quantity ?? 1); @endphp @endif @for( $i=1; $i<=$tid->package_quantity; $i++ ) @php $totalgstItem += number_format((($appPrice - $tid->package_discount)/11),2); @endphp @endfor @else @endif @if($tid->package_discount > 0) @else @if($header_discount > 0) @endif @endif @if($tid->is_gst == "on") @php $gst_total1 += ($tid->package_cost * $quantity) - $tid->package_discount; $item_discount += $tid->package_discount; @endphp @else @php $item_discount += $tid->package_discount; @endphp @endif @endif @endforeach @endif @if($courseData) @if( $courseData->course_id ) @php $quantity = 1; $courseData->course_cost = $courseData->course_cost; $total += preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00); @endphp @if($courseData->is_new_takings_gst == 1) @php $totalgst += preg_replace("/[^0-9.]/", "", $courseData->course_cost - $courseData->discount ?? 0.00); $totalgstItem += number_format((($courseData->course_cost)/11),2); @endphp @else @endif @if($courseData->discount > 0) @else @if($header_discount > 0) @endif @endif @if($courseData->is_new_takings_gst == 1) @php $gst_total1 += $courseData->course_cost - $courseData->discount; $item_discount += $courseData->discount; @endphp @else @php $item_discount += $courseData->discount; @endphp @endif {{-- --}} @endif @endif @if($paymentPlanData) @if( $paymentPlanData->payment_plan_id ) @php $quantity = 1; $paymentPlanData->amount_paid = $paymentPlanData->amount_paid; $total += preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid ?? 0.00); @endphp @if($paymentPlanData->is_new_takings_gst == 1) @php $totalgst += preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid - $paymentPlanData->discount ?? 0.00); $totalgstItem += number_format((($paymentPlanData->amount_paid)/11),2); @endphp @else @endif @if($paymentPlanData->discount > 0) @else @if($header_discount > 0) @endif @endif @if($paymentPlanData->is_new_takings_gst == 1) @php $gst_total1 += $paymentPlanData->amount_paid - $paymentPlanData->discount; $item_discount += $paymentPlanData->discount; @endphp @else @php $item_discount += $paymentPlanData->discount; @endphp @endif {{-- --}} @endif @endif {{-- @if(isset($invoice) && $invoice->course_id !=0) @if($invoice->is_new_takings_gst == 1) @php $gst_total2 += $invoice->total; @endphp @else @endif @php $total = $invoice->total; $totals = $total; @endphp @endif --}}
Description Code Code Code Cost Discount GST Price
{{ ucwords( $status ) ?? "" }} Appointment - ${{number_format( $charge, 2 ) ?? '0.00'}}
* {{$tid->services_name}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif{{$tid->services_name}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif{{$tid->code}} ${{number_format(preg_replace("/[^0-9.]/", "", $tid->app_cost ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $tid->item_discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", ($tid->app_cost * $quantity) - $tid->item_discount ?? 0.00),2)}}
* @if (strlen($prod->product_name) <=72) {{$prod->product_name}} {{"x"}} {{$prod->deduct_quantity}} @else {{ substr($prod->product_name, 0, 72) }}
{{ substr($prod->product_name, 72, strlen($prod->product_name)) }} {{"x"}} {{$prod->deduct_quantity}} @endif
{{-- {{$prod->product_name}} {{"x"}} {{$prod->deduct_quantity}} --}} @if (strlen($prod->product_name) <=72) {{$prod->product_name}} {{"x"}} {{$prod->deduct_quantity}} @else {{ substr($prod->product_name, 0, 72) }}
{{ substr($prod->product_name, 72, strlen($prod->product_name)) }} {{"x"}} {{$prod->deduct_quantity}} @endif
{{$prod->product_code}} ${{number_format($prod->product_cost,2)}} ${{number_format($prod->product_discount,2)}}10%FREE ${{number_format(($prod->deduct_quantity * $prod->product_cost) - $prod->product_discount,2)}}
* {{$tid->package->package_name}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif{{$tid->package->package_name}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif ${{number_format(preg_replace("/[^0-9.]/", "", $tid->package_cost ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $tid->package_discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", ($tid->package_cost * $quantity) - $tid->package_discount ?? 0.00),2)}}
* {{$courseData->course->course_name ?? ""}} {{$courseData->course->course_name ?? ""}} ${{number_format(preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $courseData->discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00),2) ?? "0.00"}}${{number_format(preg_replace("/[^0-9.]/", "", ($courseData->course_cost) - $courseData->discount ?? 0.00),2)}}
* {{$paymentPlanData->plan_name ?? ""}} {{$paymentPlanData->plan_name ?? ""}} ${{number_format(preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $paymentPlanData->discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00),2) ?? "0.00"}}${{number_format(preg_replace("/[^0-9.]/", "", ($paymentPlanData->amount_paid) - $paymentPlanData->discount ?? 0.00),2)}}
Course purchased ${{number_format($invoice->total,2)}}10%FREE${{number_format($invoice->total,2)}}
@if( isset($invoice) && $invoice->shipping_cost != '' && $invoice->shipping_cost != '0.00' && $shipping_method == '') @if(isset($invoice) && $invoice->shipping_cost !='' && $shiping_cost == '') @php $$totals = $total; $total = $total + $invoice->shipping_cost; @endphp @endif @endif @if( isset( $shiping_cost ) && isset( $shipping_method ) && $shipping_method != '' ) @endif @if( isset( $hide3line ) ) {{-- @if($invoice->extra_amount_paid > 0) @endif --}} @if( isset( $ownedInvArr ) ) @if( count( $ownedInvArr ) > 0 ) @foreach( $ownedInvArr as $key => $value ) @endforeach @endif @endif @if( $invoice->discount != '' && $invoice->discount != '0.00') @endif @if($historyinvoice) @foreach($historyinvoice as $hi) @if( isset( $ownedInvArr ) && $hi->payment_type == 12) @if( count( $ownedInvArr ) > 0 ) @continue; @endif @endif @endforeach @endif @if(isset($oldinvoicedata)) @if($oldinvoicedata->amount_status == 'owing') @endif @endif @endif @php if($invoice->discount !='' && $invoice->discount !='0.00' && $item_discount == 0 ) { $discount_percentage = ($invoice->discount * 100) / ($total); $total_gst_amount = ($gst_total1 + $gst_total2 + $gst_total3) / 11; $gst = $total_gst_amount - (($total_gst_amount * $discount_percentage ) / 100); } else { $gst = ($gst_total1 + $gst_total2 + $gst_total3) / 11; } @endphp @if($gst != 0) @endif

@if($invoice->is_shipping_gst_on == 1)*@endif Shipping:

${{number_format( $invoice->shipping_cost, 2 ) ?? '0.00' }}

{{ $shipping_method ?? '' }}:

${{number_format( $shiping_cost, 2 ) ?? '0.00' }}

Total:

{{-- @if($charge)${{$charge ?? '0.0'}}@else --}} @php $shiping_cost = isset( $shiping_cost ) && $shiping_cost != '' ? number_format($shiping_cost, 2) : '0.00' @endphp ${{number_format($totals?? 0, 2)}} {{-- @endif --}}

Credit applied {{$invoice->created_at->timezone(getAustraliaTimeZone())->format('d/m/y')}}:

${{ $invoice->extra_amount_paid}}

Balance Inv #{{ $value['owned_invoice_id'] }}:

${{ number_format( $value['balance'], 2 ) }}

@if( $invoice->is_coupon_applied == 1 ) Coupon applied: @else Discount: @endif

@if( $invoice->is_coupon_applied == 1 )-@endif${{number_format( $invoice->discount, 2 ) ?? '0.00' }}

{{$hi->paymentType->name ?? ''}} {{$hi->created_at->format('d/m/y')}}:

@if($hi->payment_type == 12 || $hi->payment_type == 15) -@endif${{number_format($hi->paid_amount ,2) ?? '0.00'}}

Balance:

${{ number_format( $invoice->account_balance, 2 ) ?? "0.00"}}

{{$invoice->paymentType->name ?? ''}} {{$invoice->created_at->timezone(getAustraliaTimeZone())->format('d/m/y')}}:

${{ abs($oldinvoicedata->amount)}}

* Total GST:

${{ number_format( $gst,2) }}

{{-- @php if( isset( $invoice->is_new_takings_gst ) && $invoice->is_new_takings_gst == 1 ) { $gsttoprint = $total_gst_takings; } else { if( isset( $use_new_gst ) && $use_new_gst == 1 ) { $gsttoprint = number_format( $total_gst, 2 ); } else { $gsttoprint = number_format(($totalgstItem + $totalgst1Item) ,2); } } @endphp

${{$gsttoprint}}

--}}
{{-- @if( isset($invoiceSettings) && $invoiceSettings->invoice_notes == 1 ) --}} @if( $invoice->notes != '' )

{!! nl2br(e($invoice->notes)) !!}

@endif {{-- @endif --}} @if( $paymentPlanData ) @php $planDetails=App\Models\PaymentPlansPurchaseDetails::where('id', $paymentPlanData->payment_plan_purchase_id)->firstOrFail(); $currentEmi = $paymentPlanData; // this row is from PaymentPlansEmiDetails for the opened invoice $currentEmiId = $currentEmi->id; $emiDetails = App\Models\PaymentPlansEmiDetails::where('payment_plan_purchase_id', $paymentPlanData->payment_plan_purchase_id) ->orderBy('id', 'asc') ->get(); $totalEmis = $emiDetails->count(); $emisUpToCurrent = $emiDetails->filter(function ($e) use ($currentEmiId) { return $e->id <= $currentEmiId; }); $paidEmisUpToCurrent = $emisUpToCurrent->filter(function ($e) { return $e->pay_status === 'paid'; }); $paidCount = $paidEmisUpToCurrent->count(); $paidAmount = (float) $paidEmisUpToCurrent->sum('next_emi_amount'); $totalPlanAmount = (float) $emiDetails->sum('next_emi_amount'); $remainingBalanceDisplay = $currentEmi->pay_status === 'paid' ? $currentEmi->remaining_balance : ($totalPlanAmount - $paidAmount); $nextEmiDate = $emiDetails->first(function ($e) use ($currentEmiId, $currentEmi) { // Only check EMIs after the current one return $e->id > $currentEmiId; }); if ($nextEmiDate && $nextEmiDate->pay_status === 'cancelled') { $nextEmiDate = $nextEmiDate; // preserve it } // $nextEmiDate = $emiDetails->first(function ($e) use ($currentEmiId) { // return $e->id > $currentEmiId && $e->pay_status !== 'cancelled'; // }); $output = ''; if ($planDetails->is_equal_instalment == 'on') { // Equal installments case $remaining_no_of_payment = $planDetails->breakdown_no_of_payments ?? 0; $remaining_amount = (float)($planDetails->breakdown_amount ?? 0); if ($remaining_no_of_payment > 0 && $remaining_amount > 0) { $output = "{$remaining_no_of_payment} x $" . number_format($remaining_amount, 2, '.', '') . ""; } } else { // First + Remaining case $first_emi_amount = (float)($planDetails->first_amount ?? 0); $remaining_no_of_payment = $planDetails->remaining_no_of_payment ?? 0; $remaining_amount = (float)($planDetails->remaining_amount ?? 0); if ($first_emi_amount > 0 && $remaining_no_of_payment > 0 && $remaining_amount > 0) { // Compare safely by rounding both to 2 decimals if (round($first_emi_amount, 2) == round($remaining_amount, 2)) { // Merge into one total $total_count = $remaining_no_of_payment + 1; $output = "{$total_count} x $" . number_format($remaining_amount, 2, '.', '') . ""; } else { // Show first separately + remaining $output = "1 x $" . number_format($first_emi_amount, 2, '.', '') . ", " . "{$remaining_no_of_payment} x $" . number_format($remaining_amount, 2, '.', '') . ""; } } } @endphp

Payment plan summary:

Payment plan: {!! $output !!}

Next payment due: {{ $nextEmiDate ? \Carbon\Carbon::parse($nextEmiDate->next_emi_date)->format('d/m/Y') : '' }}

Remaining balance: ${{ number_format($remainingBalanceDisplay, 2, '.', '') }}

Instalments paid: {{ $paidCount ?? 0 }} / {{ $totalEmis ?? 0 }}

@endif
@else
@if( isset( $invoiceSettings ) && $invoiceSettings->logo == 1 ) @if( isset( $businessProfile->logo ) && $businessProfile->business_image!="") {{----}} @else @endif @elseif( isset( $invoiceSettings ) && $invoiceSettings->logo == 0 ) @else @if( isset( $businessProfile->logo ) && $businessProfile->business_image!="") @else @endif @endif

{{$invoice->practitioner->full_name ?? ""}}

{{-- @if( isset( $invoiceSettings ) && $invoiceSettings->profession == 1 && isset($invoiceSettings->professionData)) --}} @if( isset( $invoiceSettings ) && $invoiceSettings->profession == 1 ) @endif
@if( isset( $invoiceSettings ) && $invoiceSettings->practitioner_provider_number==1 ) @if($invoice->practitioner->registration_number)

Registration number: {{$invoice->practitioner->registration_number ?? ""}}

@endif @elseif( isset( $invoiceSettings ) && $invoiceSettings->practitioner_provider_number==0 ) @else @if($invoice->practitioner->registration_number)

Registration number: {{$invoice->practitioner->registration_number ?? ""}}

@endif @endif @if($display == 1 && isset($phf) && isset($chf))

{{$phf->healthcodes->name ?? ""}} {{$phf->provider_number ?? ""}}

@endif @if(isset($claim_details) && $invoice->bill_to =='company' && $claim_details->display_claim_details == 1 && $claim_details->claim_number !="")

Claim no: {{$claim_details->claim_number ?? ""}}

@endif
@if( !empty( $owner->bankDetail ) ) @endif
@php $title = isset( $gst_status ) && $gst_status != 0 ? 'Tax Invoice' : 'Invoice'; @endphp

{{$title}}

ABN: {{$owner->bankDetail->abn ?? ""}}

@if( isset($invoiceSettings) && $invoiceSettings->company_name==1 )

{{$businessProfile->name ?? ""}}

@elseif( isset($invoiceSettings) && $invoiceSettings->company_name==0 ) @else

{{$businessProfile->name ?? ""}}

@endif
@if( isset( $invoiceSettings ) && $invoiceSettings->is_replace_business_address == 1 )

{{ $invoiceSettings->address1 }}

@if(!empty($invoiceSettings->address2))

{{ $invoiceSettings->address2 }}

@endif

{{ $invoiceSettings->suburb.' '.$invoiceSettings->state.' '.$invoiceSettings->postcode }}

{{ $invoiceSettings->country }}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->address == 1 ) @if( isset( $appointment_location ) && $appointment_location != '')

{!! $appointment_location->address ?? "" !!}

@elseif( isset( $invoice->invoicelocation ) == 1 )

{{$invoice->invoicelocation->address ?? ""}}

@if(!empty($invoice->invoicelocation->address2))

{{ $invoice->invoicelocation->address2 }}

@endif

{{ $invoice->invoicelocation->suburb.' '.$invoice->invoicelocation->state.' '.$invoice->invoicelocation->postcode }}

{{ $invoice->invoicelocation->country }}

@else

{{$businessProfile->address ?? ""}}

@endif @endif
@if( isset($invoiceSettings) && $invoiceSettings->phone_number==1 )

{{$businessProfile->office_phone ?? ""}}

@elseif( isset($invoiceSettings) && $invoiceSettings->phone_number==0 ) @else

{{$businessProfile->office_phone ?? ""}}

@endif

@if( isset( $invoiceSettings ) && $invoiceSettings->email == 1 )

{{$businessProfile->email ?? ""}}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->email == 0 ) @else

{{$businessProfile->email ?? ""}}

@endif

@if( isset( $invoiceSettings ) && $invoiceSettings->website == 1 )

{{$businessProfile->website ?? ""}}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->website == 0 ) @else

{{$businessProfile->website ?? ""}}

@endif
@php $header_discount = 0; @endphp @if($pii) @foreach( $pii as $tid ) @php $header_discount += $tid->item_discount; @endphp @endforeach @endif @if($pip1) @foreach( $pip1 as $prod ) @php $header_discount += $prod->product_discount; @endphp @endforeach @endif @if($packagesData) @foreach( $packagesData as $package ) @php $header_discount += $package->package_discount; @endphp @endforeach @endif @if($courseData) @php $header_discount += $courseData->discount; @endphp @endif @if($paymentPlanData) @php $header_discount += $paymentPlanData->discount; @endphp @endif @if(isset($claim_details) && $claim_details->display_claim_details == 1 && $invoice->bill_to =='company') @endif

{{$client->full_name ?? ""}}

@if( isset( $invoiceSettings ) && $invoiceSettings->client_name == 1 )

{{$client->email ?? ""}}

@elseif( isset( $invoiceSettings ) && $invoiceSettings->client_name == 0 ) @else

{{$client->email ?? ""}}

@endif
@if( isset( $invoiceSettings ) && $invoiceSettings->client_address == 1 )

{{ ucwords( $client->address ) ?? ""}}

{{ ucwords( $client->address2 ) ?? ""}}

{{ ucwords( $client->suburb_state_postcode ) ?? ""}}

{{ ucwords( $client->country ) ?? ""}}

@elseif( isset($invoiceSettings) && $invoiceSettings->client_address==0 ) @else

{{ ucwords( $client->address ) ?? ""}}

@endif
@if( isset( $invoiceSettings ) && $invoiceSettings->client_dob == 1 )

@if(isset($client->date_of_birth)) DOB: {{$client->date_of_birth->format('d/m/Y')}} @else {{""}} @endif

@elseif( isset( $invoiceSettings ) && $invoiceSettings->client_dob == 0 ) @else

@if(isset($client->date_of_birth)) DOB: {{$client->date_of_birth->format('d/m/Y')}} @else {{""}} @endif

@endif

Bill to:

{{$claim_details->company_name ?? ""}}

{{$claim_details->owner_first_name ?? ""}} {{$claim_details->owner_last_name ?? ""}}

{{$claim_details->owner_email ?? ""}}

Invoice number: {{$invoice->invoice_number ?? ""}}
Invoice date: {{\Carbon\Carbon::parse($invoice->date)->format('d/m/y')}}
{{-- @if( isset($isDisplay) && ( count($pii) > 0 ) ) @if($isDisplay == 1) @else @endif @else @endif --}} @if($header_discount > 0) @endif {{-- @if( isset( $status ) && $status ) @endif --}} @php $total=0; $totals=0; $maintotal=0; $totalgst = 0; $totalgst1 = 0; $totalgstItem = 0; $totalgst1Item = 0; $appPrice=0; $productPrice=0; $gst_total1 = 0; $gst_total2 = 0; $gst_total3 = 0; $item_discount = 0; $gst = 0; @endphp @if( $pii ) @foreach( $pii as $tid ) @if( $tid->appointment_type ) @php $quantity = isset($tid->item_qty) ? $tid->item_qty : 1; $tid->app_cost = $tid->app_cost; $total += preg_replace("/[^0-9.]/", "", $tid->app_cost * $tid->item_qty ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $tid->app_cost * $tid->item_qty ?? 0.00); @endphp @if( $tid->appointment_type->is_gst == 'on' ) @php $totalgst += preg_replace("/[^0-9.]/", "", $tid->app_cost - $tid->item_discount ?? 0.00); @endphp {{-- GST FOR MULTIPLE QTY --}} @if( $tid->item_qty == 1 ) @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->app_cost ?? 0.00); @endphp @else @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->app_cost ?? 0.00)/ preg_replace("/[^0-9.]/", "", $tid->item_qty ?? 1); @endphp @endif @for( $i=1; $i<=$tid->item_qty; $i++ ) @php $totalgstItem += number_format((($appPrice - $tid->item_discount)/11),2); @endphp @endfor @else @endif @if($tid->item_discount > 0) @else @if($header_discount > 0) @endif @endif @if($tid->appointment_type->is_gst == "on") @php $gst_total1 += ($tid->app_cost * $quantity) - $tid->item_discount; $item_discount += $tid->item_discount; @endphp @else @php $item_discount += $tid->item_discount; @endphp @endif @endif @endforeach @endif @isset( $pip1 ) @foreach( $pip1 as $prod ) @if( $prod->product_iteams ) @php $total += preg_replace("/[^0-9.]/", "", $prod->product_cost * $prod->deduct_quantity); $totals += preg_replace("/[^0-9.]/", "", $prod->product_cost * $prod->deduct_quantity); @endphp @if( $prod->product_iteams->is_gst == 'on' ) @php $totalgst1 += preg_replace("/[^0-9.]/", "",$prod->product_cost - $prod->product_discount); @endphp {{-- GST FOR MULTIPLE QTY --}} @for( $i=1; $i<=$prod->deduct_quantity; $i++ ) @php $totalgst1Item += ( preg_replace("/[^0-9.]/", "",($prod->product_cost - $prod->product_discount))/11); @endphp @endfor @else @endif @if($prod->product_discount > 0) @else @if($header_discount > 0) @endif @endif @if($prod->product_iteams->is_gst == "on") @php $gst_total2 += ($prod->deduct_quantity * $prod->product_cost) - $prod->product_discount; $item_discount += $prod->product_discount; @endphp @else @php $item_discount += $prod->product_discount; @endphp @endif @endif @endforeach @endisset @if($packagesData) @foreach( $packagesData as $tid ) @if( $tid->package_id ) @php $quantity = isset($tid->package_quantity) ? $tid->package_quantity : 1; $tid->package_cost = $tid->package_cost; $total += preg_replace("/[^0-9.]/", "", $tid->package_cost * $tid->package_quantity ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $tid->package_cost * $tid->package_quantity ?? 0.00); @endphp @if( $tid->is_gst == 'on' ) @php $totalgst += preg_replace("/[^0-9.]/", "", $tid->package_cost - $tid->package_discount ?? 0.00); @endphp {{-- GST FOR MULTIPLE QTY --}} @if( $tid->package_quantity == 1 ) @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->package_cost ?? 0.00); @endphp @else @php $appPrice= preg_replace("/[^0-9.]/", "", $tid->package_cost ?? 0.00)/ preg_replace("/[^0-9.]/", "", $tid->package_quantity ?? 1); @endphp @endif @for( $i=1; $i<=$tid->package_quantity; $i++ ) @php $totalgstItem += number_format((($appPrice - $tid->package_discount)/11),2); @endphp @endfor @else @endif @if($tid->package_discount > 0) @else @if($header_discount > 0) @endif @endif @if($tid->is_gst == "on") @php $gst_total1 += ($tid->package_cost * $quantity) - $tid->package_discount; $item_discount += $tid->package_discount; @endphp @else @php $item_discount += $tid->package_discount; @endphp @endif @endif @endforeach @endif @if($courseData) @if( $courseData->course_id ) @php $quantity = 1; $courseData->course_cost = $courseData->course_cost; $total += preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00); @endphp @if($courseData->is_new_takings_gst == 1) @php $totalgst += preg_replace("/[^0-9.]/", "", $courseData->course_cost - $courseData->discount ?? 0.00); $totalgstItem += number_format((($courseData->course_cost)/11),2); @endphp @else @endif @if($courseData->discount > 0) @else @if($header_discount > 0) @endif @endif @if($courseData->is_new_takings_gst == 1) @php $gst_total1 += $courseData->course_cost - $courseData->discount; $item_discount += $courseData->discount; @endphp @else @php $item_discount += $courseData->discount; @endphp @endif @endif @endif @if($paymentPlanData) @if( $paymentPlanData->payment_plan_id ) @php $quantity = 1; $paymentPlanData->amount_paid = $paymentPlanData->amount_paid; $total += preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid ?? 0.00); $totals += preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid ?? 0.00); @endphp @if($paymentPlanData->is_new_takings_gst == 1) @php $totalgst += preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid - $paymentPlanData->discount ?? 0.00); $totalgstItem += number_format((($paymentPlanData->amount_paid)/11),2); @endphp @else @endif @if($paymentPlanData->discount > 0) @else @if($header_discount > 0) @endif @endif @if($paymentPlanData->is_new_takings_gst == 1) @php $gst_total1 += $paymentPlanData->amount_paid - $paymentPlanData->discount; $item_discount += $paymentPlanData->discount; @endphp @else @php $item_discount += $paymentPlanData->discount; @endphp @endif @endif @endif
Description Code Code Code Cost Discount GST Price
{{ ucwords( $status ) ?? "" }} Appointment - ${{number_format( $charge, 2 ) ?? '0.00'}}
* {{$tid->appointment_type->appointment_type}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif{{$tid->appointment_type->appointment_type}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif{{$tid->appointment_type->code}} ${{number_format(preg_replace("/[^0-9.]/", "", $tid->app_cost ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $tid->item_discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", ($tid->app_cost * $quantity) - $tid->item_discount ?? 0.00),2)}}
* @if (strlen($prod->product_iteams->product_name) <=72) {{$prod->product_iteams->product_name}} {{"x"}} {{$prod->deduct_quantity}} @else {{ substr($prod->product_iteams->product_name, 0, 72) }}
{{ substr($prod->product_iteams->product_name, 72, strlen($prod->product_iteams->product_name)) }} {{"x"}} {{$prod->deduct_quantity}} @endif
{{-- {{$prod->product_iteams->product_name}} {{"x"}} {{$prod->deduct_quantity}} --}} @if (strlen($prod->product_iteams->product_name) <=72) {{$prod->product_iteams->product_name}} {{"x"}} {{$prod->deduct_quantity}} @else {{ substr($prod->product_iteams->product_name, 0, 72) }}
{{ substr($prod->product_iteams->product_name, 72, strlen($prod->product_iteams->product_name)) }} {{"x"}} {{$prod->deduct_quantity}} @endif
{{$prod->product_iteams->product_code}} ${{number_format($prod->product_cost,2)}} ${{number_format($prod->product_discount,2)}}10%FREE ${{number_format(($prod->deduct_quantity * $prod->product_cost) - $prod->product_discount,2)}}
* {{$tid->package->package_name}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif{{$tid->package->package_name}} @if($quantity > 1) {{"x"}} {{ $quantity }}@endif ${{number_format(preg_replace("/[^0-9.]/", "", $tid->package_cost ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $tid->package_discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", ($tid->package_cost * $quantity) - $tid->package_discount ?? 0.00),2)}}
* {{$courseData->course->course_name ?? ""}} {{$courseData->course->course_name ?? ""}} ${{number_format(preg_replace("/[^0-9.]/", "", $courseData->course_cost ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $courseData->discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", ($courseData->course_cost) - $courseData->discount ?? 0.00),2)}}
* {{$paymentPlanData->plan_name ?? ""}} {{$$paymentPlanData->plan_name ?? ""}} ${{number_format(preg_replace("/[^0-9.]/", "", $paymentPlanData->amount_paid ?? 0.00),2)}}${{number_format(preg_replace("/[^0-9.]/", "", $paymentPlanData->discount ?? 0.00),2)}}10%FREE${{number_format(preg_replace("/[^0-9.]/", "", ($paymentPlanData->amount_paid) - $paymentPlanData->discount ?? 0.00),2)}}
@if( isset($invoice) && $invoice->shipping_cost != '' && $invoice->shipping_cost != '0.00' && $shipping_method == '') @if(isset($invoice) && $invoice->shipping_cost !='' && $shiping_cost == '') @php $$totals = $total; $total = $total + $invoice->shipping_cost; @endphp @endif @endif @if( isset( $shiping_cost ) && isset( $shipping_method ) && $shipping_method != '' ) @endif @if( isset( $hide3line ) ) {{-- @if($invoice->extra_amount_paid > 0) @endif --}} @if( isset( $ownedInvArr ) ) @if( count( $ownedInvArr ) > 0 ) @foreach( $ownedInvArr as $key => $value ) @endforeach @endif @endif @if( $invoice->discount != '' && $invoice->discount != '0.00') @endif @if($historyinvoice) @foreach($historyinvoice as $hi) @if( isset( $ownedInvArr ) && $hi->payment_type == 12) @if( count( $ownedInvArr ) > 0 ) @continue; @endif @endif @endforeach @endif @if(isset($oldinvoicedata)) @if($oldinvoicedata->amount_status == 'owing') @endif @endif @endif @php if($invoice->discount !='' && $invoice->discount !='0.00' && $item_discount == 0 ) { $discount_percentage = ($invoice->discount * 100) / ($total); $total_gst_amount = ($gst_total1 + $gst_total2 + $gst_total3) / 11; $gst = $total_gst_amount - (($total_gst_amount * $discount_percentage ) / 100); } else { $gst = ($gst_total1 + $gst_total2 + $gst_total3) / 11; } @endphp @if($gst != 0) @endif

@if($invoice->is_shipping_gst_on == 1)*@endif Shipping:

${{number_format( $invoice->shipping_cost, 2 ) ?? '0.00' }}

{{ $shipping_method ?? '' }}:

${{number_format( $shiping_cost, 2 ) ?? '0.00' }}

Total:

{{-- @if($charge)${{$charge ?? '0.0'}}@else --}} @php $shiping_cost = isset( $shiping_cost ) && $shiping_cost != '' ? number_format($shiping_cost, 2) : '0.00' @endphp ${{number_format($totals?? 0, 2)}} {{-- @endif --}}

Credit applied {{$invoice->created_at->timezone(getAustraliaTimeZone())->format('d/m/y')}}:

${{ $invoice->extra_amount_paid}}

Balance Inv #{{ $value['owned_invoice_id'] }}:

${{ number_format( $value['balance'], 2 ) }}

@if( $invoice->is_coupon_applied == 1 ) Coupon applied: @else Discount: @endif

@if( $invoice->is_coupon_applied == 1 )-@endif${{number_format( $invoice->discount, 2 ) ?? '0.00' }}

{{$hi->paymentType->name ?? ''}} {{$hi->created_at->format('d/m/y')}}:

@if($hi->payment_type == 12 || $hi->payment_type == 15) -@endif${{number_format($hi->paid_amount ,2) ?? '0.00'}}

Balance:

${{ number_format( $invoice->account_balance, 2 ) ?? "0.00"}}

{{$invoice->paymentType->name ?? ''}} {{$invoice->created_at->timezone(getAustraliaTimeZone())->format('d/m/y')}}:

${{ abs($oldinvoicedata->amount)}}

* Total GST:

${{ number_format( $gst,2) }}

{{-- @php if( isset( $invoice->is_new_takings_gst ) && $invoice->is_new_takings_gst == 1 ) { $gsttoprint = $total_gst_takings; } else { if( isset( $use_new_gst ) && $use_new_gst == 1 ) { $gsttoprint = number_format( $total_gst, 2 ); } else { $gsttoprint = number_format(($totalgstItem + $totalgst1Item) ,2); } } @endphp

${{$gsttoprint}}

--}}
{{-- @if( isset($invoiceSettings) && $invoiceSettings->invoice_notes == 1 ) --}} @if( $invoice->notes != '' )

{!! nl2br(e($invoice->notes)) !!}

@endif {{-- @endif --}} @if( $paymentPlanData ) @php $planDetails=App\Models\PaymentPlansPurchaseDetails::where('id', $paymentPlanData->payment_plan_purchase_id)->firstOrFail(); $currentEmi = $paymentPlanData; // this row is from PaymentPlansEmiDetails for the opened invoice $currentEmiId = $currentEmi->id; $emiDetails = App\Models\PaymentPlansEmiDetails::where('payment_plan_purchase_id', $paymentPlanData->payment_plan_purchase_id) ->orderBy('id', 'asc') ->get(); $totalEmis = $emiDetails->count(); $emisUpToCurrent = $emiDetails->filter(function ($e) use ($currentEmiId) { return $e->id <= $currentEmiId; }); $paidEmisUpToCurrent = $emisUpToCurrent->filter(function ($e) { return $e->pay_status === 'paid'; }); $paidCount = $paidEmisUpToCurrent->count(); $paidAmount = (float) $paidEmisUpToCurrent->sum('next_emi_amount'); $totalPlanAmount = (float) $emiDetails->sum('next_emi_amount'); $remainingBalanceDisplay = $currentEmi->pay_status === 'paid' ? $currentEmi->remaining_balance : ($totalPlanAmount - $paidAmount); $nextEmiDate = $emiDetails->first(function ($e) use ($currentEmiId, $currentEmi) { // Only check EMIs after the current one return $e->id > $currentEmiId; }); if ($nextEmiDate && $nextEmiDate->pay_status === 'cancelled') { $nextEmiDate = $nextEmiDate; // preserve it } // $nextEmiDate = $emiDetails->first(function ($e) use ($currentEmiId) { // return $e->id > $currentEmiId && $e->pay_status !== 'cancelled'; // }); $output = ''; if ($planDetails->is_equal_instalment == 'on') { // Equal installments case $remaining_no_of_payment = $planDetails->breakdown_no_of_payments ?? 0; $remaining_amount = (float)($planDetails->breakdown_amount ?? 0); if ($remaining_no_of_payment > 0 && $remaining_amount > 0) { $output = "{$remaining_no_of_payment} x $" . number_format($remaining_amount, 2, '.', '') . ""; } } else { // First + Remaining case $first_emi_amount = (float)($planDetails->first_amount ?? 0); $remaining_no_of_payment = $planDetails->remaining_no_of_payment ?? 0; $remaining_amount = (float)($planDetails->remaining_amount ?? 0); if ($first_emi_amount > 0 && $remaining_no_of_payment > 0 && $remaining_amount > 0) { // Compare safely by rounding both to 2 decimals if (round($first_emi_amount, 2) == round($remaining_amount, 2)) { // Merge into one total $total_count = $remaining_no_of_payment + 1; $output = "{$total_count} x $" . number_format($remaining_amount, 2, '.', '') . ""; } else { // Show first separately + remaining $output = "1 x $" . number_format($first_emi_amount, 2, '.', '') . ", " . "{$remaining_no_of_payment} x $" . number_format($remaining_amount, 2, '.', '') . ""; } } } @endphp

Payment plan summary:

Payment plan: {!! $output !!}

Next payment due: {{ $nextEmiDate ? \Carbon\Carbon::parse($nextEmiDate->next_emi_date)->format('d/m/Y') : '' }}

Remaining balance: ${{ number_format($remainingBalanceDisplay, 2, '.', '') }}

Instalments paid: {{ $paidCount ?? 0 }} / {{ $totalEmis ?? 0 }}

@endif
@endif