<?php

namespace App\Http\Controllers;

use App\Models\PaymentMethod;
use App\Models\Account;
use Illuminate\Http\Request;

class TransactionController extends Controller
{
    // Helper method to get the appropriate account for payment method
    private function getAccountForPaymentMethod($paymentMethodId)
    {
        $paymentMethod = PaymentMethod::find($paymentMethodId);
        
        // Map payment methods to accounts (you'll need to configure this mapping)
        $methodAccountMap = [
            'Cash' => '1100', // Cash account code
            'Bank Transfer' => '1110', // Bank account code
            'Credit Card' => '1120', // Credit card account code
            // Add more mappings as needed
        ];
        
        $accountCode = $methodAccountMap[$paymentMethod->name] ?? '1100'; // Default to cash
        
        return Account::where('code', $accountCode)->first()->id;
    }
} 