Jbaltazar67 Posted February 4, 2022 Report Posted February 4, 2022 I need to clear my head about the listener file . After creating the expenses do I have to create them again in the admin panel of Phpvms? I have tested without adding them but for example no hard landing charged to the driver, if someone could If someone could put me on the right track before transmitting to the web master of our VA thank you very much Quote
DisposableHero Posted February 4, 2022 Report Posted February 4, 2022 Nope, if the listener is coded properly it will work. No need to add it to expenses or somewhere else. They are being checked when a pirep's finances are calculated (when it gets accepted and/or when you click recalculate finances button). What I can think of now is; 1. Either the code of the custom expense you developed is wrong (thus being skipped by the core) 2. Or it is fine but the conditions you defined in it is not met, so it is not being applied Hope this info helps Quote
Jbaltazar67 Posted February 6, 2022 Author Report Posted February 6, 2022 Thanks DiposableHero , But nothing works for the moment, not easy when you are a beginner , what I did and I don't see any error, I publish here an example of what I want to put in place : class ExpenseListener extends Listener { public function handle(Expenses $event) { $expenses = []; $amount = 5000; if (abs($event->pirep->landing_rate) < 500) { return $expenses; } $expenses[] = new Expense([ 'type' => ExpenseType::FLIGHT, 'amount' => 5000, 'transaction_group' => 'Hard Landing', 'name' => 'Hard Landing Fee For Pirep='.$event->pirep->id, 'multiplier' => false, 'charge_to_user' => true, ]); return $expenses; } } Thank you Quote
DisposableHero Posted February 6, 2022 Report Posted February 6, 2022 What is the filename ? I think I explained it somewhere before, the filename and the class name should match and this is important Also you should not be using the same class name twice or more, it may cause problems (like it being skipped or worse, erroring out all process and stopping) Filename : HardLanding.php Class Definition : class HardLanding extends Listener class HardLanding extends Listener { public function handle(Expenses $event) { $expenses = []; $amount = 5000; if (abs($event->pirep->landing_rate) < 500) { return $expenses; } $expenses[] = new Expense([ 'type' => ExpenseType::FLIGHT, 'amount' => $amount, 'transaction_group' => 'Hard Landing', 'name' => 'Hard Landing Fee For Pirep='.$event->pirep->id, 'multiplier' => false, 'charge_to_user' => true ]); return $expenses; } } Rest looks ok though. Quote
DisposableHero Posted February 6, 2022 Report Posted February 6, 2022 Also you can check your laravel log, to see if any errors are being recorded during pirep being sent and gets accepted (at this moment expenses will be considered/calculated by the finance code). There we may find valuable clues about this. Good luck Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.