[freeside-devel] Pricing Plan Question

Tim Yardley tyardley at pavlovmedia.com
Thu Jun 29 09:29:15 PDT 2006


Ivan;

I've written a pricing plan for some custom dynamic pricing per package,
but there are a few things that I am not quite sure how they are used.
I have checked out the wiki but it doesn't quite answer the question and
I haven't found a better source for documentation other than the source:
http://www.sisd.com/mediawiki/index.php/Freeside:1.5.8:Documentation:Dev
eloper

Anyway, the questions I have are as follows:
1 - What is the is_free_options actually used for?  I don't see it being
utilized anywhere apparent nor does it seem to have an affect on what
happens in my case.
2 - The $$sdate code in calc_recur in some of the pricing plans... Is it
actually necessary?  There is a note about it in the wiki, but no real
explanation.  Does the fact that I am basing this off sql_external
(which uses FS::part_pkg::flat) mean that I don't have to handle that
part on my own?

Here is what my calc_recur looks like at the moment:
sub calc_recur {
    my($self, $cust_pkg) = @_;

    my $dbh = DBI->connect( map { $self->option($_) }
                            qw( datasrc db_username db_password )
                          ) or die $DBI::errstr;

    my $sth = $dbh->prepare( $self->option('query') ) or die
$dbh->errstr;

    my $agent_sth = $dbh->prepare('SELECT agentnum FROM cust_main WHERE
custnum = ?') or die $dbh->errstr;

    my $custnum = $cust_pkg->custnum;
    my $pkgpart = $cust_pkg->pkgpart;
    $agent_sth->execute($custnum) or die $agent_sth->errstr;

    my $agent = $agent_sth->fetchrow_arrayref->[0];
    $sth->execute($agent, $pkgpart, $custnum) or die $sth->errstr;
    my $price = $sth->fetchrow_arrayref->[1];

    $self->logit("RECUR -- agentnum: " . $agent) if $DEBUG;
    $self->logit("RECUR -- pkgpart: " . $pkgpart) if $DEBUG;
    $self->logit("RECUR -- custnum: " . $custnum) if $DEBUG;
    $self->logit("RECUR -- price: " . $price) if $DEBUG;

    $self->option('recur_flat') + $price;
}

Any problems with that that I may be overlooking?  It seems to work fine
and seems to set the next_bill date correctly.

Thanks.

/tmy

----

Tim Yardley
Vice President of Research and Development
Pavlov Media, Inc.
(217) 353-3005

----

This email and any files transmitted with it are confidential and
proprietary. It is intended solely for the use of the individual or
entity to whom they are addressed. All information is the view of the
individual and not necessarily the company. If you are not the intended
recipient, you are hereby notified that any dissemination, distribution,
or copying of this communication and its attachments is strictly
prohibited. If you have received this email in error please notify
tyardley at pavlovmedia.com. This email has been swept for computer
viruses. 


More information about the freeside-devel mailing list