insert([ 'parent_id' => 1, 'invoice_number' => 'INV-1', 'status' => 'open', 'total_amount' => 100, 'paid_amount' => 20, 'balance' => 80, 'issue_date' => now()->toDateString(), 'due_date' => now()->addDays(5)->toDateString(), 'created_at' => now(), 'updated_at' => now(), ]); DB::table('payments')->insert([ 'parent_id' => 1, 'invoice_id' => 1, 'total_amount' => 100, 'paid_amount' => 20, 'balance' => 80, 'number_of_installments' => 1, 'payment_method' => 'cash', 'payment_date' => now()->toDateString(), 'status' => 'completed', 'created_at' => now(), 'updated_at' => now(), ]); $service = new FamilyFinanceService(); $result = $service->loadFinancialsForParents([1]); $this->assertSame(1, $result['summary']['invoices_count']); $this->assertSame(100.0, $result['summary']['total_amount']); $this->assertNotEmpty($result['invoices']); $this->assertNotEmpty($result['payments']); } }