feat: 增强后台设置校验、代理权限控制与财务审计能力
This commit is contained in:
@@ -152,6 +152,89 @@ test('credit ledger index includes payment on agent bill', function (): void {
|
||||
->assertJsonPath('data.items.0.bill_type', 'agent');
|
||||
});
|
||||
|
||||
test('credit ledger settlement bill reference keeps the referenced bill id', function (): void {
|
||||
$site = DB::table('admin_sites')->where('is_default', true)->first();
|
||||
$siteId = (int) $site->id;
|
||||
$siteCode = (string) $site->code;
|
||||
|
||||
$periodId = (int) DB::table('settlement_periods')->insertGetId([
|
||||
'admin_site_id' => $siteId,
|
||||
'period_start' => now()->subDay(),
|
||||
'period_end' => now()->addDay(),
|
||||
'status' => 'closed',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$player = Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'site_player_id' => 'native:bill-ref-ledger',
|
||||
'funding_mode' => PlayerFundingMode::CREDIT,
|
||||
'username' => 'bill_ref_ledger_user',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$referencedBillId = (int) DB::table('settlement_bills')->insertGetId([
|
||||
'settlement_period_id' => $periodId,
|
||||
'bill_type' => 'player',
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'counterparty_type' => 'agent',
|
||||
'counterparty_id' => 1,
|
||||
'net_amount' => -100,
|
||||
'unpaid_amount' => 0,
|
||||
'paid_amount' => 100,
|
||||
'status' => 'settled',
|
||||
'created_at' => now()->subMinute(),
|
||||
'updated_at' => now()->subMinute(),
|
||||
]);
|
||||
|
||||
$newerBillId = (int) DB::table('settlement_bills')->insertGetId([
|
||||
'settlement_period_id' => $periodId,
|
||||
'bill_type' => 'player',
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'counterparty_type' => 'agent',
|
||||
'counterparty_id' => 1,
|
||||
'net_amount' => -200,
|
||||
'unpaid_amount' => 0,
|
||||
'paid_amount' => 200,
|
||||
'status' => 'settled',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('credit_ledger')->insert([
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'amount' => 100,
|
||||
'reason' => 'settlement_payout',
|
||||
'ref_type' => 'settlement_bill',
|
||||
'ref_id' => $referencedBillId,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'ledger_bill_ref_super',
|
||||
'name' => 'Ledger Bill Ref',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($admin);
|
||||
$token = $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/credit-ledger?admin_site_id='.$siteId.'&settlement_period_id='.$periodId.'&reason=settlement_payout')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.entry_kind', 'credit')
|
||||
->assertJsonPath('data.items.0.settlement_bill_id', $referencedBillId)
|
||||
->assertJsonPath('data.items.0.ref_id', $referencedBillId);
|
||||
});
|
||||
|
||||
test('credit ledger entry_kind share returns share ledger rows', function (): void {
|
||||
$site = DB::table('admin_sites')->where('is_default', true)->first();
|
||||
$siteId = (int) $site->id;
|
||||
|
||||
Reference in New Issue
Block a user