From b72b2e12bdb4fa7641e55dca7073024ae9d2e756 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Fri, 27 Nov 2026 14:42:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8F=91=E7=A5=A8=E6=95=B0=E6=8D=AE):=20?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=B5=81=E7=A8=8B=E7=9B=B4=E6=8A=93=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E5=8F=91=E7=A5=A8=E5=AD=97=E6=AE=B5=20(#1505)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 发票明细按 OA 流程附件直抓口径展示完整字段,打款时间移到最后,并从 2026-10 开始统计。 --- .../Http/Controllers/InvoiceData.php | 29 ++- .../DingInvoiceDataMirrorRepository.php | 16 +- .../Services/DingInvoiceSyncService.php | 19 +- .../View/InvoiceDataPageData.php | 5 +- .../invoice-data.blade.php | 201 ++++++++++++------ .../Feature/Business/InvoiceDataPageTest.php | 112 +++++++++- 6 files changed, 299 insertions(+), 83 deletions(-) diff --git a/modules/EcommerceFinance/Http/Controllers/InvoiceData.php b/modules/EcommerceFinance/Http/Controllers/InvoiceData.php index 3adacf3c..52319d70 100644 --- a/modules/EcommerceFinance/Http/Controllers/InvoiceData.php +++ b/modules/EcommerceFinance/Http/Controllers/InvoiceData.php @@ -33,7 +33,6 @@ class InvoiceData extends Controller '报销类型', '费用类型', '收款人', - '打款时间', '本月付款金额', '付款合计', '发票张数', @@ -41,6 +40,7 @@ class InvoiceData extends Controller '付款差额', '扫描状态', '扫描说明', + '打款时间', ]); foreach ($this->repository->exportRows($filters) as $row) { $payment = (float) ($row['payment_amount'] ?? 0); @@ -52,7 +52,6 @@ class InvoiceData extends Controller (string) ($row['document_type'] ?? ''), (string) ($row['expense_type'] ?? ''), (string) ($row['payee_name'] ?? ''), - (string) ($row['paid_at'] ?? ''), number_format($payment, 2, '.', ''), number_format((float) ($row['payment_total'] ?? 0), 2, '.', ''), (int) ($row['invoice_count'] ?? 0), @@ -60,6 +59,7 @@ class InvoiceData extends Controller number_format(round($payment - $invoice, 2), 2, '.', ''), (string) ($row['scan_status'] ?? ''), (string) ($row['last_error'] ?? ''), + (string) ($row['paid_at'] ?? ''), ]); } } else { @@ -68,9 +68,8 @@ class InvoiceData extends Controller '标题', '提交人', '报销类型', + '费用类型', '收款人', - '打款时间', - '本月付款金额', '发票类型', '销售方名称', '销售方税号', @@ -83,8 +82,14 @@ class InvoiceData extends Controller '金额', '税率', '税额', - '付款差额', + '本月付款金额', + '付款合计', + '发票张数', + '金额校对', + '差异金额', '附件名称', + '识别来源', + '打款时间', ]); foreach ($this->repository->exportRows($filters) as $row) { $payment = (float) ($row['payment_amount'] ?? 0); @@ -94,9 +99,8 @@ class InvoiceData extends Controller (string) ($row['title'] ?? ''), (string) ($row['originator_name'] ?? ''), (string) ($row['document_type'] ?? ''), + (string) ($row['expense_type'] ?? ''), (string) ($row['payee_name'] ?? ''), - (string) ($row['paid_at'] ?? ''), - number_format($payment, 2, '.', ''), (string) ($row['invoice_type'] ?? ''), (string) ($row['seller_name'] ?? ''), (string) ($row['seller_tax_no'] ?? ''), @@ -113,8 +117,17 @@ class InvoiceData extends Controller $row['tax_amount'] === null ? '' : number_format((float) $row['tax_amount'], 2, '.', ''), - number_format(round($payment - $invoice, 2), 2, '.', ''), + number_format($payment, 2, '.', ''), + number_format((float) ($row['payment_total'] ?? 0), 2, '.', ''), + (int) ($row['invoice_count'] ?? 0), + abs(round($payment - $invoice, 2)) <= 0.005 ? '一致' : '有差异', + number_format(round( + $payment - (float) ($row['flow_invoice_total'] ?? 0), + 2, + ), 2, '.', ''), (string) ($row['source_file_name'] ?? ''), + (string) ($row['ocr_provider'] ?? ''), + (string) ($row['paid_at'] ?? ''), ]); } } diff --git a/modules/EcommerceFinance/Repositories/DingInvoiceDataMirrorRepository.php b/modules/EcommerceFinance/Repositories/DingInvoiceDataMirrorRepository.php index 7d54ccac..1ac17573 100644 --- a/modules/EcommerceFinance/Repositories/DingInvoiceDataMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/DingInvoiceDataMirrorRepository.php @@ -11,6 +11,8 @@ use RuntimeException; class DingInvoiceDataMirrorRepository { + public const FIRST_SUPPORTED_MONTH = '2026-10'; + public const PER_PAGE_OPTIONS = [50, 100, 200]; public const VIEW_DETAIL = 'detail'; @@ -86,6 +88,7 @@ class DingInvoiceDataMirrorRepository ->where('source_scope', $this->scope()) ->whereNotNull('paid_month') ->where('paid_month', '!=', '') + ->where('paid_month', '>=', self::FIRST_SUPPORTED_MONTH) ->distinct() ->orderByDesc('paid_month') ->pluck('paid_month') @@ -260,6 +263,7 @@ class DingInvoiceDataMirrorRepository 'r.buyer_name', 'r.buyer_tax_no', 'r.item_name', + 'r.invoice_date', 'f.title', 'f.originator_name', 'f.payee_name', @@ -333,7 +337,13 @@ class DingInvoiceDataMirrorRepository ->whereColumn('rk.source_scope', 'f.source_scope') ->whereColumn('rk.business_id', 'f.business_id') ->where(function (Builder $invoiceSearch) use ($keyword): void { - foreach (['invoice_number', 'seller_name', 'buyer_name', 'item_name'] as $column) { + foreach ([ + 'invoice_number', + 'seller_name', + 'buyer_name', + 'item_name', + 'invoice_date', + ] as $column) { $invoiceSearch->orWhere("rk.{$column}", 'like', $keyword); } }); @@ -410,6 +420,7 @@ class DingInvoiceDataMirrorRepository 'buyer_name', 'buyer_tax_no', 'item_name', + 'invoice_date', ] as $column) { $invoiceSearch->orWhere( 'summary_invoice_search.' . $column, @@ -435,6 +446,9 @@ class DingInvoiceDataMirrorRepository return [ 'flows' => $rows->count(), + 'invoice_flows' => $rows->filter( + static fn (object $row): bool => (int) $row->invoice_count > 0, + )->count(), 'payment_amount' => $payment, 'invoice_count' => (int) $rows->sum('invoice_count'), 'invoice_total' => $invoice, diff --git a/modules/EcommerceFinance/Services/DingInvoiceSyncService.php b/modules/EcommerceFinance/Services/DingInvoiceSyncService.php index 56fb0fdf..cbd5470d 100644 --- a/modules/EcommerceFinance/Services/DingInvoiceSyncService.php +++ b/modules/EcommerceFinance/Services/DingInvoiceSyncService.php @@ -11,6 +11,8 @@ use Throwable; class DingInvoiceSyncService { + private const DIRECT_SOURCE_NAME = 'OA attachment scan'; + private ConnectionInterface $connection; public function __construct( @@ -56,7 +58,9 @@ class DingInvoiceSyncService ->where('process_instance_id', '!=', '') ->where(function ($query): void { $query->whereIn('scan_status', ['pending', 'failed', 'partial']) - ->orWhereNull('scanned_at'); + ->orWhereNull('scanned_at') + ->orWhereNull('source_name') + ->orWhere('source_name', '!=', self::DIRECT_SOURCE_NAME); }); $flows = $query ->orderByDesc('paid_at') @@ -73,7 +77,9 @@ class DingInvoiceSyncService ->where('process_instance_id', '!=', '') ->where(function ($query): void { $query->whereIn('scan_status', ['pending', 'failed', 'partial']) - ->orWhereNull('scanned_at'); + ->orWhereNull('scanned_at') + ->orWhereNull('source_name') + ->orWhere('source_name', '!=', self::DIRECT_SOURCE_NAME); }) ->count(); @@ -140,7 +146,9 @@ class DingInvoiceSyncService ->where('process_instance_id', '!=', '') ->where(function ($query): void { $query->whereIn('scan_status', ['pending', 'failed', 'partial']) - ->orWhereNull('scanned_at'); + ->orWhereNull('scanned_at') + ->orWhereNull('source_name') + ->orWhere('source_name', '!=', self::DIRECT_SOURCE_NAME); }) ->count(); $this->updateState($metrics); @@ -160,7 +168,9 @@ class DingInvoiceSyncService ->where('process_instance_id', '!=', '') ->where(function ($query): void { $query->whereIn('scan_status', ['pending', 'failed', 'partial']) - ->orWhereNull('scanned_at'); + ->orWhereNull('scanned_at') + ->orWhereNull('source_name') + ->orWhere('source_name', '!=', self::DIRECT_SOURCE_NAME); }) ->max('paid_month'); @@ -675,6 +685,7 @@ class DingInvoiceSyncService 'attachment_count' => count($files), 'scanned_file_count' => $scannedFiles, 'last_error' => $error, + 'source_name' => self::DIRECT_SOURCE_NAME, 'scanned_at' => $now, 'updated_at' => $now, ]); diff --git a/modules/EcommerceFinance/View/InvoiceDataPageData.php b/modules/EcommerceFinance/View/InvoiceDataPageData.php index a6e1de8e..59e6560f 100644 --- a/modules/EcommerceFinance/View/InvoiceDataPageData.php +++ b/modules/EcommerceFinance/View/InvoiceDataPageData.php @@ -34,7 +34,7 @@ class InvoiceDataPageData $months = []; } $requestedMonth = trim((string) $request->query('month', '')); - $month = preg_match('/^\d{4}-\d{2}$/', $requestedMonth) === 1 + $month = in_array($requestedMonth, $months, true) ? $requestedMonth : (string) ($months[0] ?? ''); $view = $request->query('invoice_view') === DingInvoiceDataMirrorRepository::VIEW_FLOWS @@ -104,6 +104,7 @@ class InvoiceDataPageData 'invoiceStates' => DingInvoiceDataMirrorRepository::INVOICE_STATES, 'invoicePerPageOptions' => DingInvoiceDataMirrorRepository::PER_PAGE_OPTIONS, 'invoicePerPage' => $perPage, + 'invoiceStartMonth' => DingInvoiceDataMirrorRepository::FIRST_SUPPORTED_MONTH, 'invoiceSummary' => $detailResult['summary'], 'invoiceMirrorStatus' => $mirrorStatus, 'invoiceMirrorSyncedAt' => $state['last_succeeded_at'] ?? null, @@ -143,8 +144,10 @@ class InvoiceDataPageData 'invoiceStates' => DingInvoiceDataMirrorRepository::INVOICE_STATES, 'invoicePerPageOptions' => DingInvoiceDataMirrorRepository::PER_PAGE_OPTIONS, 'invoicePerPage' => $perPage, + 'invoiceStartMonth' => DingInvoiceDataMirrorRepository::FIRST_SUPPORTED_MONTH, 'invoiceSummary' => [ 'flows' => 0, + 'invoice_flows' => 0, 'payment_amount' => 0.0, 'invoice_count' => 0, 'invoice_total' => 0.0, diff --git a/resources/views/business/pages/financial-operations/invoice-data.blade.php b/resources/views/business/pages/financial-operations/invoice-data.blade.php index 92140993..8586e334 100644 --- a/resources/views/business/pages/financial-operations/invoice-data.blade.php +++ b/resources/views/business/pages/financial-operations/invoice-data.blade.php @@ -6,8 +6,9 @@ $flowRows = $invoiceFlowRows ?? collect(); $filters = $invoiceFilters ?? []; $activeView = $invoiceActiveView ?? 'detail'; + $startMonth = $invoiceStartMonth ?? '2026-10'; $statusLabels = [ - 'imported' => '已导入', + 'imported' => '已扫描', 'recognized' => '已识别', 'no_invoice' => '无票', 'partial' => '部分识别', @@ -18,8 +19,8 @@ 'failed' => '同步失败', 'pending' => '待同步', 'running' => '同步中', - 'imported' => '已导入', - 'unavailable' => '未导入', + 'imported' => '数据就绪', + 'unavailable' => '暂无数据', ]; $filterQuery = array_filter($filters, static fn (mixed $value): bool => $value !== '' && $value !== null); $detailTabUrl = $invoicePageUrl . '?' . http_build_query(array_merge($filterQuery, [ @@ -184,7 +185,7 @@ .invoice-data-kpis { display: grid; margin-top: 0.75rem; - grid-template-columns: repeat(6, minmax(0, 1fr)); + grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--invoice-border); border-radius: 0.5rem; @@ -277,7 +278,7 @@ .invoice-data-table { width: 100%; - min-width: 82rem; + min-width: 178rem; border-collapse: collapse; color: var(--invoice-ink); font-size: 0.75rem; @@ -285,7 +286,26 @@ } .invoice-data-table.is-flow { - min-width: 72rem; + min-width: 104rem; + } + + .invoice-data-table.is-detail th:first-child, + .invoice-data-table.is-detail td:first-child { + position: sticky; + left: 0; + z-index: 1; + min-width: 13rem; + background: var(--invoice-surface); + box-shadow: 1px 0 0 var(--invoice-border); + } + + .invoice-data-table.is-detail thead th:first-child { + z-index: 3; + background: var(--invoice-soft); + } + + .invoice-data-table.is-detail tbody tr:hover td:first-child { + background: #fcfaf4; } .invoice-data-table th, @@ -326,6 +346,16 @@ white-space: nowrap; } + .invoice-data-table .is-preline { + min-width: 18rem; + white-space: pre-line; + } + + .invoice-data-table .is-code { + font-family: "JetBrains Mono", monospace; + white-space: nowrap; + } + .invoice-data-primary { display: block; color: var(--invoice-ink); @@ -459,14 +489,18 @@ @media (max-width: 1180px) { .invoice-data-kpis { - grid-template-columns: repeat(3, minmax(0, 1fr)); + grid-template-columns: repeat(4, minmax(0, 1fr)); } - .invoice-data-kpi:nth-child(3) { + .invoice-data-kpi:nth-child(4) { border-right: 0; } - .invoice-data-kpi:nth-child(n + 4) { + .invoice-data-kpi:nth-child(7) { + border-right: 0; + } + + .invoice-data-kpi:nth-child(n + 5) { border-top: 1px solid var(--invoice-border); } } @@ -581,7 +615,7 @@ data-ocr-configured="{{ $invoiceOcrConfigured ? 'true' : 'false' }}" > - 抓取发票 + 从流程抓取发票 @@ -593,10 +627,10 @@
- 数据口径:按打款时间归属月份 · 一张发票一行 · 无票流程保留 + 数据口径:{{ $startMonth }} 起 · 通过 OA 审批流程附件自动识别 · 按打款时间归属月份 · 一张发票一行 - 镜像状态:{{ $mirrorStatusLabels[$invoiceMirrorStatus] ?? $invoiceMirrorStatus }} + 扫描状态:{{ $mirrorStatusLabels[$invoiceMirrorStatus] ?? $invoiceMirrorStatus }} @if ($invoiceMirrorSyncedAt) · 最近成功 {{ $invoiceMirrorSyncedAt }} @endif @@ -611,8 +645,8 @@ {{ number_format((int) ($summary['flows'] ?? 0)) }}
- 本月付款金额 - ¥{{ $wan($summary['payment_amount'] ?? 0) }} 万 + 含票流程 + {{ number_format((int) ($summary['invoice_flows'] ?? 0)) }}
发票张数 @@ -622,6 +656,10 @@ 发票价税合计 ¥{{ $wan($summary['invoice_total'] ?? 0) }} 万
+
+ 本月付款金额 + ¥{{ $wan($summary['payment_amount'] ?? 0) }} 万 +
无票流程 {{ number_format((int) ($summary['no_invoice_flows'] ?? 0)) }} @@ -667,52 +705,77 @@ @if ($activeView !== 'detail') hidden @endif >
- +
- - - - - - - + + + + + + + + + + + + + + + + + - + + + + + + @forelse ($detailRows as $row) + @php + $flowDifference = round( + (float) $row->payment_amount - (float) $row->flow_invoice_total, + 2, + ); + @endphp - - - - + + + + + + - + + + + + + + - + - + + + + + @empty - + @endforelse @@ -750,15 +816,18 @@
流程号 / 标题提交人 / 报销类型打款时间本月付款发票类型 / 项目销售方购买方流程号流程标题提交人报销类型费用类型收款人发票类型发票号码开票日期项目名称销售方名称销售方税号购买方名称购买方税号金额税率税额 价税合计发票号码 / 日期本月付款付款合计发票张数金额校对差异金额 附件打款时间
- {{ $row->title ?: '未命名审批' }} - {{ $row->business_id }} - - {{ $row->originator_name ?: '-' }} - {{ $row->document_type ?: '-' }} - - {{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }} - ¥{{ $money($row->payment_amount) }}{{ $row->business_id }}{{ $row->title ?: '未命名审批' }}{{ $row->originator_name ?: '-' }}{{ $row->document_type ?: '-' }}{{ $row->expense_type ?: '-' }}{{ $row->payee_name ?: '-' }} {{ $row->invoice_type ?: '未分类' }} - {{ \Illuminate\Support\Str::limit((string) $row->item_name, 34) }} - {{ $row->seller_name ?: '-' }} - {{ $row->seller_tax_no ?: '' }} + {{ $row->invoice_number ?: '-' }}{{ $row->invoice_date ?: '-' }}{{ $row->item_name ?: '-' }}{{ $row->seller_name ?: '-' }}{{ $row->seller_tax_no ?: '-' }}{{ $row->buyer_name ?: '-' }}{{ $row->buyer_tax_no ?: '-' }} + {{ $row->amount_without_tax === null ? '-' : '¥' . $money($row->amount_without_tax) }} - {{ $row->buyer_name ?: '-' }} - {{ $row->buyer_tax_no ?: '' }} + {{ $row->tax_rate ?: '-' }} + {{ $row->tax_amount === null ? '-' : '¥' . $money($row->tax_amount) }} ¥{{ $money($row->invoice_total) }} - {{ $row->invoice_number ?: '-' }} - {{ $row->invoice_date ?: '无开票日期' }} + ¥{{ $money($row->payment_amount) }}¥{{ $money($row->payment_total) }}{{ number_format((int) $row->invoice_count) }}{{ abs($flowDifference) <= 0.005 ? '一致' : '有差异' }} + abs($flowDifference) > 0.005])> + ¥{{ $money($flowDifference) }} + @if ($row->source_file_id) @@ -724,13 +787,16 @@ rel="noopener" >查看附件 @else - 台账导入 + 待关联原件 @endif + {{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }} +
当前筛选条件下没有发票明细。当前筛选条件下没有发票明细。
- - + + + + + - + @@ -767,21 +836,12 @@ $difference = round((float) $row->payment_amount - (float) $row->invoice_total, 2); @endphp - - - - + + + + + + @@ -800,10 +860,13 @@ 无票 @endif + @empty - + @endforelse @@ -813,8 +876,10 @@

- 口径:按 OA 付款明细中的打款时间归入月份;一张发票一行,同一流程多张发票分别列示; - 无票流程在“按流程汇总”中保留。发票金额覆盖可能出现超过 100%,表示开票金额高于本月付款,需按具体流程复核。 + 口径:统计从 {{ $startMonth }} 开始。发票通过 OA 审批流程附件自动识别,按打款时间归入月份; + 一张发票一行,同一流程多张发票分别列示,并保留对应流程号。无票流程在“按流程汇总”中保留。 + 尚未关联原件的历史记录会标记为“待关联原件”。开票金额覆盖率可能超过 100%, + 表示开票金额高于本月付款,需要按具体流程复核。

diff --git a/tests/Feature/Business/InvoiceDataPageTest.php b/tests/Feature/Business/InvoiceDataPageTest.php index e9835759..9394b5fa 100644 --- a/tests/Feature/Business/InvoiceDataPageTest.php +++ b/tests/Feature/Business/InvoiceDataPageTest.php @@ -146,14 +146,44 @@ class InvoiceDataPageTest extends FeatureTestCase ->assertSee('抓取发票') ->assertSee('data-invoice-refresh', false) ->assertSee('付款流程') + ->assertSee('含票流程') ->assertSee('发票价税合计') ->assertSee('开票金额覆盖率') + ->assertSee('通过 OA 审批流程附件自动识别') ->assertSee('FLOW-INVOICE-1') ->assertSee('10月办公用品报销') ->assertSee('26320000000000000001') ->assertSee('测试供应商') + ->assertSee('*办公用品*打印纸') + ->assertSee('2026-10-10') ->assertSee('FLOW-NO-INVOICE') - ->assertSee('无票'); + ->assertSee('无票') + ->assertDontSee('台账导入'); + + $html = $response->getContent(); + preg_match( + '/
流程号 / 标题提交人 / 报销类型流程号流程标题提交人报销类型费用类型 收款人打款时间 本月付款 发票张数 发票合计 付款差额 状态打款时间
- {{ $row->title ?: '未命名审批' }} - {{ $row->business_id }} - - {{ $row->originator_name ?: '-' }} - {{ $row->document_type ?: '-' }} - - {{ $row->payee_name ?: '-' }} - {{ $row->expense_type ?: '' }} - - {{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }} - {{ $row->business_id }}{{ $row->title ?: '未命名审批' }}{{ $row->originator_name ?: '-' }}{{ $row->document_type ?: '-' }}{{ $row->expense_type ?: '-' }}{{ $row->payee_name ?: '-' }} ¥{{ $money($row->payment_amount) }} {{ number_format((int) $row->invoice_count) }} ¥{{ $money($row->invoice_total) }} + {{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }} +
当前筛选条件下没有流程汇总。当前筛选条件下没有流程汇总。
.*?.*?<\/tr>/su', + $html, + $detailHeader, + ); + $this->assertNotEmpty($detailHeader); + $this->assertStringContainsString('>项目名称', $detailHeader[0]); + $this->assertMatchesRegularExpression( + '/>项目名称<\/th>.*>打款时间<\/th>\s*<\/tr>$/su', + $detailHeader[0], + ); + + $flowHeader = null; + preg_match( + '/
.*?.*?<\/tr>/su', + $html, + $flowHeader, + ); + $this->assertNotEmpty($flowHeader); + $this->assertMatchesRegularExpression( + '/>状态<\/th>\s*
打款时间<\/th>\s*<\/tr>$/su', + $flowHeader[0], + ); $this->assertContains( 'invoice-data', @@ -242,9 +272,69 @@ class InvoiceDataPageTest extends FeatureTestCase $this->assertSame(1, $flowResult['total']); $this->assertSame('FLOW-NO-INVOICE', $flowResult['data'][0]->business_id); $this->assertSame(1, $flowResult['summary']['flows']); + $this->assertSame(0, $flowResult['summary']['invoice_flows']); $this->assertSame(1, $flowResult['summary']['no_invoice_flows']); } + public function test_invoice_months_start_from_october(): void + { + $now = now(); + DB::connection('business_mirror')->table('ding_invoice_flow_mirror')->insert([ + 'source_scope' => 'personal_permission', + 'business_id' => 'FLOW-SEPTEMBER', + 'process_instance_id' => 'PROCESS-SEPTEMBER', + 'paid_month' => '2026-09', + 'title' => '9月不应展示的流程', + 'payment_amount' => 10, + 'payment_total' => 10, + 'invoice_count' => 0, + 'invoice_total' => 0, + 'scan_status' => 'no_invoice', + 'attachment_count' => 0, + 'scanned_file_count' => 0, + 'source_name' => 'OA attachment scan', + 'scanned_at' => $now, + 'created_at' => $now, + 'updated_at' => $now, + ]); + + $this->assertNotContains( + '2026-09', + app(DingInvoiceDataMirrorRepository::class)->months(), + ); + + $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); + $this->loginAs() + ->get(route('business.pages.show', [ + 'section' => 'process-data', + 'page' => 'invoice-data', + 'month' => '2026-09', + ])) + ->assertOk() + ->assertDontSee('9月不应展示的流程') + ->assertSee('10月办公用品报销'); + } + + public function test_invoice_exports_keep_payment_time_as_last_column(): void + { + $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); + foreach ([ + DingInvoiceDataMirrorRepository::VIEW_DETAIL, + DingInvoiceDataMirrorRepository::VIEW_FLOWS, + ] as $view) { + $response = $this->loginAs()->get(route('business.invoice-data.export', [ + 'month' => '2026-10', + 'invoice_view' => $view, + 'invoice_state' => 'all', + ])); + $response->assertOk(); + + $content = ltrim($response->streamedContent(), "\xEF\xBB\xBF"); + $header = str_getcsv((string) strtok($content, "\n")); + $this->assertSame('打款时间', end($header)); + } + } + public function test_refresh_endpoint_queues_selected_month(): void { $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); @@ -281,6 +371,7 @@ class InvoiceDataPageTest extends FeatureTestCase 'scan_status' => 'pending', 'attachment_count' => 0, 'scanned_file_count' => 0, + 'source_name' => 'OA attachment scan', 'created_at' => $now, 'updated_at' => $now, ]); @@ -296,6 +387,24 @@ class InvoiceDataPageTest extends FeatureTestCase 'scan_status' => 'failed', 'attachment_count' => 0, 'scanned_file_count' => 0, + 'source_name' => 'OA attachment scan', + 'scanned_at' => $now, + 'created_at' => $now, + 'updated_at' => $now, + ]); + DB::connection('business_mirror')->table('ding_invoice_flow_mirror')->insert([ + 'source_scope' => 'personal_permission', + 'business_id' => 'FLOW-IMPORTED-NEWER', + 'process_instance_id' => 'PROCESS-IMPORTED-NEWER', + 'paid_month' => '2026-11', + 'payment_amount' => 10, + 'payment_total' => 10, + 'invoice_count' => 1, + 'invoice_total' => 10, + 'scan_status' => 'recognized', + 'attachment_count' => 1, + 'scanned_file_count' => 1, + 'source_name' => 'invoice_recheck.xlsx', 'scanned_at' => $now, 'created_at' => $now, 'updated_at' => $now, @@ -312,6 +421,7 @@ class InvoiceDataPageTest extends FeatureTestCase 'scan_status' => 'recognized', 'attachment_count' => 1, 'scanned_file_count' => 1, + 'source_name' => 'OA attachment scan', 'scanned_at' => $now, 'created_at' => $now, 'updated_at' => $now,