feat(发票数据): 展示流程直抓完整发票字段 (#1505)
发票明细按 OA 流程附件直抓口径展示完整字段,打款时间移到最后,并从 2026-10 开始统计。
This commit is contained in:
parent
b6e06e775c
commit
b72b2e12bd
@ -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'] ?? ''),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
]);
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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' }}"
|
||||
>
|
||||
<span class="material-icons-outlined" aria-hidden="true">document_scanner</span>
|
||||
<span data-invoice-refresh-label>抓取发票</span>
|
||||
<span data-invoice-refresh-label>从流程抓取发票</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@ -593,10 +627,10 @@
|
||||
|
||||
<div class="invoice-data-status">
|
||||
<span>
|
||||
数据口径:<strong>按打款时间归属月份</strong> · 一张发票一行 · 无票流程保留
|
||||
数据口径:<strong>{{ $startMonth }} 起 · 通过 OA 审批流程附件自动识别</strong> · 按打款时间归属月份 · 一张发票一行
|
||||
</span>
|
||||
<span>
|
||||
镜像状态:<strong>{{ $mirrorStatusLabels[$invoiceMirrorStatus] ?? $invoiceMirrorStatus }}</strong>
|
||||
扫描状态:<strong>{{ $mirrorStatusLabels[$invoiceMirrorStatus] ?? $invoiceMirrorStatus }}</strong>
|
||||
@if ($invoiceMirrorSyncedAt)
|
||||
· 最近成功 {{ $invoiceMirrorSyncedAt }}
|
||||
@endif
|
||||
@ -611,8 +645,8 @@
|
||||
<strong>{{ number_format((int) ($summary['flows'] ?? 0)) }}</strong>
|
||||
</div>
|
||||
<div class="invoice-data-kpi">
|
||||
<span>本月付款金额</span>
|
||||
<strong>¥{{ $wan($summary['payment_amount'] ?? 0) }} 万</strong>
|
||||
<span>含票流程</span>
|
||||
<strong>{{ number_format((int) ($summary['invoice_flows'] ?? 0)) }}</strong>
|
||||
</div>
|
||||
<div class="invoice-data-kpi">
|
||||
<span>发票张数</span>
|
||||
@ -622,6 +656,10 @@
|
||||
<span>发票价税合计</span>
|
||||
<strong class="is-accent">¥{{ $wan($summary['invoice_total'] ?? 0) }} 万</strong>
|
||||
</div>
|
||||
<div class="invoice-data-kpi">
|
||||
<span>本月付款金额</span>
|
||||
<strong>¥{{ $wan($summary['payment_amount'] ?? 0) }} 万</strong>
|
||||
</div>
|
||||
<div class="invoice-data-kpi">
|
||||
<span>无票流程</span>
|
||||
<strong>{{ number_format((int) ($summary['no_invoice_flows'] ?? 0)) }}</strong>
|
||||
@ -667,52 +705,77 @@
|
||||
@if ($activeView !== 'detail') hidden @endif
|
||||
>
|
||||
<div class="invoice-data-table-scroll">
|
||||
<table class="invoice-data-table">
|
||||
<table class="invoice-data-table is-detail">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">流程号 / 标题</th>
|
||||
<th scope="col">提交人 / 报销类型</th>
|
||||
<th scope="col">打款时间</th>
|
||||
<th scope="col" class="is-number">本月付款</th>
|
||||
<th scope="col">发票类型 / 项目</th>
|
||||
<th scope="col">销售方</th>
|
||||
<th scope="col">购买方</th>
|
||||
<th scope="col">流程号</th>
|
||||
<th scope="col">流程标题</th>
|
||||
<th scope="col">提交人</th>
|
||||
<th scope="col">报销类型</th>
|
||||
<th scope="col">费用类型</th>
|
||||
<th scope="col">收款人</th>
|
||||
<th scope="col">发票类型</th>
|
||||
<th scope="col">发票号码</th>
|
||||
<th scope="col">开票日期</th>
|
||||
<th scope="col">项目名称</th>
|
||||
<th scope="col">销售方名称</th>
|
||||
<th scope="col">销售方税号</th>
|
||||
<th scope="col">购买方名称</th>
|
||||
<th scope="col">购买方税号</th>
|
||||
<th scope="col" class="is-number">金额</th>
|
||||
<th scope="col">税率</th>
|
||||
<th scope="col" class="is-number">税额</th>
|
||||
<th scope="col" class="is-number">价税合计</th>
|
||||
<th scope="col">发票号码 / 日期</th>
|
||||
<th scope="col" class="is-number">本月付款</th>
|
||||
<th scope="col" class="is-number">付款合计</th>
|
||||
<th scope="col" class="is-number">发票张数</th>
|
||||
<th scope="col">金额校对</th>
|
||||
<th scope="col" class="is-number">差异金额</th>
|
||||
<th scope="col">附件</th>
|
||||
<th scope="col">打款时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($detailRows as $row)
|
||||
@php
|
||||
$flowDifference = round(
|
||||
(float) $row->payment_amount - (float) $row->flow_invoice_total,
|
||||
2,
|
||||
);
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->title ?: '未命名审批' }}</span>
|
||||
<span class="invoice-data-secondary invoice-data-code">{{ $row->business_id }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->originator_name ?: '-' }}</span>
|
||||
<span class="invoice-data-secondary">{{ $row->document_type ?: '-' }}</span>
|
||||
</td>
|
||||
<td class="is-nowrap">
|
||||
{{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }}
|
||||
</td>
|
||||
<td class="is-number">¥{{ $money($row->payment_amount) }}</td>
|
||||
<td class="is-nowrap invoice-data-code">{{ $row->business_id }}</td>
|
||||
<td>{{ $row->title ?: '未命名审批' }}</td>
|
||||
<td class="is-nowrap">{{ $row->originator_name ?: '-' }}</td>
|
||||
<td>{{ $row->document_type ?: '-' }}</td>
|
||||
<td>{{ $row->expense_type ?: '-' }}</td>
|
||||
<td>{{ $row->payee_name ?: '-' }}</td>
|
||||
<td>
|
||||
<span class="invoice-data-tag">{{ $row->invoice_type ?: '未分类' }}</span>
|
||||
<span class="invoice-data-secondary" title="{{ $row->item_name }}">{{ \Illuminate\Support\Str::limit((string) $row->item_name, 34) }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->seller_name ?: '-' }}</span>
|
||||
<span class="invoice-data-secondary">{{ $row->seller_tax_no ?: '' }}</span>
|
||||
<td class="is-code">{{ $row->invoice_number ?: '-' }}</td>
|
||||
<td class="is-nowrap">{{ $row->invoice_date ?: '-' }}</td>
|
||||
<td class="is-preline">{{ $row->item_name ?: '-' }}</td>
|
||||
<td>{{ $row->seller_name ?: '-' }}</td>
|
||||
<td class="is-code">{{ $row->seller_tax_no ?: '-' }}</td>
|
||||
<td>{{ $row->buyer_name ?: '-' }}</td>
|
||||
<td class="is-code">{{ $row->buyer_tax_no ?: '-' }}</td>
|
||||
<td class="is-number">
|
||||
{{ $row->amount_without_tax === null ? '-' : '¥' . $money($row->amount_without_tax) }}
|
||||
</td>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->buyer_name ?: '-' }}</span>
|
||||
<span class="invoice-data-secondary">{{ $row->buyer_tax_no ?: '' }}</span>
|
||||
<td class="is-nowrap">{{ $row->tax_rate ?: '-' }}</td>
|
||||
<td class="is-number">
|
||||
{{ $row->tax_amount === null ? '-' : '¥' . $money($row->tax_amount) }}
|
||||
</td>
|
||||
<td class="is-number">¥{{ $money($row->invoice_total) }}</td>
|
||||
<td>
|
||||
<span class="invoice-data-primary invoice-data-code">{{ $row->invoice_number ?: '-' }}</span>
|
||||
<span class="invoice-data-secondary">{{ $row->invoice_date ?: '无开票日期' }}</span>
|
||||
<td class="is-number">¥{{ $money($row->payment_amount) }}</td>
|
||||
<td class="is-number">¥{{ $money($row->payment_total) }}</td>
|
||||
<td class="is-number">{{ number_format((int) $row->invoice_count) }}</td>
|
||||
<td class="is-nowrap">{{ abs($flowDifference) <= 0.005 ? '一致' : '有差异' }}</td>
|
||||
<td class="is-number">
|
||||
<span @class(['invoice-data-difference' => abs($flowDifference) > 0.005])>
|
||||
¥{{ $money($flowDifference) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
@if ($row->source_file_id)
|
||||
@ -724,13 +787,16 @@
|
||||
rel="noopener"
|
||||
>查看附件</a>
|
||||
@else
|
||||
<span class="invoice-data-secondary">台账导入</span>
|
||||
<span class="invoice-data-secondary">待关联原件</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="is-nowrap">
|
||||
{{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }}
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="10" class="invoice-data-empty">当前筛选条件下没有发票明细。</td>
|
||||
<td colspan="25" class="invoice-data-empty">当前筛选条件下没有发票明细。</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
@ -750,15 +816,18 @@
|
||||
<table class="invoice-data-table is-flow">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">流程号 / 标题</th>
|
||||
<th scope="col">提交人 / 报销类型</th>
|
||||
<th scope="col">流程号</th>
|
||||
<th scope="col">流程标题</th>
|
||||
<th scope="col">提交人</th>
|
||||
<th scope="col">报销类型</th>
|
||||
<th scope="col">费用类型</th>
|
||||
<th scope="col">收款人</th>
|
||||
<th scope="col">打款时间</th>
|
||||
<th scope="col" class="is-number">本月付款</th>
|
||||
<th scope="col" class="is-number">发票张数</th>
|
||||
<th scope="col" class="is-number">发票合计</th>
|
||||
<th scope="col" class="is-number">付款差额</th>
|
||||
<th scope="col">状态</th>
|
||||
<th scope="col">打款时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -767,21 +836,12 @@
|
||||
$difference = round((float) $row->payment_amount - (float) $row->invoice_total, 2);
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->title ?: '未命名审批' }}</span>
|
||||
<span class="invoice-data-secondary invoice-data-code">{{ $row->business_id }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->originator_name ?: '-' }}</span>
|
||||
<span class="invoice-data-secondary">{{ $row->document_type ?: '-' }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="invoice-data-primary">{{ $row->payee_name ?: '-' }}</span>
|
||||
<span class="invoice-data-secondary">{{ $row->expense_type ?: '' }}</span>
|
||||
</td>
|
||||
<td class="is-nowrap">
|
||||
{{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }}
|
||||
</td>
|
||||
<td class="is-nowrap invoice-data-code">{{ $row->business_id }}</td>
|
||||
<td>{{ $row->title ?: '未命名审批' }}</td>
|
||||
<td class="is-nowrap">{{ $row->originator_name ?: '-' }}</td>
|
||||
<td>{{ $row->document_type ?: '-' }}</td>
|
||||
<td>{{ $row->expense_type ?: '-' }}</td>
|
||||
<td>{{ $row->payee_name ?: '-' }}</td>
|
||||
<td class="is-number">¥{{ $money($row->payment_amount) }}</td>
|
||||
<td class="is-number">{{ number_format((int) $row->invoice_count) }}</td>
|
||||
<td class="is-number">¥{{ $money($row->invoice_total) }}</td>
|
||||
@ -800,10 +860,13 @@
|
||||
<span class="invoice-data-tag is-warning">无票</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="is-nowrap">
|
||||
{{ $row->paid_at ? \Illuminate\Support\Carbon::parse($row->paid_at)->format('Y-m-d') : '-' }}
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="9" class="invoice-data-empty">当前筛选条件下没有流程汇总。</td>
|
||||
<td colspan="12" class="invoice-data-empty">当前筛选条件下没有流程汇总。</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
@ -813,8 +876,10 @@
|
||||
</section>
|
||||
|
||||
<p class="invoice-data-note">
|
||||
口径:按 OA 付款明细中的打款时间归入月份;一张发票一行,同一流程多张发票分别列示;
|
||||
无票流程在“按流程汇总”中保留。发票金额覆盖可能出现超过 100%,表示开票金额高于本月付款,需按具体流程复核。
|
||||
口径:统计从 {{ $startMonth }} 开始。发票通过 OA 审批流程附件自动识别,按打款时间归入月份;
|
||||
一张发票一行,同一流程多张发票分别列示,并保留对应流程号。无票流程在“按流程汇总”中保留。
|
||||
尚未关联原件的历史记录会标记为“待关联原件”。开票金额覆盖率可能超过 100%,
|
||||
表示开票金额高于本月付款,需要按具体流程复核。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -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(
|
||||
'/<table class="invoice-data-table is-detail">.*?<thead>.*?<\/tr>/su',
|
||||
$html,
|
||||
$detailHeader,
|
||||
);
|
||||
$this->assertNotEmpty($detailHeader);
|
||||
$this->assertStringContainsString('>项目名称</th>', $detailHeader[0]);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/>项目名称<\/th>.*>打款时间<\/th>\s*<\/tr>$/su',
|
||||
$detailHeader[0],
|
||||
);
|
||||
|
||||
$flowHeader = null;
|
||||
preg_match(
|
||||
'/<table class="invoice-data-table is-flow">.*?<thead>.*?<\/tr>/su',
|
||||
$html,
|
||||
$flowHeader,
|
||||
);
|
||||
$this->assertNotEmpty($flowHeader);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/>状态<\/th>\s*<th scope="col">打款时间<\/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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user