fix(账户余额): 修复非镜像平台每日余额查询 (#1287)
This commit is contained in:
parent
3240342fa4
commit
e6ce84759e
@ -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 {
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user