fix: 种菜收入核对差异扣除任务佣金 #1635
@ -92,7 +92,7 @@ class PlantingReimbursementIncomeCheck
|
||||
$other[] = self::SOURCE_LABELS[$source] . ' ' . $bill['bill_item'] . ' ' . self::decimal($net) . '元(' . $bill['record_code'] . ')';
|
||||
}
|
||||
}
|
||||
$difference = self::cents($row['reimbursement_amount'] ?? null) - $income;
|
||||
$difference = self::cents($row['reimbursement_amount'] ?? null) - $income - self::cents($row['task_commission'] ?? null);
|
||||
$note = '';
|
||||
$valid = $sources !== [] && $number !== '' && $start !== null && is_numeric($row['reimbursement_amount'] ?? null);
|
||||
if (! $valid) {
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
<div><span>任务空包费(元)</span><strong>{{ number_format($plantingSummary['task_empty_package_fee'] / 100, 2) }}</strong></div>
|
||||
<div class="is-key"><span>最终报销金额(元)</span><strong>{{ number_format($plantingSummary['reimbursement_amount'] / 100, 2) }}</strong></div>
|
||||
</div>
|
||||
<details class="pw-rules"><summary>核对口径</summary><p>仅核对已完成的种菜报销,同一工单取最新一版。订单号清理开头引号及空格后完整匹配;账单范围为工单付款月上月25日至今天,仅总账备注“订单收入”,按流水号去重后合计收入减支出。差异为最终报销金额减订单收入合计,超过±0.01元才判定多报销或少报销;平台补贴和优惠券不抵消多报销。无收入时结合平台状态和账单覆盖日期提示核实。顶部卡片与发起人汇总按日期和文本筛选统计全部结论。</p></details>
|
||||
<details class="pw-rules"><summary>核对口径</summary><p>仅核对已完成的种菜报销,同一工单取最新一版。订单号清理开头引号及空格后完整匹配;账单范围为工单付款月上月25日至今天,仅总账备注“订单收入”,按流水号去重后合计收入减支出。差异为最终报销金额减订单收入合计再减任务佣金,超过±0.01元才判定多报销或少报销;平台补贴和优惠券不抵消多报销。无收入时结合平台状态和账单覆盖日期提示核实。顶部卡片与发起人汇总按日期和文本筛选统计全部结论。</p></details>
|
||||
<section class="pw-panel" aria-label="种菜报销明细">
|
||||
<div class="pw-table-scroll"><table><thead><tr>
|
||||
@foreach($columns as $key => $label)<th data-column-key="{{ $key }}">{{ $label }}</th>@endforeach
|
||||
|
||||
@ -173,10 +173,10 @@ class PlantingWorkOrderPagesTest extends FeatureTestCase
|
||||
{
|
||||
$rows = [];
|
||||
$bills = [];
|
||||
foreach (['30.00', '10.00', '17.50'] as $i => $amount) {
|
||||
foreach (['30.00', '10.00', '20.00'] as $i => $amount) {
|
||||
$rows[] = $this->row(['completed_at' => '2026-11-12 10:00:00', 'paid_at' => '2026-11-10 10:00:00',
|
||||
'platform' => '淘宝天猫', 'online_order_no' => 'ORDER' . $i, 'work_order_no' => 'GD' . $i,
|
||||
'initiator' => '测试发起人', 'task_payment' => '100.00', 'reimbursement_amount' => $amount]);
|
||||
'initiator' => '测试发起人', 'task_payment' => '100.00', 'task_commission' => '2.50', 'reimbursement_amount' => $amount]);
|
||||
$bills[] = ['source' => 'taobao-alipay', 'record_code' => 'B' . $i, 'online_order_no' => 'ORDER' . $i,
|
||||
'occurred_at' => '2026-11-11 10:00:00', 'ledger_remark' => '订单收入', 'bill_item' => '订单收入',
|
||||
'income' => '17.50', 'expense' => '0.00'];
|
||||
@ -189,18 +189,18 @@ class PlantingWorkOrderPagesTest extends FeatureTestCase
|
||||
|
||||
$query = ['month' => '2026-11', 'completed_from' => '2026-11-01', 'income_result' => '多报销'];
|
||||
$this->loginAs()->get($this->url('planting-reimbursements', $query))->assertOk()
|
||||
->assertSee('差异为最终报销金额减订单收入合计')
|
||||
->assertSee('差异为最终报销金额减订单收入合计再减任务佣金')
|
||||
->assertSee('GD0')->assertDontSee('GD1')->assertDontSee('GD2')
|
||||
->assertViewHas('content', static fn (array $content): bool => $content['plantingIncomeSummary']['多报销'] === ['count' => 1, 'difference' => 1250]
|
||||
&& $content['plantingIncomeSummary']['少报销'] === ['count' => 1, 'difference' => -750]
|
||||
->assertViewHas('content', static fn (array $content): bool => $content['plantingIncomeSummary']['多报销'] === ['count' => 1, 'difference' => 1000]
|
||||
&& $content['plantingIncomeSummary']['少报销'] === ['count' => 1, 'difference' => -1000]
|
||||
&& $content['plantingIncomeSummary']['一致']['count'] === 1
|
||||
&& $content['plantingIncomeInitiators']['测试发起人'] === ['count' => 1, 'difference' => 1250]);
|
||||
&& $content['plantingIncomeInitiators']['测试发起人'] === ['count' => 1, 'difference' => 1000]);
|
||||
|
||||
$response = $this->loginAs()->get(route('business.planting-data.planting-reimbursements.export', ['company_id' => $this->company->id] + $query + [
|
||||
'columns' => 'work_order_no,task_payment,reimbursement_amount,income_total,income_difference,income_result',
|
||||
'columns' => 'work_order_no,task_payment,reimbursement_amount,task_commission,income_total,income_difference,income_result',
|
||||
]));
|
||||
$response->assertOk();
|
||||
$this->assertStringContainsString('GD0,100.00,30.00,17.50,12.50,多报销', $response->streamedContent());
|
||||
$this->assertStringContainsString('GD0,100.00,30.00,2.50,17.50,10.00,多报销', $response->streamedContent());
|
||||
$this->assertStringNotContainsString('GD1', $response->streamedContent());
|
||||
$this->assertStringNotContainsString('GD2', $response->streamedContent());
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class PlantingReimbursementIncomeCheckTest extends TestCase
|
||||
private function row(array $patch = []): array
|
||||
{
|
||||
return array_replace(['platform' => '头条放心购', 'shop_name' => '抖音-测试', 'online_order_no' => " ' 1234567890123456789",
|
||||
'paid_at' => '2026-11-12 12:00:00', 'task_payment' => '700.00', 'reimbursement_amount' => '668.00', 'platform_order_status' => 'TRADE_FINISHED'], $patch);
|
||||
'paid_at' => '2026-11-12 12:00:00', 'task_payment' => '700.00', 'reimbursement_amount' => '668.00', 'task_commission' => '0.00', 'platform_order_status' => 'TRADE_FINISHED'], $patch);
|
||||
}
|
||||
|
||||
private function check(array $rows, array $records, ?array $expectedOrders = null): array
|
||||
@ -104,4 +104,15 @@ class PlantingReimbursementIncomeCheckTest extends TestCase
|
||||
}
|
||||
$this->assertSame('0.00', $result[3]['income_difference']);
|
||||
}
|
||||
|
||||
public function test_task_commission_is_subtracted_once_from_the_final_reimbursement_difference(): void
|
||||
{
|
||||
$rows = [];
|
||||
foreach (['40.00', '39.98', '40.02', '0.00', null] as $commission) {
|
||||
$rows[] = $this->row(['task_commission' => $commission]);
|
||||
}
|
||||
$result = $this->check($rows, [$this->bill()]);
|
||||
$this->assertSame(['0.00', '0.02', '-0.02', '40.00', '40.00'], array_column($result, 'income_difference'));
|
||||
$this->assertSame(['一致', '多报销', '少报销', '多报销', '多报销'], array_column($result, 'income_result'));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user