fix: 供应商对账日期容差调整为一周 (#846)
This commit is contained in:
parent
6e054e4e8a
commit
661fbca7d3
@ -8,7 +8,7 @@ use Carbon\CarbonImmutable;
|
||||
* 厂家对账单 vs 我方结算数据:
|
||||
* - 行键 = 采购单号 + 日期 + 我方商品编码(对应厂家条码去掉厂家编号/版本后缀);
|
||||
* - 同一行键的多行先合并数量与金额,再比较双方数量和金额;
|
||||
* - 严格行键未匹配时,采购单号+商品编码一致、数量金额一致且日期相差不超过 2 天,仍按一致处理;
|
||||
* - 严格行键未匹配时,采购单号+商品编码一致、数量金额一致且日期相差不超过 7 天,仍按一致处理;
|
||||
* - 厂家未填采购单号时,仅在同日期+商品编码能唯一对应我方一条数据时兜底匹配。
|
||||
*/
|
||||
class SupplierStatementMatcher
|
||||
@ -24,7 +24,7 @@ class SupplierStatementMatcher
|
||||
/** 厂家条码后缀:供应商编号 + 版本,如 N1097V01、N1269V01。 */
|
||||
private const SUPPLIER_SUFFIX = '/[A-Z]{1,3}\d{3,6}V\d{1,3}$/i';
|
||||
|
||||
private const DATE_TOLERANCE_DAYS = 2;
|
||||
private const DATE_TOLERANCE_DAYS = 7;
|
||||
|
||||
/**
|
||||
* @param list<array<string,mixed>> $mine 我方数据(purchaseNo/date/productCode/unitPrice/qty/amount;productCode 为空才回退货号)
|
||||
@ -257,7 +257,7 @@ class SupplierStatementMatcher
|
||||
|
||||
/**
|
||||
* 严格键未匹配时,仅对同采购单号、同商品编码、数量金额一致且日期相差
|
||||
* 不超过 2 天的记录做一对一容错配对。
|
||||
* 不超过 7 天的记录做一对一容错配对。
|
||||
*
|
||||
* @param array<string,array<string,mixed>> $mine
|
||||
* @param array<string,array<string,mixed>> $theirs
|
||||
|
||||
@ -119,7 +119,7 @@
|
||||
@endif
|
||||
<p class="sr-hint">
|
||||
比对口径:优先按「采购单号 + 日期 + 商品编码」核对,以我方货款对账的“商品编码”匹配厂家条码;同一采购单号、日期和商品编码的多行先合并数量与金额。
|
||||
日期未对上时,如采购单号+商品编码一致、数量金额一致且日期相差不超过 2 天,仍按一致处理。<br>
|
||||
日期未对上时,如采购单号+商品编码一致、数量金额一致且日期相差不超过 7 天,仍按一致处理。<br>
|
||||
数量、金额一致 → 正常结算;厂家多(我方没有)→ 不结算、退回修改;
|
||||
数量或金额不一致 → 明确列出双方数量、单价、金额及厂家多算部分,取金额低的一方结算;
|
||||
厂家少(我方有)→ 按厂家数据结算(不付款)。厂家未填采购单号时,仅在同日期+商品编码能唯一匹配我方一条数据时兜底。<br>
|
||||
|
||||
@ -7,7 +7,7 @@ use Tests\TestCase;
|
||||
|
||||
class SupplierStatementMatcherTest extends TestCase
|
||||
{
|
||||
public function test_two_day_date_difference_matches_when_purchase_barcode_quantity_and_amount_match(): void
|
||||
public function test_seven_day_date_difference_matches_when_purchase_barcode_quantity_and_amount_match(): void
|
||||
{
|
||||
$mine = [[
|
||||
'purchaseNo' => '879735',
|
||||
@ -20,7 +20,7 @@ class SupplierStatementMatcherTest extends TestCase
|
||||
]];
|
||||
$theirs = [[
|
||||
'purchaseNo' => '879735',
|
||||
'createdAt' => '2026-09-12',
|
||||
'createdAt' => '2026-09-17',
|
||||
'barcode' => 'DNZ033609N1097V01',
|
||||
'unitPrice' => '100',
|
||||
'qty' => '20',
|
||||
@ -35,11 +35,11 @@ class SupplierStatementMatcherTest extends TestCase
|
||||
$this->assertSame(0, $result['summary']['mismatch']);
|
||||
$this->assertSame(0.0, $result['summary']['differenceAmount']);
|
||||
$this->assertSame(2000.0, $result['summary']['settleAmount']);
|
||||
$this->assertSame(2, $result['rows'][0]['dateToleranceDays']);
|
||||
$this->assertStringContainsString('日期相差 2 天', $result['rows'][0]['note']);
|
||||
$this->assertSame(7, $result['rows'][0]['dateToleranceDays']);
|
||||
$this->assertStringContainsString('日期相差 7 天', $result['rows'][0]['note']);
|
||||
}
|
||||
|
||||
public function test_date_difference_over_two_days_remains_a_difference(): void
|
||||
public function test_date_difference_over_seven_days_remains_a_difference(): void
|
||||
{
|
||||
$mine = [[
|
||||
'purchaseNo' => '879735',
|
||||
@ -50,7 +50,7 @@ class SupplierStatementMatcherTest extends TestCase
|
||||
]];
|
||||
$theirs = [[
|
||||
'purchaseNo' => '879735',
|
||||
'createdAt' => '2026-09-13',
|
||||
'createdAt' => '2026-09-18',
|
||||
'barcode' => 'DNZ033609N1097V01',
|
||||
'qty' => '20',
|
||||
'amount' => '2000',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user