Difference between revisions of "Freeside:1.7:Documentation:Developer:Price Plans"

From Freeside
Jump to: navigation, search
 
(reverting spam)
 
(17 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Pricing Plans ==
 
Adding Pricing Plans is pretty easy, but has the potential to cause a lot of pain for other users.  PLEASE use your new pricing plan in production on YOUR installation for a period of time before contributing back.
 
 
 
The part_pkg class links the packages to the database.  The plan field indicates which pricing plan to use.  The pricing plans are are found in FS/FS/part_pkg/.  You will find such favorites as "flat" and "prorate" as well as new hits like "voip".  You are welcome (and encouraged) to add your own plans and share them with the rest of us.  Here's how to do it (I'm assuming that you have access to the code so that you can follow along):
 
The part_pkg class links the packages to the database.  The plan field indicates which pricing plan to use.  The pricing plans are are found in FS/FS/part_pkg/.  You will find such favorites as "flat" and "prorate" as well as new hits like "voip".  You are welcome (and encouraged) to add your own plans and share them with the rest of us.  Here's how to do it (I'm assuming that you have access to the code so that you can follow along):
  
Line 14: Line 11:
 
#* is_prepaid - If you're building a prepaid plan, this has to be 1
 
#* is_prepaid - If you're building a prepaid plan, this has to be 1
  
Once you've updated these methods, go ahead and create an account and take it for a spin.  Remember, if you're changing an existing plan, then PLEASE run it in your production environment before contributing back. Good Luck!
+
Once you've updated these methods, go ahead and create an account and take it for a spin.  Please consider contributing your price plan back to the project! Good Luck!
 
 
== Services ==
 

Latest revision as of 16:19, 25 July 2009

The part_pkg class links the packages to the database. The plan field indicates which pricing plan to use. The pricing plans are are found in FS/FS/part_pkg/. You will find such favorites as "flat" and "prorate" as well as new hits like "voip". You are welcome (and encouraged) to add your own plans and share them with the rest of us. Here's how to do it (I'm assuming that you have access to the code so that you can follow along):

  1. Find a package that is close to what you want to do. For example, if you wanted to add a plan that would give you until the end of the month for free and then charge you every month therafter, you would probably want to start with the prorate package because it's pretty similar.
  2. Make a copy of the old package under a new name. In this example you may want to call it free_rest_of_month.pm
  3. Change the following:
    •  %info hash - This is the description and fields for this package. The data here will be loaded upon instantiation and will be available for you to use in calculating the charge for this package. You should set the fieldorder and any defaults as appropriate.
    • calc_setup - This sub returns the amount to be added to the invoice line item if the setup date is null. you can do some magic here, but be VERY careful. The flat_delayed module does some of this magic. You won't have to add this one for our example.
    • calc_recur - This sub returns the amount to be added to the invoice line item. For examples of interesting recurs check out the voip packages. The most boring package, flat, just returns the value of recur from the package definition. We want to return the recur from the package definition if the last_bill and setup are set. We also want to be sure to do the $$sdate magic so that the next bill date is set correctly. We don't return anything if this is the first bill.
    • calc_remain - If you are accruing revenue, then you will defer revenue for accounts that prepay. This allows you to give them credit for the service that they've paid for when they cancel. This method calculates it for you. Be careful here because this is essentially giving back money.
    • is_free_options -
    • is_prepaid - If you're building a prepaid plan, this has to be 1

Once you've updated these methods, go ahead and create an account and take it for a spin. Please consider contributing your price plan back to the project! Good Luck!