From bdbfd5c5a3bb7bc193b82dc39b98ae9ffe99da44 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 15 Apr 2008 19:43:54 +0000 Subject: [PATCH] s/recur_flat/recur_fee/ --- FS/FS/part_pkg/sesmon_hour.pm | 14 +++++++------- FS/FS/part_pkg/sesmon_minute.pm | 14 +++++++------- FS/FS/part_pkg/sql_external.pm | 14 +++++++------- FS/FS/part_pkg/sql_generic.pm | 18 +++++++++--------- FS/FS/part_pkg/sqlradacct_hour.pm | 16 ++++++++-------- FS/FS/part_pkg/voip_cdr.pm | 12 ++++++------ FS/FS/part_pkg/voip_sqlradacct.pm | 12 ++++++------ FS/FS/part_pkg_option.pm | 21 ++++++++++++++++++++- 8 files changed, 70 insertions(+), 51 deletions(-) diff --git a/FS/FS/part_pkg/sesmon_hour.pm b/FS/FS/part_pkg/sesmon_hour.pm index acc034b70..22ece9557 100644 --- a/FS/FS/part_pkg/sesmon_hour.pm +++ b/FS/FS/part_pkg/sesmon_hour.pm @@ -14,9 +14,9 @@ use FS::part_pkg::flat; 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -28,9 +28,9 @@ use FS::part_pkg::flat; 'default' => 0, }, }, - 'fieldorder' => [ 'setup_fee', 'recur_flat', 'unused_credit', 'recur_included_hours', 'recur_hourly_charge' ], + 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'recur_included_hours', 'recur_hourly_charge' ], #'setup' => 'what.setup_fee.value', - #'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'', + #'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_fee.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'', 'weight' => 80, ); @@ -41,7 +41,7 @@ sub calc_recur { $hours -= $self->option('recur_included_hours'); $hours = 0 if $hours < 0; - $self->option('recur_flat') + $hours * $self->option('recur_hourly_charge'); + $self->option('recur_fee') + $hours * $self->option('recur_hourly_charge'); } @@ -51,7 +51,7 @@ sub is_free_options { sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg/sesmon_minute.pm b/FS/FS/part_pkg/sesmon_minute.pm index f941e00c0..7386df675 100644 --- a/FS/FS/part_pkg/sesmon_minute.pm +++ b/FS/FS/part_pkg/sesmon_minute.pm @@ -14,9 +14,9 @@ use FS::part_pkg::flat; 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -28,9 +28,9 @@ use FS::part_pkg::flat; 'default' => 0, }, }, - 'fieldorder' => [ 'setup_fee', 'recur_flat', 'unused_credit', 'recur_included_min', 'recur_minly_charge' ], + 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'recur_included_min', 'recur_minly_charge' ], #'setup' => 'what.setup_fee.value', - #'recur' => '\'my $min = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 60 - \' + what.recur_included_min.value + \'; $min = 0 if $min < 0; \' + what.recur_flat.value + \' + \' + what.recur_minly_charge.value + \' * $min;\'', + #'recur' => '\'my $min = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 60 - \' + what.recur_included_min.value + \'; $min = 0 if $min < 0; \' + what.recur_fee.value + \' + \' + what.recur_minly_charge.value + \' * $min;\'', 'weight' => 80, ); @@ -41,7 +41,7 @@ sub calc_recur { $min -= $self->option('recur_included_min'); $min = 0 if $min < 0; - $self->option('recur_flat') + $min * $self->option('recur_minly_charge'); + $self->option('recur_fee') + $min * $self->option('recur_minly_charge'); } sub is_free_options { @@ -50,7 +50,7 @@ sub is_free_options { sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg/sql_external.pm b/FS/FS/part_pkg/sql_external.pm index 2e6119c4f..70f9f048a 100644 --- a/FS/FS/part_pkg/sql_external.pm +++ b/FS/FS/part_pkg/sql_external.pm @@ -15,9 +15,9 @@ use FS::part_pkg::flat; 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -35,9 +35,9 @@ use FS::part_pkg::flat; 'default' => '', }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit datasrc db_username db_password query )], + 'fieldorder' => [qw( setup_fee recur_fee unused_credit datasrc db_username db_password query )], #'setup' => 'what.setup_fee.value', - #'recur' => q!'my $dbh = DBI->connect("' + what.datasrc.value + '", "' + what.db_username.value + '", "' + what.db_password.value + '" ) or die $DBI::errstr; my $sth = $dbh->prepare("' + what.query.value + '") or die $dbh->errstr; my $price = ' + what.recur_flat.value + '; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_external" } $cust_pkg->cust_svc ){ my $id = $cust_svc->svc_x->id; $sth->execute($id) or die $sth->errstr; $price += $sth->fetchrow_arrayref->[0]; } $price;'!, + #'recur' => q!'my $dbh = DBI->connect("' + what.datasrc.value + '", "' + what.db_username.value + '", "' + what.db_password.value + '" ) or die $DBI::errstr; my $sth = $dbh->prepare("' + what.query.value + '") or die $dbh->errstr; my $price = ' + what.recur_fee.value + '; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_external" } $cust_pkg->cust_svc ){ my $id = $cust_svc->svc_x->id; $sth->execute($id) or die $sth->errstr; $price += $sth->fetchrow_arrayref->[0]; } $price;'!, 'weight' => '58', ); @@ -52,7 +52,7 @@ sub calc_recur { my $sth = $dbh->prepare( $self->option('query') ) or die $dbh->errstr; - my $price = $self->option('recur_flat'); + my $price = $self->option('recur_fee'); foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_external" } $cust_pkg->cust_svc @@ -71,7 +71,7 @@ sub is_free { sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg/sql_generic.pm b/FS/FS/part_pkg/sql_generic.pm index 90472947d..5a6a11ab0 100644 --- a/FS/FS/part_pkg/sql_generic.pm +++ b/FS/FS/part_pkg/sql_generic.pm @@ -15,9 +15,9 @@ use FS::part_pkg::flat; 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -41,11 +41,11 @@ use FS::part_pkg::flat; 'default' => '', }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit recur_included recur_unit_charge datasrc db_username db_password query )], + 'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_included recur_unit_charge datasrc db_username db_password query )], # 'setup' => 'what.setup_fee.value', # 'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\") or die $DBI::errstr; \'', - #'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\", \"\' + what.db_password.value + \'\" ) or die $DBI::errstr; my $sth = $dbh->prepare(\"\' + what.query.value + \'\") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq \"svc_domain\" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge.value + \';\'', - #'recur' => '\'my $dbh = DBI->connect("\' + what.datasrc.value + \'", "\' + what.db_username.value + \'", "\' what.db_password.value + \'" ) or die $DBI::errstr; my $sth = $dbh->prepare("\' + what.query.value + \'") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_domain" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge + \';\'', + #'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\", \"\' + what.db_password.value + \'\" ) or die $DBI::errstr; my $sth = $dbh->prepare(\"\' + what.query.value + \'\") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq \"svc_domain\" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_fee.value + \' + $units * \' + what.recur_unit_charge.value + \';\'', + #'recur' => '\'my $dbh = DBI->connect("\' + what.datasrc.value + \'", "\' + what.db_username.value + \'", "\' what.db_password.value + \'" ) or die $DBI::errstr; my $sth = $dbh->prepare("\' + what.query.value + \'") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_domain" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_fee.value + \' + $units * \' + what.recur_unit_charge + \';\'', 'weight' => '56', ); @@ -73,16 +73,16 @@ sub calc_recur { $units -= $self->option('recur_included'); $units = 0 if $units < 0; - $self->option('recur_flat') + $units * $self->option('recur_unit_charge'); + $self->option('recur_fee') + $units * $self->option('recur_unit_charge'); } sub is_free_options { - qw( setup_fee recur_flat recur_unit_charge ); + qw( setup_fee recur_fee recur_unit_charge ); } sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg/sqlradacct_hour.pm b/FS/FS/part_pkg/sqlradacct_hour.pm index aebffe229..c86956a44 100644 --- a/FS/FS/part_pkg/sqlradacct_hour.pm +++ b/FS/FS/part_pkg/sqlradacct_hour.pm @@ -14,9 +14,9 @@ use FS::part_pkg::flat; 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -77,9 +77,9 @@ use FS::part_pkg::flat; }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit recur_included_hours recur_hourly_charge recur_hourly_cap recur_included_input recur_input_charge recur_input_cap recur_included_output recur_output_charge recur_output_cap recur_included_total recur_total_charge recur_total_cap global_cap )], + 'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_included_hours recur_hourly_charge recur_hourly_cap recur_included_input recur_input_charge recur_input_cap recur_included_output recur_output_charge recur_output_cap recur_included_total recur_total_charge recur_total_cap global_cap )], #'setup' => 'what.setup_fee.value', - #'recur' => '\'my $last_bill = $cust_pkg->last_bill; my $hours = $cust_pkg->seconds_since_sqlradacct($last_bill, $sdate ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; my $input = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctInputOctets\" ) / 1048576; my $output = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctOutputOctets\" ) / 1048576; my $total = $input + $output - \' + what.recur_included_total.value + \'; $total = 0 if $total < 0; my $input = $input - \' + what.recur_included_input.value + \'; $input = 0 if $input < 0; my $output = $output - \' + what.recur_included_output.value + \'; $output = 0 if $output < 0; my $totalcharge = sprintf(\"%.2f\", \' + what.recur_total_charge.value + \' * $total); my $inputcharge = sprintf(\"%.2f\", \' + what.recur_input_charge.value + \' * $input); my $outputcharge = sprintf(\"%.2f\", \' + what.recur_output_charge.value + \' * $output); my $hourscharge = sprintf(\"%.2f\", \' + what.recur_hourly_charge.value + \' * $hours); if ( \' + what.recur_total_charge.value + \' > 0 ) { push @details, \"Last month\\\'s data \". sprintf(\"%.1f\", $total). \" megs: \\\$$totalcharge\" } if ( \' + what.recur_input_charge.value + \' > 0 ) { push @details, \"Last month\\\'s download \". sprintf(\"%.1f\", $input). \" megs: \\\$$inputcharge\" } if ( \' + what.recur_output_charge.value + \' > 0 ) { push @details, \"Last month\\\'s upload \". sprintf(\"%.1f\", $output). \" megs: \\\$$outputcharge\" } if ( \' + what.recur_hourly_charge.value + \' > 0 ) { push @details, \"Last month\\\'s time \". sprintf(\"%.1f\", $hours). \" hours: \\\$$hourscharge\"; } \' + what.recur_flat.value + \' + $hourscharge + $inputcharge + $outputcharge + $totalcharge ;\'', + #'recur' => '\'my $last_bill = $cust_pkg->last_bill; my $hours = $cust_pkg->seconds_since_sqlradacct($last_bill, $sdate ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; my $input = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctInputOctets\" ) / 1048576; my $output = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctOutputOctets\" ) / 1048576; my $total = $input + $output - \' + what.recur_included_total.value + \'; $total = 0 if $total < 0; my $input = $input - \' + what.recur_included_input.value + \'; $input = 0 if $input < 0; my $output = $output - \' + what.recur_included_output.value + \'; $output = 0 if $output < 0; my $totalcharge = sprintf(\"%.2f\", \' + what.recur_total_charge.value + \' * $total); my $inputcharge = sprintf(\"%.2f\", \' + what.recur_input_charge.value + \' * $input); my $outputcharge = sprintf(\"%.2f\", \' + what.recur_output_charge.value + \' * $output); my $hourscharge = sprintf(\"%.2f\", \' + what.recur_hourly_charge.value + \' * $hours); if ( \' + what.recur_total_charge.value + \' > 0 ) { push @details, \"Last month\\\'s data \". sprintf(\"%.1f\", $total). \" megs: \\\$$totalcharge\" } if ( \' + what.recur_input_charge.value + \' > 0 ) { push @details, \"Last month\\\'s download \". sprintf(\"%.1f\", $input). \" megs: \\\$$inputcharge\" } if ( \' + what.recur_output_charge.value + \' > 0 ) { push @details, \"Last month\\\'s upload \". sprintf(\"%.1f\", $output). \" megs: \\\$$outputcharge\" } if ( \' + what.recur_hourly_charge.value + \' > 0 ) { push @details, \"Last month\\\'s time \". sprintf(\"%.1f\", $hours). \" hours: \\\$$hourscharge\"; } \' + what.recur_fee.value + \' + $hourscharge + $inputcharge + $outputcharge + $totalcharge ;\'', 'weight' => 40, ); @@ -155,17 +155,17 @@ sub calc_recur { push @$details, "Usage charges capped at: $charges"; } - $self->option('recur_flat') + $charges; + $self->option('recur_fee') + $charges; } sub is_free_options { - qw( setup_fee recur_flat recur_hourly_charge + qw( setup_fee recur_fee recur_hourly_charge recur_input_charge recur_output_charge recur_total_charge ); } sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 8720bb668..856f02fbf 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -32,9 +32,9 @@ tie my %rating_method, 'Tie::IxHash', 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -94,7 +94,7 @@ tie my %rating_method, 'Tie::IxHash', # }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit ratenum rating_method default_prefix disable_src domestic_prefix international_prefix )], + 'fieldorder' => [qw( setup_fee recur_fee unused_credit ratenum rating_method default_prefix disable_src domestic_prefix international_prefix )], 'weight' => 40, ); @@ -360,7 +360,7 @@ sub calc_recur { } #if ( $spool_cdr && length($downstream_cdr) ) - $self->option('recur_flat') + $charges; + $self->option('recur_fee') + $charges; } @@ -370,7 +370,7 @@ sub is_free { sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg/voip_sqlradacct.pm b/FS/FS/part_pkg/voip_sqlradacct.pm index 09e7a093a..49ef515ac 100644 --- a/FS/FS/part_pkg/voip_sqlradacct.pm +++ b/FS/FS/part_pkg/voip_sqlradacct.pm @@ -19,9 +19,9 @@ $DEBUG = 1; 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring 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', @@ -33,7 +33,7 @@ $DEBUG = 1; 'select_label' => 'ratename', }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit ratenum ignore_unrateable )], + 'fieldorder' => [qw( setup_fee recur_fee unused_credit ratenum ignore_unrateable )], 'weight' => 40, ); @@ -176,7 +176,7 @@ sub calc_recur { } # $cust_svc - $self->option('recur_flat') + $charges; + $self->option('recur_fee') + $charges; } @@ -186,7 +186,7 @@ sub is_free { sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1; diff --git a/FS/FS/part_pkg_option.pm b/FS/FS/part_pkg_option.pm index c2f609e1b..9708f11bc 100644 --- a/FS/FS/part_pkg_option.pm +++ b/FS/FS/part_pkg_option.pm @@ -2,7 +2,7 @@ package FS::part_pkg_option; use strict; use vars qw( @ISA ); -use FS::Record qw( qsearch qsearchs ); +use FS::Record qw( qsearch qsearchs dbh ); use FS::part_pkg; @ISA = qw(FS::Record); @@ -117,6 +117,25 @@ sub check { =back +=cut + +# +# Used by FS::Upgrade to migrate to a new database. +# +# + +sub _upgrade_data { # class method + my ($class, %opts) = @_; + + my $sql = "UPDATE part_pkg_option SETUP optionname = 'recur_fee'". + " WHERE optionname = 'recur_flat'"; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + + ''; + +} + =head1 BUGS Possibly. -- 2.11.0