feat: enhance reconciliation job processing and reporting features
- Updated ReconcileItemIndexController to include admin user validation and improved transfer order handling. - Refactored ReconcileJobStoreController to ensure date range handling is more precise with start and end of day adjustments. - Enhanced various report controllers to include currency code in responses for better financial clarity. - Introduced new methods in AdminReconcileJobService for wallet transfer job creation and improved item scanning logic. - Added wallet lookup idempotent path configuration for integration services to enhance API interactions.
This commit is contained in:
88
tests/Feature/AdminReconcileJobScanTest.php
Normal file
88
tests/Feature/AdminReconcileJobScanTest.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\Player;
|
||||
use App\Models\ReconcileJob;
|
||||
use App\Models\TransferOrder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Database\Seeders\AdminRbacAndUserSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function (): void {
|
||||
$this->seed(AdminRbacAndUserSeeder::class);
|
||||
$this->artisan('lottery:admin-auth-sync')->assertExitCode(0);
|
||||
});
|
||||
|
||||
function reconcileScanToken(): string
|
||||
{
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'reconcile_scan_admin',
|
||||
'name' => 'Reconcile Scan',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($admin);
|
||||
|
||||
return $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
}
|
||||
|
||||
test('manual reconcile job create runs wallet transfer detector scan', function (): void {
|
||||
$token = reconcileScanToken();
|
||||
$admin = AdminUser::query()->where('username', 'reconcile_scan_admin')->firstOrFail();
|
||||
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'main',
|
||||
'site_player_id' => 'manual-reconcile-1',
|
||||
'username' => null,
|
||||
'nickname' => null,
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
TransferOrder::query()->create([
|
||||
'transfer_no' => 'TO_manual_scan',
|
||||
'player_id' => $player->id,
|
||||
'direction' => 'out',
|
||||
'currency_code' => 'NPR',
|
||||
'amount' => 500,
|
||||
'idempotent_key' => 'manual-scan-key',
|
||||
'status' => 'pending_reconcile',
|
||||
'external_request_payload' => null,
|
||||
'external_response_payload' => null,
|
||||
'external_ref_no' => null,
|
||||
'fail_reason' => 'main_site_timeout',
|
||||
'finished_at' => null,
|
||||
'created_at' => now()->subHours(2),
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->postJson('/api/v1/admin/reconcile-jobs', [
|
||||
'reconcile_type' => 'wallet_transfer',
|
||||
'date_from' => now()->subDay()->toDateString(),
|
||||
'date_to' => now()->toDateString(),
|
||||
'player_id' => $player->id,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.item_count', 1);
|
||||
|
||||
$job = ReconcileJob::query()->latest('id')->firstOrFail();
|
||||
expect($job->admin_user_id)->toBe($admin->id)
|
||||
->and($job->items()->count())->toBe(1)
|
||||
->and($job->items()->value('side_a_ref'))->toBe('TO_manual_scan');
|
||||
});
|
||||
|
||||
test('manual reconcile job create returns zero items when scan finds nothing', function (): void {
|
||||
$token = reconcileScanToken();
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->postJson('/api/v1/admin/reconcile-jobs', [
|
||||
'reconcile_type' => 'wallet_transfer',
|
||||
'date_from' => now()->subDay()->toDateString(),
|
||||
'date_to' => now()->toDateString(),
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.item_count', 0);
|
||||
});
|
||||
Reference in New Issue
Block a user