{!! format_organization_info() !!}

{!! format_customer_info($client, 'statement', 'billing') !!}
@lang('crm.account_summary')
{{ \Carbon\Carbon::parse($data['from'])->toDateString() }} To {{ \Carbon\Carbon::parse($data['to'])->toDateString() }}

@lang('crm.statement_beginning_balance'):
@lang('crm.invoiced_amount'):
@lang('crm.amount_paid'):
@lang('crm.balance_due'):
@php $statement = $data['statement']; @endphp
{{ app_format_money($statement['beginning_balance'], $statement['currency']) }}
{{ app_format_money($statement['invoiced_amount'], $statement['currency']) }}
{{ app_format_money($statement['amount_paid'], $statement['currency'] ) }}
{{ app_format_money($statement['balance_due'], $statement['currency']) }}

{{ vsprintf(trans('crm.customer_statement_info'), array(\Carbon\Carbon::parse($data['from'])->toDateString(), \Carbon\Carbon::parse($data['to'])->toDateString())) }}
@foreach($statement['result'] as $item) @endforeach
@lang('crm.statement_heading_date') @lang('crm.statement_heading_details') @lang('crm.statement_heading_amount') @lang('crm.statement_heading_payments') @lang('crm.statement_heading_balance')
{{ $item['date'] }} {!! $item['detail'] !!} @php if(isset($item['invoice_id'])) { echo app_format_money($item['invoice_amount'], $statement['currency'], true); } else if(isset($item['credit_note_id'])) { echo app_format_money($item['credit_note_amount'], $statement['currency'], true); } @endphp @php if(isset($item['payment_id'])) { echo app_format_money($item['payment_total'], $statement['currency'], true); } else if(isset($item['credit_note_refund_id'])) { echo app_format_money($item['refund_amount'], $statement['currency'], true); } @endphp @php $tmpBeginningBalance = 0; if(isset($item['invoice_id'])) { $tmpBeginningBalance = ($tmpBeginningBalance + $item['invoice_amount']); } else if(isset($item['payment_id'])){ $tmpBeginningBalance = ($tmpBeginningBalance - $item['payment_total']); } else if(isset($item['credit_note_id'])) { $tmpBeginningBalance = ($tmpBeginningBalance - $item['credit_note_amount']); } else if(isset($item['credit_note_refund_id'])) { $tmpBeginningBalance = ($tmpBeginningBalance + $item['refund_amount']); } if(!isset($item['credit_id'])){ echo app_format_money($tmpBeginningBalance, $statement['currency'], true); } @endphp
@lang('crm.balance_due')
{{ app_format_money($statement['balance_due'], $statement['currency']) }}