parent
59e0e46b8a
commit
2f74eeab39
@ -1227,13 +1227,18 @@ class SupplierReconciliationPageData
|
||||
$allRows,
|
||||
fn (array $row): bool => $this->comparisonRowMatchesFilter($row, $comparisonFilter),
|
||||
));
|
||||
$rows = array_map(function (array $row): array {
|
||||
$row['requiresSupplierCorrection'] = $this->requiresSupplierCorrection($row);
|
||||
|
||||
return $row;
|
||||
}, $rows);
|
||||
$filteredDifferenceCount = count(array_filter(
|
||||
$rows,
|
||||
static fn (array $row): bool => (string) ($row['type'] ?? '') !== SupplierStatementMatcher::TYPE_MATCH,
|
||||
));
|
||||
$filteredCorrectionCount = count(array_filter(
|
||||
$rows,
|
||||
fn (array $row): bool => $this->requiresSupplierCorrection($row),
|
||||
static fn (array $row): bool => (bool) ($row['requiresSupplierCorrection'] ?? false),
|
||||
));
|
||||
|
||||
$detail['all_total_rows'] = count($allRows);
|
||||
@ -1248,11 +1253,14 @@ class SupplierReconciliationPageData
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $row 是否需要厂家修改账单的多报或多算。 */
|
||||
/** @param array<string,mixed> $row 是否需要厂家修改账单。 */
|
||||
public function requiresSupplierCorrection(array $row): bool
|
||||
{
|
||||
return (float) ($row['supplierOverQty'] ?? 0) > 0.005
|
||||
|| (float) ($row['supplierOverAmount'] ?? 0) > 0.005;
|
||||
return in_array((string) ($row['type'] ?? ''), [
|
||||
SupplierStatementMatcher::TYPE_SUPPLIER_EXTRA,
|
||||
SupplierStatementMatcher::TYPE_MISMATCH,
|
||||
SupplierStatementMatcher::TYPE_SUPPLIER_MISSING,
|
||||
], true);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $row */
|
||||
|
||||
@ -317,7 +317,7 @@
|
||||
<button type="submit"
|
||||
class="sr-button is-primary {{ $robot['configured'] ? '' : 'is-disabled' }}"
|
||||
@disabled(! $robot['configured'])
|
||||
title="{{ $robot['configured'] ? '推送当前筛选的全部需厂家修改差异' : '请先在下方配置厂家钉钉群机器人' }}">
|
||||
title="{{ $robot['configured'] ? '推送当前筛选中的厂家多算、厂家少算和数量/金额不一致差异' : '请先在下方配置厂家钉钉群机器人' }}">
|
||||
推送全部需厂家修改差异({{ $correctionCount }} 条)
|
||||
</button>
|
||||
</form>
|
||||
@ -827,8 +827,7 @@
|
||||
'未定价' => 'is-unpriced',
|
||||
default => 'is-match',
|
||||
};
|
||||
$requiresSupplierCorrection = (float) ($row['supplierOverQty'] ?? 0) > 0.005
|
||||
|| (float) ($row['supplierOverAmount'] ?? 0) > 0.005;
|
||||
$requiresSupplierCorrection = (bool) ($row['requiresSupplierCorrection'] ?? false);
|
||||
$rawStatementBarcode = trim((string) ($row['supplierBarcode'] ?? ''));
|
||||
if ($rawStatementBarcode === '') {
|
||||
$rawStatementBarcode = trim((string) ($row['barcode'] ?? ''));
|
||||
|
||||
@ -35,7 +35,7 @@ class SupplierReconciliationDingTalkTest extends FeatureTestCase
|
||||
|
||||
$this->loginAs()->get($this->pageUrl())
|
||||
->assertOk()
|
||||
->assertSeeText('推送全部需厂家修改差异(1 条)')
|
||||
->assertSeeText('推送全部需厂家修改差异(3 条)')
|
||||
->assertSeeText('推送选中(')
|
||||
->assertSee('aria-label="选择全部需厂家修改差异"', false)
|
||||
->assertSeeText('推送本条')
|
||||
@ -126,7 +126,7 @@ class SupplierReconciliationDingTalkTest extends FeatureTestCase
|
||||
'scope' => 'all',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHas('success', '已推送 1 条差异到 晨丰 钉钉群(1 条消息)。');
|
||||
->assertSessionHas('success', '已推送 3 条差异到 晨丰 钉钉群(1 条消息)。');
|
||||
|
||||
Http::assertSentCount(1);
|
||||
Http::assertSent(function ($request): bool {
|
||||
@ -136,6 +136,8 @@ class SupplierReconciliationDingTalkTest extends FeatureTestCase
|
||||
&& str_contains($request->url(), 'timestamp=')
|
||||
&& str_contains($request->url(), 'sign=')
|
||||
&& str_contains($text, '货款对账差异通知 · 晨丰')
|
||||
&& str_contains($text, 'B-1')
|
||||
&& str_contains($text, 'C-1')
|
||||
&& str_contains($text, 'D-1')
|
||||
&& str_contains($text, '采购单号:编号-D-1')
|
||||
&& str_contains($text, '**厂家多**')
|
||||
@ -143,14 +145,12 @@ class SupplierReconciliationDingTalkTest extends FeatureTestCase
|
||||
&& str_contains($text, ',厂家数量 ')
|
||||
&& ! str_contains($text, '日期:2026-09-30')
|
||||
&& ! str_contains($text, '`A-1`')
|
||||
&& ! str_contains($text, '`B-1`')
|
||||
&& ! str_contains($text, '`C-1`')
|
||||
&& ! str_contains($text, '鸣飞家具');
|
||||
});
|
||||
|
||||
$config = app(SupplierDingTalkNotifier::class)->configuration('晨丰');
|
||||
$this->assertNotSame('', $config['last_pushed_at']);
|
||||
$this->assertSame(1, $config['last_push_count']);
|
||||
$this->assertSame(3, $config['last_push_count']);
|
||||
}
|
||||
|
||||
public function test_push_message_shows_purchase_level_difference_details(): void
|
||||
@ -790,13 +790,14 @@ class SupplierReconciliationDingTalkTest extends FeatureTestCase
|
||||
],
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHas('success', '已推送 1 条差异到 晨丰 钉钉群(1 条消息)。');
|
||||
->assertSessionHas('success', '已推送 2 条差异到 晨丰 钉钉群(1 条消息)。');
|
||||
|
||||
Http::assertSent(function ($request): bool {
|
||||
$text = (string) ($request['markdown']['text'] ?? '');
|
||||
|
||||
return str_contains($text, 'D-1')
|
||||
&& ! str_contains($text, '`B-1`')
|
||||
&& str_contains($text, 'B-1')
|
||||
&& str_contains($text, '厂家少算')
|
||||
&& ! str_contains($text, '`C-1`');
|
||||
});
|
||||
}
|
||||
|
||||
@ -911,13 +911,23 @@ class SupplierReconciliationTest extends FeatureTestCase
|
||||
->assertDontSeeText('C-1')
|
||||
->assertSeeText('推送全部需厂家修改差异(2 条)');
|
||||
|
||||
$underDetail = app(SupplierReconciliationPageData::class)->financeDetailForFilters(
|
||||
'晨丰',
|
||||
$companyId,
|
||||
['month' => '2026-09', 'comparison_filter' => 'supplier_under'],
|
||||
);
|
||||
$this->assertSame(1, $underDetail['total_rows']);
|
||||
$this->assertSame(1, $underDetail['difference_count']);
|
||||
$this->assertSame(1, $underDetail['correction_count']);
|
||||
|
||||
$this->loginAs()->get($pageUrl('supplier_under'))
|
||||
->assertOk()
|
||||
->assertSeeText('当前显示 1 / 4 条')
|
||||
->assertSeeText('B-1')
|
||||
->assertDontSeeText('A-1')
|
||||
->assertDontSeeText('D-1')
|
||||
->assertDontSeeText('C-1');
|
||||
->assertDontSeeText('C-1')
|
||||
->assertSeeText('推送全部需厂家修改差异(1 条)');
|
||||
|
||||
$this->loginAs()->get($pageUrl('not-a-filter'))
|
||||
->assertOk()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user