201 lines
10 KiB
PHP
201 lines
10 KiB
PHP
@php
|
||
$tabSlug = $activeTab['slug'] ?? 'summary';
|
||
$isSummaryTab = $tabSlug === 'summary';
|
||
$pageTitle = $activeTab['title'] ?? '发票数据报表';
|
||
|
||
$numericFields = [
|
||
'input_goods_amount', 'input_goods_tax', 'input_service_amount', 'input_service_tax',
|
||
'input_total_amount', 'input_total_tax',
|
||
'output_goods_amount', 'output_goods_tax', 'output_service_amount', 'output_service_tax',
|
||
'output_total_amount', 'output_total_tax',
|
||
];
|
||
|
||
if ($tabSlug === 'input') {
|
||
$displayFields = ['company_name', 'input_goods_amount', 'input_goods_tax', 'input_service_amount', 'input_service_tax', 'input_total_amount', 'input_total_tax'];
|
||
$displayHeaders = ['公司名称', '商品金额', '商品税额', '服务费金额', '服务费税额', '金额合计', '税额合计'];
|
||
} elseif ($tabSlug === 'output') {
|
||
$displayFields = ['company_name', 'output_goods_amount', 'output_goods_tax', 'output_service_amount', 'output_service_tax', 'output_total_amount', 'output_total_tax'];
|
||
$displayHeaders = ['公司名称', '商品金额', '商品税额', '服务费金额', '服务费税额', '金额合计', '税额合计'];
|
||
} else {
|
||
$displayFields = [];
|
||
$displayHeaders = [];
|
||
}
|
||
|
||
$summaryRows = $summaryRows ?? collect();
|
||
$summaryTotals = $summaryTotals ?? null;
|
||
$summaryFilters = $summaryFilters ?? ['company' => '', 'taxpayer_type' => '', 'warning' => ''];
|
||
$companyOptions = $companyOptions ?? collect();
|
||
$taxpayerTypeOptions = $taxpayerTypeOptions ?? collect();
|
||
@endphp
|
||
|
||
<div class="business-page-header">
|
||
<span class="business-page-title">{{ $pageTitle }}</span>
|
||
</div>
|
||
|
||
<div class="upstream-data-page">
|
||
@include('business.pages.partials.upstream-data-styles')
|
||
<style>
|
||
.invoice-summary-table { min-width: 64rem; }
|
||
.invoice-filter-bar { margin-top: 1rem; }
|
||
.invoice-summary-table tfoot td {
|
||
background: var(--vip-content-accent-soft, #f7f0de);
|
||
font-weight: 600;
|
||
}
|
||
.invoice-warning {
|
||
display: inline-flex;
|
||
min-width: 40px;
|
||
height: 22px;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 0 9px;
|
||
border: 1px solid var(--vip-border, #d8d2c7);
|
||
border-radius: 999px;
|
||
background: #f3f4f1;
|
||
color: var(--vip-content-muted, #595959);
|
||
font-size: 11.5px;
|
||
}
|
||
.invoice-warning.is-warning {
|
||
border-color: #e6cf9f;
|
||
background: #fdf3e3;
|
||
color: var(--vip-warning, #935f07);
|
||
font-weight: 600;
|
||
}
|
||
.invoice-summary-note {
|
||
margin: 0;
|
||
padding: 0.75rem 1rem;
|
||
border-top: 1px solid var(--vip-border, #d8d2c7);
|
||
color: var(--vip-content-muted, #595959);
|
||
font-size: 0.75rem;
|
||
}
|
||
</style>
|
||
|
||
@if ($isSummaryTab)
|
||
<form method="GET" action="{{ request()->url() }}" class="upstream-data-toolbar invoice-filter-bar" aria-label="发票情况汇总筛选">
|
||
<div class="upstream-data-field">
|
||
<label for="invoice-filter-company">公司</label>
|
||
<select id="invoice-filter-company" name="company">
|
||
<option value="">全部公司</option>
|
||
@foreach ($companyOptions as $companyName)
|
||
<option value="{{ $companyName }}" @selected($summaryFilters['company'] === $companyName)>{{ $companyName }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="upstream-data-field">
|
||
<label for="invoice-filter-taxpayer">纳税人类型</label>
|
||
<select id="invoice-filter-taxpayer" name="taxpayer_type">
|
||
<option value="">全部类型</option>
|
||
@foreach ($taxpayerTypeOptions as $taxpayerType)
|
||
<option value="{{ $taxpayerType }}" @selected($summaryFilters['taxpayer_type'] === $taxpayerType)>{{ $taxpayerType }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="upstream-data-field">
|
||
<label for="invoice-filter-warning">是否预警</label>
|
||
<select id="invoice-filter-warning" name="warning">
|
||
<option value="">全部</option>
|
||
<option value="yes" @selected($summaryFilters['warning'] === 'yes')>是</option>
|
||
<option value="no" @selected($summaryFilters['warning'] === 'no')>否</option>
|
||
</select>
|
||
</div>
|
||
<div class="upstream-data-actions">
|
||
<button type="submit" class="upstream-data-button upstream-data-button--primary">
|
||
<span class="material-icons-outlined" aria-hidden="true">search</span><span>查询</span>
|
||
</button>
|
||
<a href="{{ route('business.pages.show', ['section' => $section['slug'], 'page' => $page['slug'], 'tab' => 'summary']) }}" class="upstream-data-button">
|
||
<span class="material-icons-outlined" aria-hidden="true">refresh</span><span>重置</span>
|
||
</a>
|
||
</div>
|
||
</form>
|
||
@endif
|
||
|
||
<div class="upstream-data-table-panel">
|
||
<div class="upstream-data-table-scroll">
|
||
@if ($isSummaryTab)
|
||
<table class="upstream-data-table invoice-summary-table" aria-label="发票情况汇总">
|
||
<thead>
|
||
<tr>
|
||
<th>序号</th>
|
||
<th>公司</th>
|
||
<th>纳税人类型</th>
|
||
<th class="is-number">销项金额</th>
|
||
<th class="is-number">销项税额</th>
|
||
<th class="is-number">进项金额</th>
|
||
<th class="is-number">进项税额</th>
|
||
<th>是否预警</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@forelse ($summaryRows as $row)
|
||
@php
|
||
$ratioTitle = $row->input_output_ratio === null
|
||
? '销项金额为 0,无法计算比例'
|
||
: '进项/销项 = ' . number_format($row->input_output_ratio * 100, 1) . '%';
|
||
@endphp
|
||
<tr>
|
||
<td>{{ $loop->iteration }}</td>
|
||
<td>{{ $row->company_name }}</td>
|
||
<td>{{ $row->taxpayer_type }}</td>
|
||
<td class="is-number">{{ number_format($row->output_total_amount, 2) }}</td>
|
||
<td class="is-number">{{ number_format($row->output_total_tax, 2) }}</td>
|
||
<td class="is-number">{{ number_format($row->input_total_amount, 2) }}</td>
|
||
<td class="is-number">{{ number_format($row->input_total_tax, 2) }}</td>
|
||
<td>
|
||
<span class="invoice-warning{{ $row->is_warning ? ' is-warning' : '' }}" title="{{ $ratioTitle }}">
|
||
{{ $row->is_warning ? '是' : '否' }}
|
||
</span>
|
||
</td>
|
||
</tr>
|
||
@empty
|
||
<tr class="is-empty"><td colspan="8">暂无数据</td></tr>
|
||
@endforelse
|
||
</tbody>
|
||
@if ($summaryRows->isNotEmpty() && $summaryTotals)
|
||
<tfoot>
|
||
<tr>
|
||
<td></td>
|
||
<td>合计</td>
|
||
<td>—</td>
|
||
<td class="is-number">{{ number_format($summaryTotals->output_total_amount, 2) }}</td>
|
||
<td class="is-number">{{ number_format($summaryTotals->output_total_tax, 2) }}</td>
|
||
<td class="is-number">{{ number_format($summaryTotals->input_total_amount, 2) }}</td>
|
||
<td class="is-number">{{ number_format($summaryTotals->input_total_tax, 2) }}</td>
|
||
<td>—</td>
|
||
</tr>
|
||
</tfoot>
|
||
@endif
|
||
</table>
|
||
@else
|
||
<table class="upstream-data-table" aria-label="{{ $pageTitle }}">
|
||
<thead>
|
||
<tr>
|
||
<th>序号</th>
|
||
@foreach ($displayHeaders as $header)
|
||
<th @class(['is-number' => $loop->index > 0])>{{ $header }}</th>
|
||
@endforeach
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@forelse ($items as $item)
|
||
<tr>
|
||
<td>{{ $loop->iteration }}</td>
|
||
@foreach ($displayFields as $field)
|
||
@if ($field === 'company_name')
|
||
<td>{{ $item->$field }}</td>
|
||
@else
|
||
<td class="is-number">
|
||
{{ in_array($field, $numericFields, true) ? number_format((float) $item->$field, 2) : $item->$field }}
|
||
</td>
|
||
@endif
|
||
@endforeach
|
||
</tr>
|
||
@empty
|
||
<tr class="is-empty"><td colspan="{{ count($displayHeaders) + 1 }}">暂无数据</td></tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table>
|
||
@endif
|
||
</div>
|
||
<div class="invoice-summary-note">预警口径:进项金额 ÷ 销项金额 < 80% 时为「是」,否则为「否」;合计行不参与预警判断。</div>
|
||
</div>
|
||
</div>
|