@if(!empty($purchase->return_parent))
        
            
@lang('lang_v1.purchase_return_details'):
            @lang('lang_v1.return_date'): {{@format_date($purchase->return_parent->transaction_date)}}
            @lang('purchase.supplier'): {!! $purchase->contact->contact_address !!} 
            @lang('purchase.business_location'): {{ $purchase->location->name }}
        
        
            
@lang('purchase.purchase_details'):
            @lang('purchase.ref_no'): {{ $purchase->ref_no }} 
            @lang('messages.date'): {{@format_date($purchase->transaction_date)}}
        
        @else
            
                
@lang('lang_v1.purchase_return_details'):
                @lang('lang_v1.return_date'): {{@format_date($purchase->transaction_date)}}
                @lang('purchase.supplier'): {!! $purchase->contact->contact_address !!} 
                @lang('purchase.business_location'): {{ $purchase->location->name }}
            
        @endif
        @if(empty($purchase->return_parent))
            @if($purchase->document_path)
                
            @endif
        @endif
      
 
      
      
        
          
          
            
              
                  | # | 
                  @lang('product.product_name') | 
                  @lang('sale.unit_price') | 
                  @lang('lang_v1.return_quantity') | 
                  @lang('lang_v1.return_subtotal') | 
              
          
          
              @php
                $total_before_tax = 0;
              @endphp
              @foreach($purchase->purchase_lines as $purchase_line)
              @if($purchase_line->quantity_returned == 0)
                @continue
              @endif
              @php
                $unit_name = $purchase_line->product->unit->short_name;
                if(!empty($purchase_line->sub_unit)) {
                  $unit_name = $purchase_line->sub_unit->short_name;
                }
              @endphp
              
                  | {{ $loop->iteration }} | 
                  
                    {{ $purchase_line->product->name }}
                    @if( $purchase_line->product->type == 'variable')
                      - {{ $purchase_line->variations->product_variation->name}}
                      - {{ $purchase_line->variations->name}}
                    @endif
                   | 
                  {{ $purchase_line->purchase_price_inc_tax }} | 
                  {{@format_quantity($purchase_line->quantity_returned)}} {{$unit_name}} | 
                  
                    @php
                      $line_total = $purchase_line->purchase_price_inc_tax * $purchase_line->quantity_returned;
                      $total_before_tax += $line_total ;
                    @endphp
                    {{$line_total}}
                   | 
              
              @endforeach
            
          
       
     
    
      
        
          
            | @lang('purchase.net_total_amount'):  | 
             | 
            {{ $total_before_tax }} | 
          
          
          
            | @lang('lang_v1.total_return_tax'): | 
            (+) | 
            
                @if(!empty($purchase_taxes))
                  @foreach($purchase_taxes as $k => $v)
                    {{$k}} - {{ $v }} 
                  @endforeach
                @else
                0.00
                @endif
               | 
          
          
            | @lang('lang_v1.return_total'): | 
             | 
            {{ $purchase->return_parent->final_total ??  $purchase->final_total }} | 
          
        
       
     
    
      
            {{ __('lang_v1.activities') }}:
            @includeIf('activity_log.activities', ['activity_type' => 'sell'])