feat: 接入供应商负数预警数据
供应商负数预警读取供应商应付终版数据集,筛选供应商余额小于 0 的记录。 Co-authored-by: 苏木 <594326199@qq.com> Co-committed-by: 苏木 <594326199@qq.com>
This commit is contained in:
parent
5e4d0fe356
commit
a934229ccc
@ -86,6 +86,7 @@ use Modules\EcommerceFinance\Services\SupplierPayableOverrideStore;
|
||||
use Modules\EcommerceFinance\Services\SupplierFreeShippingStore;
|
||||
use Modules\EcommerceFinance\View\PlatformPromotionAccountPageData;
|
||||
use Modules\EcommerceFinance\View\OrderDataPageData;
|
||||
use Modules\EcommerceFinance\View\SupplierNegativeAlertPageData;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
@ -4717,6 +4718,7 @@ class Pages extends Controller
|
||||
'planting-loss' => app(\Modules\EcommerceFinance\View\PlantingLossPageData::class)->page(),
|
||||
'finance-data' => app(\Modules\EcommerceFinance\View\SupplierReconciliationPageData::class)->financeData(),
|
||||
'supplier-data' => app(\Modules\EcommerceFinance\View\SupplierReconciliationPageData::class)->supplierData(),
|
||||
'supplier-negative-alert' => app(SupplierNegativeAlertPageData::class)->page(),
|
||||
'store-report-data-logic' => $this->prepareStoreReportLogic(),
|
||||
'tax-forecast-data-logic' => $this->contentForTaxForecastLogic(),
|
||||
default => null,
|
||||
|
||||
147
modules/EcommerceFinance/View/SupplierNegativeAlertPageData.php
Normal file
147
modules/EcommerceFinance/View/SupplierNegativeAlertPageData.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\EcommerceFinance\View;
|
||||
|
||||
use App\Http\Controllers\Business\PayablesFinalActions;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Modules\EcommerceFinance\Services\SupplierPayableOverrideStore;
|
||||
|
||||
/**
|
||||
* 供应商负数预警:直接读取「供应商应付(终版)→ 供应商应付表」,
|
||||
* 仅保留供应商余额小于 0 的记录。
|
||||
*/
|
||||
class SupplierNegativeAlertPageData
|
||||
{
|
||||
private const DATASET = 'supplier:supplier-payables-report';
|
||||
|
||||
private const PER_PAGE = 25;
|
||||
|
||||
public function __construct(
|
||||
private readonly SupplierPayableOverrideStore $store,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function page(): array
|
||||
{
|
||||
$rows = $this->store->listRows(
|
||||
PayablesFinalActions::DATASET_PREFIX . self::DATASET,
|
||||
(int) (company_id() ?: 1),
|
||||
);
|
||||
|
||||
$negativeRows = [];
|
||||
foreach ($rows as $row) {
|
||||
$balance = $this->number($row['supplier_balance'] ?? null);
|
||||
if ($balance === null || $balance >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row['supplier_balance'] = $balance;
|
||||
$negativeRows[] = $row;
|
||||
}
|
||||
|
||||
usort($negativeRows, static function (array $left, array $right): int {
|
||||
return strcmp(
|
||||
(string) ($right['summary_month'] ?? ''),
|
||||
(string) ($left['summary_month'] ?? ''),
|
||||
) ?: strnatcasecmp(
|
||||
(string) ($left['supplier'] ?? ''),
|
||||
(string) ($right['supplier'] ?? ''),
|
||||
);
|
||||
});
|
||||
|
||||
$months = [];
|
||||
foreach ($negativeRows as $row) {
|
||||
$month = trim((string) ($row['summary_month'] ?? ''));
|
||||
if (preg_match('/^\d{4}-\d{2}$/', $month) === 1) {
|
||||
$months[$month] = true;
|
||||
}
|
||||
}
|
||||
$months = array_keys($months);
|
||||
rsort($months);
|
||||
|
||||
$requestedMonth = trim((string) request()->query('month', ''));
|
||||
$month = in_array($requestedMonth, $months, true) ? $requestedMonth : '';
|
||||
if ($month !== '') {
|
||||
$negativeRows = array_values(array_filter(
|
||||
$negativeRows,
|
||||
static fn (array $row): bool => (string) ($row['summary_month'] ?? '') === $month,
|
||||
));
|
||||
}
|
||||
|
||||
$supplierNames = [];
|
||||
foreach ($negativeRows as $row) {
|
||||
$supplier = trim((string) ($row['supplier'] ?? ''));
|
||||
if ($supplier !== '') {
|
||||
$supplierNames[$supplier] = true;
|
||||
}
|
||||
}
|
||||
$supplierNames = array_keys($supplierNames);
|
||||
sort($supplierNames, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
|
||||
$supplierQuery = mb_substr(trim((string) request()->query('supplier', '')), 0, 191);
|
||||
if ($supplierQuery !== '') {
|
||||
$needle = mb_strtolower($supplierQuery);
|
||||
$negativeRows = array_values(array_filter(
|
||||
$negativeRows,
|
||||
static function (array $row) use ($needle): bool {
|
||||
$haystack = mb_strtolower(implode("\n", [
|
||||
(string) ($row['supplier'] ?? ''),
|
||||
(string) ($row['company'] ?? ''),
|
||||
]));
|
||||
|
||||
return str_contains($haystack, $needle);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
$supplierCounts = [];
|
||||
foreach ($negativeRows as $row) {
|
||||
$key = trim((string) ($row['company'] ?? '')) . "\0" . trim((string) ($row['supplier'] ?? ''));
|
||||
$supplierCounts[$key] = true;
|
||||
}
|
||||
|
||||
$total = count($negativeRows);
|
||||
$pages = max((int) ceil($total / self::PER_PAGE), 1);
|
||||
$page = min(max((int) request()->query('page', 1), 1), $pages);
|
||||
$items = array_map(
|
||||
static fn (array $row): object => (object) $row,
|
||||
array_slice($negativeRows, ($page - 1) * self::PER_PAGE, self::PER_PAGE),
|
||||
);
|
||||
|
||||
return [
|
||||
'view' => 'business.pages.negative-alerts.supplier-negative-alert',
|
||||
'negativeAlertRows' => new LengthAwarePaginator(
|
||||
$items,
|
||||
$total,
|
||||
self::PER_PAGE,
|
||||
$page,
|
||||
[
|
||||
'path' => request()->url(),
|
||||
'query' => request()->except('page'),
|
||||
],
|
||||
),
|
||||
'negativeAlertMonths' => $months,
|
||||
'negativeAlertMonth' => $month,
|
||||
'negativeAlertSupplier' => $supplierQuery,
|
||||
'negativeAlertSupplierNames' => $supplierNames,
|
||||
'negativeAlertSupplierCount' => count($supplierCounts),
|
||||
'negativeAlertTotal' => $total,
|
||||
'negativeAlertSourceUrl' => route('business.pages.show', [
|
||||
'section' => 'supplier-payables-final',
|
||||
'page' => 'supplier-payables-report',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
private function number(mixed $value): ?float
|
||||
{
|
||||
if ($value === null || trim((string) $value) === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$normalized = str_replace([',', ',', ' '], '', trim((string) $value));
|
||||
|
||||
return is_numeric($normalized) ? (float) $normalized : null;
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,411 @@
|
||||
@include('business.pages.negative-alerts._placeholder', [
|
||||
'icon' => 'factory',
|
||||
'scopeLabel' => '供应商',
|
||||
'statusTitle' => '供应商负数判定口径待确认',
|
||||
'description' => '待确认按“供应商余额”还是“应付余额”判定负数,并接入真实数据后,这里将展示需要关注的供应商、负数金额及异常原因。',
|
||||
'scopeItems' => [
|
||||
['label' => '判定字段', 'value' => '待确认'],
|
||||
['label' => '数据来源', 'value' => '待接入'],
|
||||
['label' => '数据日期', 'value' => '待接入'],
|
||||
],
|
||||
'emptyTitle' => '供应商预警数据将在口径确认后接入',
|
||||
'emptyDescription' => '接入后将按供应商汇总负数余额,并保留可追溯的负数原因和数据日期。',
|
||||
])
|
||||
@php
|
||||
$rows = $negativeAlertRows ?? null;
|
||||
$months = $negativeAlertMonths ?? [];
|
||||
$month = $negativeAlertMonth ?? '';
|
||||
$supplierQuery = $negativeAlertSupplier ?? '';
|
||||
$supplierNames = $negativeAlertSupplierNames ?? [];
|
||||
$supplierCount = (int) ($negativeAlertSupplierCount ?? 0);
|
||||
$total = (int) ($negativeAlertTotal ?? 0);
|
||||
$sourceUrl = $negativeAlertSourceUrl ?? '#';
|
||||
$money = static fn (mixed $value): string => $value === null ? '-' : number_format((float) $value, 2);
|
||||
@endphp
|
||||
|
||||
<div class="supplier-negative-alert-data-page">
|
||||
<style>
|
||||
.supplier-negative-alert-data-page {
|
||||
--sna-danger: var(--vip-danger, #B80000);
|
||||
--sna-warning: var(--vip-warning, #935F07);
|
||||
--sna-border: var(--vip-border, #D8D2C7);
|
||||
--sna-muted: var(--vip-content-muted, #595959);
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-hero {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid #E8D8B8;
|
||||
border-radius: 8px;
|
||||
background: #FFF8EA;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-hero-icon {
|
||||
display: inline-flex;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
flex: 0 0 36px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 8px;
|
||||
background: #FFFFFF;
|
||||
color: var(--sna-warning);
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-hero-icon .material-icons-outlined {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-hero-copy {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-hero-title {
|
||||
margin: 0;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-copy {
|
||||
margin: 0;
|
||||
color: var(--sna-muted);
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-summary-item {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--sna-border);
|
||||
border-radius: 8px;
|
||||
background: var(--vip-surface, #FFFFFF);
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-summary-item span {
|
||||
color: var(--sna-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-summary-item strong {
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--sna-border);
|
||||
border-radius: 8px;
|
||||
background: var(--vip-surface, #FFFFFF);
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-field {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
min-width: 12rem;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-field span {
|
||||
color: var(--sna-muted);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page select,
|
||||
.supplier-negative-alert-data-page input[type="search"] {
|
||||
height: 34px;
|
||||
min-width: 12rem;
|
||||
padding: 0 10px;
|
||||
border: 1px solid var(--sna-border);
|
||||
border-radius: 8px;
|
||||
background: #FFFFFF;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-size: 0.8125rem;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page select:focus,
|
||||
.supplier-negative-alert-data-page input[type="search"]:focus {
|
||||
border-color: var(--vip-content-accent-dark, #856632);
|
||||
box-shadow: 0 0 0 3px rgba(133, 102, 50, 0.20);
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-button {
|
||||
display: inline-flex;
|
||||
height: 34px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--sna-border);
|
||||
border-radius: 8px;
|
||||
background: #FFFFFF;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-button.is-primary {
|
||||
border-color: var(--vip-content-accent-dark, #856632);
|
||||
background: var(--vip-content-accent-dark, #856632);
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-table-card {
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--sna-border);
|
||||
border-radius: 8px;
|
||||
background: var(--vip-surface, #FFFFFF);
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-table-scroll {
|
||||
max-height: min(62vh, 620px);
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page table {
|
||||
width: 100%;
|
||||
min-width: 1080px;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--sna-border);
|
||||
background: var(--vip-content-accent-soft, #F7F0DE);
|
||||
color: #5B5343;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #EFEAE0;
|
||||
color: var(--vip-content-ink, #171717);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page tbody tr:hover td {
|
||||
background: #FFFDF7;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page td.is-number {
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page td.is-negative {
|
||||
color: var(--sna-danger);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-empty {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
gap: 8px;
|
||||
min-height: 220px;
|
||||
padding: 32px;
|
||||
color: var(--sna-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-empty .material-icons-outlined {
|
||||
color: var(--vip-content-accent-dark, #856632);
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-empty strong {
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-empty span:last-child {
|
||||
max-width: 560px;
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-top: 1px solid var(--sna-border);
|
||||
color: var(--sna-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-pagination-links {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-pagination a {
|
||||
color: var(--vip-content-accent-dark, #856632);
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.supplier-negative-alert-data-page .sna-summary {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.supplier-negative-alert-data-page .sna-actions {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="sna-hero" role="status">
|
||||
<span class="sna-hero-icon">
|
||||
<span class="material-icons-outlined" aria-hidden="true">warning_amber</span>
|
||||
</span>
|
||||
<div class="sna-hero-copy">
|
||||
<p class="sna-hero-title">供应商余额小于 0 的终版数据</p>
|
||||
<p class="sna-copy">数据实时读取自“供应商应付(终版)→ 供应商应付表”,仅显示供应商余额 < 0 的记录。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sna-summary">
|
||||
<div class="sna-summary-item">
|
||||
<span>负数记录</span>
|
||||
<strong>{{ number_format($total) }} 条</strong>
|
||||
</div>
|
||||
<div class="sna-summary-item">
|
||||
<span>涉及供应商</span>
|
||||
<strong>{{ number_format($supplierCount) }} 家</strong>
|
||||
</div>
|
||||
<div class="sna-summary-item">
|
||||
<span>当前筛选月份</span>
|
||||
<strong>{{ $month !== '' ? $month : '全部月份' }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="GET" class="sna-toolbar" aria-label="供应商负数预警筛选">
|
||||
<label class="sna-field">
|
||||
<span>月份</span>
|
||||
<select name="month">
|
||||
<option value="">全部月份</option>
|
||||
@foreach ($months as $optionMonth)
|
||||
<option value="{{ $optionMonth }}" @selected($month === $optionMonth)>{{ $optionMonth }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
<label class="sna-field">
|
||||
<span>供应商</span>
|
||||
<input type="search"
|
||||
name="supplier"
|
||||
value="{{ $supplierQuery }}"
|
||||
list="negative-alert-supplier-options"
|
||||
placeholder="输入供应商名称或主体"
|
||||
autocomplete="off">
|
||||
<datalist id="negative-alert-supplier-options">
|
||||
@foreach ($supplierNames as $supplierName)
|
||||
<option value="{{ $supplierName }}"></option>
|
||||
@endforeach
|
||||
</datalist>
|
||||
</label>
|
||||
<div class="sna-actions">
|
||||
<button type="submit" class="sna-button is-primary">
|
||||
<span class="material-icons-outlined" aria-hidden="true">search</span>
|
||||
查询
|
||||
</button>
|
||||
<a class="sna-button"
|
||||
href="{{ route('business.pages.show', ['section' => 'negative-alerts', 'page' => 'supplier-negative-alert']) }}">
|
||||
<span class="material-icons-outlined" aria-hidden="true">refresh</span>
|
||||
重置
|
||||
</a>
|
||||
<a class="sna-button" href="{{ $sourceUrl }}">
|
||||
<span class="material-icons-outlined" aria-hidden="true">open_in_new</span>
|
||||
查看供应商应付表
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<section class="sna-table-card" aria-label="供应商负数预警明细">
|
||||
@if ($rows && $rows->isNotEmpty())
|
||||
<div class="sna-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>月份</th>
|
||||
<th>供应商公司主体名称</th>
|
||||
<th>供应商简称</th>
|
||||
<th>供应商余额</th>
|
||||
<th>应付余额</th>
|
||||
<th>对账人</th>
|
||||
<th>结算方式</th>
|
||||
<th>负数原因</th>
|
||||
<th>备注</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($rows as $row)
|
||||
<tr>
|
||||
<td>{{ $row->summary_month ?? '-' }}</td>
|
||||
<td>{{ ($row->company ?? null) ?: '-' }}</td>
|
||||
<td>{{ ($row->supplier ?? null) ?: '-' }}</td>
|
||||
<td class="is-number is-negative">{{ $money($row->supplier_balance ?? null) }}</td>
|
||||
<td @class(['is-number', 'is-negative' => (float) ($row->should_pay ?? 0) < 0])>
|
||||
{{ $money($row->should_pay ?? null) }}
|
||||
</td>
|
||||
<td>{{ ($row->checker ?? null) ?: '-' }}</td>
|
||||
<td>{{ ($row->settlement_method ?? null) ?: '-' }}</td>
|
||||
<td>{{ ($row->negative_reason ?? null) ?: '-' }}</td>
|
||||
<td>{{ ($row->remarks ?? null) ?: '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="sna-pagination">
|
||||
<span>
|
||||
共 {{ number_format($rows->total()) }} 条 · 第 {{ $rows->currentPage() }} / {{ $rows->lastPage() }} 页
|
||||
</span>
|
||||
<span class="sna-pagination-links">
|
||||
@if (!$rows->onFirstPage())
|
||||
<a href="{{ $rows->previousPageUrl() }}">上一页</a>
|
||||
@endif
|
||||
<span>每页 {{ $rows->perPage() }} 条</span>
|
||||
@if ($rows->hasMorePages())
|
||||
<a href="{{ $rows->nextPageUrl() }}">下一页</a>
|
||||
@endif
|
||||
</span>
|
||||
</div>
|
||||
@else
|
||||
<div class="sna-empty">
|
||||
<span class="material-icons-outlined" aria-hidden="true">verified</span>
|
||||
<strong>当前筛选没有负数供应商记录</strong>
|
||||
<span>请调整月份或供应商条件后重新查询。数据仍来自供应商应付(终版)中的供应商应付表。</span>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
|
||||
namespace Tests\Feature\Business;
|
||||
|
||||
use App\Http\Controllers\Business\PayablesFinalActions;
|
||||
use App\Listeners\Menu\ShowInAdmin;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Utilities\BusinessNavigation;
|
||||
use Modules\EcommerceFinance\Services\SupplierPayableOverrideStore;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class NegativeAlertPagesTest extends FeatureTestCase
|
||||
@ -41,6 +43,12 @@ class NegativeAlertPagesTest extends FeatureTestCase
|
||||
|
||||
public function test_supplier_and_courier_negative_alert_pages_render_as_tabs(): void
|
||||
{
|
||||
$this->saveSupplierPayable('negative:1', '负余额供应商', '-128.50', '2026-09', [
|
||||
'company' => '测试供应商有限公司',
|
||||
'negative_reason' => '历史多付款',
|
||||
]);
|
||||
$this->saveSupplierPayable('positive:1', '正余额供应商', '88.00', '2026-09');
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
'section' => 'negative-alerts',
|
||||
@ -49,8 +57,11 @@ class NegativeAlertPagesTest extends FeatureTestCase
|
||||
->assertOk()
|
||||
->assertSeeText('供应商负数预警')
|
||||
->assertSeeText('快递负数预警')
|
||||
->assertSeeText('供应商负数判定口径待确认')
|
||||
->assertSeeText('待接入');
|
||||
->assertSeeText('供应商余额小于 0 的终版数据')
|
||||
->assertSeeText('负余额供应商')
|
||||
->assertSeeText('-128.50')
|
||||
->assertSeeText('历史多付款')
|
||||
->assertDontSeeText('正余额供应商');
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
@ -64,6 +75,24 @@ class NegativeAlertPagesTest extends FeatureTestCase
|
||||
->assertSeeText('待接入');
|
||||
}
|
||||
|
||||
public function test_supplier_negative_alert_filters_by_month_and_supplier(): void
|
||||
{
|
||||
$this->saveSupplierPayable('negative:sep', '九月负余额供应商', '-99.00', '2026-09');
|
||||
$this->saveSupplierPayable('negative:aug', '八月负余额供应商', '-66.00', '2026-08');
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
'section' => 'negative-alerts',
|
||||
'page' => 'supplier-negative-alert',
|
||||
'month' => '2026-08',
|
||||
'supplier' => '八月负余额',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSeeText('八月负余额供应商')
|
||||
->assertSeeText('-66.00')
|
||||
->assertDontSeeText('九月负余额供应商');
|
||||
}
|
||||
|
||||
public function test_supplier_negative_alert_route_no_longer_renders_under_supplier_reconciliation(): void
|
||||
{
|
||||
$this->withExceptionHandling()
|
||||
@ -74,4 +103,24 @@ class NegativeAlertPagesTest extends FeatureTestCase
|
||||
]))
|
||||
->assertRedirect();
|
||||
}
|
||||
|
||||
private function saveSupplierPayable(
|
||||
string $key,
|
||||
string $supplier,
|
||||
string $supplierBalance,
|
||||
string $month,
|
||||
array $extra = [],
|
||||
): void {
|
||||
app(SupplierPayableOverrideStore::class)->save(
|
||||
PayablesFinalActions::DATASET_PREFIX . 'supplier:supplier-payables-report',
|
||||
$key,
|
||||
$extra + [
|
||||
'summary_month' => $month,
|
||||
'supplier' => $supplier,
|
||||
'supplier_balance' => $supplierBalance,
|
||||
],
|
||||
(int) $this->company->id,
|
||||
(int) $this->user->id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user