diff --git a/app/Business/InvoiceReportsPageData.php b/app/Business/InvoiceReportsPageData.php new file mode 100644 index 00000000..dc7a04dc --- /dev/null +++ b/app/Business/InvoiceReportsPageData.php @@ -0,0 +1,198 @@ +reportRows(InputInvoiceReport::class); + $outputRows = $this->reportRows(OutputInvoiceReport::class); + + if ($tab === 'summary') { + $allRows = $this->summaryRows($inputRows, $outputRows); + $filters = $this->summaryFilters(); + $summaryRows = $this->filterSummaryRows($allRows, $filters); + + return [ + 'view' => 'business.pages.invoice_reports', + 'summaryRows' => $summaryRows, + 'summaryTotals' => $this->summaryTotals($summaryRows), + 'summaryFilters' => $filters, + 'companyOptions' => $allRows->pluck('company_name') + ->filter(static fn ($name): bool => (string) $name !== '') + ->unique() + ->sort() + ->values(), + 'taxpayerTypeOptions' => $allRows->pluck('taxpayer_type') + ->filter(static fn ($type): bool => (string) $type !== '' && (string) $type !== '—') + ->unique() + ->sort() + ->values(), + ]; + } + + return [ + 'view' => 'business.pages.invoice_reports', + 'items' => $tab === 'output' ? $outputRows : $inputRows, + ]; + } + + /** + * 报表表在部分老环境可能尚未迁移,缺失时保持页面可用并展示空表。 + * + * @param class-string $model + */ + private function reportRows(string $model): Collection + { + try { + return $model::query() + ->orderBy('company_name') + ->orderBy('id') + ->get(); + } catch (Throwable $exception) { + report($exception); + + return collect(); + } + } + + private function summaryRows(Collection $inputRows, Collection $outputRows): Collection + { + $inputs = $inputRows->groupBy(fn ($row): string => trim((string) $row->company_name)); + $outputs = $outputRows->groupBy(fn ($row): string => trim((string) $row->company_name)); + + $companyNames = $inputs->keys() + ->merge($outputs->keys()) + ->filter(static fn ($name): bool => $name !== '') + ->unique() + ->sort() + ->values(); + + $taxpayerTypes = $this->taxpayerTypes($companyNames); + + return $companyNames->map(function (string $companyName) use ($inputs, $outputs, $taxpayerTypes): object { + $inputRows = $inputs->get($companyName, collect()); + $outputRows = $outputs->get($companyName, collect()); + + $inputAmount = $this->sumField($inputRows, 'input_total_amount'); + $inputTax = $this->sumField($inputRows, 'input_total_tax'); + $outputAmount = $this->sumField($outputRows, 'output_total_amount'); + $outputTax = $this->sumField($outputRows, 'output_total_tax'); + $ratio = $outputAmount > 0 ? $inputAmount / $outputAmount : null; + + return (object) [ + 'company_name' => $companyName, + 'taxpayer_type' => $taxpayerTypes->get($companyName, '—'), + 'input_total_amount' => $inputAmount, + 'input_total_tax' => $inputTax, + 'output_total_amount' => $outputAmount, + 'output_total_tax' => $outputTax, + 'input_output_ratio' => $ratio, + 'is_warning' => $ratio !== null && $ratio < 0.8, + ]; + }); + } + + private function summaryTotals(Collection $rows): object + { + return (object) [ + 'input_total_amount' => round((float) $rows->sum('input_total_amount'), 2), + 'input_total_tax' => round((float) $rows->sum('input_total_tax'), 2), + 'output_total_amount' => round((float) $rows->sum('output_total_amount'), 2), + 'output_total_tax' => round((float) $rows->sum('output_total_tax'), 2), + ]; + } + + /** + * @return array{company:string,taxpayer_type:string,warning:string} + */ + private function summaryFilters(): array + { + $warning = strtolower(trim((string) request()->query('warning', ''))); + + return [ + 'company' => trim((string) request()->query('company', '')), + 'taxpayer_type' => trim((string) request()->query('taxpayer_type', '')), + 'warning' => in_array($warning, ['yes', 'no'], true) ? $warning : '', + ]; + } + + /** + * @param array{company:string,taxpayer_type:string,warning:string} $filters + */ + private function filterSummaryRows(Collection $rows, array $filters): Collection + { + return $rows->filter(function (object $row) use ($filters): bool { + if ($filters['company'] !== '' && $row->company_name !== $filters['company']) { + return false; + } + + if ($filters['taxpayer_type'] !== '' && $row->taxpayer_type !== $filters['taxpayer_type']) { + return false; + } + + if ($filters['warning'] === 'yes' && ! $row->is_warning) { + return false; + } + + if ($filters['warning'] === 'no' && $row->is_warning) { + return false; + } + + return true; + })->values(); + } + + /** + * 纳税人类型取公司基础信息共享镜像;镜像未就绪或公司未登记时显示「—」。 + */ + private function taxpayerTypes(Collection $companyNames): Collection + { + $names = $companyNames + ->map(static fn ($name): string => trim((string) $name)) + ->filter(static fn (string $name): bool => $name !== '') + ->unique() + ->values() + ->all(); + + if ($names === []) { + return collect(); + } + + try { + $rows = app(\Modules\EcommerceFinance\Repositories\BusinessInformationMirrorRepository::class) + ->allCompaniesForClassification(['_company_names' => $names]); + + return collect($rows) + ->mapWithKeys(static fn (array $row): array => [ + trim((string) ($row['company_name'] ?? '')) => trim((string) ($row['taxpayer_category'] ?? '')), + ]) + ->filter(static fn ($value, $key): bool => $key !== '' && (string) $value !== ''); + } catch (Throwable $exception) { + report($exception); + + return collect(); + } + } + + private function sumField(Collection $rows, string $field): float + { + return round($rows->sum(static fn ($row): float => (float) $row->{$field}), 2); + } +} diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 7bd193c4..36579403 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -29,6 +29,8 @@ use App\Models\Business\CourierQuoteSignature; use App\Models\Business\CourierQuoteVersion; use App\Models\Business\CourierSigningSubject; use App\Models\Business\InstallationDetail; +use App\Models\Business\InvoiceBasic; +use App\Models\Business\InvoiceBasicDetail; use App\Models\Business\InventoryWarehouseNameMapping; use App\Models\Business\Todo; use App\Business\CourierSurchargeAuditLogRepository; @@ -3938,6 +3940,13 @@ class Pages extends Controller ): array { $descriptor = null; $rows = collect(); + $isInvoiceBasicPage = ($section['slug'] ?? null) === 'invoice-management' + && ($page['slug'] ?? null) === 'basic-information'; + $invoiceBasicFilters = ['seller_entity' => '', 'store_name' => '', 'period' => '']; + $invoiceBasicPeriodOptions = collect(); + $invoiceBasicPageTotals = ['invoice_limit' => 0.0, 'output_amount' => 0.0, 'input_amount' => 0.0]; + $invoiceBasicAllTotals = ['invoice_limit' => 0.0, 'output_amount' => 0.0, 'input_amount' => 0.0]; + $invoiceBasicDetails = collect(); $tabValue = null; $tabColumn = null; $upstreamError = null; @@ -4094,6 +4103,66 @@ class Pages extends Controller } else { $query = ($descriptor->model)::query(); + if ($isInvoiceBasicPage) { + $invoiceBasicFilters = [ + 'seller_entity' => mb_substr(trim((string) request()->query('seller_entity', '')), 0, 100), + 'store_name' => mb_substr(trim((string) request()->query('store_name', '')), 0, 100), + 'period' => trim((string) request()->query('period', '')), + ]; + + if ($invoiceBasicFilters['period'] !== '' + && preg_match('/^\d{4}-\d{2}$/', $invoiceBasicFilters['period']) !== 1) { + $invoiceBasicFilters['period'] = ''; + } + + if ($invoiceBasicFilters['seller_entity'] !== '') { + $needle = '%' . addcslashes($invoiceBasicFilters['seller_entity'], '%_\\') . '%'; + $query->where('store_entity', 'like', $needle); + } + + if ($invoiceBasicFilters['store_name'] !== '') { + $needle = '%' . addcslashes($invoiceBasicFilters['store_name'], '%_\\') . '%'; + $pairs = collect(); + try { + $pairs = InvoiceBasicDetail::query() + ->where('shop_name', 'like', $needle) + ->select(['seller_entity', 'period']) + ->distinct() + ->limit(500) + ->get(); + } catch (Throwable $exception) { + report($exception); + } + + $query->where(function ($builder) use ($needle, $pairs): void { + $builder->where('store_name', 'like', $needle); + foreach ($pairs as $pair) { + $builder->orWhere(function ($sub) use ($pair): void { + $sub->where('store_entity', $pair->seller_entity) + ->where('period', $pair->period); + }); + } + }); + } + + if ($invoiceBasicFilters['period'] !== '') { + $query->where('period', $invoiceBasicFilters['period']); + } + + $invoiceBasicPeriodOptions = InvoiceBasic::query() + ->select('period') + ->where('period', '<>', '') + ->distinct() + ->orderByDesc('period') + ->pluck('period'); + + $invoiceBasicAllTotals = [ + 'invoice_limit' => round((float) (clone $query)->sum('invoice_limit'), 2), + 'output_amount' => round((float) (clone $query)->sum('output_amount'), 2), + 'input_amount' => round((float) (clone $query)->sum('input_amount'), 2), + ]; + } + if ($descriptor->tabFilterColumn && $activeTab) { $tabValue = TableRegistry::tabValue($section['slug'], $page['slug'], $activeTab['slug']); @@ -4109,6 +4178,35 @@ class Pages extends Controller } $rows = $query->orderByDesc('id')->paginate(50)->withQueryString(); + + if ($isInvoiceBasicPage) { + $invoiceBasicPageRows = $rows->getCollection(); + $invoiceBasicPageTotals = [ + 'invoice_limit' => round((float) $invoiceBasicPageRows->sum('invoice_limit'), 2), + 'output_amount' => round((float) $invoiceBasicPageRows->sum('output_amount'), 2), + 'input_amount' => round((float) $invoiceBasicPageRows->sum('input_amount'), 2), + ]; + } + + if (($section['slug'] ?? null) === 'invoice-management' + && ($page['slug'] ?? null) === 'basic-information') { + try { + $pageRows = $rows->getCollection(); + $periods = $pageRows->pluck('period')->filter()->unique()->values(); + $sellers = $pageRows->pluck('store_entity')->filter()->unique()->values(); + + if ($periods->isNotEmpty() && $sellers->isNotEmpty()) { + $invoiceBasicDetails = InvoiceBasicDetail::query() + ->whereIn('period', $periods->all()) + ->whereIn('seller_entity', $sellers->all()) + ->orderByDesc('output_amount') + ->get() + ->groupBy(static fn (InvoiceBasicDetail $detail): string => $detail->seller_entity . '|' . $detail->period); + } + } catch (Throwable $exception) { + report($exception); + } + } } } } @@ -4140,6 +4238,11 @@ class Pages extends Controller 'inventoryUnmappedWarehouseError' => $inventoryUnmappedWarehouseError, 'inventoryWarehouseMappingView' => $inventoryWarehouseMappingView, 'receiptStats' => $receiptStats, + 'invoiceBasicDetails' => $invoiceBasicDetails, + 'invoiceBasicFilters' => $invoiceBasicFilters, + 'invoiceBasicPeriodOptions' => $invoiceBasicPeriodOptions, + 'invoiceBasicPageTotals' => $invoiceBasicPageTotals, + 'invoiceBasicAllTotals' => $invoiceBasicAllTotals, 'payablesFinal' => $this->payablesFinalData($section, $page), 'kukaPostingBase' => $kukaPostingBase, ]; @@ -4882,6 +4985,7 @@ class Pages extends Controller 'preview-statistics' => $this->contentForPreviewStatistics(), 'planting-details' => $this->contentForPlantingDetails(), 'jst-order-labels' => $this->contentForJstOrderLabels(), + 'invoice-reports' => app(\App\Business\InvoiceReportsPageData::class)->page($tab), 'planting-reimbursements' => app(\Modules\EcommerceFinance\View\PlantingReimbursementPageData::class)->page(), 'planting-loss' => app(\Modules\EcommerceFinance\View\PlantingLossPageData::class)->page(), 'finance-data' => app(\Modules\EcommerceFinance\View\SupplierReconciliationPageData::class)->financeData(), diff --git a/app/Models/Business/InvoiceBasicDetail.php b/app/Models/Business/InvoiceBasicDetail.php new file mode 100644 index 00000000..02525555 --- /dev/null +++ b/app/Models/Business/InvoiceBasicDetail.php @@ -0,0 +1,27 @@ + 'integer', + 'invoice_count' => 'integer', + 'output_amount' => 'decimal:2', + 'tax_amount' => 'decimal:2', + 'net_amount' => 'decimal:2', + ]; +} diff --git a/config/business_navigation.php b/config/business_navigation.php index 56df8b6a..4b4eecb3 100644 --- a/config/business_navigation.php +++ b/config/business_navigation.php @@ -659,6 +659,7 @@ $navigation = [ 'slug' => 'invoice-reports', 'title' => '发票数据报表', 'tabs' => [ + ['slug' => 'summary', 'title' => '发票情况汇总', 'icon' => 'summarize'], ['slug' => 'input', 'title' => '进项报表', 'icon' => 'download'], ['slug' => 'output', 'title' => '销项报表', 'icon' => 'upload'], ], diff --git a/database/migrations/2026_11_10_160000_create_invoice_basic_details_table.php b/database/migrations/2026_11_10_160000_create_invoice_basic_details_table.php new file mode 100644 index 00000000..713fe4a1 --- /dev/null +++ b/database/migrations/2026_11_10_160000_create_invoice_basic_details_table.php @@ -0,0 +1,38 @@ +increments('id'); + $table->unsignedInteger('company_id')->default(1); + $table->string('period', 10)->comment('期间,YYYY-MM'); + $table->string('seller_entity')->comment('销方开票主体'); + $table->string('shop_name')->comment('店铺名称'); + $table->unsignedInteger('invoice_count')->default(0)->comment('成功开票张数'); + $table->decimal('output_amount', 18, 2)->default(0)->comment('销项金额(含税)'); + $table->decimal('tax_amount', 18, 2)->default(0)->comment('税额'); + $table->decimal('net_amount', 18, 2)->default(0)->comment('不含税金额'); + $table->timestamps(); + + $table->unique( + ['company_id', 'period', 'seller_entity', 'shop_name'], + 'invoice_basic_details_unique' + ); + $table->index( + ['company_id', 'period', 'seller_entity'], + 'invoice_basic_details_lookup' + ); + }); + } + + public function down(): void + { + Schema::dropIfExists('ak_biz_invoice_basic_details'); + } +}; diff --git a/resources/views/business/pages/invoice_reports.blade.php b/resources/views/business/pages/invoice_reports.blade.php index f742b881..befd5edb 100644 --- a/resources/views/business/pages/invoice_reports.blade.php +++ b/resources/views/business/pages/invoice_reports.blade.php @@ -1,44 +1,200 @@ @php - // Determine which fields to show based on active tab - $isInputTab = isset($activeTab) && $activeTab['slug'] === 'input'; - $pageTitle = $isInputTab ? '进项报表' : '销项报表'; - if ($isInputTab) { - $displayFields = ['id', 'company_name', 'input_goods_amount', 'input_goods_tax', 'input_service_amount', 'input_service_tax', 'input_total_amount', 'input_total_tax']; - $displayHeaders = ['序号', '公司名称', '商品金额', '商品税额', '服务费金额', '服务费税额', '金额合计', '税额合计']; + $tabSlug = $activeTab['slug'] ?? 'summary'; + $isSummaryTab = $tabSlug === 'summary'; + $pageTitle = $activeTab['title'] ?? '发票数据报表'; + + $numericFields = [ + 'input_goods_amount', 'input_goods_tax', 'input_service_amount', 'input_service_tax', + 'input_total_amount', 'input_total_tax', + 'output_goods_amount', 'output_goods_tax', 'output_service_amount', 'output_service_tax', + 'output_total_amount', 'output_total_tax', + ]; + + if ($tabSlug === 'input') { + $displayFields = ['company_name', 'input_goods_amount', 'input_goods_tax', 'input_service_amount', 'input_service_tax', 'input_total_amount', 'input_total_tax']; + $displayHeaders = ['公司名称', '商品金额', '商品税额', '服务费金额', '服务费税额', '金额合计', '税额合计']; + } elseif ($tabSlug === 'output') { + $displayFields = ['company_name', 'output_goods_amount', 'output_goods_tax', 'output_service_amount', 'output_service_tax', 'output_total_amount', 'output_total_tax']; + $displayHeaders = ['公司名称', '商品金额', '商品税额', '服务费金额', '服务费税额', '金额合计', '税额合计']; } else { - $displayFields = ['id', 'company_name', 'output_goods_amount', 'output_goods_tax', 'output_service_amount', 'output_service_tax', 'output_total_amount', 'output_total_tax']; - $displayHeaders = ['序号', '公司名称', '商品金额', '商品税额', '服务费金额', '服务费税额', '金额合计', '税额合计']; + $displayFields = []; + $displayHeaders = []; } + + $summaryRows = $summaryRows ?? collect(); + $summaryTotals = $summaryTotals ?? null; + $summaryFilters = $summaryFilters ?? ['company' => '', 'taxpayer_type' => '', 'warning' => '']; + $companyOptions = $companyOptions ?? collect(); + $taxpayerTypeOptions = $taxpayerTypeOptions ?? collect(); @endphp +
- {{ $pageTitle ?? '发票数据报表' }} + {{ $pageTitle }}
-
- - - - @foreach($displayHeaders as $h) - - @endforeach - - - - @foreach($items as $item) - - @foreach($displayFields as $f) - @if($f === 'id') - - @elseif(in_array($f, ['input_goods_amount', 'input_goods_tax', 'input_service_amount', 'input_service_tax', 'input_total_amount', 'input_total_tax', 'output_goods_amount', 'output_goods_tax', 'output_service_amount', 'output_service_tax', 'output_total_amount', 'output_total_tax'])) - - @else - - @endif + +
+ @include('business.pages.partials.upstream-data-styles') + + + @if ($isSummaryTab) +
+
+ +
- @endforeach - @if($items->isEmpty()) - + + +
+ + +
+
+ + +
+
+ + + 重置 + +
+ + @endif + +
+
+ @if ($isSummaryTab) +
{{ $h }}
{{ $loop->iteration }}{{ number_format($item->$f, 2) }}{{ $item->$f }}
暂无数据
+ + + + + + + + + + + + + + @forelse ($summaryRows as $row) + @php + $ratioTitle = $row->input_output_ratio === null + ? '销项金额为 0,无法计算比例' + : '进项/销项 = ' . number_format($row->input_output_ratio * 100, 1) . '%'; + @endphp + + + + + + + + + + + @empty + + @endforelse + + @if ($summaryRows->isNotEmpty() && $summaryTotals) + + + + + + + + + + + + + @endif +
序号公司纳税人类型销项金额销项税额进项金额进项税额是否预警
{{ $loop->iteration }}{{ $row->company_name }}{{ $row->taxpayer_type }}{{ number_format($row->output_total_amount, 2) }}{{ number_format($row->output_total_tax, 2) }}{{ number_format($row->input_total_amount, 2) }}{{ number_format($row->input_total_tax, 2) }} + + {{ $row->is_warning ? '是' : '否' }} + +
暂无数据
合计—{{ number_format($summaryTotals->output_total_amount, 2) }}{{ number_format($summaryTotals->output_total_tax, 2) }}{{ number_format($summaryTotals->input_total_amount, 2) }}{{ number_format($summaryTotals->input_total_tax, 2) }}—
+ @else + + + + + @foreach ($displayHeaders as $header) + + @endforeach + + + + @forelse ($items as $item) + + + @foreach ($displayFields as $field) + @if ($field === 'company_name') + + @else + + @endif + @endforeach + + @empty + + @endforelse + +
序号 $loop->index > 0])>{{ $header }}
{{ $loop->iteration }}{{ $item->$field }} + {{ in_array($field, $numericFields, true) ? number_format((float) $item->$field, 2) : $item->$field }} +
暂无数据
@endif - - -
\ No newline at end of file + +
预警口径:进项金额 ÷ 销项金额 < 80% 时为「是」,否则为「否」;合计行不参与预警判断。
+ + diff --git a/resources/views/business/pages/show.blade.php b/resources/views/business/pages/show.blade.php index 6916420d..824c33dc 100644 --- a/resources/views/business/pages/show.blade.php +++ b/resources/views/business/pages/show.blade.php @@ -9,6 +9,8 @@ && ($page['slug'] ?? null) === 'marketing-account-balance'; $isStoreReceivingAccountsPage = ($section['slug'] ?? null) === 'fund-management' && ($page['slug'] ?? null) === 'store-receiving-accounts'; + $isInvoiceBasicPage = ($section['slug'] ?? null) === 'invoice-management' + && ($page['slug'] ?? null) === 'basic-information'; $isSupplierWorkspace = in_array($section['slug'] ?? null, ['supplier-payables', 'supplier-payables-final'], true); $supplierWorkspaceSection = $section; $isCourierFinalDirectory = ($section['slug'] ?? null) === 'courier-payables-final'; @@ -1054,6 +1056,77 @@ @elseif ($pageView) @include($pageView) @elseif ($descriptor) + @if ($isInvoiceBasicPage) + + @endif
@if ($page['slug'] === 'installation-details') @include('business.pages.partials.date-range-picker') @@ -1102,6 +1175,58 @@ @endunless
+ @if ($isInvoiceBasicPage) + + @endif + @if ($isStoreReceivingAccountsPage)
- @if ($page['slug'] !== 'installation-details'){{ $row->id }}@endif + @if ($page['slug'] !== 'installation-details'){{ $isInvoiceBasicPage ? (($rows->firstItem() ?? 1) + $loop->index) : $row->id }}@endif @foreach ($descriptor->fields as $field) @php $val = $row->{$field['name']}; @@ -1163,6 +1296,11 @@ {{ \Illuminate\Support\Carbon::parse($val)->format('Y-m-d') }} @elseif ($field['currency']) {{ number_format((float) $val, 2) }} + @elseif ($showInvoiceDetails && $field['name'] === 'store_name') + @else {{ $val }} @endif @@ -1188,6 +1326,36 @@ @endunless + @if ($showInvoiceDetails) + + +
+ + + + + + + + + + + + @foreach ($invoiceDetailsForRow->sortByDesc('output_amount') as $detail) + + + + + + + + @endforeach + +
店铺名称开票张数销项金额(含税)税额不含税金额
{{ $detail->shop_name }}{{ number_format((int) $detail->invoice_count) }}{{ number_format((float) $detail->output_amount, 2) }}{{ number_format((float) $detail->tax_amount, 2) }}{{ number_format((float) $detail->net_amount, 2) }}
+
+ + + @endif @empty @@ -1202,6 +1370,22 @@ + @if ($isInvoiceBasicPage) +
+ @foreach ([ + '本页合计' => ($invoiceBasicPageTotals ?? []), + '全部合计' => ($invoiceBasicAllTotals ?? []), + ] as $totalLabel => $totals) +
+ {{ $totalLabel }} + 开票额度 {{ number_format((float) ($totals['invoice_limit'] ?? 0), 2) }} + 销项金额 {{ number_format((float) ($totals['output_amount'] ?? 0), 2) }} + 进项金额 {{ number_format((float) ($totals['input_amount'] ?? 0), 2) }} +
+ @endforeach +
+ @endif +
共 {{ $rows->total() }} 条 · 第 {{ $rows->currentPage() }} / {{ $rows->lastPage() }} 页 @@ -1277,6 +1461,24 @@ @endif + @if ($isInvoiceBasicPage) + + @endif +
@unless ($descriptor->readOnly) diff --git a/tests/Feature/Business/InvoiceBasicFiltersTotalsTest.php b/tests/Feature/Business/InvoiceBasicFiltersTotalsTest.php new file mode 100644 index 00000000..21e75124 --- /dev/null +++ b/tests/Feature/Business/InvoiceBasicFiltersTotalsTest.php @@ -0,0 +1,129 @@ +user->attachPermission( + Permission::where('name', 'read-admin-panel')->firstOrFail() + ); + + InvoiceBasic::create([ + 'company_id' => $this->company->id, + 'store_name' => '多店铺(2)', + 'store_entity' => '甲公司', + 'invoice_issuer' => '甲开票员', + 'invoice_limit' => 50, + 'output_amount' => 300, + 'input_amount' => 100, + 'period' => '2026-10', + ]); + InvoiceBasic::create([ + 'company_id' => $this->company->id, + 'store_name' => '乙店铺', + 'store_entity' => '乙公司', + 'invoice_issuer' => '乙开票员', + 'invoice_limit' => 20, + 'output_amount' => 200, + 'input_amount' => 50, + 'period' => '2026-11', + ]); + + InvoiceBasicDetail::create([ + 'company_id' => $this->company->id, + 'period' => '2026-10', + 'seller_entity' => '甲公司', + 'shop_name' => '一号店', + 'invoice_count' => 1, + 'output_amount' => 100, + 'tax_amount' => 10, + 'net_amount' => 90, + ]); + InvoiceBasicDetail::create([ + 'company_id' => $this->company->id, + 'period' => '2026-10', + 'seller_entity' => '甲公司', + 'shop_name' => '二号店', + 'invoice_count' => 2, + 'output_amount' => 200, + 'tax_amount' => 20, + 'net_amount' => 180, + ]); + InvoiceBasicDetail::create([ + 'company_id' => $this->company->id, + 'period' => '2026-11', + 'seller_entity' => '乙公司', + 'shop_name' => '三号店', + 'invoice_count' => 1, + 'output_amount' => 200, + 'tax_amount' => 20, + 'net_amount' => 180, + ]); + } + + public function test_invoice_basic_shows_filters_and_page_and_all_totals(): void + { + $this->loginAs() + ->get($this->pageUrl()) + ->assertOk() + ->assertSeeText('店铺主体') + ->assertSeeText('店铺名称') + ->assertSeeText('期间') + ->assertSeeText('本页合计') + ->assertSeeText('全部合计') + ->assertSeeText('300.00') + ->assertSeeText('200.00') + ->assertSeeText('500.00') + ->assertSeeText('150.00') + ->assertSeeText('70.00') + ->assertSee('