feat(财务台账): 增加银行账单页与余额联动
新增银行账单独立页面与银行原始账单存储,账户总览余额可联动到对应账号账单。
This commit is contained in:
parent
1e02737f92
commit
d2d58276fb
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
private function connection(): string
|
||||
{
|
||||
return (string) config('upstream_mirrors.connection', 'business_mirror');
|
||||
}
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection($this->connection());
|
||||
if ($schema->hasTable('fin_bank_direct_bills')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$schema->create('fin_bank_direct_bills', function (Blueprint $table): void {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('bank_name', 80);
|
||||
$table->unsignedBigInteger('finance_account_id')->nullable();
|
||||
$table->string('company_name', 100)->nullable();
|
||||
$table->string('account_short', 100);
|
||||
$table->string('account_no', 64);
|
||||
$table->date('txn_date');
|
||||
$table->timestamp('txn_at')->nullable();
|
||||
$table->string('record_code', 128)->nullable();
|
||||
$table->string('counterparty_name', 255)->nullable();
|
||||
$table->string('counterparty_account', 100)->nullable();
|
||||
$table->string('counterparty_bank', 100)->nullable();
|
||||
$table->text('detail')->nullable();
|
||||
$table->text('payment_remark')->nullable();
|
||||
$table->decimal('income', 18, 2)->default(0);
|
||||
$table->decimal('expense', 18, 2)->default(0);
|
||||
$table->decimal('balance', 18, 2)->nullable();
|
||||
$table->string('currency', 16)->default('人民币');
|
||||
$table->string('source', 32)->default('bank-direct');
|
||||
$table->string('source_file_name', 255)->nullable();
|
||||
$table->char('source_file_sha256', 64)->nullable();
|
||||
$table->char('row_key', 64)->unique('fin_bank_direct_bill_row_key_unique');
|
||||
$table->timestamp('imported_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['bank_name', 'txn_date'], 'fin_bank_direct_bill_bank_date_index');
|
||||
$table->index(['account_no', 'txn_date'], 'fin_bank_direct_bill_account_date_index');
|
||||
$table->index('account_short', 'fin_bank_direct_bill_account_short_index');
|
||||
$table->index('imported_at', 'fin_bank_direct_bill_imported_index');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection($this->connection())->dropIfExists('fin_bank_direct_bills');
|
||||
}
|
||||
};
|
||||
160
modules/EcommerceFinance/View/BankBillPageData.php
Normal file
160
modules/EcommerceFinance/View/BankBillPageData.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\EcommerceFinance\View;
|
||||
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class BankBillPageData
|
||||
{
|
||||
private const TABLE = 'fin_bank_direct_bills';
|
||||
|
||||
private const PER_PAGE = 100;
|
||||
|
||||
public function page(): array
|
||||
{
|
||||
$filters = $this->filters();
|
||||
$query = DB::connection((string) config('upstream_mirrors.connection', 'business_mirror'))
|
||||
->table(self::TABLE);
|
||||
|
||||
if ($filters['from'] !== '') {
|
||||
$query->where('txn_date', '>=', $filters['from']);
|
||||
}
|
||||
if ($filters['to'] !== '') {
|
||||
$query->where('txn_date', '<=', $filters['to']);
|
||||
}
|
||||
if ($filters['bank'] !== 'all') {
|
||||
$query->where('bank_name', $filters['bank']);
|
||||
}
|
||||
if ($filters['account_no'] !== '') {
|
||||
$query->where('account_no', $filters['account_no']);
|
||||
}
|
||||
if ($filters['search'] !== '') {
|
||||
$search = $filters['search'];
|
||||
$query->where(function ($builder) use ($search): void {
|
||||
foreach ([
|
||||
'company_name',
|
||||
'account_short',
|
||||
'account_no',
|
||||
'counterparty_name',
|
||||
'counterparty_account',
|
||||
'counterparty_bank',
|
||||
'detail',
|
||||
'payment_remark',
|
||||
'record_code',
|
||||
] as $column) {
|
||||
$builder->orWhere($column, 'like', '%' . $search . '%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$summaryQuery = clone $query;
|
||||
$summary = [
|
||||
'count' => (int) (clone $summaryQuery)->count(),
|
||||
'income' => round((float) (clone $summaryQuery)->sum('income'), 2),
|
||||
'expense' => round((float) (clone $summaryQuery)->sum('expense'), 2),
|
||||
'latest_imported_at' => (clone $summaryQuery)->max('imported_at'),
|
||||
];
|
||||
|
||||
$page = min(
|
||||
max(1, (int) request('bills_page', 1)),
|
||||
max(1, (int) ceil($summary['count'] / self::PER_PAGE)),
|
||||
);
|
||||
$rows = (clone $query)
|
||||
->orderByDesc('txn_date')
|
||||
->orderByDesc('txn_at')
|
||||
->orderByDesc('id')
|
||||
->forPage($page, self::PER_PAGE)
|
||||
->get();
|
||||
$paginator = new LengthAwarePaginator(
|
||||
$rows->values()->all(),
|
||||
$summary['count'],
|
||||
self::PER_PAGE,
|
||||
$page,
|
||||
['path' => request()->url(), 'query' => request()->query()],
|
||||
);
|
||||
$paginator->setPageName('bills_page');
|
||||
|
||||
return [
|
||||
'filters' => $filters,
|
||||
'period' => ['from' => $filters['from'], 'to' => $filters['to']],
|
||||
'summary' => $summary,
|
||||
'page' => $paginator,
|
||||
'bankOptions' => $this->bankOptions(),
|
||||
'accountOptions' => $this->accountOptions($filters['bank']),
|
||||
];
|
||||
}
|
||||
|
||||
private function filters(): array
|
||||
{
|
||||
$defaultFrom = now()->startOfMonth()->toDateString();
|
||||
$defaultTo = now()->endOfMonth()->toDateString();
|
||||
$from = $this->date((string) request('bills_from', '')) ?? $defaultFrom;
|
||||
$to = $this->date((string) request('bills_to', '')) ?? $defaultTo;
|
||||
if ($from > $to) {
|
||||
[$from, $to] = [$to, $from];
|
||||
}
|
||||
|
||||
return [
|
||||
'from' => $from,
|
||||
'to' => $to,
|
||||
'bank' => trim((string) request('bills_bank', 'all')) ?: 'all',
|
||||
'account_no' => preg_replace('/\D+/', '', (string) request('bills_account_no', '')) ?? '',
|
||||
'search' => trim((string) request('bills_search', '')),
|
||||
];
|
||||
}
|
||||
|
||||
private function date(string $value): ?string
|
||||
{
|
||||
if ($value === '') {
|
||||
return null;
|
||||
}
|
||||
$date = \DateTimeImmutable::createFromFormat('!Y-m-d', $value);
|
||||
|
||||
return $date !== false && $date->format('Y-m-d') === $value ? $value : null;
|
||||
}
|
||||
|
||||
private function bankOptions(): array
|
||||
{
|
||||
return DB::connection((string) config('upstream_mirrors.connection', 'business_mirror'))
|
||||
->table(self::TABLE)
|
||||
->whereNotNull('bank_name')
|
||||
->where('bank_name', '<>', '')
|
||||
->distinct()
|
||||
->orderBy('bank_name')
|
||||
->pluck('bank_name')
|
||||
->map(static fn (mixed $value): string => trim((string) $value))
|
||||
->filter()
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
private function accountOptions(string $bank): array
|
||||
{
|
||||
$query = DB::connection((string) config('upstream_mirrors.connection', 'business_mirror'))
|
||||
->table(self::TABLE)
|
||||
->select(['bank_name', 'company_name', 'account_short', 'account_no'])
|
||||
->distinct();
|
||||
if ($bank !== 'all') {
|
||||
$query->where('bank_name', $bank);
|
||||
}
|
||||
|
||||
return $query
|
||||
->orderBy('bank_name')
|
||||
->orderBy('account_short')
|
||||
->get()
|
||||
->map(static fn (object $row): array => [
|
||||
'bank_name' => (string) $row->bank_name,
|
||||
'company_name' => (string) ($row->company_name ?? ''),
|
||||
'account_short' => (string) $row->account_short,
|
||||
'account_no' => (string) $row->account_no,
|
||||
'label' => trim(implode(' · ', array_filter([
|
||||
(string) $row->account_short,
|
||||
(string) $row->account_no,
|
||||
(string) ($row->company_name ?? ''),
|
||||
]))),
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ class FinanceLedgerPageData
|
||||
public const TABS = [
|
||||
'accounts' => ['title' => '账户总表', 'icon' => 'account_balance'],
|
||||
'overview' => ['title' => '账户总览', 'icon' => 'account_balance'],
|
||||
'bills' => ['title' => '银行账单', 'icon' => 'receipt_long'],
|
||||
'shops' => ['title' => '店铺台账', 'icon' => 'storefront'],
|
||||
'transactions' => ['title' => '动账明细', 'icon' => 'receipt_long'],
|
||||
'mapping' => ['title' => '账户映射', 'icon' => 'alt_route'],
|
||||
@ -138,6 +139,7 @@ class FinanceLedgerPageData
|
||||
private readonly FinanceLedgerShopDirectory $shopDirectory,
|
||||
private readonly JushuitanShopBalanceRepository $shopBalances,
|
||||
private readonly NonStoreAccountMonitorPageData $nonStoreAccountMonitor,
|
||||
private readonly BankBillPageData $bankBills,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -192,6 +194,7 @@ class FinanceLedgerPageData
|
||||
'ledgerTab' => $tab,
|
||||
'ledgerTabs' => array_diff_key(self::TABS, self::HIDDEN_TABS),
|
||||
'ledgerOverview' => $ledgerOverview,
|
||||
'ledgerBankBills' => $this->bankBills->page(),
|
||||
'ledgerOpeningDate' => $openingDate,
|
||||
'ledgerAccountView' => $accountView,
|
||||
'ledgerAccounts' => $accounts['rows'],
|
||||
|
||||
@ -1108,6 +1108,11 @@
|
||||
@endif
|
||||
</section>
|
||||
|
||||
{{-- 银行账单 --}}
|
||||
<section class="ledger-panel" id="ledger-panel-bills" role="tabpanel" data-ledger-panel="bills" @if ($activeTab !== 'bills') hidden @endif>
|
||||
@include('business.pages.financial-ledger.partials.bank-bills-panel', $ledgerBankBills)
|
||||
</section>
|
||||
|
||||
{{-- 账户总表 --}}
|
||||
<section class="ledger-panel" id="ledger-panel-accounts" role="tabpanel" data-ledger-panel="accounts" @if ($activeTab !== 'accounts') hidden @endif>
|
||||
@if ($standaloneAccountView === 'wangshang' && session('success'))
|
||||
|
||||
@ -0,0 +1,360 @@
|
||||
@php
|
||||
$money = static fn ($value): string => number_format((float) $value, 2, '.', ',');
|
||||
@endphp
|
||||
|
||||
<style>
|
||||
.bank-bills {
|
||||
--bb-border: var(--vip-border, #D8D2C7);
|
||||
--bb-muted: var(--vip-content-muted, #595959);
|
||||
--bb-soft: var(--vip-content-accent-soft, #F7F0DE);
|
||||
--bb-accent: var(--vip-content-accent-dark, #856632);
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-family: "JetBrains Mono", "CaiWu CJK", monospace;
|
||||
}
|
||||
|
||||
.bank-bills * { box-sizing: border-box; }
|
||||
.bank-bills__head,
|
||||
.bank-bills__summary,
|
||||
.bank-bills__filters,
|
||||
.bank-bills__table-panel {
|
||||
border: 1px solid var(--bb-border);
|
||||
border-radius: .75rem;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.bank-bills__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.15rem;
|
||||
}
|
||||
|
||||
.bank-bills__head h2 {
|
||||
margin: 0;
|
||||
font-size: .875rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.bank-bills__head p {
|
||||
margin: .35rem 0 0;
|
||||
color: var(--bb-muted);
|
||||
font-size: .72rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.bank-bills__sync {
|
||||
flex: 0 0 auto;
|
||||
color: var(--bb-muted);
|
||||
font-size: .68rem;
|
||||
}
|
||||
|
||||
.bank-bills__summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bank-bills__metric {
|
||||
display: grid;
|
||||
gap: .35rem;
|
||||
padding: .9rem 1rem;
|
||||
border-right: 1px solid #ece7de;
|
||||
}
|
||||
|
||||
.bank-bills__metric:last-child { border-right: 0; }
|
||||
.bank-bills__metric span { color: var(--bb-muted); font-size: .68rem; }
|
||||
.bank-bills__metric strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
|
||||
|
||||
.bank-bills__filters {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(11rem, 1.1fr) minmax(12rem, 1.35fr) minmax(15rem, 1.5fr) minmax(9rem, .8fr);
|
||||
gap: .75rem;
|
||||
padding: .9rem 1rem;
|
||||
}
|
||||
|
||||
.bank-bills__field {
|
||||
display: grid;
|
||||
gap: .3rem;
|
||||
min-width: 0;
|
||||
color: var(--bb-muted);
|
||||
font-size: .68rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.bank-bills__field input,
|
||||
.bank-bills__field select {
|
||||
width: 100%;
|
||||
height: 2.15rem;
|
||||
padding: 0 .55rem;
|
||||
border: 1px solid var(--bb-border);
|
||||
border-radius: .45rem;
|
||||
background: #fff;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font: inherit;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.bank-bills__period {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: .35rem;
|
||||
}
|
||||
|
||||
.bank-bills__actions {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
.bank-bills__btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: .3rem;
|
||||
min-height: 2.15rem;
|
||||
padding: 0 .85rem;
|
||||
border: 1px solid var(--bb-border);
|
||||
border-radius: .45rem;
|
||||
background: #fff;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font: inherit;
|
||||
font-size: .7rem;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bank-bills__btn--primary {
|
||||
border-color: var(--bb-accent);
|
||||
background: var(--bb-accent);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.bank-bills__table-panel { overflow: hidden; }
|
||||
|
||||
.bank-bills__table-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: .85rem 1rem;
|
||||
border-bottom: 1px solid #ece7de;
|
||||
}
|
||||
|
||||
.bank-bills__table-head strong { font-size: .78rem; }
|
||||
.bank-bills__table-head span { color: var(--bb-muted); font-size: .68rem; }
|
||||
.bank-bills__scroll { width: 100%; overflow: auto; }
|
||||
|
||||
.bank-bills__table {
|
||||
width: 100%;
|
||||
min-width: 86rem;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.bank-bills__table th,
|
||||
.bank-bills__table td {
|
||||
padding: .58rem .62rem;
|
||||
border-bottom: 1px solid #eee9df;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bank-bills__table th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
background: var(--bb-soft);
|
||||
color: #3b352d;
|
||||
font-size: .68rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.bank-bills__table td {
|
||||
max-width: 18rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: .7rem;
|
||||
}
|
||||
|
||||
.bank-bills__table .num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.bank-bills__table tbody tr:hover td { background: #fcfaf5; }
|
||||
|
||||
.bank-bills__empty {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
gap: .5rem;
|
||||
min-height: 12rem;
|
||||
color: var(--bb-muted);
|
||||
font-size: .72rem;
|
||||
}
|
||||
|
||||
.bank-bills__pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: .75rem 1rem;
|
||||
color: var(--bb-muted);
|
||||
font-size: .68rem;
|
||||
}
|
||||
|
||||
.bank-bills__pagination-links {
|
||||
display: flex;
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.bank-bills__summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.bank-bills__filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.bank-bills__summary,
|
||||
.bank-bills__filters { grid-template-columns: minmax(0, 1fr); }
|
||||
.bank-bills__metric { border-right: 0; border-bottom: 1px solid #ece7de; }
|
||||
.bank-bills__actions { justify-content: flex-start; flex-wrap: wrap; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="bank-bills">
|
||||
<header class="bank-bills__head">
|
||||
<div>
|
||||
<h2>银行账单</h2>
|
||||
<p>集中查看银企直连自动下载的招商银行、华夏银行原始账单。账单只用于查看、导出和月度核对,不参与当前余额计算。</p>
|
||||
</div>
|
||||
<span class="bank-bills__sync">
|
||||
最近下载:{{ $summary['latest_imported_at'] ? $summary['latest_imported_at'] : '暂无' }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<section class="bank-bills__summary" aria-label="银行账单汇总">
|
||||
<div class="bank-bills__metric"><span>账单笔数</span><strong>{{ number_format((int) $summary['count']) }}</strong></div>
|
||||
<div class="bank-bills__metric"><span>收入合计</span><strong>{{ $money($summary['income']) }}</strong></div>
|
||||
<div class="bank-bills__metric"><span>支出合计</span><strong>{{ $money($summary['expense']) }}</strong></div>
|
||||
<div class="bank-bills__metric"><span>筛选区间</span><strong>{{ $period['from'] }} 至 {{ $period['to'] }}</strong></div>
|
||||
</section>
|
||||
|
||||
<form class="bank-bills__filters" method="GET" action="{{ url()->current() }}">
|
||||
<input type="hidden" name="tab" value="bills">
|
||||
<label class="bank-bills__field">
|
||||
银行
|
||||
<select name="bills_bank">
|
||||
<option value="all" @selected($filters['bank'] === 'all')>全部银行</option>
|
||||
@foreach ($bankOptions as $bank)
|
||||
<option value="{{ $bank }}" @selected($filters['bank'] === $bank)>{{ $bank }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
<label class="bank-bills__field">
|
||||
账户
|
||||
<select name="bills_account_no">
|
||||
<option value="">全部账户</option>
|
||||
@foreach ($accountOptions as $account)
|
||||
<option value="{{ $account['account_no'] }}" @selected($filters['account_no'] === $account['account_no'])>
|
||||
{{ $account['label'] }}
|
||||
</option>
|
||||
@endforeach
|
||||
@if ($filters['account_no'] !== '' && collect($accountOptions)->every(fn ($account) => $account['account_no'] !== $filters['account_no']))
|
||||
<option value="{{ $filters['account_no'] }}" selected>账号 {{ $filters['account_no'] }}</option>
|
||||
@endif
|
||||
</select>
|
||||
</label>
|
||||
<div class="bank-bills__field">
|
||||
账务日期
|
||||
<div class="bank-bills__period">
|
||||
<input type="date" name="bills_from" value="{{ $filters['from'] }}">
|
||||
<span>至</span>
|
||||
<input type="date" name="bills_to" value="{{ $filters['to'] }}">
|
||||
</div>
|
||||
</div>
|
||||
<label class="bank-bills__field">
|
||||
关键词
|
||||
<input name="bills_search" value="{{ $filters['search'] }}" placeholder="公司、账户、对方、摘要">
|
||||
</label>
|
||||
<div class="bank-bills__actions">
|
||||
<a class="bank-bills__btn" href="{{ url()->current() }}?tab=bills">重置</a>
|
||||
<button class="bank-bills__btn bank-bills__btn--primary" type="submit">
|
||||
<span class="material-icons-outlined" aria-hidden="true">search</span>
|
||||
查询
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<section class="bank-bills__table-panel">
|
||||
<header class="bank-bills__table-head">
|
||||
<strong>账单明细</strong>
|
||||
<span>共 {{ number_format($page->total()) }} 条,单页 {{ $page->perPage() }} 条</span>
|
||||
</header>
|
||||
@if ($page->isEmpty())
|
||||
<div class="bank-bills__empty">
|
||||
<span class="material-icons-outlined" aria-hidden="true">receipt_long</span>
|
||||
<span>当前筛选条件下暂无已下载的银行账单。</span>
|
||||
</div>
|
||||
@else
|
||||
<div class="bank-bills__scroll">
|
||||
<table class="bank-bills__table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>账务时间</th>
|
||||
<th>银行</th>
|
||||
<th>公司名称</th>
|
||||
<th>账户简称</th>
|
||||
<th>银行账号</th>
|
||||
<th>流水号</th>
|
||||
<th class="num">收入</th>
|
||||
<th class="num">支出</th>
|
||||
<th class="num">交易后余额</th>
|
||||
<th>对方户名</th>
|
||||
<th>对方账号</th>
|
||||
<th>对方机构</th>
|
||||
<th>摘要</th>
|
||||
<th>备注</th>
|
||||
<th>下载时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($page as $row)
|
||||
<tr>
|
||||
<td title="{{ $row->txn_at ?: $row->txn_date }}">{{ $row->txn_at ?: $row->txn_date }}</td>
|
||||
<td>{{ $row->bank_name }}</td>
|
||||
<td title="{{ $row->company_name }}">{{ $row->company_name ?: '—' }}</td>
|
||||
<td title="{{ $row->account_short }}">{{ $row->account_short }}</td>
|
||||
<td>{{ $row->account_no }}</td>
|
||||
<td title="{{ $row->record_code }}">{{ $row->record_code ?: '—' }}</td>
|
||||
<td class="num">{{ (float) $row->income ? $money($row->income) : '—' }}</td>
|
||||
<td class="num">{{ (float) $row->expense ? $money($row->expense) : '—' }}</td>
|
||||
<td class="num">{{ $row->balance === null ? '—' : $money($row->balance) }}</td>
|
||||
<td title="{{ $row->counterparty_name }}">{{ $row->counterparty_name ?: '—' }}</td>
|
||||
<td>{{ $row->counterparty_account ?: '—' }}</td>
|
||||
<td title="{{ $row->counterparty_bank }}">{{ $row->counterparty_bank ?: '—' }}</td>
|
||||
<td title="{{ $row->detail }}">{{ $row->detail ?: '—' }}</td>
|
||||
<td title="{{ $row->payment_remark }}">{{ $row->payment_remark ?: '—' }}</td>
|
||||
<td>{{ $row->imported_at ?: '—' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
<footer class="bank-bills__pagination">
|
||||
<span>第 {{ $page->currentPage() }} / {{ $page->lastPage() }} 页</span>
|
||||
<div class="bank-bills__pagination-links">
|
||||
@if ($page->onFirstPage())
|
||||
<span>上一页</span>
|
||||
@else
|
||||
<a href="{{ $page->previousPageUrl() }}">上一页</a>
|
||||
@endif
|
||||
@if ($page->hasMorePages())
|
||||
<a href="{{ $page->nextPageUrl() }}">下一页</a>
|
||||
@else
|
||||
<span>下一页</span>
|
||||
@endif
|
||||
</div>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
@ -7,6 +7,27 @@
|
||||
'section' => 'financial-operations',
|
||||
'page' => 'non-store-accounts',
|
||||
]);
|
||||
$bankBillPageUrl = route('business.pages.show', [
|
||||
'section' => 'financial-operations',
|
||||
'page' => 'ledger',
|
||||
]);
|
||||
$bankBillUrl = static function (array $account) use ($bankBillPageUrl, $period): ?string {
|
||||
if (! ($account['is_direct'] ?? false)) {
|
||||
return null;
|
||||
}
|
||||
$accountNo = preg_replace('/\D+/', '', (string) ($account['account_no'] ?? '')) ?? '';
|
||||
if ($accountNo === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $bankBillPageUrl . '?' . http_build_query([
|
||||
'tab' => 'bills',
|
||||
'bills_bank' => (string) ($account['platform_label'] ?? 'all'),
|
||||
'bills_account_no' => $accountNo,
|
||||
'bills_from' => (string) ($period['from'] ?? now()->startOfMonth()->toDateString()),
|
||||
'bills_to' => (string) ($period['to'] ?? now()->endOfMonth()->toDateString()),
|
||||
]);
|
||||
};
|
||||
$accountStorageKey = 'caiwu.non-store-accounts.columns.v3.'
|
||||
. auth()->id() . '.' . company_id() . '.' . ($accountFilters['category'] ?? 'all');
|
||||
@endphp
|
||||
@ -2044,7 +2065,18 @@
|
||||
<td data-detail-column="connection_label">{{ $account['is_direct'] ? '银企直连' : '非银企直连' }}</td>
|
||||
<td data-detail-column="account_status_label">{{ $account['account_status_label'] ?: '—' }}</td>
|
||||
<td data-detail-column="account_no">{{ in_array($account['account_no'], ['', '/'], true) ? '—' : $account['account_no'] }}</td>
|
||||
<td class="num" data-detail-column="current_balance">{{ number_format((float) $account['current_balance'], 2) }}</td>
|
||||
<td class="num" data-detail-column="current_balance">
|
||||
@php
|
||||
$billUrl = $bankBillUrl($account);
|
||||
@endphp
|
||||
@if ($billUrl !== null)
|
||||
<a class="nsm-number-link" href="{{ $billUrl }}" title="查看{{ $account['account_display_short'] }}的银行账单">
|
||||
{{ number_format((float) $account['current_balance'], 2) }}
|
||||
</a>
|
||||
@else
|
||||
{{ number_format((float) $account['current_balance'], 2) }}
|
||||
@endif
|
||||
</td>
|
||||
<td class="num" data-detail-column="available_balance">{{ number_format((float) $account['available_balance'], 2) }}</td>
|
||||
<td class="num" data-detail-column="blocked_balance">{{ number_format((float) $account['blocked_balance'], 2) }}</td>
|
||||
</tr>
|
||||
@ -2377,7 +2409,14 @@
|
||||
'nsm-sticky-2' => $column['key'] === 'company_name',
|
||||
])>
|
||||
@if ($column['type'] === 'number')
|
||||
{{ $money($value) }}
|
||||
@php
|
||||
$billUrl = $key === 'current_balance' ? $bankBillUrl($row) : null;
|
||||
@endphp
|
||||
@if ($billUrl !== null)
|
||||
<a class="nsm-number-link" href="{{ $billUrl }}" title="查看{{ $row['account_display_short'] }}的银行账单">{{ $money($value) }}</a>
|
||||
@else
|
||||
{{ $money($value) }}
|
||||
@endif
|
||||
@elseif ($column['type'] === 'integer')
|
||||
{{ $value === null ? '—' : number_format((int) $value) }}
|
||||
@elseif ($column['type'] === 'limit')
|
||||
|
||||
110
tests/Feature/Business/BankBillPageTest.php
Normal file
110
tests/Feature/Business/BankBillPageTest.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Business;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class BankBillPageTest extends FeatureTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Carbon::setTestNow('2026-11-24 10:00:00');
|
||||
|
||||
$connection = DB::connection('business_mirror');
|
||||
$connection->table('fin_accounts')->insert([
|
||||
'company_name' => '测试招商公司',
|
||||
'account_short' => '测试招行',
|
||||
'account_type' => '公户',
|
||||
'bank_name' => '招商银行常州分行',
|
||||
'account_no' => '5199050000000001',
|
||||
'account_should_keep' => '是',
|
||||
'current_balance' => 12000,
|
||||
'daily_available' => 12000,
|
||||
'blocked_amount' => 0,
|
||||
]);
|
||||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||||
'account_short' => '测试招行',
|
||||
'data_source' => '银企直连',
|
||||
'updated_by' => '测试',
|
||||
]);
|
||||
$connection->table('fin_bank_direct_bills')->insert([
|
||||
'bank_name' => '招商银行',
|
||||
'company_name' => '测试招商公司',
|
||||
'account_short' => '测试招行',
|
||||
'account_no' => '5199050000000001',
|
||||
'txn_date' => '2026-11-23',
|
||||
'txn_at' => '2026-11-23 16:30:00',
|
||||
'record_code' => 'CMB-TEST-001',
|
||||
'counterparty_name' => '测试收款方',
|
||||
'counterparty_account' => '6222000000000001',
|
||||
'counterparty_bank' => '中国银行',
|
||||
'detail' => '跨行转账',
|
||||
'payment_remark' => '测试备注',
|
||||
'income' => 5000,
|
||||
'expense' => 0,
|
||||
'balance' => 12000,
|
||||
'source_file_name' => '招商账单.xlsx',
|
||||
'source_file_sha256' => str_repeat('a', 64),
|
||||
'row_key' => hash('sha256', 'cmb-test-bill'),
|
||||
'imported_at' => '2026-11-24 08:30:00',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Carbon::setTestNow();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_bank_bill_tab_filters_and_displays_account_statement(): void
|
||||
{
|
||||
$html = $this->loginAs()->get($this->ledgerUrl([
|
||||
'tab' => 'bills',
|
||||
'bills_bank' => '招商银行',
|
||||
'bills_account_no' => '5199050000000001',
|
||||
'bills_from' => '2026-11-01',
|
||||
'bills_to' => '2026-11-30',
|
||||
]))->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('data-ledger-tab="bills"', $html);
|
||||
$this->assertStringContainsString('银行账单', $html);
|
||||
$this->assertStringContainsString('CMB-TEST-001', $html);
|
||||
$this->assertStringContainsString('测试收款方', $html);
|
||||
$this->assertStringContainsString('测试备注', $html);
|
||||
$this->assertStringContainsString('5,000.00', $html);
|
||||
$this->assertStringContainsString('12,000.00', $html);
|
||||
}
|
||||
|
||||
public function test_direct_account_current_balance_links_to_filtered_bank_bills(): void
|
||||
{
|
||||
$billUrl = $this->ledgerUrl([
|
||||
'tab' => 'bills',
|
||||
'bills_bank' => '招商银行',
|
||||
'bills_account_no' => '5199050000000001',
|
||||
'bills_from' => '2026-11-01',
|
||||
'bills_to' => '2026-11-30',
|
||||
]);
|
||||
|
||||
$response = $this->loginAs()->get($this->ledgerUrl([
|
||||
'tab' => 'overview',
|
||||
'period_from' => '2026-11-01',
|
||||
'period_to' => '2026-11-30',
|
||||
]))->assertOk();
|
||||
|
||||
$response->assertSee('href="' . e($billUrl) . '"', false);
|
||||
$response->assertSeeText('测试招行');
|
||||
$response->assertSeeText('12,000.00');
|
||||
}
|
||||
|
||||
private function ledgerUrl(array $query = []): string
|
||||
{
|
||||
return route('business.pages.show', [
|
||||
'company_id' => $this->company->id,
|
||||
'section' => 'financial-operations',
|
||||
'page' => 'ledger',
|
||||
]) . ($query === [] ? '' : '?' . http_build_query($query));
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ class FinanceLedgerNavigationTest extends FeatureTestCase
|
||||
|
||||
$this->assertSame(1, preg_match('/<nav class="ledger-tabbar"[^>]*>(.*?)<\/nav>/s', $html, $tabBar));
|
||||
$this->assertSame(
|
||||
['overview', 'shops', 'transactions', 'mapping', 'sources'],
|
||||
['overview', 'bills', 'shops', 'transactions', 'mapping', 'sources'],
|
||||
preg_match_all('/data-ledger-tab="([^"]+)"/', $tabBar[1], $tabKeys) ? $tabKeys[1] : []
|
||||
);
|
||||
$this->assertStringNotContainsString('账户总表', $tabBar[1]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user