Administrators ProAvia Posted December 29, 2016 Administrators Report Share Posted December 29, 2016 (edited) I could swear I've seen this somewhere, but can't find it now. And was unable to find ANY reference using Search. Can the flight time separator be changed from ' . ' to ' : '? And where is this setting? My present 2.x site uses the period ( . ) and I'd like to change to the colon ( : ) on my 5.5.2 site. With a 5.5.2 site, does it matter which separator is used? Is there an advantage to using one over the other? TIA! Edited February 14, 2017 by ProAvia Quote Link to comment Share on other sites More sharing options...
web541 Posted December 29, 2016 Report Share Posted December 29, 2016 It can be changed, you'd have to change some files though, it would just be easier to do a str_replace() to the .where you want it changed. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted December 29, 2016 Author Administrators Report Share Posted December 29, 2016 It's not that I necessarily want it changed - but on my 5.5.2 test site, I processed a test Pirep and noticed the flight time addition was odd. The pilot had 3348.38 total hours - 3348 hours 38 minutes. His Pirep added 2.22 - 2 hours 22 minutes. The result should have been 3351.00 - 3351 hours 00 minutes. Instead the result was 3350.6 - 3350 hours 60 minutes. While I know that 3350 hours 60 minutes is actually 3351 hours 00 minutes, it might be confusing to my pilots. I'll do some more testing to see if the times add up correctly. Maybe there's an issue with 60 minutes not converting over to 1 hour - possibly it happens at 61 minutes? I thought there was a reference - maybe during install - to choose between a period or colon for the separator. Quote Link to comment Share on other sites More sharing options...
web541 Posted December 29, 2016 Report Share Posted December 29, 2016 Alright, in that case https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/PIREPData.class.php#L704 That should be what you are looking for. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted December 29, 2016 Author Administrators Report Share Posted December 29, 2016 Thanks! Mine is set the exact same as that. Lines 704-705 (proper timestamp section) and 825-826 (Update a specific PIREP section) match those of that file. As a matter of fact, my PIREPData.class.php file matches the one linked above exactly. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 22, 2017 Author Administrators Report Share Posted January 22, 2017 Now I'm noticing the pilot pay per hour computation for the flight time is messed up. Pilot pay / hour - $60 Flight time - 2.17 (flighttime) 2:17:00 (flighttime_stamp) Total pay for this flight - $130.20 So in the above example, the pilot makes $1 for every minute ($60/hour) - TIMES - 137 minutes (2 hours 17 minutes) - EQUALS - $137.00 (should be). The $130.20 paid is based on 2.17 hours(approx. 2 hours 10 minutes - 2 and 17/100 hours), not 2:17 hours (2 hours 17 minutes - 2 and 17/60 hours). While this example doesn't show a big discrepancy in dollar value, it's still an error. I don't know where to look to try to fix it. I believe the issue is the number after the decimal is being divided by 100 instead of 60. In my example above - 17/100 instead of 17/60. I am not sure if this same issue (x/100 versus x/60) is affecting the flight time calculation between kACARS and phpVMS - I don't presently have enough conclusive data, as the kACARS log totals usually equal - but not always - the flight time shown in the 'pireps' table. It's not that I mind virtually paying the pilots a little less, but I know one of them will eventually catch this. LOL - Hopefully there's an easy fix.... or at least it can be incorporated into version 3. Any and all help is appreciated! Quote Link to comment Share on other sites More sharing options...
web541 Posted January 22, 2017 Report Share Posted January 22, 2017 (edited) Just to confirm that your Pilot Pay / Hour is $60 for the rank that you are on and that the schedule doesn't have anything in the the "payforflight" field of the database. Also, in the above example, the algorithm is correct. Pilot Pay / hour X num hours = payforflight $60 X 2.17 = $130.20 If the issue was that the pilot was given the pay for their payrate (e.g. $30 for pay / hour on rank then $30 every pirep), then I posted a fix in the spoiler here but it seems it is not your issue. (just putting it out there in case you come across this later, feel free to take a look anyway). If you are looking for the pay conversion point (there are many), the main one is here But on a closer look at the algorithm, it is mostly correct -> Just as an example // This would usually be dynamic $pirep->flighttime_stamp = "02:00:00"; $pirep->pilotpay = "18"; // Sets it to the payrate as phpvms does, will have to override later $peices = explode(':', $pirep->flighttime_stamp); // Take the flighttime_stamp and make it like this 020000 $minutes = ($peices[0] * 60) + $peices[1]; // should equal 120mins $amount = $minutes * ($pirep->pilotpay / 60); // Do the conversion echo $amount; // should equal $36 You can try that on your machine as a test and it should equal $36. This is a whole number though, so when you go into decimal values, it gets a bit trickier. // This would usually be dynamic $pirep->flighttime_stamp = "02:00:00"; $pirep->pilotpay = "18"; // Sets it to the payrate as phpvms does, will have to override later // Do the conversion $peices = explode(':', $pirep->flighttime_stamp); // 021700 $minutes = ($peices[0] * 60) + $peices[1]; // 137mins /* Pretty sure this is the cause */ $amount = $minutes * ($pirep->pilotpay / 60); // 0.3 /* The above is basically 137 X (18 / 60) = 0.3 */ echo $amount; // $41.1 Not sure if this is exactly what your after or if it was any help at all, but it does shed some light on what's going on. I believe this is going to be easier in v3 (calculating pay in one place, not four perhaps). And after reading your above post, yes the conversion it's doing takes the flighttime_stamp value not the flighttime (decimal) value. Edited January 22, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 23, 2017 Author Administrators Report Share Posted January 23, 2017 (edited) Quote Just to confirm that your Pilot Pay / Hour is $60 for the rank that you are on and that the schedule doesn't have anything in the the "payforflight" field of the database. Yes, $60/hour - nothing in "payforflight" field Quote Also, in the above example, the algorithm is correct. The multiplication is correct - if I were looking for hours and tenths. But I am looking for hours and minutes. $60 x 2.17=$130.20 - and - $60x2:17=$137.00 Quote If you are looking for the pay conversion point (there are many), the main one is here Thanks, I will review that. My issue is with the minutes conversion. I will have to compare my files with those on GitHub to be sure I didn't muck mine up in some way. In the 'ledger' table the pay amount is correct. I wonder where the incorrect amount in my example above is being pulled from? Hmm, more research needed. A few questions if I may - so I can understand this a bit better..... I numbered the lines to hopefully make it easier 1 - // This would usually be dynamic 2 - $pirep->flighttime_stamp = "02:00:00"; 3 - $pirep->pilotpay = "18"; // Sets it to the payrate as phpvms does, will have to override later 4 - // Do the conversion 5 - $peices = explode(':', $pirep->flighttime_stamp); // 021700 6 - $minutes = ($peices[0] * 60) + $peices[1]; // 137mins 7 - /* Pretty sure this is the cause */ 8 - $amount = $minutes * ($pirep->pilotpay / 60); // 0.3 9 - /* The above is basically 137 X (18 / 60) = 0.3 */ 10 - echo $amount; // $41.1 Line 5 - converts the flighttime_stamp from 02:17:00 to 021700 in the example? Line 6 - converts to minutes - $peices[0] = 02 (hours), $peices[1] = 17 (minutes) and the seconds are disgarded? Line 8 - takes the minutes from line 6 and multiplies by (pilotpay/60) - so minutes times pay/minute? Line 10 - shows total pay for 2:17 flight at $18/hour? Since the ledger table amounts are correct - at least since I converted to 5.5.2, I have to believe them. I need to find where the dollar amount I am seeing is being drawn from. Here's to hoping version 3 only has one pay conversion point! Thanks! EDIT: Added file attachment showing discrepancy. Pilot Pay Discrepancy.txt Edited January 23, 2017 by ProAvia Add attachment Quote Link to comment Share on other sites More sharing options...
web541 Posted January 23, 2017 Report Share Posted January 23, 2017 (edited) Ah ok, so I think by the txt file your pay is being calculated by the decimal (flighttime field) value instead of the flighttime_stamp value? Then instead of taking the tenths value / 60 it takes it / 100? If so, there's a missing link somewhere during the conversion (but it seems to be calculating for me) And your right, I hope v3 changes the calculation points, right now it goes from PIREP Filing => Controller => PIREPData File => another function to calculate it => ledger => calculate it again => PilotData file to reset it just about. I believe this is being worked on though. In regards to your "lines", line 5: affirm, by getting rid (exploding) the : in the flighttime string line 6: also correct, and it does this because when the PIREP is filed from the ACARS Client, I believe it only reports the rounded value of it's calculated flighttime thus discarding the 00:00:sec value. line 8: Mostly correct, though it's actually minutes (from line 6) * (pilotpay / 60) where pilotpay is the payrate per hour based on the pilot (who filed the PIREP)'s rank. line 10: Correct, 2hr 17min flight with $18 per hour which from the above algorith [137 * (18 / 60) = $41.1] Just confirm the above is what you are getting so we can track down your issue. Calculation Steps From ACARS... PIREPData.class.php FileReport PIREPData.class.php PopulatePIREPFinance PIREPData.class.php GetPIREPRevenue This could be your problem as a quick glance shows it calculating the pilotpay based on the decimal value (flighttime field in DB), not sure if it gets parsed though so have to look a bit more later. EDIT: nevermind, only used to calculate Revenue. Sets the pilotpay field in the DB to the pilot's payrate (without my potential fix in a previous post) to potentially recalculate it later This is called when a flight report is updated or it has changed status (accepted, rejected, etc.) PIREPData.class.php CalculatePIREPPayment This calculates it using the algorithm above which seems to be correct and it is only now when the Ledger DB Values are added which you said were correct, so theoretically the pay should be fine up until now. (we can dump the values later if we have to) This function is then called PilotData.class.php resetPilotpay which also should be fine as it just adds up the values from the ledger table and resets the total pilot pay for every pirep the pilot has filed. Seems like a round circle, might have to start dumping data (var_dump or print_r) in various places to see what values are being processed. Edited January 23, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 23, 2017 Author Administrators Report Share Posted January 23, 2017 (edited) Thanks for the affirmation on the "lines". Yeah, I over-simplified line 8, but the end result is the same. The text file is just to list what shows in the tables. The ledger table shows the correct pilot payment. The pirep table only shows pilotpay rate, not amount of pilotpay for that flight. However, given your 2., 1. PIREPData.class.php GetPIREPRevenue, it seems that net revenue is not calculated correctly - or maybe just not displayed correctly. And that's how I am determining the supposed 'error' - subtracting fuel cost, expenses and net revenue from gross revenue to see what the pilot pay is. Then comparing that number to what's reported in the ledger. That's where I'm seeing the difference. In version 2.1.936, I don't recall a ledger table - but need to look closer when I get home later. If it's true there was no ledger table, where was that data located? I don't care if the finances are incorrect prior to moving to 5.5.2. But moving forward, I'd like them to be correct. Additionally, after moving to 5.5.2, I noticed that 'Financial Reports' in admin shows 0.00 Pilot Pay for all months prior to conversion month. And a large negative number for pilot pay in the conversion to 5.5.2 month. I'm guessing the large negative number is accounting for all pilot pay prior to the conversion to 5.5.2. I'll look at the PIREPData.class.php file in detail later today also. Thanks! Edited January 23, 2017 by ProAvia Quote Link to comment Share on other sites More sharing options...
web541 Posted January 23, 2017 Report Share Posted January 23, 2017 Yeah, the revenue may not be calculated correctly, but this shouldn't have anything to do with the pay as only the revenue data is returned in that function. And yes, also correct as before phpVMS 5.5.x, there was no Ledger table, so all pilot pay was calculated internally. The calculation points are also a bit simpler in the earlier version as most of it is done in the PilotData.class.php file and what's interesting is the algorithm is slightly different as in phpVMS 5.5.x, the flighttime_stamp is used, rather in the earlier, the flighttime value (with the decimal) is used. In addition, the pay is being calculated the same, just using the pilotpay (payrate) and flighttime of the PIREPS table instead of reading it from a Ledger Table. https://github.com/nabeelio/phpVMS/blob/master/core/common/PilotData.class.php#L680 https://github.com/nabeelio/phpVMS/blob/master/core/common/PilotData.class.php#L717 https://github.com/nabeelio/phpVMS/blob/master/core/common/PilotData.class.php#L749 And that large negative number is yes, probably accounting for the pay prior to the conversion, you could fix this or ignore it for later, but if you want to dump some data in a few places, we can get an idea of which data is correct and where it is being incorrectly parsed. I'll go and get these places for you. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 23, 2017 Author Administrators Report Share Posted January 23, 2017 Your 3 links for PilotData.class.php are for version 2.1.x showing the pilot pay calculations? As for PIREPData.class.php, for getPILOTRevenue, lines 841, 1009 and 1038. 841 - Update a specific PIREP, recalculate finances - references '$pirepinfo->paytype' and looks to be using '$flighttime_stamp' 1009 - Populate PIREP with financial info, Set the pilotpay here - references '$payment_type' as in pay per schedule or per hour. But right above this line references 'flighttime' 1038 - Calculate gross revenue of PIREP - references '$payment_type = PILOT_PAY_HOURLY'. But again references 'flighttime' three lines later. This section returns '$revenue', as in net revenue. Lines 1249-1290 looks to actually calculate the pilot payment, uses 'flighttime_stamp', and enters that into the ledger table. Lines 1009 and 1038 might be where my issue originates. For now, I'm going to ignore the large negative number and assume the version 2.1.x calculations were correct. But am willing to look at it at a later time. Thanks! Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 (edited) Yes, those links are the conversion points in phpvms 2.x.x (the original) But I think you might be getting a little sidetracked here. The lines you mentioned actually refer to the revenue that is being returned, and then inserts that into the revenue field in the DB which shouldn't have anything to do with the pilot pay (though it is being used to calculate it) and the values with . and : shouldn't make a difference as it is being treated the same way. Please confirm the following The issue is with the pilot pay being calculated more than expected Does this occur with just the one rank or several (with different payrates, not just $60) With your discrepancy of $6.40, the algorithm is Supposedly doing this payrate * flighttime = dollars $60 * 2.17 = $130.20 When it should be doing this payrate * total_flight_minutes = dollars $60 / 60 * 137 = $137 $1 per minute in this case. In your Ledger Table, are your amount values correct? Once you confirm all of those, can I get you to try putting the attached file into a module (e.g. core/module/PayChecker/place this file here) and then open it up and edit the top pilotid and pirepid values Once you confirm all of those, can I get you to do the following Put the attached file into a module (e.g. core/module/PayChecker/place this file here) File a PIREP (any will do) and take note of the PIREP ID in the database or just use one which you've already filed Open up the PayChecker.php file and edit the top two values pilotid and pirepid respectively. In your url, go to http://yourvaurl.com/index.php/PayChecker and hit go Check the outcomes and report back That should allow us to have a look and confirm the values you are seeing. Edited January 25, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 55 minutes ago, web541 said: Please confirm the following The issue is with the pilot pay being calculated more than expected Does this occur with just the one rank or several (with different payrates, not just $60) With your discrepancy of $6.40, the algorithm is Supposedly doing this payrate * flighttime = dollars $60 * 2.17 = $130.20 When it should be doing this payrate * total_flight_minutes = dollars $60 / 60 * 137 = $137 $1 per minute in this case. In your Ledger Table, are your amount values correct? Not necessarily MORE than expected. And it may not affect actual credited pay to the pilot. All ranks with differing payrates. I used the rank @ $60/hour to make the math easier. ... Yes - but may only be using this in revenue computation Yes - this amount is shown in ledger table Yes - as per 3.2 above - $137 PayChecker.php results PIREPData => CalculatePIREPPayment 137 PilotData => resetPilotPay 10642.50 New Algorithm Using Decimal Form 137 New Algorithm Using Flight Stamp Form 137 What you are getting now (I think) 130.2 Here's what I think is happening: Net revenue is being determined using flighttime method of pilotpay. Net revenue = revenue in the pireps table. Now: gross - fuelprice - expenses - pilotpay(flighttime) = revenue Should be: gross - fuelprice - expenses - pilotpay(flighttime_stamp) = revenue Pilot pay for given PIREP is being determined using flighttime_stamp method of pilotpay. This is what shows correctly in the ledger table. This all started when I added the following to pilot_viewreport.php to display via 'pireps/viewreport'. And I can see now that I am calling Pilot Pay incorrectly. But, this lead to finding that Net Revenue is being computed incorrectly. <table class="balancesheet" cellpadding="0" cellspacing="0" width="100%"> <tr class="balancesheet_header"> <td align="" colspan="2">Flight Details</td> </tr> <tr> <td align="right">Gross Revenue: <br /> (<?php echo $pirep->load;?> load / <?php echo FinanceData::FormatMoney($pirep->price);?> per unit)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->load * $pirep->price);?></td> </tr> <tr> <td align="right">Fuel Cost: <br /> (<?php echo $pirep->fuelused;?> lbs fuel used @ <?php echo $pirep->fuelunitcost?> / lb)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->fuelused * $pirep->fuelunitcost);?></td> </tr> <tr> <td align="right">Pilot Pay: <br /> (per hour based on rank)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->pilotpay * $pirep->flighttime);?></td> </tr> <tr> <td align="right">Net Revenue: <br /> (after <u>all</u> expenses)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->revenue);?></td> </tr> </table> So, it appears that revenue is not correct as it's computed using flighttime instead of flighttime_stamp. And if that's the case, I guess pilotpay is correct. If this is what is occurring, is there an easy fix for the revenue computation? At this point, I don't really care if it will be retroactive - but moving forward, I'd like it to be correct. Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 9 minutes ago, ProAvia said: Not necessarily MORE than expected. And it may not affect actual credited pay to the pilot. All ranks with differing payrates. I used the rank @ $60/hour to make the math easier. ... Yes - but may only be using this in revenue computation Yes - this amount is shown in ledger table Yes - as per 3.2 above - $137 PayChecker.php results PIREPData => CalculatePIREPPayment 137 PilotData => resetPilotPay 10642.50 New Algorithm Using Decimal Form 137 New Algorithm Using Flight Stamp Form 137 What you are getting now (I think) 130.2 Here's what I think is happening: Net revenue is being determined using flighttime method of pilotpay. Net revenue = revenue in the pireps table. Now: gross - fuelprice - expenses - pilotpay(flighttime) = revenue Should be: gross - fuelprice - expenses - pilotpay(flighttime_stamp) = revenue Pilot pay for given PIREP is being determined using flighttime_stamp method of pilotpay. This is what shows correctly in the ledger table. This all started when I added the following to pilot_viewreport.php to display via 'pireps/viewreport'. And I can see now that I am calling Pilot Pay incorrectly. But, this lead to finding that Net Revenue is being computed incorrectly. <table class="balancesheet" cellpadding="0" cellspacing="0" width="100%"> <tr class="balancesheet_header"> <td align="" colspan="2">Flight Details</td> </tr> <tr> <td align="right">Gross Revenue: <br /> (<?php echo $pirep->load;?> load / <?php echo FinanceData::FormatMoney($pirep->price);?> per unit)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->load * $pirep->price);?></td> </tr> <tr> <td align="right">Fuel Cost: <br /> (<?php echo $pirep->fuelused;?> lbs fuel used @ <?php echo $pirep->fuelunitcost?> / lb)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->fuelused * $pirep->fuelunitcost);?></td> </tr> <tr> <td align="right">Pilot Pay: <br /> (per hour based on rank)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->pilotpay * $pirep->flighttime);?></td> </tr> <tr> <td align="right">Net Revenue: <br /> (after <u>all</u> expenses)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->revenue);?></td> </tr> </table> So, it appears that revenue is not correct as it's computed using flighttime instead of flighttime_stamp. And if that's the case, I guess pilotpay is correct. If this is what is occurring, is there an easy fix for the revenue computation? At this point, I don't really care if it will be retroactive - but moving forward, I'd like it to be correct. Ah ok, that clears things up, so I guess it's the revenue that's stuffed up. I'll take a look and see if there's a fix to this revenue issue and I guess the pilot pay will work itself out afterwards, providing that it is correct in the ledger. And just another question, is your revenue column mainly filled with negative number? This might also fix the 0 issue in the admin. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 (edited) I checked random ledger amounts and compared to PIREP. The pilot pay appears correct. The revenue column is all positive - except for a couple random negative entries. Not enough that it should have anything to do with the 0 issue in admin. Here's that report. I converted over in January of this year. Month Flights Revenue Pilot Pay Expenses Fuel Total 2016-10 2 $ 25, 300.00 $ 0.00 $ 0.00 ($ -9, 570.32) $ 15, 729.68 2016-11 8 $ 164, 100.00 $ 0.00 $ 0.00 ($ -40, 284.56) $ 123, 815.44 2016-12 3 $ 75, 300.00 $ 0.00 $ 0.00 ($ -20, 744.08) $ 54, 555.92 2017-01 19 $ 346, 750.00 ($ -123, 709.70) $ 0.00 ($ -125, 454.56) $ 97, 585.74 Total: $ 291, 686.78 My guess is that the addition of the ledger table caused this. There's probably not a method to compute the data correctly for prior to conversion. That's why the 0 entries and negative hit on conversion. It should all balance out in the end though. Edited January 24, 2017 by ProAvia Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 I just checked, for all months prior to January 2017, Pilot Pay column shows $0.00. This is from when we switched over to phpVMS in May of 2014 through December 2016. Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 (edited) Ok thanks, you should be able to reset it, but I'd do it after as it may recalculate revenue as well which might screw it up further. With this, I just took a look and it seems that it is just multiplying the pilotpay in the pirep (which is the payrate set by phpvms) by the flight time, so I should be able to fix this for you pretty easily with the scripts from the PayChecker confirming your results, just as you thought earlier. Edited January 24, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 (edited) I just had a thought, maybe the revenue is being counted like that on purpose? Anyway, if you want to calculate the pilotpay (to affect the revenue) based on pilot's payrate and correct flighttime (number of minutes instead of the flighttime itself as a decimal form / 100), then here is the fix. Go to PIREPData.class.php line 1042 and between the if statement (the one with if($payment_type == PILOT_PAY_HOURLY) {) on it replace it's content with this $pilot = PilotData::getPilotData($data['pilotid']); # Get the pilot info for payrate in case pay field is changed later $flighttime = explode('.', $data['flighttime']); # split the flighttime into two parts $flighttime_min = ($flighttime[0] * 60) + ($flighttime[1]); # Calculate no. minutes $pilotpay = ($pilot->payrate / 60) * $flighttime_min; # Finalise the payment // This was the original // Only multiplies payrate (pay field) by the flight time without taking into account the minutes / 60 but min. / 100 # $pilotpay = $data['pilotpay'] * $data['flighttime']; And you should be able to see the calculation affect the revenue with the correct amount as per the ledger table. Once you check this, report back with your results and if they're correct, I'll amend the PayChecker script with a reset revenue function which will allow you to reset all revenue and recalculate it using the new method, without fully resetting the pilot pay itself (unless you want it to do this). Edited January 24, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 (edited) 22 minutes ago, web541 said: I just had a thought, maybe the revenue is being counted like that on purpose? Quite possibly - or it just slipped through the cracks over the years. Maybe it's to adjust for the big virtual bucks the management gets paid. Quote And you should be able to see the calculation affect the revenue with the correct amount as per the ledger table. Will this update the revenue column in pireps for previous entries too? Hmm, I'll back up the DB before I attempt. Will have to wait until tomorrow though. Thanks for all your time and effort with this. I really do appreciate it! Hard to believe I started this thread asking about the flight time separator (period vs colon) and morphed to pilotpay only to find that's correct and the revenue was off. I do have two more questions, if I may - While I NOW know that the way I tried calling Pilot Pay below is incorrect, how do I call it? I tried substituting flighttime_stamp for flighttime, but that gave me pilotpay based on the hour and dropped the minutes. So 02:37 was computed as 2 hours. Is there a way for pilots and admins to see how much a pilot has been paid for a PIREP and a total pay somewhere? I'd like to provide a table with that data for pilots/admins to review. <tr> <td align="right">Pilot Pay: <br /> (per hour based on rank)<br /> <td align="right" valign="top"><?php echo FinanceData::FormatMoney($pirep->pilotpay * $pirep->flighttime);?></td> </tr> Thanks!! Edited January 24, 2017 by ProAvia 1 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 (edited) Thinking about that again, I think it just slipped through the cracks. In the example I gave the data for the flight was: Gross Revenue: (187 load / $ 180.00 per unit) $ 33, 660.00 Fuel Cost: (16367 lbs fuel used @ 0.68 / lb) $ 11, 129.56 Net Revenue: (after all expenses) $ 22, 400.20 Which leave $130.24 - of which pilotpay(flighttime) was $130.20. I'll assume the 4 cents was for rounding somewhere. But the pilotpay(flighttime_stamp) was $137.00. So the revenue as reported is a higher dollar value that the actual ending dollar value giving pilotpay @ $137.00 Jeez - I'm really glad I didn't go into accounting! Edited January 24, 2017 by ProAvia Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 Nope, it won't affect your previous entries, but I will amend my PayChecker script to change this data for you (and possibly recalculate the pilot's pay), but please back up your DB first. Now for your questions The way it is calculated is different (I assume this info will be placed on the view pirep page), use something like this <tr> <td align="right">Pilot Pay: <br /> (per hour based on rank)<br /> <td align="right" valign="top"> <?php echo FinanceData::FormatMoney($pirep->pilotpay * $pirep->flighttime);?> <?php $flighttime = explode('.', $pirep->flighttime); $totalminutes = ($flighttime[0] * 60) + ($flighttime[1]); $pilot = PilotData::getPilotData($pirep->pilotid); // In case the pilotpay value changes in the future $totalpay = ($pilot->payrate / 60) * $totalminutes; return FinanceData::formatMoney($totalpay); ?> </td> </tr> You should be able to view this in edit pirep (admin), but I'll make a table for you to show this, do you want it per pilot or per pirep? Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 13 minutes ago, ProAvia said: Thinking about that again, I think it just slipped through the cracks. In the example I gave the data for the flight was: Gross Revenue: (187 load / $ 180.00 per unit) $ 33, 660.00 Fuel Cost: (16367 lbs fuel used @ 0.68 / lb) $ 11, 129.56 Net Revenue: (after all expenses) $ 22, 400.20 Which leave $130.24 - of which pilotpay(flighttime) was $130.20. I'll assume the 4 cents was for rounding somewhere. But the pilotpay(flighttime_stamp) was $137.00. So the revenue as reported is a higher dollar value that the actual ending dollar value giving pilotpay @ $137.00 Jeez - I'm really glad I didn't go into accounting! I found out the issue here, if you look closely at your figures here for fuel cost (11,129.56), but in your database (from the txt file provided) the fuel cost is 11129.6 so it rounded it up before entry into the database, this one is probably to do with your acars client rounding it off as it doesn't go through phpvms I don't think. After the revenue change above, the pilot pay will be adjusted, so these figures are before the change above has been implemented (I'm guessing). Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 48 minutes ago, web541 said: Nope, it won't affect your previous entries, but I will amend my PayChecker script to change this data for you (and possibly recalculate the pilot's pay), but please back up your DB first. Now for your questions The way it is calculated is different (I assume this info will be placed on the view pirep page), use something like this <tr> <td align="right">Pilot Pay: <br /> (per hour based on rank)<br /> <td align="right" valign="top"> <?php echo FinanceData::FormatMoney($pirep->pilotpay * $pirep->flighttime);?> <?php $flighttime = explode('.', $pirep->flighttime); $totalminutes = ($flighttime[0] * 60) + ($flighttime[1]); $pilot = PilotData::getPilotData($pirep->pilotid); // In case the pilotpay value changes in the future $totalpay = ($pilot->payrate / 60) * $totalminutes; return FinanceData::formatMoney($totalpay); ?> </td> </tr> You should be able to view this in edit pirep (admin), but I'll make a table for you to show this, do you want it per pilot or per pirep? 1. Yup, on the view pirep page. 2. I was thinking per pilot - showing a a column for date, flight number and pay. I can add more or incorporate into other areas once I know what to call and how to call it. Would this be available for onky the associated pilot to view, as well as admins? Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 (edited) Alright, shouldn't be a problem then. I can make it that the pilot can see their pay for their flight on their view pireps page as well as an admin page for all pilots and their last pirep (as well as a link to view all other pireps as well) Edited January 24, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 24, 2017 Author Administrators Report Share Posted January 24, 2017 39 minutes ago, web541 said: I found out the issue here, if you look closely at your figures here for fuel cost (11,129.56), but in your database (from the txt file provided) the fuel cost is 11129.6 so it rounded it up before entry into the database, this one is probably to do with your acars client rounding it off as it doesn't go through phpvms I don't think. After the revenue change above, the pilot pay will be adjusted, so these figures are before the change above has been implemented (I'm guessing). Right you are! I hadn't gotten around to looking there. I'll have a go at making the changes you provided above - tomorrow. Again, thank you so much for your efforts and time! Quote Link to comment Share on other sites More sharing options...
web541 Posted January 24, 2017 Report Share Posted January 24, 2017 Just now, ProAvia said: Right you are! I hadn't gotten around to looking there. I'll have a go at making the changes you provided above - tomorrow. Again, thank you so much for your efforts and time! No problem, glad to help. Quote Link to comment Share on other sites More sharing options...
web541 Posted January 25, 2017 Report Share Posted January 25, 2017 Ok, I've gone ahead and made the module again (now with extra features) and it should allow you to recalculate all your PIREP's revenue (and Pilot pay if you wish) and allow you to monitor the pay of each PIREP from each pilot. Before you do this, please, please backup your database as I've tested the script multiple times and it seems fine to me, but if it's wrong for you, it might screw up. If you've got a local version of your website handy, I suggest you try this there first before bringing it live. The upside is that it shouldn't delete any data, only update it. Grab the module More details here Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted January 25, 2017 Author Administrators Report Share Posted January 25, 2017 (edited) OK - finally have some uninterrupted time to do this. Between taking the dog to the vet and my grandson being here all day, I've had basically no time. Yes - I will definitely backup the DB. And I will try this on my online test site first (with a separate DB from the live site) also. If I understand correctly, I should: backup the DB, do the replacement in PIREPData.class.php starting at line 1042 see what the results are submit a new PIREP see what the results are again then attempt your last see what happens Edited January 25, 2017 by ProAvia Quote Link to comment Share on other sites More sharing options...
web541 Posted January 25, 2017 Report Share Posted January 25, 2017 Yep, that should do it. Quote Link to comment Share on other sites More sharing options...
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.