@lang( 'purchase.add_payment' )
@if(!empty($transaction->contact))
@endif
@php
// Get total sell return amount for this transaction
$sell_return_total = \App\Transaction::where('return_parent_id', $transaction->id)
->where('type', 'sell_return')
->sum('final_total');
// Calculate net total after returns
$net_total = $transaction->final_total - $sell_return_total;
@endphp
@if(in_array($transaction->type, ['purchase', 'purchase_return']))
@lang('purchase.supplier')
@elseif(in_array($transaction->type, ['sell', 'sell_return']))
@lang('contact.customer')
@endif
:{{ $transaction->contact->full_name_with_business }}
@lang('business.business'): {{ $transaction->contact->supplier_business_name }}
@lang('business.business'): {{ $transaction->contact->supplier_business_name }}
@if(in_array($transaction->type, ['sell', 'sell_return']))
@lang('sale.invoice_no'): {{ $transaction->invoice_no }}
@else
@lang('purchase.ref_no'): {{ $transaction->ref_no }}
@endif
@if(!empty($transaction->location))
@lang('purchase.location'): {{ $transaction->location->name }} @endif
@lang('purchase.location'): {{ $transaction->location->name }} @endif
@lang('sale.total_amount'):
@if($sell_return_total > 0)
@format_currency($net_total)
@else
@format_currency($transaction->final_total)
@endif
@lang('purchase.payment_note'): @if(!empty($transaction->additional_notes)) {{ $transaction->additional_notes }} @else -- @endif
@lang('purchase.payment_note'): @if(!empty($transaction->additional_notes)) {{ $transaction->additional_notes }} @else -- @endif
@if(!empty($transaction->contact))
@lang('lang_v1.advance_balance'): {{$transaction->contact->balance}}
{!! Form::hidden('advance_balance', $transaction->contact->balance, ['id' => 'advance_balance', 'data-error-msg' => __('lang_v1.required_advance_balance_not_available')]); !!}
@endif
{!! Form::label("method" , __('purchase.payment_method') . ':*') !!}
{!! Form::select("method", $payment_types, $payment_line->method, ['class' => 'form-control select2 payment_types_dropdown', 'required', 'style' => 'width:100%;', 'id' => 'payment_method_select']); !!}
{!! Form::label("paid_on" , __('lang_v1.paid_on') . ':*') !!}
{!! Form::text('paid_on', @format_datetime($payment_line->paid_on), ['class' => 'form-control', 'readonly', 'required']); !!}
{!! Form::label("amount" , __('sale.amount') . ':*') !!}
{!! Form::text("amount", @num_format($payment_line->amount), ['class' => 'form-control input_number payment_amount', 'required', 'placeholder' => 'Amount', 'data-rule-max-value' => $payment_line->amount, 'data-msg-max-value' => __('lang_v1.max_amount_to_be_paid_is', ['amount' => $amount_formated])]); !!}
{!! Form::label("account_id" , __('lang_v1.payment_account') . ':') !!}
{!! Form::select("account_id", $accounts, !empty ($payment_line->account_id) ? $payment_line->account_id : '' , ['class' => 'form-control select2', 'id' => "account_id", 'style' => 'width:100%;']); !!}
{!! Form::label('document', __('purchase.attach_document') . ':') !!}
{!! Form::file('document', ['accept' => implode(',', array_keys(config('constants.document_upload_mimes_types')))]); !!}
@includeIf('components.document_help_text')
{!! Form::label("note", __('lang_v1.payment_note') . ':') !!}
{!! Form::textarea("note", $payment_line->note, ['class' => 'form-control', 'rows' => 3]); !!}