fix(供应商应付终版):供应商应付表默认展示最新月份 (#1583)
Co-authored-by: 苏木 <594326199@qq.com> Co-committed-by: 苏木 <594326199@qq.com>
This commit is contained in:
parent
1187739217
commit
259b7db6cc
@ -4982,6 +4982,11 @@ class Pages extends Controller
|
||||
$storeDataset = PayablesFinalActions::DATASET_PREFIX
|
||||
. ($sectionSlug === PayablesFinalRegistry::SECTION_COURIER ? 'courier:' : 'supplier:')
|
||||
. $dataset;
|
||||
$isSupplierPayablesReport = $dataset === 'supplier-payables-report';
|
||||
$requestedMonth = trim((string) request('month', ''));
|
||||
$month = $isSupplierPayablesReport && preg_match('/^\d{4}-\d{2}$/', $requestedMonth) === 1
|
||||
? $requestedMonth
|
||||
: '';
|
||||
$perPage = in_array($dataset, [
|
||||
'payment-reconciliation',
|
||||
'return-reconciliation',
|
||||
@ -5038,7 +5043,12 @@ class Pages extends Controller
|
||||
$perPage,
|
||||
$currentPage,
|
||||
$keyword,
|
||||
in_array($dataset, ['payment-reconciliation', 'return-reconciliation'], true),
|
||||
in_array($dataset, [
|
||||
'payment-reconciliation',
|
||||
'return-reconciliation',
|
||||
'supplier-payables-report',
|
||||
], true),
|
||||
$month === '' ? [] : ['summary_month' => $month],
|
||||
);
|
||||
$pagedRows = $paged['rows'];
|
||||
$totalRows = $paged['total'];
|
||||
@ -5058,6 +5068,7 @@ class Pages extends Controller
|
||||
['path' => request()->url(), 'query' => request()->query()],
|
||||
),
|
||||
'keyword' => $keyword,
|
||||
'month' => $month,
|
||||
'summary' => $unpricedSummary,
|
||||
'actions' => url('/' . (company_id() ?: 1) . '/workspace/' . $sectionSlug . '/actions/' . $dataset),
|
||||
];
|
||||
|
||||
@ -392,6 +392,7 @@ class SupplierPayableOverrideStore
|
||||
int $page,
|
||||
string $keyword = '',
|
||||
bool $latestFirst = false,
|
||||
array $exactFilters = [],
|
||||
): array {
|
||||
$perPage = max(1, min($perPage, 200));
|
||||
$page = max(1, $page);
|
||||
@ -399,6 +400,14 @@ class SupplierPayableOverrideStore
|
||||
->where('company_id', $companyId)
|
||||
->where('dataset', $dataset);
|
||||
|
||||
foreach ($exactFilters as $field => $value) {
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$query->where('values->' . $field, $value);
|
||||
}
|
||||
|
||||
$keyword = trim($keyword);
|
||||
if ($keyword !== '') {
|
||||
$query->where('values', 'like', '%' . $keyword . '%');
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
$finalFields = $payablesFinal['fields'] ?? [];
|
||||
$finalRows = $payablesFinal['rows'] ?? null;
|
||||
$finalKeyword = $payablesFinal['keyword'] ?? '';
|
||||
$finalMonth = $payablesFinal['month'] ?? '';
|
||||
$finalSummary = $payablesFinal['summary'] ?? null;
|
||||
$finalActions = $payablesFinal['actions'] ?? '';
|
||||
$finalMaintenance = ['dataset' => $finalDataset, 'fields' => $finalFields];
|
||||
@ -76,6 +77,12 @@
|
||||
</style>
|
||||
|
||||
<form method="GET" class="payables-final-toolbar" aria-label="{{ $page['title'] ?? '' }}筛选">
|
||||
@if ($finalDataset === 'supplier-payables-report')
|
||||
<div class="payables-final-field">
|
||||
<label for="payables-final-month">月份</label>
|
||||
<input id="payables-final-month" name="month" type="month" value="{{ $finalMonth }}">
|
||||
</div>
|
||||
@endif
|
||||
<div class="payables-final-field">
|
||||
<label for="payables-final-keyword">关键词</label>
|
||||
<input id="payables-final-keyword" name="keyword" type="search" value="{{ $finalKeyword }}" placeholder="按本表任意内容筛选">
|
||||
|
||||
@ -663,15 +663,62 @@ class SupplierPayableFinalPagesTest extends FeatureTestCase
|
||||
->assertSee('data-caiwu-replay', false)
|
||||
->assertSeeText('每页 15 条')
|
||||
->assertSeeText('第 1 页 / 共 2 页')
|
||||
->assertSeeText('SUP-01')
|
||||
->assertDontSeeText('SUP-16');
|
||||
->assertSeeText('SUP-20')
|
||||
->assertDontSeeText('SUP-05');
|
||||
|
||||
$this->loginAs()->get($url(2))
|
||||
->assertOk()
|
||||
->assertSeeText('第 2 页 / 共 2 页')
|
||||
->assertSeeText('SUP-16')
|
||||
->assertSeeText('SUP-20')
|
||||
->assertDontSeeText('SUP-01');
|
||||
->assertSeeText('SUP-05')
|
||||
->assertSeeText('SUP-01')
|
||||
->assertDontSeeText('SUP-20');
|
||||
}
|
||||
|
||||
public function test_final_supplier_payables_report_shows_latest_month_and_filters_by_month(): void
|
||||
{
|
||||
$records = [
|
||||
'sep' => [
|
||||
'summary_month' => '2026-09',
|
||||
'checker' => '张宏',
|
||||
'settlement_method' => '月结',
|
||||
'company' => '九月供应商主体',
|
||||
'supplier' => 'SEP-ONLY',
|
||||
],
|
||||
];
|
||||
for ($index = 1; $index <= 16; $index++) {
|
||||
$records[sprintf('oct-%02d', $index)] = [
|
||||
'summary_month' => '2026-10',
|
||||
'checker' => '陈亲园',
|
||||
'settlement_method' => '月结',
|
||||
'company' => sprintf('十月供应商主体%02d', $index),
|
||||
'supplier' => sprintf('OCT-%02d', $index),
|
||||
];
|
||||
}
|
||||
app(SupplierPayableOverrideStore::class)->saveBatch(
|
||||
'final:supplier:supplier-payables-report',
|
||||
$records,
|
||||
(int) $this->company->id,
|
||||
(int) $this->user->id,
|
||||
);
|
||||
|
||||
$url = route('business.pages.show', [
|
||||
'company_id' => (int) $this->company->id,
|
||||
'section' => 'supplier-payables-final',
|
||||
'page' => 'supplier-payables-report',
|
||||
]);
|
||||
|
||||
$this->loginAs()->get($url)
|
||||
->assertOk()
|
||||
->assertSeeText('OCT-16')
|
||||
->assertDontSeeText('OCT-01')
|
||||
->assertDontSeeText('SEP-ONLY')
|
||||
->assertSee('id="payables-final-month"', false);
|
||||
|
||||
$this->loginAs()->get($url . '?month=2026-09')
|
||||
->assertOk()
|
||||
->assertSeeText('SEP-ONLY')
|
||||
->assertDontSeeText('OCT-16')
|
||||
->assertSee('value="2026-09"', false);
|
||||
}
|
||||
|
||||
public function test_final_import_reads_files_larger_than_one_chunk(): void
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user