Jump to content

[SOLVED] Maths, preventing double ups


Ninjakreborn

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.