feat: 财务端供应商对账差异筛选与布局优化 #996
@ -130,6 +130,7 @@ class SupplierReconciliation extends Controller
|
||||
$request->validate([
|
||||
'month' => ['nullable', 'string', 'regex:/^\d{4}-\d{2}$/'],
|
||||
'reconciler' => ['nullable', 'string', 'max:191'],
|
||||
'comparison_filter' => ['nullable', 'in:,supplier_over,supplier_under,mismatch,match'],
|
||||
]);
|
||||
[$supplier, $companyId] = $this->returnTarget($request);
|
||||
$detail = $this->pageData->financeDetailForFilters($supplier, $companyId, $request->query());
|
||||
@ -172,6 +173,7 @@ class SupplierReconciliation extends Controller
|
||||
'date' => ['nullable', 'string', 'max:32'],
|
||||
'barcode' => ['nullable', 'string', 'max:191'],
|
||||
'difference_type' => ['nullable', 'string', 'max:32'],
|
||||
'comparison_filter' => ['nullable', 'in:,supplier_over,supplier_under,mismatch,match'],
|
||||
'selected_rows' => ['nullable', 'array', 'max:600'],
|
||||
'selected_rows.*' => ['string', 'max:2048'],
|
||||
]);
|
||||
|
||||
@ -18,6 +18,15 @@ use Modules\EcommerceFinance\Services\SupplierStatementStore;
|
||||
*/
|
||||
class SupplierReconciliationPageData
|
||||
{
|
||||
/** 财务端比对结果筛选。 */
|
||||
private const COMPARISON_FILTERS = [
|
||||
'',
|
||||
'supplier_over',
|
||||
'supplier_under',
|
||||
'mismatch',
|
||||
'match',
|
||||
];
|
||||
|
||||
/** 厂家上传的对账数据表:每页行数(短表 + 翻页)。 */
|
||||
private const PER_PAGE = 15;
|
||||
|
||||
@ -166,8 +175,15 @@ class SupplierReconciliationPageData
|
||||
}
|
||||
|
||||
$detail = null;
|
||||
$comparisonFilter = '';
|
||||
$comparisonFilters = [];
|
||||
if ($selected !== '') {
|
||||
$detail = $this->detail($mine, $selected, $companyId);
|
||||
$comparisonFilter = $this->normalizeComparisonFilter(
|
||||
request()->query('comparison_filter', ''),
|
||||
);
|
||||
$detail = $this->filterComparisonDetail($detail, $comparisonFilter);
|
||||
$comparisonFilters = $this->comparisonFilterOptions($detail['comparison_counts']);
|
||||
$totalRows = count($detail['rows']);
|
||||
$pages = max((int) ceil($totalRows / self::COMPARISON_PER_PAGE), 1);
|
||||
$currentPage = min(max((int) request()->query('compare_page', 1), 1), $pages);
|
||||
@ -229,6 +245,8 @@ class SupplierReconciliationPageData
|
||||
'reconciler' => $reconciler,
|
||||
'selectedSupplier' => $selected,
|
||||
'detail' => $detail,
|
||||
'comparisonFilter' => $comparisonFilter,
|
||||
'comparisonFilters' => $comparisonFilters,
|
||||
'financeReturnPanel' => $detail !== null
|
||||
? $this->financeReturnPanel($selected, $companyId, $month, $reconciler)
|
||||
: null,
|
||||
@ -398,7 +416,10 @@ class SupplierReconciliationPageData
|
||||
));
|
||||
}
|
||||
|
||||
return $this->detail($mine, $supplier, $companyId);
|
||||
return $this->filterComparisonDetail(
|
||||
$this->detail($mine, $supplier, $companyId),
|
||||
$this->normalizeComparisonFilter($input['comparison_filter'] ?? ''),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -592,6 +613,123 @@ class SupplierReconciliationPageData
|
||||
return $compared;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按财务端关注方向筛选比对行,并保留未筛选的汇总数据。
|
||||
*
|
||||
* @param array<string,mixed> $detail
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
private function filterComparisonDetail(array $detail, string $comparisonFilter): array
|
||||
{
|
||||
$allRows = array_values((array) ($detail['rows'] ?? []));
|
||||
$counts = [
|
||||
'all' => count($allRows),
|
||||
'supplier_over' => 0,
|
||||
'supplier_under' => 0,
|
||||
'mismatch' => 0,
|
||||
'match' => 0,
|
||||
];
|
||||
$differenceCount = 0;
|
||||
|
||||
foreach ($allRows as $row) {
|
||||
if ((string) ($row['type'] ?? '') !== SupplierStatementMatcher::TYPE_MATCH) {
|
||||
$differenceCount++;
|
||||
}
|
||||
foreach (['supplier_over', 'supplier_under', 'mismatch', 'match'] as $filter) {
|
||||
if ($this->comparisonRowMatchesFilter($row, $filter)) {
|
||||
$counts[$filter]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rows = array_values(array_filter(
|
||||
$allRows,
|
||||
fn (array $row): bool => $this->comparisonRowMatchesFilter($row, $comparisonFilter),
|
||||
));
|
||||
$filteredDifferenceCount = count(array_filter(
|
||||
$rows,
|
||||
static fn (array $row): bool => (string) ($row['type'] ?? '') !== SupplierStatementMatcher::TYPE_MATCH,
|
||||
));
|
||||
|
||||
$detail['all_total_rows'] = count($allRows);
|
||||
$detail['total_rows'] = count($rows);
|
||||
$detail['rows'] = $rows;
|
||||
$detail['comparison_filter'] = $comparisonFilter;
|
||||
$detail['comparison_counts'] = $counts;
|
||||
$detail['difference_count'] = $filteredDifferenceCount;
|
||||
$detail['all_difference_count'] = $differenceCount;
|
||||
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $row */
|
||||
private function comparisonRowMatchesFilter(array $row, string $comparisonFilter): bool
|
||||
{
|
||||
$type = (string) ($row['type'] ?? '');
|
||||
$amountDifference = (float) ($row['amountDifference'] ?? 0);
|
||||
|
||||
return match ($comparisonFilter) {
|
||||
'supplier_over' => $type === SupplierStatementMatcher::TYPE_SUPPLIER_EXTRA
|
||||
|| ($type !== SupplierStatementMatcher::TYPE_MATCH && $amountDifference > 0.005),
|
||||
'supplier_under' => $type === SupplierStatementMatcher::TYPE_SUPPLIER_MISSING
|
||||
|| ($type !== SupplierStatementMatcher::TYPE_MATCH && $amountDifference < -0.005),
|
||||
'mismatch' => $type === SupplierStatementMatcher::TYPE_MISMATCH,
|
||||
'match' => $type === SupplierStatementMatcher::TYPE_MATCH,
|
||||
default => true,
|
||||
};
|
||||
}
|
||||
|
||||
private function normalizeComparisonFilter(mixed $value): string
|
||||
{
|
||||
if (! is_scalar($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$filter = trim((string) $value);
|
||||
|
||||
return in_array($filter, self::COMPARISON_FILTERS, true) ? $filter : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{all:int,supplier_over:int,supplier_under:int,mismatch:int,match:int} $counts
|
||||
* @return list<array{value:string,label:string,count:int,description:string}>
|
||||
*/
|
||||
private function comparisonFilterOptions(array $counts): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'value' => '',
|
||||
'label' => '全部结果',
|
||||
'count' => (int) ($counts['all'] ?? 0),
|
||||
'description' => '显示双方一致和全部差异行',
|
||||
],
|
||||
[
|
||||
'value' => 'supplier_over',
|
||||
'label' => '厂家多算',
|
||||
'count' => (int) ($counts['supplier_over'] ?? 0),
|
||||
'description' => '厂家金额高于我方,包含整条多报和金额多算',
|
||||
],
|
||||
[
|
||||
'value' => 'supplier_under',
|
||||
'label' => '厂家少算',
|
||||
'count' => (int) ($counts['supplier_under'] ?? 0),
|
||||
'description' => '厂家金额低于我方,包含漏报和金额少报',
|
||||
],
|
||||
[
|
||||
'value' => 'mismatch',
|
||||
'label' => '数量/金额不一致',
|
||||
'count' => (int) ($counts['mismatch'] ?? 0),
|
||||
'description' => '双方均已匹配,但数量或金额不一致',
|
||||
],
|
||||
[
|
||||
'value' => 'match',
|
||||
'label' => '双方一致',
|
||||
'count' => (int) ($counts['match'] ?? 0),
|
||||
'description' => '数量、金额一致,可正常结算',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<array<string,mixed>> 该厂家的退货明细(我方数据,展示给厂家确认扣减) */
|
||||
public function returnRows(string $supplier, int $companyId): array
|
||||
{
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
<div class="supplier-reconciliation-page">
|
||||
<style>
|
||||
.supplier-reconciliation-page { display: grid; gap: 16px; }
|
||||
.supplier-reconciliation-page .sr-card { min-width: 0; max-width: 100%; padding: 16px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: var(--vip-surface, #fff); display: grid; gap: 12px; }
|
||||
.supplier-reconciliation-page { display: grid; gap: 12px; }
|
||||
.supplier-reconciliation-page .sr-card { min-width: 0; max-width: 100%; padding: 14px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: var(--vip-surface, #fff); display: grid; gap: 10px; }
|
||||
.supplier-reconciliation-page h2 { margin: 0; font-size: .875rem; font-weight: 600; color: var(--vip-content-ink, #171717); }
|
||||
.supplier-reconciliation-page .sr-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
|
||||
.supplier-reconciliation-page .sr-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0; }
|
||||
.supplier-reconciliation-page .sr-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
|
||||
.supplier-reconciliation-page .sr-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; margin: 0; }
|
||||
.supplier-reconciliation-page .sr-field { display: grid; gap: 4px; }
|
||||
.supplier-reconciliation-page .sr-field span { color: var(--vip-content-muted, #595959); font-size: .75rem; font-weight: 600; }
|
||||
.supplier-reconciliation-page select,
|
||||
.supplier-reconciliation-page input[type="search"],
|
||||
.supplier-reconciliation-page input[type="url"],
|
||||
.supplier-reconciliation-page input[type="password"] { height: 36px; min-width: 12rem; padding: 0 10px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: #fff; font-size: .8125rem; }
|
||||
.supplier-reconciliation-page .sr-button { display: inline-flex; height: 36px; align-items: center; gap: 6px; padding: 0 14px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: #fff; color: var(--vip-content-ink, #171717); font-size: .8125rem; font-weight: 600; text-decoration: none; cursor: pointer; }
|
||||
.supplier-reconciliation-page input[type="password"] { height: 34px; min-width: 10.5rem; padding: 0 10px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: #fff; font-size: .8125rem; }
|
||||
.supplier-reconciliation-page .sr-button { display: inline-flex; height: 34px; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: #fff; color: var(--vip-content-ink, #171717); font-size: .8125rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
|
||||
.supplier-reconciliation-page .sr-button.is-primary { border-color: var(--vip-content-accent-dark, #856632); background: var(--vip-content-accent-dark, #856632); color: #fff; }
|
||||
.supplier-reconciliation-page .sr-button.is-disabled { opacity: .55; cursor: not-allowed; }
|
||||
.supplier-reconciliation-page .sr-button.is-small { height: 26px; padding: 0 9px; font-size: .75rem; }
|
||||
@ -23,7 +23,17 @@
|
||||
.supplier-reconciliation-page .sr-batch-summary { color: var(--vip-content-muted, #595959); font-size: .75rem; }
|
||||
.supplier-reconciliation-page .sr-list-select-cell { width: 48px; text-align: center; }
|
||||
.supplier-reconciliation-page .sr-list-select-cell input { width: 15px; height: 15px; accent-color: var(--vip-content-accent-dark, #856632); }
|
||||
.supplier-reconciliation-page .sr-hint { margin: 0; color: var(--vip-content-muted, #595959); font-size: .75rem; line-height: 1.7; }
|
||||
.supplier-reconciliation-page .sr-hint { margin: 0; color: var(--vip-content-muted, #595959); font-size: .75rem; line-height: 1.65; }
|
||||
.supplier-reconciliation-page .sr-guide { border: 1px solid #EFEAE0; border-radius: 8px; background: #FCFAF5; }
|
||||
.supplier-reconciliation-page .sr-guide summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 9px 12px; color: #5B5343; font-size: .75rem; line-height: 1.5; cursor: pointer; list-style: none; }
|
||||
.supplier-reconciliation-page .sr-guide summary::-webkit-details-marker { display: none; }
|
||||
.supplier-reconciliation-page .sr-guide summary::after { content: "展开规则"; margin-left: auto; color: var(--vip-content-accent-dark, #856632); font-weight: 600; }
|
||||
.supplier-reconciliation-page .sr-guide[open] summary::after { content: "收起规则"; }
|
||||
.supplier-reconciliation-page .sr-guide summary b { color: var(--vip-content-ink, #171717); font-weight: 600; }
|
||||
.supplier-reconciliation-page .sr-guide-body { padding: 0 12px 12px; color: var(--vip-content-muted, #595959); font-size: .75rem; line-height: 1.7; }
|
||||
.supplier-reconciliation-page .sr-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
|
||||
.supplier-reconciliation-page .sr-detail-actions form { margin: 0; }
|
||||
.supplier-reconciliation-page .sr-detail-meta { color: var(--vip-content-muted, #595959); font-size: .75rem; line-height: 1.5; }
|
||||
.supplier-reconciliation-page .sr-scroll { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
|
||||
.supplier-reconciliation-page table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: .8125rem; }
|
||||
.supplier-reconciliation-page th { padding: 8px 10px; background: var(--vip-content-accent-soft, #F7F0DE); border-bottom: 1px solid var(--vip-border, #D8D2C7); color: #5B5343; font-size: .75rem; font-weight: 600; text-align: left; white-space: nowrap; }
|
||||
@ -40,12 +50,31 @@
|
||||
.supplier-reconciliation-page tr.is-extra td,
|
||||
.supplier-reconciliation-page tr.is-mismatch td { background: #FFFDF7; }
|
||||
.supplier-reconciliation-page tr.is-logistics td { background: #FFFDF7; }
|
||||
.supplier-reconciliation-page .sr-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
|
||||
.supplier-reconciliation-page .sr-summary-cell { padding: 10px 12px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; display: grid; gap: 4px; }
|
||||
.supplier-reconciliation-page .sr-summary-cell b { font-size: 1.125rem; font-weight: 600; }
|
||||
.supplier-reconciliation-page .sr-comparison-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 9px 10px; border: 1px solid #E4DCCB; border-radius: 8px; background: var(--vip-content-accent-soft, #F7F0DE); }
|
||||
.supplier-reconciliation-page .sr-filter-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
||||
.supplier-reconciliation-page .sr-filter-caption { margin-right: 3px; color: #5B5343; font-size: .75rem; font-weight: 600; white-space: nowrap; }
|
||||
.supplier-reconciliation-page .sr-filter-tab { display: inline-flex; height: 30px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid #DED3BD; border-radius: 999px; background: #FFFDF8; color: #5B5343; font-size: .75rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
|
||||
.supplier-reconciliation-page .sr-filter-tab b { display: inline-flex; min-width: 19px; height: 19px; align-items: center; justify-content: center; padding: 0 5px; border-radius: 999px; background: #F0E8D8; color: #735A32; font-size: .6875rem; font-weight: 600; }
|
||||
.supplier-reconciliation-page .sr-filter-tab.is-active { border-color: var(--vip-content-accent-dark, #856632); background: var(--vip-content-accent-dark, #856632); color: #fff; }
|
||||
.supplier-reconciliation-page .sr-filter-tab.is-active b { background: rgba(255, 255, 255, .2); color: #fff; }
|
||||
.supplier-reconciliation-page .sr-filter-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: #5B5343; font-size: .75rem; }
|
||||
.supplier-reconciliation-page .sr-filter-result a { color: var(--vip-content-accent-dark, #856632); font-weight: 600; }
|
||||
.supplier-reconciliation-page .sr-summary-groups { display: grid; grid-template-columns: minmax(380px, .9fr) minmax(520px, 1.1fr); gap: 16px; }
|
||||
.supplier-reconciliation-page .sr-summary-group { min-width: 0; padding: 0; border: 0; background: transparent; }
|
||||
.supplier-reconciliation-page .sr-summary-group + .sr-summary-group { padding-left: 16px; border-left: 1px solid #EFEAE0; }
|
||||
.supplier-reconciliation-page .sr-summary-group h3 { margin: 0 0 8px; color: #5B5343; font-size: .75rem; font-weight: 600; }
|
||||
.supplier-reconciliation-page .sr-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
|
||||
.supplier-reconciliation-page .sr-summary-cell { padding: 8px 10px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 7px; background: #fff; display: grid; gap: 3px; }
|
||||
.supplier-reconciliation-page .sr-summary-cell b { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||
.supplier-reconciliation-page .sr-summary-cell span { color: var(--vip-content-muted, #595959); font-size: .75rem; }
|
||||
.supplier-reconciliation-page .sr-comparison-scroll { max-height: min(62vh, 560px); overflow: auto; scrollbar-gutter: stable; }
|
||||
.supplier-reconciliation-page .sr-comparison-scroll { max-height: min(64vh, 620px); overflow: auto; scrollbar-gutter: stable; }
|
||||
.supplier-reconciliation-page .sr-comparison-scroll thead th { position: sticky; top: 0; z-index: 4; box-shadow: 0 1px 0 var(--vip-border, #D8D2C7); }
|
||||
.supplier-reconciliation-page .sr-comparison-table { min-width: 1540px; font-size: .75rem; }
|
||||
.supplier-reconciliation-page .sr-comparison-table th { padding: 7px 8px; }
|
||||
.supplier-reconciliation-page .sr-comparison-table td { padding: 7px 8px; line-height: 1.45; vertical-align: top; }
|
||||
.supplier-reconciliation-page .sr-comparison-table td.is-num { white-space: nowrap; }
|
||||
.supplier-reconciliation-page .sr-comparison-note { min-width: 210px; max-width: 260px; color: var(--vip-content-muted, #595959); font-size: .7rem; line-height: 1.45; }
|
||||
.supplier-reconciliation-page .sr-note-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
|
||||
.supplier-reconciliation-page .sr-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--vip-content-muted, #595959); font-size: .8125rem; }
|
||||
.supplier-reconciliation-page .sr-robot-config { padding: 10px 12px; border: 1px solid #EFEAE0; border-radius: 8px; background: #FCFAF5; }
|
||||
.supplier-reconciliation-page .sr-robot-config summary { cursor: pointer; color: #5B5343; font-size: .8125rem; font-weight: 600; }
|
||||
@ -58,8 +87,13 @@
|
||||
.supplier-reconciliation-page .sr-select-cell input { width: 15px; height: 15px; accent-color: var(--vip-content-accent-dark, #856632); }
|
||||
.supplier-reconciliation-page .sr-robot-form input[type="url"],
|
||||
.supplier-reconciliation-page .sr-robot-form input[type="password"] { width: 100%; min-width: 0; }
|
||||
@media (max-width: 1180px) {
|
||||
.supplier-reconciliation-page .sr-summary-groups { grid-template-columns: minmax(0, 1fr); }
|
||||
.supplier-reconciliation-page .sr-summary-group + .sr-summary-group { padding-top: 12px; padding-left: 0; border-top: 1px solid #EFEAE0; border-left: 0; }
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.supplier-reconciliation-page .sr-robot-form { grid-template-columns: minmax(0, 1fr); }
|
||||
.supplier-reconciliation-page .sr-detail-actions { width: 100%; margin-left: 0; }
|
||||
}
|
||||
.supplier-reconciliation-page .sr-empty { padding: 28px; border: 1px dashed var(--vip-border, #D8D2C7); border-radius: 8px; color: var(--vip-content-muted, #595959); font-size: .8125rem; text-align: center; }
|
||||
</style>
|
||||
@ -126,27 +160,31 @@
|
||||
未找到名为「{{ $supplierQuery }}」的供应商,请输入完整名称并从搜索建议中选择。
|
||||
</div>
|
||||
@endif
|
||||
<p class="sr-hint">
|
||||
比对口径:双方都有快递单号时,第一层优先按「快递单号 + 商品编码」汇总核对;没有快递单号或第一层无法匹配时,再按「采购单号 + 日期 + 商品编码」核对,以我方货款对账的“商品编码”匹配厂家条码;同一匹配键的多行先合并数量与金额。
|
||||
日期未对上时,如采购单号+商品编码一致、数量金额一致且日期相差不超过 7 天,仍按一致处理。<br>
|
||||
数量、金额一致 → 正常结算;厂家多(我方没有)→ 不结算、退回修改;
|
||||
数量或金额不一致 → 明确列出双方数量、单价、金额及厂家多算部分,取金额低的一方结算;
|
||||
厂家少(我方有)→ 按厂家数据结算(不付款)。厂家未填采购单号时,仅在同日期+商品编码能唯一匹配我方一条数据时兜底。<br>
|
||||
厂家登录:在「厂家登录账号管理」新增供应商并勾选可登录,供应商名称必须与对账数据中的厂家名称完全一致;
|
||||
厂家登录后只能查看自己的对账单上传记录、全部退货明细及导出数据。
|
||||
</p>
|
||||
<details class="sr-guide">
|
||||
<summary>
|
||||
<b>比对口径</b>
|
||||
<span>优先按「快递单号 + 商品编码」,无法匹配时再按「采购单号 + 日期 + 商品编码」;数量或金额不一致时按金额低的一方结算。</span>
|
||||
</summary>
|
||||
<div class="sr-guide-body">
|
||||
双方都有快递单号时,第一层优先按「快递单号 + 商品编码」汇总核对;没有快递单号或第一层无法匹配时,再按「采购单号 + 日期 + 商品编码」核对,以我方货款对账的“商品编码”匹配厂家条码;同一匹配键的多行先合并数量与金额。<br>
|
||||
日期未对上时,如采购单号+商品编码一致、数量金额一致且日期相差不超过 7 天,仍按一致处理。<br>
|
||||
数量、金额一致 → 正常结算;厂家多(我方没有)→ 不结算、退回修改;
|
||||
数量或金额不一致 → 明确列出双方数量、单价、金额及厂家多算部分,取金额低的一方结算;
|
||||
厂家少(我方有)→ 按厂家数据结算(不付款)。厂家未填采购单号时,仅在同日期+商品编码能唯一匹配我方一条数据时兜底。<br>
|
||||
厂家登录:在「厂家登录账号管理」新增供应商并勾选可登录,供应商名称必须与对账数据中的厂家名称完全一致;
|
||||
厂家登录后只能查看自己的对账单上传记录、全部退货明细及导出数据。
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
@if ($detail)
|
||||
@php
|
||||
$differenceCount = (int) $detail['summary']['supplierExtra']
|
||||
+ (int) $detail['summary']['mismatch']
|
||||
+ (int) $detail['summary']['supplierMissing'];
|
||||
$differenceCount = (int) ($detail['difference_count'] ?? 0);
|
||||
@endphp
|
||||
<div class="sr-card">
|
||||
<div class="sr-toolbar">
|
||||
<h2>{{ $selectedSupplier }} · 比对明细</h2>
|
||||
<span class="sr-muted" style="font-size:.75rem">
|
||||
<span class="sr-detail-meta">
|
||||
月份 {{ $month !== '' ? $month : '全部' }}
|
||||
@if ($reconciler !== '') · 对账人 {{ $reconciler }} @endif
|
||||
@if (($uploads[$selectedSupplier]['uploaded_at'] ?? null) !== null)
|
||||
@ -155,53 +193,56 @@
|
||||
· 该厂家还没有上传对账单
|
||||
@endif
|
||||
</span>
|
||||
<span style="flex:1 1 auto"></span>
|
||||
<a href="{{ $listUrl }}" class="sr-button">← 返回供应商列表</a>
|
||||
<a href="{{ route('business.supplier-reconciliation.comparison.export', array_filter([
|
||||
'supplier' => $selectedSupplier,
|
||||
'month' => $month,
|
||||
'reconciler' => $reconciler,
|
||||
], static fn (mixed $value): bool => $value !== '' && $value !== null)) }}"
|
||||
class="sr-button">导出比对汇总</a>
|
||||
<a href="{{ $statementTemplateUrl }}" class="sr-button">下载对账单模板</a>
|
||||
@if ($differenceCount > 0)
|
||||
<form method="POST"
|
||||
action="{{ route('business.supplier-reconciliation.push-differences') }}"
|
||||
onsubmit="return confirm('确认将当前筛选的 {{ $differenceCount }} 条差异推送到该厂家钉钉群?')">
|
||||
@csrf
|
||||
<input type="hidden" name="supplier" value="{{ $selectedSupplier }}">
|
||||
<input type="hidden" name="month" value="{{ $month }}">
|
||||
<input type="hidden" name="reconciler" value="{{ $reconciler }}">
|
||||
<input type="hidden" name="scope" value="all">
|
||||
<button type="submit"
|
||||
class="sr-button is-primary {{ $robot['configured'] ? '' : 'is-disabled' }}"
|
||||
@disabled(! $robot['configured'])
|
||||
title="{{ $robot['configured'] ? '推送当前筛选的全部差异' : '请先在下方配置厂家钉钉群机器人' }}">
|
||||
推送全部差异({{ $differenceCount }} 条)
|
||||
</button>
|
||||
</form>
|
||||
<form id="push-selected-form"
|
||||
method="POST"
|
||||
action="{{ route('business.supplier-reconciliation.push-differences') }}">
|
||||
@csrf
|
||||
<input type="hidden" name="supplier" value="{{ $selectedSupplier }}">
|
||||
<input type="hidden" name="month" value="{{ $month }}">
|
||||
<input type="hidden" name="reconciler" value="{{ $reconciler }}">
|
||||
<input type="hidden" name="scope" value="selected">
|
||||
<button id="push-selected-button"
|
||||
type="submit"
|
||||
class="sr-button is-primary is-disabled"
|
||||
disabled
|
||||
title="先在表格中勾选需要推送的差异">
|
||||
推送选中(<span id="push-selected-count">0</span>)
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
<div class="sr-detail-actions">
|
||||
<a href="{{ $listUrl }}" class="sr-button">← 返回供应商列表</a>
|
||||
<a href="{{ route('business.supplier-reconciliation.comparison.export', array_filter([
|
||||
'supplier' => $selectedSupplier,
|
||||
'month' => $month,
|
||||
'reconciler' => $reconciler,
|
||||
'comparison_filter' => $comparisonFilter,
|
||||
], static fn (mixed $value): bool => $value !== '' && $value !== null)) }}"
|
||||
class="sr-button">导出当前筛选</a>
|
||||
@if ($differenceCount > 0)
|
||||
<form method="POST"
|
||||
action="{{ route('business.supplier-reconciliation.push-differences') }}"
|
||||
onsubmit="return confirm('确认将当前筛选的 {{ $differenceCount }} 条差异推送到该厂家钉钉群?')">
|
||||
@csrf
|
||||
<input type="hidden" name="supplier" value="{{ $selectedSupplier }}">
|
||||
<input type="hidden" name="month" value="{{ $month }}">
|
||||
<input type="hidden" name="reconciler" value="{{ $reconciler }}">
|
||||
<input type="hidden" name="comparison_filter" value="{{ $comparisonFilter }}">
|
||||
<input type="hidden" name="scope" value="all">
|
||||
<button type="submit"
|
||||
class="sr-button is-primary {{ $robot['configured'] ? '' : 'is-disabled' }}"
|
||||
@disabled(! $robot['configured'])
|
||||
title="{{ $robot['configured'] ? '推送当前筛选的全部差异' : '请先在下方配置厂家钉钉群机器人' }}">
|
||||
推送全部差异({{ $differenceCount }} 条)
|
||||
</button>
|
||||
</form>
|
||||
<form id="push-selected-form"
|
||||
method="POST"
|
||||
action="{{ route('business.supplier-reconciliation.push-differences') }}">
|
||||
@csrf
|
||||
<input type="hidden" name="supplier" value="{{ $selectedSupplier }}">
|
||||
<input type="hidden" name="month" value="{{ $month }}">
|
||||
<input type="hidden" name="reconciler" value="{{ $reconciler }}">
|
||||
<input type="hidden" name="comparison_filter" value="{{ $comparisonFilter }}">
|
||||
<input type="hidden" name="scope" value="selected">
|
||||
<button id="push-selected-button"
|
||||
type="submit"
|
||||
class="sr-button is-primary is-disabled"
|
||||
disabled
|
||||
title="先在表格中勾选需要推送的差异">
|
||||
推送选中(<span id="push-selected-count">0</span>)
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<details id="dingtalk-robot-config" class="sr-robot-config" @if (! $robot['configured']) open @endif>
|
||||
<details id="dingtalk-robot-config" class="sr-robot-config">
|
||||
<summary>
|
||||
厂家钉钉群机器人:
|
||||
{{ $robot['configured'] ? '已配置' : '未配置,配置后才能推送差异' }}
|
||||
{{ $robot['configured'] ? '已配置' : '未配置(点击展开配置)' }}
|
||||
@if ($robot['last_pushed_at'] !== '')
|
||||
· 上次推送 {{ $robot['last_pushed_at'] }}({{ $robot['last_push_count'] }} 条)
|
||||
@endif
|
||||
@ -402,23 +443,65 @@
|
||||
@if ($detail)
|
||||
<div class="sr-card">
|
||||
<h2>比对汇总(我方 {{ number_format($detail['mineRows']) }} 行 / 厂家 {{ number_format($detail['theirsRows']) }} 行)</h2>
|
||||
<div class="sr-summary">
|
||||
<div class="sr-summary-cell"><span>双方一致</span><b>{{ $detail['summary']['match'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家多(退回修改)</span><b>{{ $detail['summary']['supplierExtra'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>数量/金额不一致(按低结算)</span><b>{{ $detail['summary']['mismatch'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家少(按厂家结算)</span><b>{{ $detail['summary']['supplierMissing'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>我方金额合计</span><b>{{ number_format($detail['summary']['mineAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家金额合计</span><b>{{ number_format($detail['summary']['theirsAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家多算金额</span><b>{{ number_format($detail['summary']['supplierOverAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>按口径结算合计</span><b>{{ number_format($detail['summary']['settleAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>差异金额</span><b>{{ number_format($detail['summary']['differenceAmount'], 2) }}</b></div>
|
||||
@php
|
||||
$comparisonFilterUrl = fn (string $value): string => route('business.pages.show', array_merge(request()->query(), [
|
||||
'section' => $section['slug'],
|
||||
'page' => $page['slug'],
|
||||
'comparison_filter' => $value,
|
||||
'compare_page' => 1,
|
||||
]));
|
||||
@endphp
|
||||
<div class="sr-comparison-tools">
|
||||
<nav class="sr-filter-tabs" aria-label="比对结果筛选">
|
||||
<span class="sr-filter-caption">差异筛选</span>
|
||||
@foreach ($comparisonFilters as $filterOption)
|
||||
<a href="{{ $comparisonFilterUrl($filterOption['value']) }}"
|
||||
class="sr-filter-tab {{ $comparisonFilter === $filterOption['value'] ? 'is-active' : '' }}"
|
||||
title="{{ $filterOption['description'] }}"
|
||||
@if ($comparisonFilter === $filterOption['value']) aria-current="true" @endif>
|
||||
{{ $filterOption['label'] }}
|
||||
<b>{{ number_format($filterOption['count']) }}</b>
|
||||
</a>
|
||||
@endforeach
|
||||
</nav>
|
||||
<div class="sr-filter-result">
|
||||
<span>当前显示 {{ number_format((int) $detail['total_rows']) }} / {{ number_format((int) $detail['all_total_rows']) }} 条</span>
|
||||
@if ($comparisonFilter !== '')
|
||||
<a href="{{ $comparisonFilterUrl('') }}">清除筛选</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="sr-summary-groups">
|
||||
<section class="sr-summary-group" aria-label="比对结果汇总">
|
||||
<h3>比对结果</h3>
|
||||
<div class="sr-summary">
|
||||
<div class="sr-summary-cell"><span>双方一致</span><b>{{ $detail['summary']['match'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家多(退回修改)</span><b>{{ $detail['summary']['supplierExtra'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>数量/金额不一致(按低结算)</span><b>{{ $detail['summary']['mismatch'] }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家少(按厂家结算)</span><b>{{ $detail['summary']['supplierMissing'] }}</b></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="sr-summary-group" aria-label="金额汇总">
|
||||
<h3>金额概览</h3>
|
||||
<div class="sr-summary">
|
||||
<div class="sr-summary-cell"><span>我方金额合计</span><b>{{ number_format($detail['summary']['mineAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家金额合计</span><b>{{ number_format($detail['summary']['theirsAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>厂家多算金额</span><b>{{ number_format($detail['summary']['supplierOverAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>按口径结算合计</span><b>{{ number_format($detail['summary']['settleAmount'], 2) }}</b></div>
|
||||
<div class="sr-summary-cell"><span>差异金额</span><b>{{ number_format($detail['summary']['differenceAmount'], 2) }}</b></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="sr-scroll sr-comparison-scroll">
|
||||
<table>
|
||||
<table class="sr-comparison-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="sr-select-cell">
|
||||
<input id="select-all-differences" type="checkbox" aria-label="选择全部差异">
|
||||
@if ($differenceCount > 0)
|
||||
<input id="select-all-differences" type="checkbox" aria-label="选择全部差异">
|
||||
@else
|
||||
<span class="sr-muted">—</span>
|
||||
@endif
|
||||
</th>
|
||||
<th scope="col">比对结果</th>
|
||||
<th scope="col">采购单号</th>
|
||||
@ -489,7 +572,9 @@
|
||||
厂家{{ $row['amountDifference'] > 0 ? '多' : '少' }} ¥{{ number_format(abs($row['amountDifference']), 2) }}
|
||||
@endif
|
||||
</td>
|
||||
<td class="sr-muted">{{ $row['note'] }}</td>
|
||||
<td class="sr-comparison-note">
|
||||
<span class="sr-note-text" title="{{ $row['note'] }}">{{ $row['note'] }}</span>
|
||||
</td>
|
||||
<td class="is-num">{{ number_format($row['settleAmount'], 2) }}</td>
|
||||
<td>
|
||||
@if ($row['type'] !== '一致')
|
||||
@ -500,6 +585,7 @@
|
||||
<input type="hidden" name="supplier" value="{{ $selectedSupplier }}">
|
||||
<input type="hidden" name="month" value="{{ $month }}">
|
||||
<input type="hidden" name="reconciler" value="{{ $reconciler }}">
|
||||
<input type="hidden" name="comparison_filter" value="{{ $comparisonFilter }}">
|
||||
<input type="hidden" name="scope" value="row">
|
||||
<input type="hidden" name="purchase_no" value="{{ $row['purchaseNo'] }}">
|
||||
<input type="hidden" name="date" value="{{ $row['date'] }}">
|
||||
@ -518,7 +604,18 @@
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="16"><div class="sr-empty">该厂家还没有上传对账单,或我方还没有这家供应商的结算数据。</div></td></tr>
|
||||
<tr>
|
||||
<td colspan="16">
|
||||
<div class="sr-empty">
|
||||
@if ($comparisonFilter !== '')
|
||||
当前筛选没有比对记录。
|
||||
<a href="{{ $comparisonFilterUrl('') }}">查看全部结果</a>
|
||||
@else
|
||||
该厂家还没有上传对账单,或我方还没有这家供应商的结算数据。
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -239,7 +239,7 @@ class SupplierReconciliationTest extends FeatureTestCase
|
||||
->assertSeeText('厂家多 1.00')
|
||||
->assertSeeText('厂家多 ¥128.00')
|
||||
->assertSeeText('编号-ZSJ-1N1097V01')
|
||||
->assertSeeText('导出比对汇总')
|
||||
->assertSeeText('导出当前筛选')
|
||||
->assertSee('sr-comparison-scroll', false)
|
||||
->assertSeeText('每页 15 条')
|
||||
->assertSeeText('ZSJ-3')
|
||||
@ -247,6 +247,96 @@ class SupplierReconciliationTest extends FeatureTestCase
|
||||
->assertDontSeeText('各厂家上传情况');
|
||||
}
|
||||
|
||||
public function test_finance_comparison_filters_supplier_over_and_under_amounts(): void
|
||||
{
|
||||
$companyId = (int) $this->company->id;
|
||||
$store = app(SupplierPayableOverrideStore::class);
|
||||
foreach ([
|
||||
'mine:over' => ['purchaseNo' => 'PO-OVER', 'skuCode' => 'A-1'],
|
||||
'mine:under' => ['purchaseNo' => 'PO-UNDER', 'skuCode' => 'B-1'],
|
||||
'mine:match' => ['purchaseNo' => 'PO-MATCH', 'skuCode' => 'C-1'],
|
||||
] as $key => $row) {
|
||||
$store->save('final:supplier:payment-reconciliation', $key, $row + [
|
||||
'summary_month' => '2026-09',
|
||||
'date' => '2026-09-30',
|
||||
'supplier' => '晨丰',
|
||||
'qty' => '1',
|
||||
'unitPrice' => '100',
|
||||
'amount' => '100',
|
||||
'reconciler' => '张三',
|
||||
], $companyId, null);
|
||||
}
|
||||
$this->seedStatement('晨丰', [
|
||||
array_merge($this->statementRow('A-1N1097V01', '100.00', '2', '200.00'), [
|
||||
'purchaseNo' => 'PO-OVER',
|
||||
]),
|
||||
array_merge($this->statementRow('C-1N1097V01', '100.00', '1', '100.00'), [
|
||||
'purchaseNo' => 'PO-MATCH',
|
||||
]),
|
||||
array_merge($this->statementRow('D-1N1097V01', '100.00', '1', '100.00'), [
|
||||
'purchaseNo' => 'PO-EXTRA',
|
||||
]),
|
||||
]);
|
||||
|
||||
$detail = app(SupplierReconciliationPageData::class)->financeDetailForFilters(
|
||||
'晨丰',
|
||||
$companyId,
|
||||
['month' => '2026-09', 'comparison_filter' => 'supplier_over'],
|
||||
);
|
||||
$this->assertSame(4, $detail['all_total_rows']);
|
||||
$this->assertSame(2, $detail['total_rows']);
|
||||
$this->assertSame(2, $detail['difference_count']);
|
||||
$this->assertSame(2, $detail['comparison_counts']['supplier_over']);
|
||||
$this->assertSame(1, $detail['comparison_counts']['supplier_under']);
|
||||
|
||||
$pageUrl = fn (string $filter): string => route('business.pages.show', [
|
||||
'section' => 'supplier-reconciliation',
|
||||
'page' => 'finance-data',
|
||||
'supplier' => '晨丰',
|
||||
'month' => '2026-09',
|
||||
'comparison_filter' => $filter,
|
||||
]);
|
||||
|
||||
$this->loginAs()->get($pageUrl('supplier_over'))
|
||||
->assertOk()
|
||||
->assertSeeText('厂家多算')
|
||||
->assertSeeText('厂家少算')
|
||||
->assertSeeText('当前显示 2 / 4 条')
|
||||
->assertSeeText('A-1')
|
||||
->assertSeeText('D-1')
|
||||
->assertDontSeeText('B-1')
|
||||
->assertDontSeeText('C-1')
|
||||
->assertSeeText('推送全部差异(2 条)');
|
||||
|
||||
$this->loginAs()->get($pageUrl('supplier_under'))
|
||||
->assertOk()
|
||||
->assertSeeText('当前显示 1 / 4 条')
|
||||
->assertSeeText('B-1')
|
||||
->assertDontSeeText('A-1')
|
||||
->assertDontSeeText('D-1')
|
||||
->assertDontSeeText('C-1');
|
||||
|
||||
$this->loginAs()->get($pageUrl('not-a-filter'))
|
||||
->assertOk()
|
||||
->assertSeeText('当前显示 4 / 4 条')
|
||||
->assertSeeText('A-1')
|
||||
->assertSeeText('B-1')
|
||||
->assertSeeText('C-1')
|
||||
->assertSeeText('D-1');
|
||||
|
||||
$export = $this->loginAs()->get(route('business.supplier-reconciliation.comparison.export', [
|
||||
'supplier' => '晨丰',
|
||||
'month' => '2026-09',
|
||||
'comparison_filter' => 'supplier_over',
|
||||
]));
|
||||
$content = $export->streamedContent();
|
||||
$export->assertOk()->assertDownload();
|
||||
$this->assertStringContainsString('A-1', $content);
|
||||
$this->assertStringContainsString('D-1', $content);
|
||||
$this->assertStringNotContainsString('B-1', $content);
|
||||
$this->assertStringNotContainsString('C-1', $content);
|
||||
}
|
||||
|
||||
public function test_supplier_without_upload_does_not_generate_or_push_missing_differences(): void
|
||||
{
|
||||
$store = app(SupplierPayableOverrideStore::class);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user