ultimatepos/Modules/Portal/Resources/views/customer/ledger/partials/content.blade.php

154 lines
8.3 KiB
PHP

@php
$periodRows = [];
if ($contact->type == 'supplier' || $contact->type == 'both') {
$periodRows[] = ['label' => __('report.total_purchase'), 'value' => $ledger_details['total_purchase']];
}
if ($contact->type == 'customer' || $contact->type == 'both') {
$periodRows[] = ['label' => __('lang_v1.total_invoice'), 'value' => $ledger_details['total_invoice']];
}
$periodRows[] = ['label' => __('sale.total_paid'), 'value' => $ledger_details['total_paid']];
if ($ledger_details['ledger_discount'] > 0) {
$periodRows[] = ['label' => __('lang_v1.ledger_discount'), 'value' => $ledger_details['ledger_discount']];
}
$overallRows = [];
if ($contact->type == 'supplier' || $contact->type == 'both') {
$overallRows[] = ['label' => __('report.total_purchase'), 'value' => $ledger_details['all_total_purchase']];
}
if ($contact->type == 'customer' || $contact->type == 'both') {
$overallRows[] = ['label' => __('lang_v1.total_invoice'), 'value' => $ledger_details['all_total_invoice']];
$overallRows[] = ['label' => __('sale.total_paid'), 'value' => $ledger_details['all_invoice_paid']];
}
if ($contact->type == 'supplier' || $contact->type == 'both') {
$overallRows[] = ['label' => __('sale.total_paid'), 'value' => $ledger_details['all_purchase_paid']];
}
@endphp
<div class="portal-ledger">
<div class="portal-stat-grid portal-ledger-stat-grid">
@if($contact->type == 'customer' || $contact->type == 'both')
<div class="portal-stat-card portal-stat-card--blue">
<div class="portal-stat-card__icon"><i class="fas fa-file-invoice"></i></div>
<div class="portal-stat-card__body">
<span class="portal-stat-card__label">@lang('lang_v1.total_invoice')</span>
<strong class="portal-stat-card__value display_currency" data-currency_symbol="true">{{ $ledger_details['all_total_invoice'] }}</strong>
</div>
</div>
<div class="portal-stat-card portal-stat-card--green">
<div class="portal-stat-card__icon"><i class="fas fa-check-circle"></i></div>
<div class="portal-stat-card__body">
<span class="portal-stat-card__label">@lang('sale.total_paid')</span>
<strong class="portal-stat-card__value display_currency" data-currency_symbol="true">{{ $ledger_details['all_invoice_paid'] }}</strong>
</div>
</div>
@endif
<div class="portal-stat-card portal-stat-card--orange">
<div class="portal-stat-card__icon"><i class="fas fa-balance-scale"></i></div>
<div class="portal-stat-card__body">
<span class="portal-stat-card__label">@lang('lang_v1.balance_due')</span>
<strong class="portal-stat-card__value display_currency" data-currency_symbol="true">{{ $ledger_details['all_balance_due'] }}</strong>
</div>
</div>
</div>
<div class="portal-ledger-summary-grid">
<div class="portal-ledger-summary-card">
<div class="portal-ledger-summary-card__head">
<h3>@lang('lang_v1.account_summary')</h3>
<span class="portal-ledger-period">{{ $ledger_details['start_date'] }} @lang('lang_v1.to') {{ $ledger_details['end_date'] }}</span>
</div>
<dl class="portal-ledger-kv">
@foreach($periodRows as $row)
<div class="portal-ledger-kv__row">
<dt>{{ $row['label'] }}</dt>
<dd class="display_currency" data-currency_symbol="true">{{ $row['value'] }}</dd>
</div>
@endforeach
</dl>
</div>
<div class="portal-ledger-summary-card portal-ledger-summary-card--accent">
<div class="portal-ledger-summary-card__head">
<h3>@lang('lang_v1.overall_summary')</h3>
</div>
<dl class="portal-ledger-kv">
@foreach($overallRows as $row)
<div class="portal-ledger-kv__row">
<dt>{{ $row['label'] }}</dt>
<dd class="display_currency" data-currency_symbol="true">{{ $row['value'] }}</dd>
</div>
@endforeach
<div class="portal-ledger-kv__row portal-ledger-kv__row--total">
<dt>@lang('lang_v1.balance_due')</dt>
<dd class="display_currency" data-currency_symbol="true">{{ $ledger_details['all_balance_due'] }}</dd>
</div>
</dl>
</div>
</div>
<div class="portal-ledger-table-card">
<div class="portal-ledger-table-card__head">
<h3>@lang('portal::lang.ledger_transactions')</h3>
<span class="portal-ledger-period">{{ $ledger_details['start_date'] }} @lang('lang_v1.to') {{ $ledger_details['end_date'] }}</span>
</div>
<div class="table-responsive">
<table class="table portal-ledger-table" id="ledger_table">
<thead>
<tr>
<th>@lang('lang_v1.date')</th>
<th>@lang('purchase.ref_no')</th>
<th>@lang('lang_v1.type')</th>
<th>@lang('sale.location')</th>
<th>@lang('sale.payment_status')</th>
<th class="text-end">@lang('account.debit')</th>
<th class="text-end">@lang('account.credit')</th>
<th>@lang('lang_v1.payment_method')</th>
<th>@lang('report.others')</th>
</tr>
</thead>
<tbody>
@forelse($ledger_details['ledger'] as $data)
@if($data['type'] == 'Opening Balance')
@continue
@endif
@php
$statusClass = '';
$statusKey = strtolower((string) ($data['payment_status'] ?? ''));
if (str_contains($statusKey, 'paid') || str_contains($statusKey, 'پرداخت')) {
$statusClass = 'portal-ledger-badge--paid';
} elseif (str_contains($statusKey, 'partial') || str_contains($statusKey, 'جز')) {
$statusClass = 'portal-ledger-badge--partial';
} elseif (!empty($data['payment_status'])) {
$statusClass = 'portal-ledger-badge--due';
}
@endphp
<tr>
<td data-label="@lang('lang_v1.date')">@format_datetime($data['date'])</td>
<td data-label="@lang('purchase.ref_no')">{{ $data['ref_no'] }}</td>
<td data-label="@lang('lang_v1.type')">{{ $data['type'] }}</td>
<td data-label="@lang('sale.location')">{{ $data['location'] }}</td>
<td data-label="@lang('sale.payment_status')">
@if(!empty($data['payment_status']))
<span class="portal-ledger-badge {{ $statusClass }}">{{ $data['payment_status'] }}</span>
@endif
</td>
<td data-label="@lang('account.debit')" class="text-end ws-nowrap">
@if($data['debit'] != '') @format_currency($data['debit']) @endif
</td>
<td data-label="@lang('account.credit')" class="text-end ws-nowrap">
@if($data['credit'] != '') @format_currency($data['credit']) @endif
</td>
<td data-label="@lang('lang_v1.payment_method')">{{ $data['payment_method'] }}</td>
<td data-label="@lang('report.others')">{!! $data['others'] !!}</td>
</tr>
@empty
<tr>
<td colspan="9" class="portal-ledger-empty">@lang('portal::lang.no_records')</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>