Ninjakreborn Posted May 1, 2007 Share Posted May 1, 2007 Ok, I have a billing system I created, and it has a lot of information in it. It's a pretty large system. I have to create a maintenance page, that will be ran manually for now but will eventually be setup to a cron job to run automatically, like everything day, or every 15 minutes or something. I have 2 things I need to accomplish with this, and I was doing some Pre-planning to try to make sure everything was going to run smoothly. Ok, well basically I need to pull out all the user information, check to see what billing date they have, when it comes 15 days after the billing date and if they haven't paid it charges a 10.00 late fee. At the end of each billing cycle they are also billed 19.95, and it resets the next billing cycle to the next month. All of that is very simple. Another thing I needed to do was check the list of billers and see if the user requested a "reminder" and if they did, from there I could send out a monthly reminder (easy as well). After thinking about both of these problems I was trying to come up with a decent structure for my maintenance page, and it's fairly straight forward (haven't started on it yet, I am just planning right now). The current problem I keep going over is, I can do everything I mentioned. however now when I think about the different problems that can encounter, if someone re-runs the script on the same day, or within the same month for that matter then a few bad things will happen. 1. It will double up the late fee. 2. It will send double monthly reminders. Those are just 2 bad things I know will happen before I even create the script, does anyone have any advice on how I can keep that from happening. Quote Link to comment https://forums.phpfreaks.com/topic/49458-solved-maths-preventing-double-ups/ Share on other sites More sharing options...
AndyB Posted May 1, 2007 Share Posted May 1, 2007 track and store last_billed_date - if that's older than a month (or whatever the recurrence period is) send a bill and update last_billed_date Quote Link to comment https://forums.phpfreaks.com/topic/49458-solved-maths-preventing-double-ups/#findComment-242401 Share on other sites More sharing options...
Ninjakreborn Posted May 1, 2007 Author Share Posted May 1, 2007 Hmm that gave me an idea, but I already have lastbillingcycle nextbillingcycle. I have to keep tracking those. However I could have a last modified date on both, and record in the system when last the system was modified, and use that to decide when the last maintenance check was ran, and then use that to base my calculations on, how does that sound. Quote Link to comment https://forums.phpfreaks.com/topic/49458-solved-maths-preventing-double-ups/#findComment-242426 Share on other sites More sharing options...
AndyB Posted May 1, 2007 Share Posted May 1, 2007 ... how does that sound. Much the same as the solution I offered, albeit with a different variable name. Quote Link to comment https://forums.phpfreaks.com/topic/49458-solved-maths-preventing-double-ups/#findComment-242434 Share on other sites More sharing options...
Ninjakreborn Posted May 1, 2007 Author Share Posted May 1, 2007 No, I also meant I have that already taken into account. In the database I have to have the last billed date, and next billing date so I can show them to the client throughout the system. Maybe I didn't fully understand what you meant, because I thought through calculations that I could perform with last billed/next billing date but I couldn't think of anything. That's why I took the same idea you presented but with a different date (add a third date in there to tell me when the system check was last ran. Either way based on your advice, I have now something I can wrap my head around, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/49458-solved-maths-preventing-double-ups/#findComment-242437 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.