From e6ce84759ea2a4559fd4d125b00bf3c80d63aaee Mon Sep 17 00:00:00 2001 From: qiuxiang <394405259@qq.com> Date: Thu, 19 Nov 2026 18:40:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=B4=A6=E6=88=B7=E4=BD=99=E9=A2=9D):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=9E=E9=95=9C=E5=83=8F=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=AF=8F=E6=97=A5=E4=BD=99=E9=A2=9D=E6=9F=A5=E8=AF=A2=20(#1287?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreReceivingBalanceOverviewService.php | 2 +- ...reReceivingBalanceOverviewEndpointTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php b/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php index 72939a94..c1342b63 100644 --- a/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php +++ b/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php @@ -1518,7 +1518,7 @@ class StoreReceivingBalanceOverviewService ->where('company_id', company_id()) ->where('bill_type', $platform); if ($flow === null) { - $query->where(function (Builder $query): void { + $query->where(function (EloquentBuilder $query): void { $query->where('income', '>', 0)->orWhere('expense', '>', 0); }); } else { diff --git a/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php b/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php index 326918f3..e091d415 100644 --- a/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php +++ b/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php @@ -4,8 +4,10 @@ namespace Tests\Feature\Business; use App\Models\Auth\Permission; use Mockery; +use Modules\EcommerceFinance\Models\AccountBill; use Modules\EcommerceFinance\Services\PeriodBalanceReconciliationService; use Modules\EcommerceFinance\Services\StoreReceivingBalanceOverviewService; +use ReflectionMethod; use Tests\Feature\FeatureTestCase; class StoreReceivingBalanceOverviewEndpointTest extends FeatureTestCase @@ -191,6 +193,36 @@ class StoreReceivingBalanceOverviewEndpointTest extends FeatureTestCase ->assertJsonPath('pagination.total', 1); } + public function test_account_bill_daily_rows_include_both_flows_when_direction_is_unspecified(): void + { + $this->company->makeCurrent(); + AccountBill::create([ + 'company_id' => $this->company->id, + 'bill_type' => 'xiaohongshu', + 'record_code' => 'daily-balance-null-flow', + 'store_name' => '小红书-测试店', + 'order_no' => 'DAILY-BALANCE-1', + 'amount' => 5.0, + 'bill_item' => '销售', + 'occurred_at' => '2026-10-15 12:00:00', + 'income' => 5.0, + 'expense' => 0.0, + 'payload' => [], + ]); + + $service = $this->app->make(StoreReceivingBalanceOverviewService::class); + $method = new ReflectionMethod($service, 'accountBillRows'); + $method->setAccessible(true); + $rows = iterator_to_array( + $method->invoke($service, 'xiaohongshu', '2026-10-01', '2026-10-31', null), + ); + + $this->assertCount(1, $rows); + $this->assertSame('小红书-测试店', $rows[0]['store_name']); + $this->assertSame(5.0, $rows[0]['income']); + $this->assertSame(0.0, $rows[0]['expense']); + } + public function test_overview_page_uses_the_vue_mount_point(): void { $this->user->attachPermission(