X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fsql_external.pm;h=4bf9ecbe72871cd04e53795fea33753701cbea3c;hb=96783bdc58be6e4f2fc56d516a9ceba57af00ba8;hp=8e803f967c5f06d0a507416bcaadab13aaf201af;hpb=86119e342d95f16b799043e9cf66230d015c37de;p=freeside.git diff --git a/FS/FS/part_pkg/sql_external.pm b/FS/FS/part_pkg/sql_external.pm index 8e803f967..4bf9ecbe7 100644 --- a/FS/FS/part_pkg/sql_external.pm +++ b/FS/FS/part_pkg/sql_external.pm @@ -1,7 +1,7 @@ package FS::part_pkg::sql_external; +use base qw( FS::part_pkg::discount_Mixin FS::part_pkg::recur_Common ); use strict; -use base qw( FS::part_pkg::recur_Common ); use vars qw( %info ); use DBI; #use FS::Record qw(qsearch qsearchs); @@ -9,25 +9,12 @@ use DBI; %info = ( 'name' => 'Base charge plus additional fees for external services from a configurable SQL query', 'shortname' => 'External SQL query', + 'inherit_fields' => [ 'prorate_Mixin', 'global_Mixin' ], 'fields' => { - 'setup_fee' => { 'name' => 'Setup fee for this package', - 'default' => 0, - }, - 'recur_fee' => { 'name' => 'Base recurring fee for this package', - 'default' => 0, - }, - 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'. - ' of service at cancellation', - 'type' => 'checkbox', - }, 'cutoff_day' => { 'name' => 'Billing Day (1 - 28) for prorating or '. 'subscription', 'default' => '1', }, - 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. - 'for one full period after that', - 'type' => 'checkbox', - }, 'recur_method' => { 'name' => 'Recurring fee method', #'type' => 'radio', @@ -48,17 +35,24 @@ use DBI; 'default' => '', }, }, - 'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_method cutoff_day - add_full_period datasrc db_username db_password query + 'fieldorder' => [qw( recur_method cutoff_day ), + FS::part_pkg::prorate_Mixin::fieldorder, + qw( datasrc db_username db_password query )], 'weight' => '58', ); +sub price_info { + my $self = shift; + my $str = $self->SUPER::price_info; + $str .= " plus per-service charges" if $str; + $str; +} + sub calc_recur { my $self = shift; - my($cust_pkg) = @_; #, $sdate, $details, $param ) = @_; - - my $price = $self->calc_recur_Common(@_); + my($cust_pkg, $sdate, $details, $param ) = @_; + my $price = 0; my $dbh = DBI->connect( map { $self->option($_) } qw( datasrc db_username db_password ) @@ -76,10 +70,11 @@ sub calc_recur { $price += $sth->fetchrow_arrayref->[0]; } - $price; + $param->{'override_charges'} = $price; + $self->calc_recur_Common($cust_pkg,$sdate,$details,$param); } -sub can_discount { 0; } +sub can_discount { 1; } sub is_free { 0; }