fix: 完善OA流程付款状态与日期筛选 #702

Merged
yueyang merged 2 commits from fix/yueyang-oa-process-payment-state-final into main 2026-10-27 18:32:51 +08:00
9 changed files with 311 additions and 101 deletions

View File

@ -23,10 +23,19 @@ class ProcessDetails extends Controller
$filters = $this->filters($request);
$page = max((int) $request->query('page', 1), 1);
$perPage = ProcessDetailsPageData::normalizePerPage($request->query('per_page'));
$paginationQuery = array_filter(
[...$filters, 'per_page' => $perPage],
static fn (mixed $value): bool => $value !== '' && $value !== null,
);
try {
$options = $this->repository->filterOptions($filters);
if ($filters['payment_state'] !== ''
&& ! in_array($filters['payment_state'], $options['payment_states'], true)) {
$filters['payment_state'] = '';
unset($paginationQuery['payment_state']);
}
$result = $this->repository->paginate($filters, $page, $perPage);
$options = $this->repository->filterOptions();
return view('business.pages.financial-operations.process-details', [
'section' => ['slug' => 'process-data', 'title' => '流程数据'],
@ -36,7 +45,7 @@ class ProcessDetails extends Controller
$result['total'],
$perPage,
$page,
['path' => $request->url(), 'query' => $request->except('page')],
['path' => $request->url(), 'query' => $paginationQuery],
),
'filters' => $filters,
'summary' => $result['summary'],
@ -58,7 +67,7 @@ class ProcessDetails extends Controller
'page' => ['slug' => 'oa-process', 'title' => 'OA流程'],
'processRows' => new LengthAwarePaginator([], 0, $perPage, $page, [
'path' => $request->url(),
'query' => $request->except('page'),
'query' => $paginationQuery,
]),
'filters' => $filters,
'summary' => [
@ -137,11 +146,9 @@ class ProcessDetails extends Controller
$status = trim((string) $request->query('status', ''));
$paidDateValid = preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $paidDate, $dateParts) === 1
&& checkdate((int) $dateParts[2], (int) $dateParts[3], (int) $dateParts[1]);
$paymentState = trim((string) $request->query('payment_state', ''));
if (! in_array($paymentState, DingProcessDetailMirrorRepository::PAYMENT_STATES, true)
&& $paymentState !== DingProcessDetailMirrorRepository::LEGACY_PAYMENT_STATE) {
$paymentState = '';
}
$paymentState = DingProcessDetailMirrorRepository::normalizePaymentStateFilter(
$request->query('payment_state'),
);
return [
'paid_date' => $paidDateValid ? $paidDate : '',

View File

@ -16,17 +16,24 @@ class DingProcessDetailMirrorRepository
public const DATASET_PREFIX = 'ding.process_details.';
public const PAYMENT_STATES = [
'出纳状态待同步',
'出纳未开始',
'出纳待打款',
'出纳退回',
'出纳已打款',
'流程终止',
'待付款',
'已付款',
'付款待核实',
'不涉及付款',
];
public const LEGACY_PAYMENT_STATE = '未确认';
public const LEGACY_PAYMENT_STATE_MAP = [
'未确认' => '付款待核实',
'出纳状态待同步' => '付款待核实',
'出纳未开始' => '待付款',
'出纳待打款' => '待付款',
'出纳退回' => '待付款',
'出纳已打款' => '已付款',
'流程终止' => '不涉及付款',
];
private readonly ConnectionInterface $connection;
private ?bool $paymentSourceStateColumn = null;
@ -50,6 +57,14 @@ class DingProcessDetailMirrorRepository
return $scope !== '' ? $scope : self::DEFAULT_SCOPE;
}
public static function normalizePaymentStateFilter(mixed $value): string
{
$paymentState = trim((string) $value);
$paymentState = self::LEGACY_PAYMENT_STATE_MAP[$paymentState] ?? $paymentState;
return in_array($paymentState, self::PAYMENT_STATES, true) ? $paymentState : '';
}
public function datasetKey(): string
{
return self::DATASET_PREFIX . $this->scope();
@ -149,8 +164,11 @@ class DingProcessDetailMirrorRepository
];
}
/** @return array{document_types:list<string>,statuses:list<string>,payment_states:list<string>} */
public function filterOptions(): array
/**
* @param array<string,string> $filters
* @return array{document_types:list<string>,statuses:list<string>,payment_states:list<string>}
*/
public function filterOptions(array $filters = []): array
{
if (! Schema::connection($this->connection->getName())->hasTable('ding_process_detail_mirror')) {
return ['document_types' => [], 'statuses' => [], 'payment_states' => []];
@ -176,9 +194,7 @@ class DingProcessDetailMirrorRepository
->pluck('status')
->map(static fn (mixed $value): string => (string) $value)
->all(),
'payment_states' => $this->structuredPaymentsEnabled()
? self::PAYMENT_STATES
: [self::LEGACY_PAYMENT_STATE],
'payment_states' => $this->paymentStatesAvailableFor($filters),
];
}
@ -251,7 +267,7 @@ class DingProcessDetailMirrorRepository
$query
->selectRaw(
'NULL as payment_fact_amount, NULL as payment_difference, ? as payment_state',
[self::LEGACY_PAYMENT_STATE],
['付款待核实'],
);
}
@ -289,19 +305,12 @@ class DingProcessDetailMirrorRepository
}
}
$paymentState = trim((string) ($filters['payment_state'] ?? ''));
$paymentState = self::normalizePaymentStateFilter($filters['payment_state'] ?? '');
if ($paymentState !== '') {
$allowed = $this->structuredPaymentsEnabled()
? self::PAYMENT_STATES
: [self::LEGACY_PAYMENT_STATE];
if (in_array($paymentState, $allowed, true)) {
if ($paymentState !== self::LEGACY_PAYMENT_STATE) {
$query->whereRaw(
'(' . $this->paymentStateExpression() . ') = ?',
[$paymentState],
);
}
}
$query->whereRaw(
'(' . $this->paymentStateExpression() . ') = ?',
[$paymentState],
);
}
return $query;
@ -315,18 +324,47 @@ class DingProcessDetailMirrorRepository
$cashierState = $this->cashierStatusColumnAvailable()
? 'ding_process_detail_mirror.cashier_status'
: "'pending_sync'";
$workflowStatus = 'ding_process_detail_mirror.status';
return "CASE
WHEN {$sourceState} = 'not_applicable' THEN '不涉及付款'
WHEN {$cashierState} = 'completed' THEN '出纳已打款'
WHEN {$cashierState} = 'pending' THEN '出纳待打款'
WHEN {$cashierState} = 'returned' THEN '出纳退回'
WHEN {$cashierState} = 'not_started' THEN '出纳未开始'
WHEN {$cashierState} = 'terminated' THEN '流程终止'
ELSE '出纳状态待同步'
WHEN {$sourceState} = 'not_applicable'
OR {$cashierState} = 'terminated'
OR (({$cashierState} IS NULL OR {$cashierState} = '') AND {$workflowStatus} = '已终止')
THEN '不涉及付款'
WHEN {$cashierState} = 'completed'
OR (({$cashierState} IS NULL OR {$cashierState} = '')
AND {$workflowStatus} = '已完成'
AND {$sourceState} <> 'not_applicable')
THEN '已付款'
WHEN {$cashierState} IN ('pending', 'returned', 'not_started') THEN '待付款'
ELSE '付款待核实'
END";
}
/**
* @param array<string,string> $filters
* @return list<string>
*/
private function paymentStatesAvailableFor(array $filters): array
{
$optionFilters = $filters;
$optionFilters['payment_state'] = '';
$available = $this->applyFilters(
$this->connection->table('ding_process_detail_mirror'),
$optionFilters,
)
->selectRaw($this->paymentStateExpression() . ' as payment_state')
->groupByRaw($this->paymentStateExpression())
->pluck('payment_state')
->map(static fn (mixed $value): string => (string) $value)
->all();
return array_values(array_filter(
self::PAYMENT_STATES,
static fn (string $state): bool => in_array($state, $available, true),
));
}
private function paymentSourceStateColumnAvailable(): bool
{
return $this->paymentSourceStateColumn ??= Schema::connection(

View File

@ -674,6 +674,9 @@ class DingProcessDetailMirrorSynchronizer
];
}
$orderBy = $cursorExpression === 'w.processInstanceId'
? 'w.processInstanceId'
: "{$cursorExpression}, w.processInstanceId";
$workflows = $query->select(
'SELECT w.processInstanceId, w.processCode, w.businessId, w.title, w.status, w.result, '
. 'w.originatorUserId, w.originatorDeptName, w.joinAt, w.updateAt, w.finishTime, '
@ -681,7 +684,7 @@ class DingProcessDetailMirrorSynchronizer
. 'FROM rpt.ding_Workflow w '
. "WHERE w.processCode IN ({$processPlaceholders}) AND {$where}"
. $cursorSql
. " ORDER BY {$cursorExpression}, w.processInstanceId"
. " ORDER BY {$orderBy}"
. ' OFFSET 0 ROWS FETCH NEXT ' . $batchSize . ' ROWS ONLY',
[...$processCodes, ...$bindings, ...$cursorBindings],
);

View File

@ -32,10 +32,19 @@ class ProcessDetailsPageData
$filters = $this->filters($request);
$page = max((int) $request->query('page', 1), 1);
$perPage = self::normalizePerPage($request->query('per_page'));
$paginationQuery = array_filter(
[...$filters, 'per_page' => $perPage],
static fn (mixed $value): bool => $value !== '' && $value !== null,
);
try {
$options = $this->repository->filterOptions($filters);
if ($filters['payment_state'] !== ''
&& ! in_array($filters['payment_state'], $options['payment_states'], true)) {
$filters['payment_state'] = '';
unset($paginationQuery['payment_state']);
}
$result = $this->repository->paginate($filters, $page, $perPage);
$options = $this->repository->filterOptions();
return [
'processRows' => new LengthAwarePaginator(
@ -43,7 +52,7 @@ class ProcessDetailsPageData
$result['total'],
$perPage,
$page,
['path' => $request->url(), 'query' => $request->except('page')],
['path' => $request->url(), 'query' => $paginationQuery],
),
'filters' => $filters,
'summary' => $result['summary'],
@ -63,7 +72,7 @@ class ProcessDetailsPageData
return [
'processRows' => new LengthAwarePaginator([], 0, $perPage, $page, [
'path' => $request->url(),
'query' => $request->except('page'),
'query' => $paginationQuery,
]),
'filters' => $filters,
'summary' => [
@ -92,11 +101,9 @@ class ProcessDetailsPageData
$status = trim((string) $request->query('status', ''));
$paidDateValid = preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $paidDate, $dateParts) === 1
&& checkdate((int) $dateParts[2], (int) $dateParts[3], (int) $dateParts[1]);
$paymentState = trim((string) $request->query('payment_state', ''));
if (! in_array($paymentState, DingProcessDetailMirrorRepository::PAYMENT_STATES, true)
&& $paymentState !== DingProcessDetailMirrorRepository::LEGACY_PAYMENT_STATE) {
$paymentState = '';
}
$paymentState = DingProcessDetailMirrorRepository::normalizePaymentStateFilter(
$request->query('payment_state'),
);
return [
'paid_date' => $paidDateValid ? $paidDate : '',

View File

@ -24,10 +24,9 @@
default => 'is-neutral',
};
$paymentStateClass = static fn (string $state): string => match ($state) {
'出纳已打款' => 'is-success',
'出纳待打款', '出纳退回' => 'is-warning',
'出纳状态待同步', '未确认' => 'is-warning',
'出纳未开始', '流程终止', '不涉及付款' => 'is-neutral',
'已付款' => 'is-success',
'待付款', '付款待核实', '未确认' => 'is-warning',
'不涉及付款' => 'is-neutral',
default => 'is-neutral',
};
$pageUrl ??= route('business.pages.show', [
@ -122,6 +121,42 @@
font-size: .8125rem;
}
.process-details-field input[type="date"] {
color-scheme: light;
}
.process-details-field input[type="date"]::-webkit-calendar-picker-indicator {
cursor: pointer;
opacity: .72;
}
.process-details-date-control {
display: grid;
grid-template-columns: minmax(0, 1fr) 2.125rem;
gap: .35rem;
}
.process-details-date-picker {
display: inline-flex;
align-items: center;
justify-content: center;
width: 2.125rem;
height: 2.125rem;
padding: 0;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: #fff;
color: var(--vip-content-accent-dark, #856632);
cursor: pointer;
}
.process-details-date-picker:hover,
.process-details-date-picker:focus-visible {
border-color: var(--vip-content-accent-dark, #856632);
outline: none;
box-shadow: 0 0 0 3px rgba(133, 102, 50, .2);
}
.process-details-field input:focus,
.process-details-field select:focus {
border-color: var(--vip-content-accent-dark, #856632);
@ -615,8 +650,26 @@
<form method="GET" action="{{ $pageUrl }}" class="process-details-toolbar" aria-label="OA流程筛选">
<input type="hidden" name="per_page" value="{{ $processRows->perPage() }}">
<div class="process-details-field">
<label for="process-details-paid-date">打款日期</label>
<input id="process-details-paid-date" type="date" name="paid_date" value="{{ $filters['paid_date'] ?? '' }}">
<label for="process-details-paid-date">打款时间</label>
<div class="process-details-date-control">
<input
id="process-details-paid-date"
type="date"
name="paid_date"
value="{{ $filters['paid_date'] ?? '' }}"
lang="zh-CN"
title="选择打款日期"
>
<button
class="process-details-date-picker"
type="button"
data-process-date-picker="paid-date"
title="打开日历选择打款日期"
aria-label="打开日历选择打款日期"
>
<span class="material-icons-outlined" aria-hidden="true">calendar_today</span>
</button>
</div>
</div>
<div class="process-details-field">
<label for="process-details-type">单据类型</label>
@ -680,7 +733,9 @@
<p class="process-details-note">
金额合计按审批费用明细汇总,付款合计按结构化付款明细汇总,同一笔付款不会因关联多条费用而重复计算。
付款状态按钉钉“出纳打款”节点判断;付款差额按“费用合计 − 已付款合计”单独计算,不参与付款状态判断。
“出纳状态待同步”表示尚未取得出纳节点任务,不能据此推断已付款或未付款。
@if (in_array('付款待核实', $paymentStates, true))
“付款待核实”表示尚未取得可靠的出纳节点任务,不能据此推断已付款或待付款。
@endif
当前展示的是当前账号权限范围内可读取的钉钉OA审批流程;审批中的金额和行项目仍可能随流程变化。
企业级全量数据待领导开通 OA 权限后切换。
</p>
@ -826,3 +881,27 @@
</footer>
</div>
</div>
<script>
(() => {
const input = document.getElementById('process-details-paid-date');
const picker = document.querySelector('[data-process-date-picker="paid-date"]');
if (!input || !picker) {
return;
}
picker.addEventListener('click', () => {
if (typeof input.showPicker === 'function') {
try {
input.showPicker();
return;
} catch (error) {
// Fall back to focus when the browser blocks showPicker().
}
}
input.focus();
input.click();
});
})();
</script>

View File

@ -24,7 +24,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
'line_no' => 1,
'originator_name' => '张三',
'status' => '已完成',
'payment_state' => '出纳已打款',
'payment_state' => '已付款',
'payment_fact_amount' => 0,
'payment_difference' => 0.20,
'document_type' => '公摊日常报销',
@ -56,12 +56,9 @@ class ProcessDetailsPageTest extends FeatureTestCase
'document_types' => ['公摊日常报销'],
'statuses' => ['已完成'],
'payment_states' => [
'出纳状态待同步',
'出纳未开始',
'出纳待打款',
'出纳退回',
'出纳已打款',
'流程终止',
'待付款',
'已付款',
'付款待核实',
'不涉及付款',
],
]);
@ -84,13 +81,18 @@ class ProcessDetailsPageTest extends FeatureTestCase
->assertSee('审批编号')
->assertSee('发起人')
->assertSee('单据类型')
->assertSee('打款日期')
->assertSee('打款时间')
->assertSee('name="paid_date"', false)
->assertSee('lang="zh-CN"', false)
->assertSee('title="选择打款日期"', false)
->assertSee('data-process-date-picker="paid-date"', false)
->assertSee('aria-label="打开日历选择打款日期"', false)
->assertSee('calendar_today', false)
->assertSee('name="payment_state"', false)
->assertSee('审批状态')
->assertSee('付款状态')
->assertSee('出纳已打款')
->assertSee('出纳状态待同步')
->assertSee('已付款')
->assertSee('付款待核实')
->assertSee('付款金额')
->assertSee('付款差额')
->assertSee('0.20')
@ -115,7 +117,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
$repository = Mockery::mock(DingProcessDetailMirrorRepository::class);
$repository->shouldReceive('paginate')->once()->andThrow(new RuntimeException('not ready'));
$repository->shouldReceive('filterOptions')->once()->andThrow(new RuntimeException('not ready'));
$repository->shouldReceive('scope')->once()->andReturn('personal_permission');
$this->app->instance(DingProcessDetailMirrorRepository::class, $repository);
@ -162,7 +164,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
'business_id' => '202601011200000000001',
'originator_name' => '张三',
'status' => '已完成',
'payment_state' => '出纳已打款',
'payment_state' => '已付款',
'payment_difference' => 0.20,
'document_type' => '公摊日常报销',
'purpose' => '办公用品采购',
@ -181,7 +183,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
$response = $this->loginAs()->get(route('business.process-details.export', [
'status' => '已完成',
'payment_state' => '出纳已打款',
'payment_state' => '已付款',
]));
$response->assertOk();
@ -191,7 +193,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
$this->assertStringContainsString('张三', $content);
$this->assertStringContainsString('管理费用_办公费', $content);
$this->assertStringContainsString('付款状态', $content);
$this->assertStringContainsString('出纳已打款', $content);
$this->assertStringContainsString('已付款', $content);
$this->assertStringContainsString('付款差额', $content);
$this->assertStringContainsString('0.20', $content);
}

View File

@ -45,8 +45,8 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
$this->assertEqualsWithDelta(350.5, $result['summary']['bank_amount_total'], 0.001);
$this->assertSame('personal_permission', $result['scope']);
$paymentStates = collect($result['data'])->pluck('payment_state')->unique()->all();
$this->assertContains('出纳已打款', $paymentStates);
$this->assertContains('出纳待打款', $paymentStates);
$this->assertContains('已付款', $paymentStates);
$this->assertContains('待付款', $paymentStates);
$options = $this->repository->filterOptions();
$this->assertArrayNotHasKey('months', $options);
@ -55,16 +55,26 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
$this->assertContains('已完成', $options['statuses']);
$this->assertContains('审批中', $options['statuses']);
$this->assertSame([
'出纳状态待同步',
'出纳未开始',
'出纳待打款',
'出纳退回',
'出纳已打款',
'流程终止',
'不涉及付款',
'待付款',
'已付款',
], $options['payment_states']);
}
public function test_filter_options_only_return_payment_states_available_in_context(): void
{
$this->assertSame(
['已付款'],
$this->repository->filterOptions(['status' => '已完成'])['payment_states'],
);
$this->assertSame(
['待付款'],
$this->repository->filterOptions([
'status' => '审批中',
'payment_state' => '付款待核实',
])['payment_states'],
);
}
public function test_paginate_applies_paid_date_status_and_keyword_filters(): void
{
$this->assertSame(
@ -100,11 +110,11 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
);
$this->assertSame(
2,
$this->repository->paginate(['payment_state' => '出纳已打款'], 1, 50)['total'],
$this->repository->paginate(['payment_state' => '已付款'], 1, 50)['total'],
);
$this->assertSame(
2,
$this->repository->paginate(['payment_state' => '出纳待打款'], 1, 50)['total'],
$this->repository->paginate(['payment_state' => '待付款'], 1, 50)['total'],
);
}
@ -116,14 +126,14 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
->update(['cashier_status' => 'pending_sync', 'cashier_checked_at' => null]);
$result = $this->repository->paginate(
['payment_state' => '出纳状态待同步'],
['payment_state' => '付款待核实'],
1,
50,
);
$this->assertSame(2, $result['total']);
$this->assertSame(
['出纳状态待同步'],
['付款待核实'],
collect($result['data'])->pluck('payment_state')->unique()->values()->all(),
);
}
@ -143,7 +153,7 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
$this->assertSame(2, $result['total']);
$this->assertEqualsWithDelta(500.0, (float) $result['data'][0]->payment_difference, 0.001);
$this->assertSame('出纳待打款', $result['data'][0]->payment_state);
$this->assertSame('待付款', $result['data'][0]->payment_state);
}
public function test_process_without_payment_fields_is_not_applicable(): void
@ -180,12 +190,31 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
->where('business_id', '202602031200000000002')
->update(['payment_source_state' => 'api', 'cashier_status' => 'completed']);
$result = $this->repository->paginate(['payment_state' => '出纳已打款'], 1, 50);
$result = $this->repository->paginate(['payment_state' => '已付款'], 1, 50);
$this->assertSame(4, $result['total']);
$this->assertSame('api', (string) $result['data'][0]->payment_source_state);
}
public function test_completed_workflow_with_legacy_null_cashier_status_is_paid(): void
{
DB::connection('business_mirror')
->table('ding_process_detail_mirror')
->where('business_id', '202601011200000000001')
->update(['cashier_status' => null, 'cashier_checked_at' => null]);
$result = $this->repository->paginate([
'business_id' => '202601011200000000001',
'payment_state' => '已付款',
], 1, 50);
$this->assertSame(2, $result['total']);
$this->assertSame(
['已付款'],
collect($result['data'])->pluck('payment_state')->unique()->values()->all(),
);
}
public function test_export_rows_returns_every_filtered_row(): void
{
$rows = iterator_to_array($this->repository->exportRows(['status' => '已完成']));

View File

@ -143,7 +143,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
$row = app(DingProcessDetailMirrorRepository::class)
->paginate(['business_id' => '202606031318000506330'], 1, 50)['data'][0];
$this->assertSame('completed', $row->cashier_status);
$this->assertSame('出纳已打款', $row->payment_state);
$this->assertSame('已付款', $row->payment_state);
$this->assertEqualsWithDelta(0.20, (float) $row->payment_difference, 0.001);
}
@ -175,7 +175,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
$row = app(DingProcessDetailMirrorRepository::class)
->paginate(['business_id' => '202610221534000124202'], 1, 50)['data'][0];
$this->assertSame('returned', $row->cashier_status);
$this->assertSame('出纳退回', $row->payment_state);
$this->assertSame('待付款', $row->payment_state);
$this->assertEqualsWithDelta(750.0, (float) $row->payment_difference, 0.001);
}
@ -250,7 +250,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
$this->assertSame('missing', $row->payment_source_state);
$this->assertSame('not_started', $row->cashier_status);
$page = app(DingProcessDetailMirrorRepository::class)->paginate(
['payment_state' => '出纳未开始'],
['payment_state' => '待付款'],
1,
50,
);
@ -316,6 +316,12 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
->table('business_mirror_table_states')
->first();
$this->assertSame(101, (int) json_decode((string) $state->cursor, true)['scheme_high_watermark']);
$this->assertFalse(collect($this->query->calls)->contains(
static fn (array $call): bool => str_contains(
(string) ($call['sql'] ?? ''),
'ORDER BY w.processInstanceId, w.processInstanceId',
),
));
}
public function test_official_api_fills_payment_when_replica_omits_payment_table(): void

View File

@ -50,7 +50,7 @@ class ProcessDetailsPageDataTest extends TestCase
->method('paginate')
->with($this->callback(static fn (array $filters): bool =>
$filters['paid_date'] === '2026-10-24'
&& $filters['payment_state'] === '出纳已打款'
&& $filters['payment_state'] === '已付款'
), 2, 50)
->willReturn([
'data' => [$row],
@ -73,12 +73,9 @@ class ProcessDetailsPageDataTest extends TestCase
'document_types' => ['种菜核销/种菜报销'],
'statuses' => ['审批中'],
'payment_states' => [
'出纳状态待同步',
'出纳未开始',
'出纳待打款',
'出纳退回',
'出纳已打款',
'流程终止',
'待付款',
'已付款',
'付款待核实',
'不涉及付款',
],
]);
@ -97,15 +94,12 @@ class ProcessDetailsPageDataTest extends TestCase
$this->assertSame('succeeded', $data['mirrorStatus']);
$this->assertSame(11331, $data['summary']['rows']);
$this->assertSame('2026-10-24', $data['filters']['paid_date']);
$this->assertSame('出纳已打款', $data['filters']['payment_state']);
$this->assertSame('已付款', $data['filters']['payment_state']);
$this->assertSame(
[
'出纳状态待同步',
'出纳未开始',
'出纳待打款',
'出纳退回',
'出纳已打款',
'流程终止',
'待付款',
'已付款',
'付款待核实',
'不涉及付款',
],
$data['paymentStates'],
@ -116,6 +110,51 @@ class ProcessDetailsPageDataTest extends TestCase
$this->assertNull($data['error']);
}
public function test_unavailable_payment_state_filter_is_cleared_before_querying(): void
{
$repository = $this->createMock(DingProcessDetailMirrorRepository::class);
$repository->expects($this->once())
->method('filterOptions')
->with($this->callback(static fn (array $filters): bool =>
$filters['status'] === '已完成'
&& $filters['payment_state'] === '付款待核实'
))
->willReturn([
'document_types' => ['公摊日常报销'],
'statuses' => ['已完成'],
'payment_states' => ['已付款'],
]);
$repository->expects($this->once())
->method('paginate')
->with($this->callback(static fn (array $filters): bool =>
$filters['status'] === '已完成'
&& $filters['payment_state'] === ''
), 1, 50)
->willReturn([
'data' => [],
'total' => 51,
'summary' => [
'rows' => 51,
'approvals' => 0,
'amount_total' => 0,
'bank_amount_total' => 0,
],
'status' => 'succeeded',
'last_synced_at' => null,
'scope' => 'personal_permission',
]);
$data = (new ProcessDetailsPageData($repository))->page(Request::create(
'/1/workspace/process-data/oa-process',
'GET',
['status' => '已完成', 'payment_state' => '付款待核实'],
));
$this->assertSame('', $data['filters']['payment_state']);
$this->assertSame(['已付款'], $data['paymentStates']);
$this->assertStringNotContainsString('payment_state', $data['processRows']->url(2));
}
#[DataProvider('perPageProvider')]
public function test_page_size_only_accepts_supported_options(mixed $requested, int $expected): void
{