summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/AccessRight.pm19
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm2
-rw-r--r--FS/FS/ClientAPI/Signup.pm142
-rw-r--r--FS/FS/Conf.pm47
-rw-r--r--FS/FS/ConfDefaults.pm12
-rw-r--r--FS/FS/Cron/backup.pm6
-rw-r--r--FS/FS/Cron/bill.pm20
-rw-r--r--FS/FS/Cron/notify.pm4
-rw-r--r--FS/FS/Mason.pm2
-rw-r--r--FS/FS/Misc.pm36
-rw-r--r--FS/FS/Record.pm6
-rw-r--r--FS/FS/Schema.pm35
-rw-r--r--FS/FS/access_right.pm35
-rw-r--r--FS/FS/access_user.pm24
-rw-r--r--FS/FS/agent_type.pm14
-rw-r--r--FS/FS/cdr.pm2
-rw-r--r--FS/FS/contact.pm133
-rw-r--r--FS/FS/contact_phone.pm2
-rw-r--r--FS/FS/cust_bill.pm56
-rw-r--r--FS/FS/cust_bill_pkg_detail.pm5
-rw-r--r--FS/FS/cust_credit.pm7
-rw-r--r--FS/FS/cust_location.pm80
-rw-r--r--FS/FS/cust_main.pm403
-rw-r--r--FS/FS/cust_main/Billing.pm34
-rw-r--r--FS/FS/cust_main/Packages.pm17
-rw-r--r--FS/FS/cust_main/Search.pm67
-rw-r--r--FS/FS/cust_main_Mixin.pm16
-rw-r--r--FS/FS/cust_pay.pm42
-rw-r--r--FS/FS/cust_pay_void.pm52
-rw-r--r--FS/FS/cust_pkg.pm102
-rw-r--r--FS/FS/cust_refund.pm7
-rw-r--r--FS/FS/domain_record.pm2
-rw-r--r--FS/FS/geocode_Mixin.pm163
-rw-r--r--FS/FS/msg_template.pm40
-rw-r--r--FS/FS/option_Common.pm29
-rw-r--r--FS/FS/part_event/Condition/cust_status.pm8
-rw-r--r--FS/FS/part_event/Condition/has_referral_custnum.pm10
-rw-r--r--FS/FS/part_event/Condition/pkg_age.pm16
-rw-r--r--FS/FS/part_event/Condition/pkg_recurring.pm9
-rw-r--r--FS/FS/part_event/Condition/pkg_status.pm7
-rw-r--r--FS/FS/part_export/acct_http.pm63
-rw-r--r--FS/FS/part_export/cust_http.pm66
-rw-r--r--FS/FS/part_export/http.pm13
-rw-r--r--FS/FS/part_export/rt_ticket.pm214
-rw-r--r--FS/FS/part_export/sqlradius.pm43
-rw-r--r--FS/FS/part_pkg.pm2
-rw-r--r--FS/FS/part_pkg/agent.pm6
-rw-r--r--FS/FS/part_pkg/bulk.pm43
-rw-r--r--FS/FS/part_pkg/cdr_termination.pm5
-rw-r--r--FS/FS/part_pkg/discount_Mixin.pm128
-rw-r--r--FS/FS/part_pkg/flat.pm124
-rw-r--r--FS/FS/part_pkg/prorate.pm15
-rw-r--r--FS/FS/part_pkg/prorate_Mixin.pm62
-rw-r--r--FS/FS/part_pkg/recur_Common.pm50
-rw-r--r--FS/FS/part_pkg/sql_external.pm6
-rw-r--r--FS/FS/part_pkg/subscription.pm2
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm48
-rw-r--r--FS/FS/part_pkg/voip_inbound.pm6
-rw-r--r--FS/FS/part_pkg_option.pm4
-rw-r--r--FS/FS/svc_Common.pm36
-rw-r--r--FS/FS/svc_acct.pm27
-rw-r--r--FS/FS/svc_pbx.pm53
-rw-r--r--FS/FS/svc_phone.pm2
-rwxr-xr-xFS/bin/freeside-daily2
-rwxr-xr-xFS/bin/freeside-monthly2
-rw-r--r--FS/bin/freeside-radgroup8
-rwxr-xr-xFS/bin/freeside-upgrade15
67 files changed, 639 insertions, 2119 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index e7d77b5..92c4d22 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -113,7 +113,6 @@ tie my %rights, 'Tie::IxHash',
'View customer history',
'Cancel customer',
'Complimentary customer', #aka users-allow_comp
- 'Merge customer',
{ rightname=>'Delete customer', desc=>"Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customer's packages if they cancel service." }, #aka. deletecustomers
'Bill customer now', #NEW
'Bulk send customer notices', #NEW
@@ -183,16 +182,15 @@ tie my %rights, 'Tie::IxHash',
# customer payment rights
###
'Customer payment rights' => [
- { rightname=>'Post payment', desc=>'Make check or cash payments.' },
- 'Post check payment',
- 'Post cash payment',
+ 'Post payment',
'Post payment batch',
'Apply payment', #NEWNEW
{ rightname=>'Unapply payment', desc=>'Enable "unapplication" of unclosed payments from specific invoices.' }, #aka. unapplypayments
- { rightname=>'Process payment', desc=>'Process credit card or e-check payments' },
- 'Process credit card payment',
- 'Process Echeck payment',
+ 'Process payment',
+ { rightname=>'Refund payment', desc=>'Enable refund of existing customer payments.' },
+
{ rightname=>'Delete payment', desc=>'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments.' }, #aka. deletepayments Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.
+
],
###
@@ -204,12 +202,7 @@ tie my %rights, 'Tie::IxHash',
{ rightname=>'Unapply credit', desc=>'Enable "unapplication" of unclosed credits.' }, #aka unapplycredits
{ rightname=>'Delete credit', desc=>'Enable deletion of unclosed credits. Be very careful! Only delete credits that were data-entry errors, not adjustments.' }, #aka. deletecredits Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted.
{ rightname=>'Post refund', desc=>'Enable posting of check and cash refunds.' },
- 'Post check refund',
- 'Post cash refund',
# { rightname=>'Process refund', desc=>'Enable processing of generic credit card/ACH refunds (i.e. not associated with a specific prior payment).' },
- { rightname=>'Refund payment', desc=>'Enable refund of existing customer credit card or e-check payments.' },
- 'Refund credit card payment',
- 'Refund Echeck payment',
'Delete refund', #NEW
'Add on-the-fly credit reason', #NEW
],
@@ -353,8 +346,6 @@ sub default_superuser_rights {
'Redownload resolved batches',
'Raw SQL',
'Configuration download',
- 'View customers of all agents',
- 'View/link unlinked services',
);
no warnings 'uninitialized';
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 1e1d1d3..dbcef7d 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -596,7 +596,7 @@ sub process_payment {
my $amount = $1;
return { error => 'Amount must be greater than 0' } unless $amount > 0;
- $p->{'discount_term'} =~ /^\s*(\d*)\s*$/
+ $p->{'discount_term'} =~ /^\s*(\d+)\s*$/
or return { 'error' => gettext('illegal_discount_term'). ': '. $p->{'discount_term'} };
my $discount_term = $1;
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index 65bb4e3..ec45e79 100644
--- a/FS/FS/ClientAPI/Signup.pm
+++ b/FS/FS/ClientAPI/Signup.pm
@@ -93,31 +93,7 @@ sub signup_info {
my @agent_fields = qw( agentnum agent );
- my @bools = qw( emailinvoiceonly security_phrase );
-
- my @signup_bools = qw( no_company recommend_daytime recommend_email );
-
- my @signup_server_scalars = qw( default_pkgpart default_svcpart );
-
- my @selfservice_textareas = qw( head body_header body_footer );
-
- my @selfservice_scalars = qw(
- body_bgcolor box_bgcolor
- text_color link_color vlink_color hlink_color alink_color
- font title_color title_align title_size menu_bgcolor menu_fontsize
- );
-
- #XXX my @selfservice_bools = qw(
- # menu_skipblanks menu_skipheadings menu_nounderline
- #);
-
- #my $selfservice_binaries = qw(
- # title_left_image title_right_image
- # menu_top_image menu_body_image menu_bottom_image
- #);
-
$signup_info_cache = {
-
'cust_main_county' => [ map $_->hashref,
qsearch('cust_main_county', {} )
],
@@ -149,44 +125,46 @@ sub signup_info {
'card_types' => card_types(),
- ( map { $_ => $conf->exists("signup-$_") } @signup_bools ),
-
- ( map { $_ => scalar($conf->config("signup_server-$_")) }
- @signup_server_scalars
- ),
-
- ( map { $_ => join("\n", $conf->config("selfservice-$_")) }
- @selfservice_textareas
- ),
- ( map { $_ => scalar($conf->config("selfservice-$_")) }
- @selfservice_scalars
- ),
-
- #( map { $_ => scalar($conf->config_binary("selfservice-$_")) }
- # @selfservice_binaries
- #),
-
- 'agentnum2part_pkg' => $agentnum2part_pkg,
- 'svc_acct_pop' => [ map $_->hashref, qsearch('svc_acct_pop',{} ) ],
- 'nomadix' => $conf->exists('signup_server-nomadix'),
- 'payby' => [ $conf->config('signup_server-payby') ],
- 'card_types' => card_types(),
- 'paytypes' => [ @FS::cust_main::paytypes ],
- 'cvv_enabled' => 1,
- 'stateid_enabled' => $conf->exists('show_stateid'),
- 'paystate_enabled' => $conf->exists('show_bankstate'),
- 'ship_enabled' => 1,
- 'msgcat' => $msgcat,
- 'label' => $label,
- 'statedefault' => scalar($conf->config('statedefault')) || 'CA',
- 'countrydefault' => scalar($conf->config('countrydefault')) || 'US',
- 'refnum' => scalar($conf->config('signup_server-default_refnum')),
- 'signup_service' => $svc_x,
- 'company_name' => scalar($conf->config('company_name')),
+ 'paytypes' => [ @FS::cust_main::paytypes ],
+
+ 'cvv_enabled' => 1,
+
+ 'stateid_enabled' => $conf->exists('show_stateid'),
+
+ 'paystate_enabled' => $conf->exists('show_bankstate'),
+
+ 'ship_enabled' => 1,
+
+ 'msgcat' => $msgcat,
+
+ 'label' => $label,
+
+ 'statedefault' => scalar($conf->config('statedefault')) || 'CA',
+
+ 'countrydefault' => scalar($conf->config('countrydefault')) || 'US',
+
+ 'refnum' => scalar($conf->config('signup_server-default_refnum')),
+
+ 'default_pkgpart' => scalar($conf->config('signup_server-default_pkgpart')),
+
+ 'signup_service' => $svc_x,
+ 'default_svcpart' => scalar($conf->config('signup_server-default_svcpart')),
+
+ 'head' => join("\n", $conf->config('selfservice-head') ),
+ 'body_header' => join("\n", $conf->config('selfservice-body_header') ),
+ 'body_footer' => join("\n", $conf->config('selfservice-body_footer') ),
+ 'body_bgcolor' => scalar( $conf->config('selfservice-body_bgcolor') ),
+ 'box_bgcolor' => scalar( $conf->config('selfservice-box_bgcolor') ),
+
+ 'company_name' => scalar($conf->config('company_name')),
+
#per-agent?
'agent_ship_address' => scalar($conf->exists('agent-ship_address')),
- 'require_phone' => scalar($conf->exists('cust_main-require_phone')),
- 'logo' => scalar($conf->config_binary('logo.png')),
+
+ 'no_company' => scalar($conf->exists('signup-no_company')),
+ 'require_phone' => scalar($conf->exists('cust_main-require_phone')),
+ 'recommend_daytime' => scalar($conf->exists('signup-recommend_daytime')),
+ 'recommend_email' => scalar($conf->exists('signup-recommend_email')),
};
@@ -390,7 +368,7 @@ sub signup_info {
#( map { $_ => scalar( $conf->config($_, $agentnum) ) }
# qw( company_name ) ),
( map { $_ => scalar( $conf->config("selfservice-$_", $agentnum ) ) }
- qw( body_bgcolor box_bgcolor menu_bgcolor ) ),
+ qw( body_bgcolor box_bgcolor) ),
( map { $_ => join("\n", $conf->config("selfservice-$_", $agentnum ) ) }
qw( head body_header body_footer ) ),
};
@@ -609,7 +587,7 @@ sub new_customer {
push @acct_snarf, $acct_snarf;
}
$svc->child_objects( \@acct_snarf );
- push @svc, $svc;
+
} elsif ( $svc_x eq 'svc_phone' ) {
@@ -630,6 +608,8 @@ sub new_customer {
} else {
die "unknown signup service $svc_x";
}
+ my $y = $svc[0]->setdefault; # arguably should be in new method
+ return { 'error' => $y } if $y && !ref($y);
if ($packet->{'mac_addr'} && $conf->exists('signup_server-mac_addr_svcparts'))
{
@@ -648,16 +628,15 @@ sub new_customer {
'_password' => '', #blank as requested (set passwordmin to 0)
};
+ my $y = $svc->setdefault; # arguably should be in new method
+ return { 'error' => $y } if $y && !ref($y);
+
push @svc, $svc;
}
- foreach my $svc ( @svc ) {
- my $y = $svc->setdefault; # arguably should be in new method
- return { 'error' => $y } if $y && !ref($y);
- #$error = $svc->check;
- #return { 'error' => $error } if $error;
- }
+ #$error = $svc->check;
+ #return { 'error' => $error } if $error;
#setup a job dependancy to delay provisioning
my $placeholder = new FS::queue ( {
@@ -751,25 +730,20 @@ sub new_customer {
my %return = ( 'error' => '',
'signup_service' => $svc_x,
+ 'svcnum' => $svc[0]->svcnum,
'custnum' => $cust_main->custnum,
);
- if ( $svc[0] ) {
-
- $return{'svcnum'} = $svc[0]->svcnum;
-
- if ( $svc_x eq 'svc_acct' ) {
- $return{$_} = $svc[0]->$_() for qw( username _password );
- } elsif ( $svc_x eq 'svc_phone' ) {
- $return{$_} = $svc[0]->$_() for qw(countrycode phonenum sip_password pin);
- } elsif ( $svc_x eq 'svc_pbx' ) {
- #$return{$_} = $svc[0]->$_() for qw( ) #nothing yet
- } else {
- return {'error' => "configuration error: unknown signup service $svc_x"};
- #die "unknown signup service $svc_x";
- # return an error that's visible to someone somewhere
- }
-
+ if ( $svc_x eq 'svc_acct' ) {
+ $return{$_} = $svc[0]->$_() for qw( username _password );
+ } elsif ( $svc_x eq 'svc_phone' ) {
+ $return{$_} = $svc[0]->$_() for qw( countrycode phonenum sip_password pin );
+ } elsif ( $svc_x eq 'svc_pbx' ) {
+ #$return{$_} = $svc[0]->$_() for qw( ) #nothing yet
+ } else {
+ return { 'error' => "configuration error: unknown signup service $svc_x" };
+ #die "unknown signup service $svc_x";
+ # return an error that's visible to someone somewhere
}
return \%return;
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 8fce990..b3e5477 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -395,7 +395,6 @@ sub verify_config_item {
} else {
- no warnings 'uninitialized';
$error .= "$key fails binary comparison; "
unless scalar($self->config_binary($key)) eq scalar($compat->config_binary($key));
@@ -1182,7 +1181,7 @@ and customer address. Include units.',
'section' => 'invoicing',
'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
'type' => 'select',
- 'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 20', 'Net 30', 'Net 45', 'Net 60', 'Net 90' ],
+ 'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 20', 'Net 30', 'Net 45', 'Net 60' ],
},
{
@@ -1626,20 +1625,6 @@ and customer address. Include units.',
'type' => 'checkbox',
},
- {
- 'key' => 'username-slash',
- 'section' => 'username',
- 'description' => 'Allow the slash character (/) in usernames. When using, make sure to set "Home directory" to fixed and blank in all svc_acct service definitions.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-equals',
- 'section' => 'username',
- 'description' => 'Allow the equal sign character (=) in usernames.',
- 'type' => 'checkbox',
- },
-
{
'key' => 'safe-part_bill_event',
'section' => 'UI',
@@ -2319,15 +2304,7 @@ and customer address. Include units.',
{
'key' => 'global_unique-pbx_title',
'section' => '',
- 'description' => 'Global phone number uniqueness control: none (check uniqueness per exports), enabled (check across all services), or disabled (no duplicate checking).',
- 'type' => 'select',
- 'select_enum' => [ 'enabled', 'disabled' ],
- },
-
- {
- 'key' => 'global_unique-pbx_id',
- 'section' => '',
- 'description' => 'Global PBX id uniqueness control: none (check uniqueness per exports), enabled (check across all services), or disabled (no duplicate checking).',
+ 'description' => 'Global phone number uniqueness control: enabled (usual setting - svc_pbx.title must be unique), or disabled turns off duplicate checking for this field.',
'type' => 'select',
'select_enum' => [ 'enabled', 'disabled' ],
},
@@ -2499,7 +2476,7 @@ and customer address. Include units.',
{
'key' => 'address1-search',
'section' => 'UI',
- 'description' => 'Enable the ability to search the address1 field from the quick customer search. Not recommended in most cases as it tends to bring up too many search results - use explicit address searching from the advanced customer search instead.',
+ 'description' => 'Enable the ability to search the address1 field from customer search.',
'type' => 'checkbox',
},
@@ -2654,13 +2631,6 @@ and customer address. Include units.',
},
{
- 'key' => 'cust_pkg-large_pkg_size',
- 'section' => 'UI',
- 'description' => "In customer view, summarize packages with more than this many services. Set to zero to never summarize packages.",
- 'type' => 'text',
- },
-
- {
'key' => 'svc_acct-edit_uid',
'section' => 'shell',
'description' => 'Allow UID editing.',
@@ -2705,7 +2675,7 @@ and customer address. Include units.',
{
'key' => 'voip-cdr_email',
'section' => '',
- 'description' => 'Include the call details on emailed invoices (and HTML invoices viewed in the backend), even if the customer is configured for not printing them on the invoices.',
+ 'description' => 'Include the call details on emailed invoices even if the customer is configured for not printing them on the invoices.',
'type' => 'checkbox',
},
@@ -2747,7 +2717,7 @@ and customer address. Include units.',
{
'key' => 'tax-pkg_address',
'section' => 'billing',
- 'description' => 'By default, tax calculations are done based on the billing address. Enable this switch to calculate tax based on the package address instead (when present).',
+ 'description' => 'By default, tax calculations are done based on the billing address. Enable this switch to calculate tax based on the package address instead (when present). Note that this option is currently incompatible with vendor data taxation enabled by enable_taxproducts.',
'type' => 'checkbox',
},
@@ -4021,13 +3991,6 @@ and customer address. Include units.',
'type' => 'text',
},
- {
- 'key' => 'part_pkg-default_suspend_bill',
- 'section' => 'billing',
- 'description' => 'Default the "Continue recurring billing while suspended" flag to on for new package definitions.',
- 'type' => 'checkbox',
- },
-
{ key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
{ key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
{ key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/FS/FS/ConfDefaults.pm b/FS/FS/ConfDefaults.pm
index de65b44..12c82e6 100644
--- a/FS/FS/ConfDefaults.pm
+++ b/FS/FS/ConfDefaults.pm
@@ -49,22 +49,22 @@ sub cust_fields_avail { (
'custnum | Status | Last, First | Company | (same for service contact if present)',
'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Invoicing email(s)' =>
- 'custnum | Status | Last, First | Company | (address) | Day phone | Night phone | Invoicing email(s)',
+ 'custnum | Status | Last, First | Company | (all address fields) | Day phone | Night phone | Invoicing email(s)',
'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Fax number | Invoicing email(s) | Payment Type' =>
- 'custnum | Status | Last, First | Company | (address) | (all phones) | Invoicing email(s) | Payment Type',
+ 'custnum | Status | Last, First | Company | (all address fields) | (all phones) | Invoicing email(s) | Payment Type',
'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Fax number | Invoicing email(s) | Payment Type | Current Balance' =>
- 'custnum | Status | Last, First | Company | (address) | (all phones) | Invoicing email(s) | Payment Type | Current Balance',
+ 'custnum | Status | Last, First | Company | (all address fields) | (all phones) | Invoicing email(s) | Payment Type | Current Balance',
'Cust# | Cust. Status | (bill) Name | (bill) Company | (bill) Address 1 | (bill) Address 2 | (bill) City | (bill) State | (bill) Zip | (bill) Country | (bill) Day phone | (bill) Night phone | (service) Name | (service) Company | (service) Address 1 | (service) Address 2 | (service) City | (service) State | (service) Zip | (service) Country | (service) Day phone | (service) Night phone | Invoicing email(s)' =>
- 'custnum | Status | Last, First | Company | (address) | Day phone | Night phone | (service address) | Invoicing email(s)',
+ 'custnum | Status | Last, First | Company | (all address fields) | Day phone | Night phone | (service address) | Invoicing email(s)',
'Cust# | Cust. Status | (bill) Name | (bill) Company | (bill) Address 1 | (bill) Address 2 | (bill) City | (bill) State | (bill) Zip | (bill) Country | (bill) Day phone | (bill) Night phone | (bill) Fax number | (service) Name | (service) Company | (service) Address 1 | (service) Address 2 | (service) City | (service) State | (service) Zip | (service) Country | (service) Day phone | (service) Night phone | (service) Fax number | Invoicing email(s) | Payment Type' =>
- 'custnum | Status | Last, First | Company | (address) | (all phones) | (service address) | Invoicing email(s) | Payment Type',
+ 'custnum | Status | Last, First | Company | (all address fields) | (all phones) | (service address) | Invoicing email(s) | Payment Type',
'Cust# | Cust. Status | (bill) Name | (bill) Company | (bill) Address 1 | (bill) Address 2 | (bill) City | (bill) State | (bill) Zip | (bill) Country | (bill) Day phone | (bill) Night phone | (bill) Fax number | (service) Name | (service) Company | (service) Address 1 | (service) Address 2 | (service) City | (service) State | (service) Zip | (service) Country | (service) Day phone | (service) Night phone | (service) Fax number | Invoicing email(s) | Payment Type | Current Balance' =>
- 'custnum | Status | Last, First | Company | (address) | (all phones) | (service address) | Invoicing email(s) | Payment Type | Current Balance',
+ 'custnum | Status | Last, First | Company | (all address fields) | (all phones) | (service address) | Invoicing email(s) | Payment Type | Current Balance',
'Invoicing email(s)' => 'Invoicing email(s)',
'Cust# | Invoicing email(s)' => 'custnum | Invoicing email(s)',
diff --git a/FS/FS/Cron/backup.pm b/FS/FS/Cron/backup.pm
index 9d88261..204069a 100644
--- a/FS/FS/Cron/backup.pm
+++ b/FS/FS/Cron/backup.pm
@@ -3,7 +3,6 @@ package FS::Cron::backup;
use strict;
use vars qw( @ISA @EXPORT_OK );
use Exporter;
-use Date::Format;
use FS::UID qw(driver_name datasrc);
@ISA = qw( Exporter );
@@ -13,7 +12,6 @@ sub backup_scp {
my $conf = new FS::Conf;
my $dest = $conf->config('dump-scpdest');
if ( $dest ) {
- $dest .= time2str('/%Y%m%d%H%M%S',time);
datasrc =~ /dbname=([\w\.]+)$/ or die "unparsable datasrc ". datasrc;
my $database = $1;
eval "use Net::SCP qw(scp);";
@@ -32,11 +30,11 @@ sub backup_scp {
recipient => $conf->config('dump-pgpid'),
);
chmod 0600, '/var/tmp/$database.gpg';
- scp("/var/tmp/$database.gpg", "$dest.gpg");
+ scp("/var/tmp/$database.gpg", $dest);
unlink "/var/tmp/$database.gpg" or die $!;
} else {
chmod 0600, '/var/tmp/$database.sql';
- scp("/var/tmp/$database.sql", "$dest.sql");
+ scp("/var/tmp/$database.sql", $dest);
}
unlink "/var/tmp/$database.sql" or die $!;
}
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 7388733..5de2ee3 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -5,7 +5,7 @@ use vars qw( @ISA @EXPORT_OK );
use Exporter;
use Date::Parse;
use DBI 1.33; #The "clone" method was added in DBI 1.33.
-use FS::UID qw( dbh driver_name );
+use FS::UID qw(dbh);
use FS::Record qw( qsearch qsearchs );
use FS::queue;
use FS::cust_main;
@@ -56,20 +56,14 @@ sub bill {
my $cursor_dbh = dbh->clone;
- my $select = 'SELECT custnum FROM cust_main WHERE '. bill_where( %opt );
-
- unless ( driver_name =~ /^mysql/ ) {
- $cursor_dbh->do( "DECLARE cron_bill_cursor CURSOR FOR $select" )
- or die $cursor_dbh->errstr;
- }
+ $cursor_dbh->do(
+ "DECLARE cron_bill_cursor CURSOR FOR ".
+ " SELECT custnum FROM cust_main WHERE ". bill_where( %opt )
+ ) or die $cursor_dbh->errstr;
while ( 1 ) {
- my $sql = (driver_name =~ /^mysql/)
- ? $select
- : 'FETCH 100 FROM cron_bill_cursor';
-
- my $sth = $cursor_dbh->prepare($sql);
+ my $sth = $cursor_dbh->prepare('FETCH 100 FROM cron_bill_cursor'); #mysql?
$sth->execute or die $sth->errstr;
@@ -126,8 +120,6 @@ sub bill {
}
- last if driver_name =~ /^mysql/;
-
}
$cursor_dbh->commit or die $cursor_dbh->errstr;
diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm
index 3d427b2..dcc7b30 100644
--- a/FS/FS/Cron/notify.pm
+++ b/FS/FS/Cron/notify.pm
@@ -37,7 +37,7 @@ sub notify_flat_delay {
and 0 < ( select count(*) from part_pkg_option
where part_pkg.pkgpart = part_pkg_option.pkgpart
and part_pkg_option.optionname = 'recur_notify'
- and CAST( part_pkg_option.optionvalue AS $integer ) > 0
+ and CAST( part_pkg_option.optionvalue AS INTEGER ) > 0
and 0 <= ( $time
+ CAST( part_pkg_option.optionvalue AS $integer )
* 86400
@@ -64,7 +64,7 @@ END
0 = ( select count(*) from cust_pkg_option
where cust_pkg.pkgnum = cust_pkg_option.pkgnum
and cust_pkg_option.optionname = 'impending_recur_notification_sent'
- and CAST( cust_pkg_option.optionvalue AS $integer ) = 1
+ and CAST( cust_pkg_option.optionvalue AS INTEGER ) = 1
)
END
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 550ea1a..2282bc5 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -126,7 +126,7 @@ if ( -e $addl_handler_use_file ) {
use FS::UI::Web::small_custview qw(small_custview);
use FS::UI::bytecount;
use FS::Msgcat qw(gettext geterror);
- use FS::Misc qw( send_email send_fax ocr_image
+ use FS::Misc qw( send_email send_fax
states_hash counties cities state_label
);
use FS::Misc::eps2png qw( eps2png );
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index fe8ac60..0e8d92b 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -20,7 +20,6 @@ use Tie::IxHash;
pkg_freqs
generate_ps generate_pdf do_print
csv_from_fixed
- ocr_image
);
$DEBUG = 0;
@@ -851,41 +850,6 @@ sub csv_from_fixed {
'';
}
-=item ocr_image IMAGE_SCALAR
-
-Runs OCR on the provided image data and returns a list of text lines.
-
-=cut
-
-sub ocr_image {
- my $logo_data = shift;
-
- #XXX use conf dir location from Makefile
- my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
- my $fh = new File::Temp(
- TEMPLATE => 'bizcard.XXXXXXXX',
- SUFFIX => '.png', #XXX assuming, but should handle jpg, gif, etc. too
- DIR => $dir,
- UNLINK => 0,
- ) or die "can't open temp file: $!\n";
-
- my $filename = $fh->filename;
-
- print $fh $logo_data;
- close $fh;
-
- run( [qw(ocroscript recognize), $filename], '>'=>"$filename.hocr" )
- or die "ocroscript recognize failed\n";
-
- run( [qw(ocroscript hocr-to-text), "$filename.hocr"], '>pipe'=>\*OUT )
- or die "ocroscript hocr-to-text failed\n";
-
- my @lines = split(/\n/, <OUT> );
-
- foreach (@lines) { s/\.c0m\s*$/.com/; }
-
- @lines;
-}
=back
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 92f503f..4f0984c 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -2171,7 +2171,7 @@ sub ut_text {
#warn "notexist ". \&notexist. "\n";
#warn "AUTOLOAD ". \&AUTOLOAD. "\n";
$self->getfield($field)
- =~ /^([µ_0123456789aAáÁàÀâÂåÅäÄãêæÆbBcCçÇdDðÐeEéÉèÈêÊëËfFgGhHiIíÍìÌîÎïÏjJkKlLmMnNñÑoOóÓòÒôÔöÖõÕøغpPqQrRsSßtTuUúÚùÙûÛüÜvVwWxXyYýÝÿzZþÞ \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]\<\>]+)$/
+ =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]\<\>]+)$/
or return gettext('illegal_or_empty_text'). " $field: ".
$self->getfield($field);
$self->setfield($field,$1);
@@ -2458,9 +2458,7 @@ May not be null.
sub ut_name {
my( $self, $field ) = @_;
-# warn "ut_name allowed alphanumerics: +(sort grep /\w/, map { chr() } 0..255), "\n";
- #$self->getfield($field) =~ /^([\w \,\.\-\']+)$/
- $self->getfield($field) =~ /^([µ_0123456789aAáÁàÀâÂåÅäÄãêæÆbBcCçÇdDðÐeEéÉèÈêÊëËfFgGhHiIíÍìÌîÎïÏjJkKlLmMnNñÑoOóÓòÒôÔöÖõÕøغpPqQrRsSßtTuUúÚùÙûÛüÜvVwWxXyYýÝÿzZþÞ \,\.\-\']+)$/
+ $self->getfield($field) =~ /^([\w \,\.\-\']+)$/
or return gettext('illegal_name'). " $field: ". $self->getfield($field);
$self->setfield($field,$1);
'';
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 1838036..a601843 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -831,8 +831,8 @@ sub tables_hashref {
'last', 'varchar', '', $char_d, '', '',
# 'middle', 'varchar', 'NULL', $char_d, '', '',
'first', 'varchar', '', $char_d, '', '',
- 'title', 'varchar', 'NULL', $char_d, '', '', #eg Head Bottle Washer
- 'comment', 'varchar', 'NULL', $char_d, '', '',
+ 'title', 'varchar', '', $char_d, '', '', #eg Head Bottle Washer
+ 'comment', 'varchar', '', $char_d, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'contactnum',
@@ -844,13 +844,13 @@ sub tables_hashref {
'contact_phone' => {
'columns' => [
- 'contactphonenum', 'serial', '', '', '', '',
- 'contactnum', 'int', '', '', '', '',
- 'phonetypenum', 'int', '', '', '', '',
- 'countrycode', 'varchar', '', 3, '', '',
- 'phonenum', 'varchar', '', 14, '', '',
- 'extension', 'varchar', 'NULL', 7, '', '',
- #?#'comment', 'varchar', '', $char_d, '', '',
+ 'contactphonenum', 'serial', '', '', '', '',
+ 'contactnum', 'int', '', '', '', '',
+ 'phonetypenum', 'int', '', '', '', '',
+ 'countrycode', 'varchar', '', 3, '', '',
+ 'phonenum', 'varchar', '', 14, '', '',
+ 'extension', 'varchar', '', 7, '', '',
+ #?#'comment', 'varchar', '', $char_d, '', '',
],
'primary_key' => 'contactphonenum',
'unique' => [],
@@ -1194,11 +1194,10 @@ sub tables_hashref {
'reason', 'varchar', 'NULL', $char_d, '', '',
'otaker', 'varchar', 'NULL', 32, '', '',
'usernum', 'int', 'NULL', '', '', '',
- 'void_usernum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'paynum',
'unique' => [],
- 'index' => [ [ 'custnum' ], [ 'usernum' ], [ 'void_usernum' ] ],
+ 'index' => [ [ 'custnum' ], [ 'usernum' ], ],
},
'cust_bill_pay' => {
@@ -1304,7 +1303,6 @@ sub tables_hashref {
'adjourn', @date_type, '', '',
'cancel', @date_type, '', '',
'expire', @date_type, '', '',
- 'contract_end', @date_type, '', '',
'change_date', @date_type, '', '',
'change_pkgnum', 'int', 'NULL', '', '', '',
'change_pkgpart', 'int', 'NULL', '', '', '',
@@ -2970,18 +2968,7 @@ sub tables_hashref {
'index' => [ ['agentnum'], ]
},
- 'svc_cert' => {
- 'columns' => [
- 'svcnum', 'int', '', '', '', '',
- 'recnum', 'int', '', '', '', '',
- 'something', 'text', '', '', '', '',
- #XXX more fields
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [], #recnum
- },
-
+
# name type nullability length default local
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index ef8cc6c..bc6dd5d 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -145,41 +145,6 @@ sub _upgrade_data { # class method
if $error;
}
- my %migrate = (
- 'Post payment' => [ 'Post check payment', 'Post cash payment' ],
- 'Process payment' => [ 'Process credit card payment', 'Process Echeck payment' ],
- 'Post refund' => [ 'Post check refund', 'Post cash refund' ],
- 'Refund payment' => [ 'Refund credit card payment', 'Refund Echeck payment' ],
- );
-
- foreach my $oldright (keys %migrate) {
- my @old = qsearch('access_right', { 'righttype'=>'FS::access_group',
- 'rightname'=>$oldright,
- }
- );
-
- foreach my $old ( @old ) {
-
- foreach my $newright ( @{ $migrate{$oldright} } ) {
- my %hash = (
- 'righttype' => 'FS::access_group',
- 'rightobjnum' => $old->rightobjnum,
- 'rightname' => $newright,
- );
- next if qsearchs('access_right', \%hash);
- my $access_right = new FS::access_right \%hash;
- my $error = $access_right->insert;
- die $error if $error;
- }
-
- #after the WEST stuff is sorted, etc.
- #my $error = $old->delete;
- #die $error if $error;
-
- }
-
- }
-
'';
}
diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm
index 075733a..72e9140 100644
--- a/FS/FS/access_user.pm
+++ b/FS/FS/access_user.pm
@@ -132,8 +132,9 @@ sub insert {
sub htpasswd_kludge {
my $self = shift;
-
- return '' if $self->is_system_user;
+
+ #awful kludge to skip setting htpasswd for fs_* users
+ return '' if $self->username =~ /^fs_/;
unshift @_, '-c' unless -e $htpasswd_file;
if (
@@ -511,25 +512,6 @@ sub default_customer_view {
}
-=item is_system_user
-
-Returns true if this user has the name of a known system account. These
-users will not appear in the htpasswd file and can't have passwords set.
-
-=cut
-
-sub is_system_user {
- my $self = shift;
- return grep { $_ eq $self->username } ( qw(
- fs_queue
- fs_daily
- fs_selfservice
- fs_signup
- fs_bootstrap
- fs_selfserv
-) );
-}
-
=back
=head1 BUGS
diff --git a/FS/FS/agent_type.pm b/FS/FS/agent_type.pm
index 5d6b94e..2660bb4 100644
--- a/FS/FS/agent_type.pm
+++ b/FS/FS/agent_type.pm
@@ -2,7 +2,7 @@ package FS::agent_type;
use strict;
use vars qw( @ISA );
-use FS::Record qw( qsearch dbh );
+use FS::Record qw( qsearch );
use FS::m2m_Common;
use FS::agent;
use FS::type_pkgs;
@@ -119,7 +119,9 @@ L<FS::part_pkg>.
sub pkgpart_hashref {
my $self = shift;
my %pkgpart;
- $pkgpart{$_}++ foreach $self->pkgpart;
+ #$pkgpart{$_}++ foreach $self->pkgpart;
+ # not compatible w/5.004_04 (fixed in 5.004_05)
+ foreach ( $self->pkgpart ) { $pkgpart{$_}++; }
\%pkgpart;
}
@@ -164,13 +166,7 @@ agent type.
sub pkgpart {
my $self = shift;
-
- #map $_->pkgpart, $self->type_pkgs;
-
- my $sql = 'SELECT pkgpart FROM type_pkgs WHERE typenum = ?';
- my $sth = dbh->prepare($sql) or die dbh->errstr;
- $sth->execute( $self->typenum ) or die $sth->errstr;
- map $_->[0], @{ $sth->fetchall_arrayref };
+ map $_->pkgpart, $self->type_pkgs;
}
=back
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 8f6a43c..002e2d2 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -285,7 +285,7 @@ sub check {
# ;
# return $error if $error;
- for my $f ( grep { $self->$_ =~ /\D/ } qw(startdate answerdate enddate)){
+ for my $f ( grep { $self->$_ =~ /[a-z ]/i } qw( startdate enddate ) ) {
$self->$f( str2time($self->$f) );
}
diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 774aed0..d3ab411 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -2,12 +2,10 @@ package FS::contact;
use strict;
use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs dbh );
+use FS::Record qw( qsearch qsearchs );
use FS::prospect_main;
use FS::cust_main;
use FS::cust_location;
-use FS::contact_phone;
-use FS::contact_email;
=head1 NAME
@@ -98,59 +96,7 @@ otherwise returns false.
=cut
-sub insert {
- my $self = shift;
-
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $pf ( grep { /^phonetypenum(\d+)$/ && $self->get($_) =~ /\S/ }
- keys %{ $self->hashref } ) {
- $pf =~ /^phonetypenum(\d+)$/ or die "wtf (daily, the)";
- my $phonetypenum = $1;
-
- my $contact_phone = new FS::contact_phone {
- 'contactnum' => $self->contactnum,
- 'phonetypenum' => $phonetypenum,
- _parse_phonestring( $self->get($pf) ),
- };
- $error = $contact_phone->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- if ( $self->get('emailaddress') =~ /\S/ ) {
- my $contact_email = new FS::contact_email {
- 'contactnum' => $self->contactnum,
- 'emailaddress' => $self->get('emailaddress'),
- };
- $error = $contact_email->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
+# the insert method can be inherited from FS::Record
=item delete
@@ -160,8 +106,6 @@ Delete this record from the database.
# the delete method can be inherited from FS::Record
-# XXX delete contact_phone, contact_email
-
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
@@ -169,76 +113,7 @@ returns the error, otherwise returns false.
=cut
-sub replace {
- my $self = shift;
-
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::replace(@_);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $pf ( grep { /^phonetypenum(\d+)$/ && $self->get($_) }
- keys %{ $self->hashref } ) {
- $pf =~ /^phonetypenum(\d+)$/ or die "wtf (daily, the)";
- my $phonetypenum = $1;
-
- my %cp = ( 'contactnum' => $self->contactnum,
- 'phonetypenum' => $phonetypenum,
- );
- my $contact_phone = qsearchs('contact_phone', \%cp)
- || new FS::contact_phone \%cp;
-
- my %cpd = _parse_phonestring( $self->get($pf) );
- $contact_phone->set( $_ => $cpd{$_} ) foreach keys %cpd;
-
- my $method = $contact_phone->contactphonenum ? 'replace' : 'insert';
-
- $error = $contact_phone->$method;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-#i probably belong in contact_phone.pm
-sub _parse_phonestring {
- my $value = shift;
-
- my($countrycode, $extension) = ('1', '');
-
- #countrycode
- if ( $value =~ s/^\s*\+\s*(\d+)// ) {
- $countrycode = $1;
- } else {
- $value =~ s/^\s*1//;
- }
- #extension
- if ( $value =~ s/\s*(ext|x)\s*(\d+)\s*$//i ) {
- $extension = $2;
- }
-
- ( 'countrycode' => $countrycode,
- 'phonenum' => $value,
- 'extension' => $extension,
- );
-}
+# the replace method can be inherited from FS::Record
=item check
@@ -290,6 +165,8 @@ sub line {
=head1 BUGS
+The author forgot to customize this manpage.
+
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
diff --git a/FS/FS/contact_phone.pm b/FS/FS/contact_phone.pm
index ad8e8f7..bb9cf03 100644
--- a/FS/FS/contact_phone.pm
+++ b/FS/FS/contact_phone.pm
@@ -120,7 +120,7 @@ sub check {
|| $self->ut_number('phonetypenum')
|| $self->ut_text('countrycode')
|| $self->ut_text('phonenum')
- || $self->ut_textn('extension')
+ || $self->ut_text('extension')
;
return $error if $error;
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 335c4b6..d364ac5 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -263,13 +263,13 @@ sub delete {
}
-=item replace [ OLD_RECORD ]
+=item replace OLD_RECORD
-You can, but probably shouldn't modify invoices...
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
-Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not
-supplied, replaces this record. If there is an error, returns the error,
-otherwise returns false.
+Only printed may be changed. printed is normally updated by calling the
+collect method of a customer object (see L<FS::cust_main>).
=cut
@@ -280,11 +280,11 @@ otherwise returns false.
sub replace_check {
my( $new, $old ) = ( shift, shift );
- return "Can't modify closed invoice" if $old->closed =~ /^Y/i;
+ return "Can't change custnum!" unless $old->custnum == $new->custnum;
#return "Can't change _date!" unless $old->_date eq $new->_date;
- return "Can't change _date" unless $old->_date == $new->_date;
- return "Can't change charged" unless $old->charged == $new->charged
- || $old->charged == 0;
+ return "Can't change _date!" unless $old->_date == $new->_date;
+ return "Can't change charged!" unless $old->charged == $new->charged
+ || $old->charged == 0;
'';
}
@@ -2291,12 +2291,10 @@ sub print_generic {
my $nbsp = $nbsps{$format};
my %escape_functions = ( 'latex' => \&_latex_escape,
- 'html' => \&_html_escape_nbsp,#\&encode_entities,
+ 'html' => \&encode_entities,
'template' => sub { shift },
);
my $escape_function = $escape_functions{$format};
- my $escape_function_nonbsp = ($format eq 'html')
- ? \&_html_escape : $escape_function;
my %date_formats = ( 'latex' => '%b %o, %Y',
'html' => '%b&nbsp;%o,&nbsp;%Y',
@@ -2600,7 +2598,7 @@ sub print_generic {
my $extra_lines = ();
if ( $multisection ) {
($extra_sections, $extra_lines) =
- $self->_items_extra_usage_sections($escape_function_nonbsp, $format)
+ $self->_items_extra_usage_sections($escape_function, $format)
if $conf->exists('usage_class_as_a_section', $cust_main->agentnum);
push @$extra_sections, $adjust_section if $adjust_section->{sort_weight};
@@ -2609,13 +2607,13 @@ sub print_generic {
push @sections,
$self->_items_sections( $late_sections, # this could stand a refactor
$summarypage,
- $escape_function_nonbsp,
+ $escape_function,
$extra_sections,
$format, #bah
);
if ($conf->exists('svc_phone_sections')) {
my ($phone_sections, $phone_lines) =
- $self->_items_svc_phone_sections($escape_function_nonbsp, $format);
+ $self->_items_svc_phone_sections($escape_function, $format);
push @{$late_sections}, @$phone_sections;
push @detail_items, @$phone_lines;
}
@@ -3167,18 +3165,6 @@ sub _latex_escape {
$value;
}
-sub _html_escape {
- my $value = shift;
- encode_entities($value);
- $value;
-}
-
-sub _html_escape_nbsp {
- my $value = _html_escape(shift);
- $value =~ s/ +/&nbsp;/g;
- $value;
-}
-
#utility methods for print_*
sub _translate_old_latex_format {
@@ -4100,20 +4086,15 @@ sub _items_cust_bill_pkg {
unless ( $cust_pkg->part_pkg->hide_svc_detail
|| $cust_bill_pkg->hidden )
{
-
push @d, map &{$escape_function}($_),
- $cust_pkg->h_labels_short($self->_date)
- unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
-
+ $cust_pkg->h_labels_short($self->_date);
if ( $multilocation ) {
my $loc = $cust_pkg->location_label;
- $loc = substr($loc, 0, 50). '...'
+ $loc = substr($desc, 0, 50). '...'
if $format eq 'latex' && length($loc) > 50;
push @d, &{$escape_function}($loc);
}
-
}
-
push @d, $cust_bill_pkg->details(%details_opt)
if $cust_bill_pkg->recur == 0;
@@ -4162,20 +4143,17 @@ sub _items_cust_bill_pkg {
|| $cust_bill_pkg->hidden
|| $is_summary && $type && $type eq 'U' )
{
-
push @d, map &{$escape_function}($_),
$cust_pkg->h_labels_short(@dates)
#$cust_bill_pkg->edate,
#$cust_bill_pkg->sdate)
- unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
-
+ ;
if ( $multilocation ) {
my $loc = $cust_pkg->location_label;
- $loc = substr($loc, 0, 50). '...'
+ $loc = substr($desc, 0, 50). '...'
if $format eq 'latex' && length($loc) > 50;
push @d, &{$escape_function}($loc);
}
-
}
push @d, $cust_bill_pkg->details(%details_opt)
diff --git a/FS/FS/cust_bill_pkg_detail.pm b/FS/FS/cust_bill_pkg_detail.pm
index 7badaa3..b8af013 100644
--- a/FS/FS/cust_bill_pkg_detail.pm
+++ b/FS/FS/cust_bill_pkg_detail.pm
@@ -238,10 +238,7 @@ sub _upgrade_schema { # class method
warn "$me upgrading $class\n" if $DEBUG;
- my $classnum = dbdef->table($class->table)->column('classnum')
- or return;
-
- my $type = $classnum->type;
+ my $type = dbdef->table($class->table)->column('classnum')->type;
unless ( $type =~ /^int/i || $type =~ /int$/i ) {
my $dbh = dbh;
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 6185fc4..0f8ac97 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -270,17 +270,14 @@ sub delete {
}
-=item replace [ OLD_RECORD ]
+=item replace OLD_RECORD
You can, but probably shouldn't modify credits...
-Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not
-supplied, replaces this record. If there is an error, returns the error,
-otherwise returns false.
-
=cut
sub replace {
+ #return "Can't modify credit!"
my $self = shift;
return "Can't modify closed credit" if $self->closed =~ /^Y/i;
$self->SUPER::replace(@_);
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index ab80941..0c5c023 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -1,7 +1,7 @@
package FS::cust_location;
use strict;
-use base qw( FS::geocode_Mixin FS::Record );
+use base qw( FS::Record );
use Locale::Country;
use FS::Record qw( qsearch ); #qsearchs );
use FS::prospect_main;
@@ -163,35 +163,91 @@ sub country_full {
code2country($self->country);
}
-=item line
+=item location_label [ OPTION => VALUE ... ]
-Synonym for location_label
+Returns the label of the service location for this customer.
+
+Options are
+
+=over 4
+
+=item join_string
+
+used to separate the address elements (defaults to ', ')
+
+=item escape_function
+
+
+a callback used for escaping the text of the address elements
+
+=back
=cut
-sub line {
+# false laziness with FS::cust_main::location_label
+
+sub location_label {
my $self = shift;
- $self->location_label;
+ my %opt = @_;
+
+ my $separator = $opt{join_string} || ', ';
+ my $escape = $opt{escape_function} || sub{ shift };
+ my $ds = $opt{double_space} || ' ';
+ my $line = '';
+ my $cydefault =
+ $opt{'countrydefault'} || FS::Conf->new->config('countrydefault') || 'US';
+ my $prefix = '';
+
+ my $notfirst = 0;
+ foreach (qw ( address1 address2 ) ) {
+ my $method = "$prefix$_";
+ $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
+ if $self->$method;
+ $notfirst++;
+ }
+ $notfirst = 0;
+ foreach (qw ( city county state zip ) ) {
+ my $method = "$prefix$_";
+ if ( $self->$method ) {
+ $line .= ($notfirst ? ($method eq 'zip' ? $ds : ' ') : $separator);
+ $line .= '(' if $method eq 'county';
+ $line .= &$escape($self->$method);
+ $line .= ')' if $method eq 'county';
+ $notfirst++;
+ }
+ $line .= ',' if $method eq 'county';
+ }
+ $line .= $separator. &$escape(code2country($self->country))
+ if $self->country ne $cydefault;
+
+ $line;
}
-=item has_ship_address
+=item line
-Returns false since cust_location objects do not have a separate shipping
-address.
+Synonym for location_label
=cut
-sub has_ship_address {
- '';
+sub line {
+ my $self = shift;
+ $self->location_label;
}
=item location_hash
-Returns a list of key/value pairs, with the following keys: address1, address2,
-city, county, state, zip, country, geocode.
+Returns a list of key/value pairs, with the following keys: address1, adddress2,
+city, county, state, zip, country.
=cut
+#geocode? not yet set
+
+sub location_hash {
+ my $self = shift;
+ map { $_ => $self->$_ } qw( address1 address2 city county state zip country );
+}
+
=back
=head1 BUGS
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 7969965..fc781d2 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -6,7 +6,6 @@ use strict;
use base qw( FS::cust_main::Packages
FS::cust_main::Billing FS::cust_main::Billing_Realtime
FS::otaker_Mixin FS::payinfo_Mixin FS::cust_main_Mixin
- FS::geocode_Mixin
FS::Record
);
use vars qw( $DEBUG $me $conf
@@ -26,7 +25,7 @@ use Tie::IxHash;
use Digest::MD5 qw(md5_base64);
use Date::Format;
#use Date::Manip;
-use File::Temp; #qw( tempfile );
+use File::Temp qw( tempfile );
use Business::CreditCard 0.28;
use Locale::Country;
use FS::UID qw( getotaker dbh driver_name );
@@ -1159,227 +1158,6 @@ sub delete {
}
-=item merge NEW_CUSTNUM [ , OPTION => VALUE ... ]
-
-This merges this customer into the provided new custnum, and then deletes the
-customer. If there is an error, returns the error, otherwise returns false.
-
-The source customer's name, company name, phone numbers, agent,
-referring customer, customer class, advertising source, order taker, and
-billing information (except balance) are discarded.
-
-All packages are moved to the target customer. Packages with package locations
-are preserved. Packages without package locations are moved to a new package
-location with the source customer's service/shipping address.
-
-All invoices, statements, payments, credits and refunds are moved to the target
-customer. The source customer's balance is added to the target customer.
-
-All notes, attachments, tickets and customer tags are moved to the target
-customer.
-
-Change history is not currently moved.
-
-=cut
-
-sub merge {
- my( $self, $new_custnum, %opt ) = @_;
-
- return "Can't merge a customer into self" if $self->custnum == $new_custnum;
-
- unless ( qsearchs( 'cust_main', { 'custnum' => $new_custnum } ) ) {
- return "Invalid new customer number: $new_custnum";
- }
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- if ( qsearch('agent', { 'agent_custnum' => $self->custnum } ) ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't merge a master agent customer";
- }
-
- #use FS::access_user
- if ( qsearch('access_user', { 'user_custnum' => $self->custnum } ) ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't merge a master employee customer";
- }
-
- if ( qsearch('cust_pay_pending', { 'custnum' => $self->custnum,
- 'status' => { op=>'!=', value=>'done' },
- }
- )
- ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't merge a customer with pending payments";
- }
-
- tie my %financial_tables, 'Tie::IxHash',
- 'cust_bill' => 'invoices',
- 'cust_statement' => 'statements',
- 'cust_credit' => 'credits',
- 'cust_pay' => 'payments',
- 'cust_pay_void' => 'voided payments',
- 'cust_refund' => 'refunds',
- ;
-
- foreach my $table ( keys %financial_tables ) {
-
- my @records = $self->$table();
-
- foreach my $record ( @records ) {
- $record->custnum($new_custnum);
- my $error = $record->replace;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error merging ". $financial_tables{$table}. ": $error\n";
- }
- }
-
- }
-
- my $name = $self->ship_name;
-
- my $locationnum = '';
- foreach my $cust_pkg ( $self->all_pkgs ) {
- $cust_pkg->custnum($new_custnum);
-
- unless ( $cust_pkg->locationnum ) {
- unless ( $locationnum ) {
- my $cust_location = new FS::cust_location {
- $self->location_hash,
- 'custnum' => $new_custnum,
- };
- my $error = $cust_location->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $locationnum = $cust_location->locationnum;
- }
- $cust_pkg->locationnum($locationnum);
- }
-
- my $error = $cust_pkg->replace;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- # add customer (ship) name to svc_phone.phone_name if blank
- my @cust_svc = $cust_pkg->cust_svc;
- foreach my $cust_svc (@cust_svc) {
- my($label, $value, $svcdb) = $cust_svc->label;
- next unless $svcdb eq 'svc_phone';
- my $svc_phone = $cust_svc->svc_x;
- next if $svc_phone->phone_name;
- $svc_phone->phone_name($name);
- my $error = $svc_phone->replace;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- }
-
- #not considered:
- # cust_tax_exempt (texas tax exemptions)
- # cust_recon (some sort of not-well understood thing for OnPac)
-
- #these are moved over
- foreach my $table (qw(
- cust_tag cust_location contact cust_attachment cust_main_note
- cust_tax_adjustment cust_pay_batch queue
- )) {
- foreach my $record ( qsearch( $table, { 'custnum' => $self->custnum } ) ) {
- $record->custnum($new_custnum);
- my $error = $record->replace;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- #these aren't preserved
- foreach my $table (qw(
- cust_main_exemption cust_main_invoice
- )) {
- foreach my $record ( qsearch( $table, { 'custnum' => $self->custnum } ) ) {
- my $error = $record->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
-
- my $sth = $dbh->prepare(
- 'UPDATE cust_main SET referral_custnum = ? WHERE referral_custnum = ?'
- ) or do {
- my $errstr = $dbh->errstr;
- $dbh->rollback if $oldAutoCommit;
- return $errstr;
- };
- $sth->execute($new_custnum, $self->custnum) or do {
- my $errstr = $sth->errstr;
- $dbh->rollback if $oldAutoCommit;
- return $errstr;
- };
-
- #tickets
-
- my $ticket_dbh = '';
- if ($conf->config('ticket_system') eq 'RT_Internal') {
- $ticket_dbh = $dbh;
- } elsif ($conf->config('ticket_system') eq 'RT_External') {
- my ($datasrc, $user, $pass) = $conf->config('ticket_system-rt_external_datasrc');
- $ticket_dbh = DBI->connect($datasrc, $user, $pass, { 'ChopBlanks' => 1 });
- #or die "RT_External DBI->connect error: $DBI::errstr\n";
- }
-
- if ( $ticket_dbh ) {
-
- my $ticket_sth = $ticket_dbh->prepare(
- 'UPDATE Links SET Target = ? WHERE Target = ?'
- ) or do {
- my $errstr = $ticket_dbh->errstr;
- $dbh->rollback if $oldAutoCommit;
- return $errstr;
- };
- $ticket_sth->execute('freeside://freeside/cust_main/'.$new_custnum,
- 'freeside://freeside/cust_main/'.$self->custnum)
- or do {
- my $errstr = $ticket_sth->errstr;
- $dbh->rollback if $oldAutoCommit;
- return $errstr;
- };
-
- }
-
- #delete the customer record
-
- my $error = $self->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
=item replace [ OLD_RECORD ] [ INVOICING_LIST_ARYREF ] [ , OPTION => VALUE ... ] ]
@@ -1421,17 +1199,6 @@ sub replace {
return "You are not permitted to create complimentary accounts.";
}
- if ( $old->get('geocode') && $old->get('geocode') eq $self->get('geocode')
- && $conf->exists('enable_taxproducts')
- )
- {
- my $pre = ($conf->exists('tax-ship_address') && $self->ship_zip)
- ? 'ship_' : '';
- $self->set('geocode', '')
- if $old->get($pre.'zip') ne $self->get($pre.'zip')
- && length($self->get($pre.'zip')) >= 10;
- }
-
local($ignore_expired_card) = 1
if $old->payby =~ /^(CARD|DCRD)$/
&& $self->payby =~ /^(CARD|DCRD)$/
@@ -1888,14 +1655,12 @@ sub check {
$self->payinfo($payinfo);
$self->paycvv('');
- unless ( $ignore_banned_card ) {
- my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref);
- if ( $ban ) {
- return 'Banned ACH account: banned on '.
- time2str('%a %h %o at %r', $ban->_date).
- ' by '. $ban->otaker.
- ' (ban# '. $ban->bannum. ')';
- }
+ my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref);
+ if ( $ban ) {
+ return 'Banned ACH account: banned on '.
+ time2str('%a %h %o at %r', $ban->_date).
+ ' by '. $ban->otaker.
+ ' (ban# '. $ban->bannum. ')';
}
} elsif ( $self->payby eq 'LECB' ) {
@@ -1955,7 +1720,6 @@ sub check {
} else {
return "Illegal expiration date: ". $self->paydate;
}
- $m = sprintf('%02d',$m);
$self->paydate("$y-$m-01");
my($nowm,$nowy)=(localtime(time))[4,5]; $nowm++; $nowy+=1900;
return gettext('expired_card')
@@ -1970,7 +1734,7 @@ sub check {
) {
$self->payname( $self->first. " ". $self->getfield('last') );
} else {
- $self->payname =~ /^([µ_0123456789aAáÁàÀâÂåÅäÄãêæÆbBcCçÇdDðÐeEéÉèÈêÊëËfFgGhHiIíÍìÌîÎïÏjJkKlLmMnNñÑoOóÓòÒôÔöÖõÕøغpPqQrRsSßtTuUúÚùÙûÛüÜvVwWxXyYýÝÿzZþÞ \,\.\-\'\&]+)$/
+ $self->payname =~ /^([\w \,\.\-\'\&]+)$/
or return gettext('illegal_name'). " payname: ". $self->payname;
$self->payname($1);
}
@@ -2015,10 +1779,22 @@ sub has_ship_address {
=item location_hash
Returns a list of key/value pairs, with the following keys: address1, adddress2,
-city, county, state, zip, country, and geocode. The shipping address is used if present.
+city, county, state, zip, country. The shipping address is used if present.
=cut
+#geocode? dependent on tax-ship_address config, not available in cust_location
+#mostly. not yet then.
+
+sub location_hash {
+ my $self = shift;
+ my $prefix = $self->has_ship_address ? 'ship_' : '';
+
+ map { $_ => $self->get($prefix.$_) }
+ qw( address1 address2 city county state zip country geocode );
+ #fields that cust_location has
+}
+
=item cust_location
Returns all locations (see L<FS::cust_location>) for this customer.
@@ -2030,6 +1806,61 @@ sub cust_location {
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
+=item location_label [ OPTION => VALUE ... ]
+
+Returns the label of the service location (see analog in L<FS::cust_location>) for this customer.
+
+Options are
+
+=over 4
+
+=item join_string
+
+used to separate the address elements (defaults to ', ')
+
+=item escape_function
+
+a callback used for escaping the text of the address elements
+
+=back
+
+=cut
+
+# false laziness with FS::cust_location::line
+
+sub location_label {
+ my $self = shift;
+ my %opt = @_;
+
+ my $separator = $opt{join_string} || ', ';
+ my $escape = $opt{escape_function} || sub{ shift };
+ my $line = '';
+ my $cydefault = FS::conf->new->config('countrydefault') || 'US';
+ my $prefix = length($self->ship_last) ? 'ship_' : '';
+
+ my $notfirst = 0;
+ foreach (qw ( address1 address2 ) ) {
+ my $method = "$prefix$_";
+ $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
+ if $self->$method;
+ $notfirst++;
+ }
+ $notfirst = 0;
+ foreach (qw ( city county state zip ) ) {
+ my $method = "$prefix$_";
+ if ( $self->$method ) {
+ $line .= ' (' if $method eq 'county';
+ $line .= ($notfirst ? ' ' : $separator). &$escape($self->$method);
+ $line .= ' )' if $method eq 'county';
+ $notfirst++;
+ }
+ }
+ $line .= $separator. &$escape(code2country($self->country))
+ if $self->country ne $cydefault;
+
+ $line;
+}
+
=item unsuspend
Unsuspends all unflagged suspended packages (see L</unflagged_suspended_pkgs>
@@ -2502,7 +2333,7 @@ sub total_owed_date {
AND _date <= $time
";
- sprintf( "%.2f", $self->scalar_sql($sql) || 0 );
+ sprintf( "%.2f", $self->scalar_sql($sql) );
}
@@ -2582,7 +2413,7 @@ sub total_unapplied_credits {
WHERE custnum = $custnum
";
- sprintf( "%.2f", $self->scalar_sql($sql) || 0 );
+ sprintf( "%.2f", $self->scalar_sql($sql) );
}
@@ -2620,7 +2451,7 @@ sub total_unapplied_payments {
WHERE custnum = $custnum
";
- sprintf( "%.2f", $self->scalar_sql($sql) || 0 );
+ sprintf( "%.2f", $self->scalar_sql($sql) );
}
@@ -2658,7 +2489,7 @@ sub total_unapplied_refunds {
WHERE custnum = $custnum
";
- sprintf( "%.2f", $self->scalar_sql($sql) || 0 );
+ sprintf( "%.2f", $self->scalar_sql($sql) );
}
@@ -2716,7 +2547,7 @@ sub balance_date_range {
my $self = shift;
my $sql = 'SELECT SUM('. $self->balance_date_sql(@_).
') FROM cust_main WHERE custnum='. $self->custnum;
- sprintf( '%.2f', $self->scalar_sql($sql) || 0 );
+ sprintf( '%.2f', $self->scalar_sql($sql) );
}
=item balance_pkgnum PKGNUM
@@ -3785,6 +3616,38 @@ Currently this only makes sense for "CCH" as DATA_VENDOR.
=cut
+sub geocode {
+ my ($self, $data_vendor) = (shift, shift); #always cch for now
+
+ my $geocode = $self->get('geocode'); #XXX only one data_vendor for geocode
+ return $geocode if $geocode;
+
+ my $prefix = ( $conf->exists('tax-ship_address') && length($self->ship_last) )
+ ? 'ship_'
+ : '';
+
+ my($zip,$plus4) = split /-/, $self->get("${prefix}zip")
+ if $self->country eq 'US';
+
+ $zip ||= '';
+ $plus4 ||= '';
+ #CCH specific location stuff
+ my $extra_sql = "AND plus4lo <= '$plus4' AND plus4hi >= '$plus4'";
+
+ my @cust_tax_location =
+ qsearch( {
+ 'table' => 'cust_tax_location',
+ 'hashref' => { 'zip' => $zip, 'data_vendor' => $data_vendor },
+ 'extra_sql' => $extra_sql,
+ 'order_by' => 'ORDER BY plus4hi',#overlapping with distinct ends
+ }
+ );
+ $geocode = $cust_tax_location[0]->geocode
+ if scalar(@cust_tax_location);
+
+ $geocode;
+}
+
=item cust_status
=item status
@@ -3813,6 +3676,7 @@ sub status { shift->cust_status(@_); }
sub cust_status {
my $self = shift;
+ # prospect ordered active inactive suspended cancelled
for my $status ( FS::cust_main->statuses() ) {
my $method = $status.'_sql';
my $numnum = ( my $sql = $self->$method() ) =~ s/cust_main\.custnum/?/g;
@@ -3849,9 +3713,9 @@ tie %statuscolor, 'Tie::IxHash',
'prospect' => '7e0079', #'000000', #black? naw, purple
'active' => '00CC00', #green
'ordered' => '009999', #teal? cyan?
+ 'inactive' => '0000CC', #blue
'suspended' => 'FF9900', #yellow
'cancelled' => 'FF0000', #red
- 'inactive' => '0000CC', #blue
;
sub statuscolor { shift->cust_statuscolor(@_); }
@@ -3958,24 +3822,6 @@ sub statuses {
keys %statuscolor;
}
-=item cust_status_sql
-
-Returns an SQL fragment to determine the status of a cust_main record, as a
-string.
-
-=cut
-
-sub cust_status_sql {
- my $sql = 'CASE';
- for my $status ( FS::cust_main->statuses() ) {
- my $method = $status.'_sql';
- $sql .= ' WHEN ('.FS::cust_main->$method.") THEN '$status'";
- }
- $sql .= ' END';
- return $sql;
-}
-
-
=item prospect_sql
Returns an SQL expression identifying prospective cust_main records (customers
@@ -4076,8 +3922,8 @@ sub cancel_sql {
AND 0 = ( $select_count_pkgs AND $recurring_sql
AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
)
+ AND 0 = ( $select_count_pkgs AND ". FS::cust_pkg->inactive_sql. " )
";
-# AND 0 = ( $select_count_pkgs AND ". FS::cust_pkg->inactive_sql. " )
}
@@ -4763,21 +4609,10 @@ sub process_bill_and_collect {
sub _upgrade_data { #class method
my ($class, %opts) = @_;
- my @statements = (
+ foreach my $sql (
'UPDATE h_cust_main SET paycvv = NULL WHERE paycvv IS NOT NULL',
- 'UPDATE cust_main SET signupdate = (SELECT signupdate FROM h_cust_main WHERE signupdate IS NOT NULL AND h_cust_main.custnum = cust_main.custnum ORDER BY historynum DESC LIMIT 1) WHERE signupdate IS NULL',
- );
- # fix yyyy-m-dd formatted paydates
- if ( driver_name =~ /^mysql$/i ) {
- push @statements,
- "UPDATE cust_main SET paydate = CONCAT( SUBSTRING(paydate FROM 1 FOR 5), '0', SUBSTRING(paydate FROM 6) ) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
- }
- else { # the SQL standard
- push @statements,
- "UPDATE cust_main SET paydate = SUBSTRING(paydate FROM 1 FOR 5) || '0' || SUBSTRING(paydate FROM 6) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
- }
-
- foreach my $sql ( @statements ) {
+ 'UPDATE cust_main SET signupdate = (SELECT signupdate FROM h_cust_main WHERE h_cust_main.custnum = cust_main.custnum ORDER BY historynum ASC LIMIT 1) WHERE signupdate IS NULL',
+ ) {
my $sth = dbh->prepare($sql) or die dbh->errstr;
$sth->execute or die $sth->errstr;
}
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index e004788..0cd304b 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -856,14 +856,15 @@ sub _make_lines {
my $recur = 0;
my $unitrecur = 0;
my $sdate;
- if ( ! $cust_pkg->start_date
- and ( ! $cust_pkg->susp || $part_pkg->option('suspend_bill') )
- and
- ( $part_pkg->freq ne '0' && ( $cust_pkg->bill || 0 ) <= $time )
- || ( $part_pkg->plan eq 'voip_cdr'
- && $part_pkg->option('bill_every_call')
- )
- || $options{cancel}
+ if ( ! $cust_pkg->get('susp')
+ and ! $cust_pkg->get('start_date')
+ and ( $part_pkg->getfield('freq') ne '0'
+ && ( $cust_pkg->getfield('bill') || 0 ) <= $time
+ )
+ || ( $part_pkg->plan eq 'voip_cdr'
+ && $part_pkg->option('bill_every_call')
+ )
+ || ( $options{cancel} )
) {
# XXX should this be a package event? probably. events are called
@@ -1047,14 +1048,18 @@ sub _handle_taxes {
)
{
+ if ( $conf->exists('tax-pkg_address') && $cust_pkg->locationnum ) {
+ return "fatal: Can't (yet) use tax-pkg_address with taxproducts";
+ }
+
foreach my $class (@classes) {
- my $err_or_ref = $self->_gather_taxes( $part_pkg, $class, $cust_pkg );
+ my $err_or_ref = $self->_gather_taxes( $part_pkg, $class );
return $err_or_ref unless ref($err_or_ref);
$taxes{$class} = $err_or_ref;
}
unless (exists $taxes{''}) {
- my $err_or_ref = $self->_gather_taxes( $part_pkg, '', $cust_pkg );
+ my $err_or_ref = $self->_gather_taxes( $part_pkg, '' );
return $err_or_ref unless ref($err_or_ref);
$taxes{''} = $err_or_ref;
}
@@ -1221,18 +1226,11 @@ sub _gather_taxes {
my $self = shift;
my $part_pkg = shift;
my $class = shift;
- my $cust_pkg = shift;
local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
- my $geocode;
- if ( $cust_pkg->locationnum && $conf->exists('tax-pkg_address') ) {
- $geocode = $cust_pkg->cust_location->geocode('cch');
- } else {
- $geocode = $self->geocode('cch');
- }
-
my @taxes = ();
+ my $geocode = $self->geocode('cch');
my @taxclassnums = map { $_->taxclassnum }
$part_pkg->part_pkg_taxoverride($class);
diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm
index ab7bde3..316ae37 100644
--- a/FS/FS/cust_main/Packages.pm
+++ b/FS/FS/cust_main/Packages.pm
@@ -385,21 +385,6 @@ sub unsuspended_pkgs {
grep { ! $_->susp } $self->ncancelled_pkgs;
}
-=item active_pkgs
-
-Returns all unsuspended (and uncancelled) packages (see L<FS::cust_pkg>) for
-this customer that are active (recurring).
-
-=cut
-
-sub active_pkgs {
- my $self = shift;
- grep { my $part_pkg = $_->part_pkg;
- $part_pkg->freq ne '' && $part_pkg->freq ne '0';
- }
- $self->unsuspended_pkgs;
-}
-
=item next_bill_date
Returns the next date this customer will be billed, as a UNIX timestamp, or
@@ -409,7 +394,7 @@ undef if no active package has a next bill date.
sub next_bill_date {
my $self = shift;
- min( map $_->get('bill'), grep $_->get('bill'), $self->active_pkgs );
+ min( map $_->get('bill'), grep $_->get('bill'), $self->unsuspended_pkgs );
}
=item num_cancelled_pkgs
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index ad24ff8..3813f89 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -203,7 +203,7 @@ sub smart_search {
} elsif ( ! $NameParse->parse($value) ) {
my %name = $NameParse->components;
- $first = $name{'given_name_1'} || $name{'initials_1'}; #wtf NameParse, Ed?
+ $first = $name{'given_name_1'};
$last = $name{'surname_1'};
}
@@ -422,8 +422,6 @@ HASHREF. Valid parameters are
=item status
-=item address
-
=item cancelled_pkgs
bool
@@ -490,19 +488,7 @@ sub search {
#push @where, $class->$method();
push @where, FS::cust_main->$method();
}
-
- ##
- # address
- ##
- if ( $params->{'address'} =~ /\S/ ) {
- my $address = dbh->quote('%'. lc($params->{'address'}). '%');
- push @where, '('. join(' OR ',
- map "LOWER($_) LIKE $address",
- qw(address1 address2 ship_address1 ship_address2)
- ).
- ')';
- }
-
+
##
# parse cancelled package checkbox
##
@@ -520,13 +506,6 @@ sub search {
if $params->{'no_censustract'};
##
- # parse with hardcoded tax location checkbox
- ##
-
- push @where, "geocode is not null"
- if $params->{'with_geocode'};
-
- ##
# dates
##
@@ -541,13 +520,11 @@ sub search {
"cust_main.$field >= $beginning",
"cust_main.$field <= $ending";
+ # XXX: do this for mysql and/or pull it out of here
if(defined $hour) {
- if ($dbh->{Driver}->{Name} =~ /Pg/i) {
+ if ($dbh->{Driver}->{Name} eq 'Pg') {
push @where, "extract(hour from to_timestamp(cust_main.$field)) = $hour";
}
- elsif( $dbh->{Driver}->{Name} =~ /mysql/i) {
- push @where, "hour(from_unixtime(cust_main.$field)) = $hour"
- }
else {
warn "search by time of day not supported on ".$dbh->{Driver}->{Name}." databases";
}
@@ -658,21 +635,6 @@ sub search {
push @where,
"cust_main.custbatch = '$1'";
}
-
- if ( $params->{'tagnum'} ) {
- my @tagnums = ref( $params->{'tagnum'} ) ? @{ $params->{'tagnum'} } : ( $params->{'tagnum'} );
-
- @tagnums = grep /^(\d+)$/, @tagnums;
-
- if ( @tagnums ) {
- my $tags_where = "0 < (select count(1) from cust_tag where "
- . " cust_tag.custnum = cust_main.custnum and tagnum in ("
- . join(',', @tagnums) . "))";
-
- push @where, $tags_where;
- }
- }
-
##
# setup queries, subs, etc. for the search
@@ -689,7 +651,7 @@ sub search {
my $count_query = "SELECT COUNT(*) FROM cust_main $extra_sql";
- my @select = (
+ my $select = join(', ',
'cust_main.custnum',
FS::UI::Web::cust_sql_fields($params->{'cust_fields'}),
);
@@ -701,10 +663,10 @@ sub search {
if ($dbh->{Driver}->{Name} eq 'Pg') {
- push @select, "array_to_string(array(select pkg from cust_pkg left join part_pkg using ( pkgpart ) where cust_main.custnum = cust_pkg.custnum $pkgwhere),'|') as magic";
+ $select .= ", array_to_string(array(select pkg from cust_pkg left join part_pkg using ( pkgpart ) where cust_main.custnum = cust_pkg.custnum $pkgwhere),'|') as magic";
}elsif ($dbh->{Driver}->{Name} =~ /^mysql/i) {
- push @select, "GROUP_CONCAT(pkg SEPARATOR '|') as magic";
+ $select .= ", GROUP_CONCAT(pkg SEPARATOR '|') as magic";
$addl_from .= " LEFT JOIN part_pkg using ( pkgpart )";
}else{
warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
@@ -728,21 +690,6 @@ sub search {
}
- if ( $params->{'with_geocode'} ) {
-
- unshift @extra_headers, 'Tax location override', 'Calculated tax location';
- unshift @extra_fields, sub { my $c = shift; $c->get('geocode'); },
- sub { my $c = shift;
- $c->set('geocode', '');
- $c->geocode('cch'); #XXX only cch right now
- };
- push @select, 'geocode';
- push @select, 'zip' unless grep { $_ eq 'zip' } @select;
- push @select, 'ship_zip' unless grep { $_ eq 'ship_zip' } @select;
- }
-
- my $select = join(', ', @select);
-
my $sql_query = {
'table' => 'cust_main',
'select' => $select,
diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm
index 8c8553c..b446d69 100644
--- a/FS/FS/cust_main_Mixin.pm
+++ b/FS/FS/cust_main_Mixin.pm
@@ -423,9 +423,7 @@ sub email_search_result {
my( $num, $last, $min_sec ) = (0, time, 5); #progresbar foo
my @retry_jobs = ();
- my $dups = 0;
my $success = 0;
- my %sent_to = ();
#eventually order+limit magic to reduce memory use?
foreach my $obj ( qsearch($sql_query) ) {
@@ -445,21 +443,9 @@ sub email_search_result {
if ( !$cust_main ) {
next; # unlinked object; nothing else we can do
}
-
- if( $sent_to{$cust_main->custnum} ) {
- # avoid duplicates
- $dups++;
- next;
- }
-
- $sent_to{$cust_main->custnum} = 1;
if ( $msg_template ) {
# XXX add support for other context objects?
- # If we do that, handling of "duplicates" will
- # have to be smarter. Currently we limit to
- # one message per custnum because they'd all
- # be identical.
@message = $msg_template->prepare( 'cust_main' => $cust_main );
}
else {
@@ -508,7 +494,7 @@ sub email_search_result {
if(@retry_jobs) {
# fail the job, but with a status message that makes it clear
# something was sent.
- return "Sent $success, skipped $dups duplicate(s), failed ".scalar(@retry_jobs).". Failed attempts placed in job queue.\n";
+ return "Sent $success, failed ".scalar(@retry_jobs).". Failed attempts placed in job queue.\n";
}
return '';
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 014affe..e0c99f8 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -264,36 +264,6 @@ sub insert {
}
#eslaf
- #bill setup fees for voip_cdr bill_every_call packages
- #some false laziness w/search in freeside-cdrd
- my $addl_from =
- 'LEFT JOIN part_pkg USING ( pkgpart ) '.
- "LEFT JOIN part_pkg_option
- ON ( cust_pkg.pkgpart = part_pkg_option.pkgpart
- AND part_pkg_option.optionname = 'bill_every_call' )";
-
- my $extra_sql = " AND plan = 'voip_cdr' AND optionvalue = '1' ".
- " AND ( cust_pkg.setup IS NULL OR cust_pkg.setup = 0 ) ";
-
- my @cust_pkg = qsearch({
- 'table' => 'cust_pkg',
- 'addl_from' => $addl_from,
- 'hashref' => { 'custnum' => $self->custnum,
- 'susp' => '',
- 'cancel' => '',
- },
- 'extra_sql' => $extra_sql,
- });
-
- if ( @cust_pkg ) {
- warn "voip_cdr bill_every_call packages found; billing customer\n";
- my $bill_error = $self->cust_main->bill_and_collect( 'fatal' => 'return' );
- if ( $bill_error ) {
- warn "WARNING: Error billing customer: $bill_error\n";
- }
- }
- #end of billing setup fees for voip_cdr bill_every_call packages
-
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
#payment receipt
@@ -431,17 +401,14 @@ sub delete {
}
-=item replace [ OLD_RECORD ]
+=item replace OLD_RECORD
You can, but probably shouldn't modify payments...
-Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not
-supplied, replaces this record. If there is an error, returns the error,
-otherwise returns false.
-
=cut
sub replace {
+ #return "Can't modify payment!"
my $self = shift;
return "Can't modify closed payment" if $self->closed =~ /^Y/i;
$self->SUPER::replace(@_);
@@ -833,10 +800,9 @@ sub _upgrade_data { #class method
my $h_cust_pay = $cust_pay->h_search('insert');
if ( $h_cust_pay ) {
next if $cust_pay->otaker eq $h_cust_pay->history_user;
- #$cust_pay->otaker($h_cust_pay->history_user);
- $cust_pay->set('otaker', $h_cust_pay->history_user);
+ $cust_pay->otaker($h_cust_pay->history_user);
} else {
- $cust_pay->set('otaker', 'legacy');
+ $cust_pay->otaker('legacy');
}
delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge
diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm
index 3a30acb..9293ef6 100644
--- a/FS/FS/cust_pay_void.pm
+++ b/FS/FS/cust_pay_void.pm
@@ -1,14 +1,12 @@
package FS::cust_pay_void;
use strict;
-use base qw( FS::otaker_Mixin FS::payinfo_Mixin FS::cust_main_Mixin
- FS::Record );
+use base qw( FS::otaker_Mixin FS::payinfo_Mixin FS::Record );
use vars qw( @encrypted_fields $otaker_upgrade_kludge );
use Business::CreditCard;
use FS::UID qw(getotaker);
-use FS::Record qw(qsearch qsearchs dbh fields);
+use FS::Record qw(qsearchs dbh fields); # qsearch );
use FS::CurrentUser;
-use FS::access_user;
use FS::cust_pay;
#use FS::cust_bill;
#use FS::cust_bill_pay;
@@ -157,13 +155,16 @@ sub unvoid {
Deletes this voided payment. You probably don't want to use this directly; see
the B<unvoid> method to add the original payment back.
-=item replace [ OLD_RECORD ]
+=item replace OLD_RECORD
-You can, but probably shouldn't modify voided payments...
+Currently unimplemented.
-Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not
-supplied, replaces this record. If there is an error, returns the error,
-otherwise returns false.
+=cut
+
+sub replace {
+ return "Can't modify voided payments!" unless $otaker_upgrade_kludge;
+ shift->SUPER::replace(@_);
+}
=item check
@@ -221,8 +222,7 @@ sub check {
return $error if $error;
}
- $self->void_usernum($FS::CurrentUser::CurrentUser->usernum)
- unless $self->void_usernum;
+ $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum;
$self->SUPER::check;
}
@@ -238,41 +238,11 @@ sub cust_main {
qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
}
-=item void_access_user
-
-Returns the voiding employee object (see L<FS::access_user>).
-
-=cut
-
-sub void_access_user {
- my $self = shift;
- qsearchs('access_user', { 'usernum' => $self->void_usernum } );
-}
-
# Used by FS::Upgrade to migrate to a new database.
sub _upgrade_data { # class method
my ($class, %opts) = @_;
-
- my $sql = "SELECT usernum FROM access_user WHERE username = ( SELECT history_user FROM h_cust_pay_void WHERE paynum = ? AND history_action = 'insert' ORDER BY history_date LIMIT 1 ) ";
- my $sth = dbh->prepare($sql) or die dbh->errstr;
-
- foreach my $cust_pay_void (qsearch('cust_pay_void', {'void_usernum' => ''})) {
- $sth->execute($cust_pay_void->paynum) or die $sth->errstr;
- my $usernum = $sth->fetchrow_arrayref->[0] or next;
- if ( $usernum ) {
- $cust_pay_void->void_usernum($usernum);
- my $error = $cust_pay_void->replace;
- die $error if $error;
- } else {
- warn "cust_pay_void upgrade: can't find access_user record for ". $cust_pay_void->paynum. "\n";
- }
- }
-
local($otaker_upgrade_kludge) = 1;
$class->_upgrade_otaker(%opts);
-
- #XXX look for the h_cust_pay delete records and when that's a different
- # usernum, set usernum
}
=back
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index ce5ee11..3e37ec9 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -153,10 +153,6 @@ date
date
-=item contract_end
-
-date
-
=item cancel
date
@@ -263,7 +259,7 @@ sub insert {
$self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) );
}
- foreach my $action ( qw(expire adjourn contract_end) ) {
+ foreach my $action ( qw(expire adjourn) ) {
my $months = $self->part_pkg->option("${action}_months",1);
if($months and !$self->$action) {
my $start = $self->start_date || $self->setup || time;
@@ -1118,7 +1114,7 @@ Options are:
=over 4
-=item locationnum
+=item locaitonnum
New locationnum, to change the location for this package.
@@ -1135,15 +1131,9 @@ New pkgpart (see L<FS::part_pkg>).
New refnum (see L<FS::part_referral>).
-=item keep_dates
-
-Set to true to transfer billing dates (start_date, setup, last_bill, bill,
-susp, adjourn, cancel, expire, and contract_end) to the new package.
-
=back
-At least one of locationnum, cust_location, pkgpart, refnum must be specified
-(otherwise, what's the point?)
+At least one option must be specified (otherwise, what's the point?)
Returns either the new FS::cust_pkg object or a scalar error.
@@ -1201,13 +1191,6 @@ sub change {
$opt->{'locationnum'} = $opt->{'cust_location'}->locationnum;
}
- if ( $opt->{'keep_dates'} ) {
- foreach my $date ( qw(setup bill last_bill susp adjourn cancel expire
- start_date contract_end ) ) {
- $hash{$date} = $self->getfield($date);
- }
- }
-
# Create the new package.
my $cust_pkg = new FS::cust_pkg {
custnum => $self->custnum,
@@ -1257,7 +1240,7 @@ sub change {
? ()
: ( 'null' => 1 )
)
- if $part_pkg->can('reset_usage') && ! $part_pkg->option('usage_rollover',1);
+ if $part_pkg->can('reset_usage') && ! $part_pkg->option('usage_rollover');
if ($error) {
$dbh->rollback if $oldAutoCommit;
@@ -1287,60 +1270,6 @@ sub change {
}
-use Data::Dumper;
-use Storable 'thaw';
-use MIME::Base64;
-sub process_bulk_cust_pkg {
- my $job = shift;
- my $param = thaw(decode_base64(shift));
- warn Dumper($param) if $DEBUG;
-
- my $old_part_pkg = qsearchs('part_pkg',
- { pkgpart => $param->{'old_pkgpart'} });
- my $new_part_pkg = qsearchs('part_pkg',
- { pkgpart => $param->{'new_pkgpart'} });
- die "Must select a new package type\n" unless $new_part_pkg;
- #my $keep_dates = $param->{'keep_dates'} || 0;
- my $keep_dates = 1; # there is no good reason to turn this off
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my @cust_pkgs = qsearch('cust_pkg', { 'pkgpart' => $param->{'old_pkgpart'} } );
-
- my $i = 0;
- foreach my $old_cust_pkg ( @cust_pkgs ) {
- $i++;
- $job->update_statustext(int(100*$i/(scalar @cust_pkgs)));
- if ( $old_cust_pkg->getfield('cancel') ) {
- warn '[process_bulk_cust_pkg ] skipping canceled pkgnum '.
- $old_cust_pkg->pkgnum."\n"
- if $DEBUG;
- next;
- }
- warn '[process_bulk_cust_pkg] changing pkgnum '.$old_cust_pkg->pkgnum."\n"
- if $DEBUG;
- my $error = $old_cust_pkg->change(
- 'pkgpart' => $param->{'new_pkgpart'},
- 'keep_dates' => $keep_dates
- );
- if ( !ref($error) ) { # change returns the cust_pkg on success
- $dbh->rollback;
- die "Error changing pkgnum ".$old_cust_pkg->pkgnum.": '$error'\n";
- }
- }
- $dbh->commit if $oldAutoCommit;
- return;
-}
-
=item last_bill
Returns the last bill date, or if there is no last bill date, the setup date.
@@ -1879,7 +1808,7 @@ Class method that returns the list of possible status strings for packages
=cut
tie my %statuscolor, 'Tie::IxHash',
- 'not yet billed' => '009999', #teal? cyan?
+ 'not yet billed' => '000000',
'one-time charge' => '000000',
'active' => '00CC00',
'suspended' => 'FF9900',
@@ -2609,22 +2538,6 @@ sub cancel_sql {
"cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0";
}
-=item status_sql
-
-Returns an SQL expression to give the package status as a string.
-
-=cut
-
-sub status_sql {
-"CASE
- WHEN cust_pkg.cancel IS NOT NULL THEN 'cancelled'
- WHEN cust_pkg.susp IS NOT NULL THEN 'suspended'
- WHEN cust_pkg.setup IS NULL THEN 'not yet billed'
- WHEN ".onetime_sql()." THEN 'one-time charge'
- ELSE 'active'
-END"
-}
-
=item search HASHREF
(Class method)
@@ -2893,7 +2806,7 @@ sub search {
"NOT (".FS::cust_pkg->onetime_sql . ")";
}
else {
- foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel )) {
+ foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
next unless exists($params->{$field});
@@ -3318,9 +3231,6 @@ sub bulk_change {
sub _upgrade_data { # class method
my ($class, %opts) = @_;
$class->_upgrade_otaker(%opts);
- my $sql =('UPDATE cust_pkg SET contract_end = NULL WHERE contract_end = -1');
- my $sth = dbh->prepare($sql);
- $sth->execute or die $sth->errstr;
}
=back
diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm
index 7df7a55..4086f0f 100644
--- a/FS/FS/cust_refund.pm
+++ b/FS/FS/cust_refund.pm
@@ -238,17 +238,12 @@ sub delete {
=item replace OLD_RECORD
-You can, but probably shouldn't modify refunds...
-
-Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not
-supplied, replaces this record. If there is an error, returns the error,
-otherwise returns false.
+Modifying a refund? Well, don't say I didn't warn you.
=cut
sub replace {
my $self = shift;
- return "Can't modify closed refund" if $self->closed =~ /^Y/i;
$self->SUPER::replace(@_);
}
diff --git a/FS/FS/domain_record.pm b/FS/FS/domain_record.pm
index 8d767d5..9f1eb53 100644
--- a/FS/FS/domain_record.pm
+++ b/FS/FS/domain_record.pm
@@ -440,7 +440,7 @@ sub reverse_record {
#http://en.wikipedia.org/wiki/List_of_DNS_record_types
#DHCID? other things?
sub rectypes {
- [ qw(SOA A AAAA CNAME MX NS PTR SPF SRV TXT), #most common types
+ [ qw(A AAAA CNAME MX NS PTR SPF SRV TXT), #most common types
#qw(DNAME), #uncommon types
qw(DLV DNSKEY DS NSEC NSEC3 NSEC3PARAM RRSIG), #DNSSEC types
];
diff --git a/FS/FS/geocode_Mixin.pm b/FS/FS/geocode_Mixin.pm
deleted file mode 100644
index c153914..0000000
--- a/FS/FS/geocode_Mixin.pm
+++ /dev/null
@@ -1,163 +0,0 @@
-package FS::geocode_Mixin;
-
-use strict;
-use vars qw( $DEBUG $me );
-use Carp;
-use Locale::Country;
-use FS::Record qw( qsearchs qsearch );
-use FS::Conf;
-use FS::cust_pkg;
-use FS::cust_location;
-use FS::cust_tax_location;
-use FS::part_pkg;
-
-$DEBUG = 0;
-$me = '[FS::geocode_Mixin]';
-
-=head1 NAME
-
-FS::geocode_Mixin - Mixin class for records that contain address and other
-location fields.
-
-=head1 SYNOPSIS
-
- package FS::some_table;
- use base ( FS::geocode_Mixin FS::Record );
-
-=head1 DESCRIPTION
-
-FS::geocode_Mixin - This is a mixin class for records that contain address
-and other location fields.
-
-=head1 METHODS
-
-=over 4
-
-=cut
-
-=item location_hash
-
-Returns a list of key/value pairs, with the following keys: address1, address2,
-city, county, state, zip, country. The shipping address is used if present.
-
-=cut
-
-#geocode dependent on tax-ship_address config
-
-sub location_hash {
- my $self = shift;
- my $prefix = $self->has_ship_address ? 'ship_' : '';
-
- map { my $method = ($_ eq 'geocode') ? $_ : $prefix.$_;
- $_ => $self->get($method);
- }
- qw( address1 address2 city county state zip country geocode );
-}
-
-=item location_label [ OPTION => VALUE ... ]
-
-Returns the label of the service location (see analog in L<FS::cust_location>) for this customer.
-
-Options are
-
-=over 4
-
-=item join_string
-
-used to separate the address elements (defaults to ', ')
-
-=item escape_function
-
-a callback used for escaping the text of the address elements
-
-=back
-
-=cut
-
-sub location_label {
- my $self = shift;
- my %opt = @_;
-
- my $separator = $opt{join_string} || ', ';
- my $escape = $opt{escape_function} || sub{ shift };
- my $ds = $opt{double_space} || ' ';
- my $line = '';
- my $cydefault =
- $opt{'countrydefault'} || FS::Conf->new->config('countrydefault') || 'US';
- my $prefix = $self->has_ship_address ? 'ship_' : '';
-
- my $notfirst = 0;
- foreach (qw ( address1 address2 ) ) {
- my $method = "$prefix$_";
- $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
- if $self->$method;
- $notfirst++;
- }
- $notfirst = 0;
- foreach (qw ( city county state zip ) ) {
- my $method = "$prefix$_";
- if ( $self->$method ) {
- $line .= ' (' if $method eq 'county';
- $line .= ($notfirst ? ' ' : $separator). &$escape($self->$method);
- $line .= ' )' if $method eq 'county';
- $notfirst++;
- }
- }
- $line .= $separator. &$escape(code2country($self->country))
- if $self->country ne $cydefault;
-
- $line;
-}
-
-=item geocode DATA_VENDOR
-
-Returns a value for the customer location as encoded by DATA_VENDOR.
-Currently this only makes sense for "CCH" as DATA_VENDOR.
-
-=cut
-
-sub geocode {
- my ($self, $data_vendor) = (shift, shift); #always cch for now
-
- my $geocode = $self->get('geocode'); #XXX only one data_vendor for geocode
- return $geocode if $geocode;
-
- my $prefix =
- ( FS::Conf->new->exists('tax-ship_address') && $self->has_ship_address )
- ? 'ship_'
- : '';
-
- my($zip,$plus4) = split /-/, $self->get("${prefix}zip")
- if $self->country eq 'US';
-
- $zip ||= '';
- $plus4 ||= '';
- #CCH specific location stuff
- my $extra_sql = "AND plus4lo <= '$plus4' AND plus4hi >= '$plus4'";
-
- my @cust_tax_location =
- qsearch( {
- 'table' => 'cust_tax_location',
- 'hashref' => { 'zip' => $zip, 'data_vendor' => $data_vendor },
- 'extra_sql' => $extra_sql,
- 'order_by' => 'ORDER BY plus4hi',#overlapping with distinct ends
- }
- );
- $geocode = $cust_tax_location[0]->geocode
- if scalar(@cust_tax_location);
-
- $geocode;
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 270eb1f..7321351 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -166,13 +166,7 @@ Customer object (required).
=item object
Additional context object (currently, can be a cust_main, cust_pkg,
-cust_bill, svc_acct, cust_pay, or cust_pay_pending). If the object
-is a svc_acct, its cust_pkg will be fetched and used for substitution.
-
-As a special case, this may be an arrayref of two objects. Both
-objects will be available for substitution, with their field names
-prefixed with 'new_' and 'old_' respectively. This is used in the
-rt_ticket export when exporting "replace" events.
+cust_bill, svc_acct, cust_pay, or cust_pay_pending object).
=item to
@@ -197,37 +191,15 @@ sub prepare {
# create substitution table
###
my %hash;
- my @objects = ($cust_main);
- my @prefixes = ('');
- my $svc;
- if( ref $object ) {
- if( ref($object) eq 'ARRAY' ) {
- # [new, old], for provisioning tickets
- push @objects, $object->[0], $object->[1];
- push @prefixes, 'new_', 'old_';
- $svc = $object->[0] if $object->[0]->isa('FS::svc_Common');
- }
- else {
- push @objects, $object;
- push @prefixes, '';
- $svc = $object if $object->isa('FS::svc_Common');
- }
- }
- if( $svc ) {
- push @objects, $svc->cust_svc->cust_pkg;
- push @prefixes, '';
- }
-
- foreach my $obj (@objects) {
- my $prefix = shift @prefixes;
+ foreach my $obj ($cust_main, $object || ()) {
foreach my $name (@{ $subs->{$obj->table} }) {
if(!ref($name)) {
# simple case
- $hash{$prefix.$name} = $obj->$name();
+ $hash{$name} = $obj->$name();
}
elsif( ref($name) eq 'ARRAY' ) {
# [ foo => sub { ... } ]
- $hash{$prefix.($name->[0])} = $name->[1]->($obj);
+ $hash{$name->[0]} = $name->[1]->($obj);
}
else {
warn "bad msg_template substitution: '$name'\n";
@@ -368,7 +340,7 @@ sub substitutions {
],
# next_bill_date
'cust_pkg' => [qw(
- pkgnum pkg pkg_label pkg_label_long
+ pkgnum pkg_label pkg_label_long
location_label
status statuscolor
@@ -394,9 +366,7 @@ sub substitutions {
# for welcome and limit warning messages
'svc_acct' => [qw(
- svcnum
username
- domain
),
[ password => sub { shift->getfield('_password') } ],
],
diff --git a/FS/FS/option_Common.pm b/FS/FS/option_Common.pm
index 26bb7ca..a786ae3 100644
--- a/FS/FS/option_Common.pm
+++ b/FS/FS/option_Common.pm
@@ -173,15 +173,10 @@ sub replace {
? shift
: $self->replace_old;
- my $options;
- my $options_supplied = 0;
- if ( ref($_[0]) eq 'HASH' ) {
- $options = shift;
- $options_supplied = 1;
- } else {
- $options = { @_ };
- $options_supplied = scalar(@_) ? 1 : 0;
- }
+ my $options =
+ ( ref($_[0]) eq 'HASH' )
+ ? shift
+ : { @_ };
warn "FS::option_Common::replace called on $self with options ".
join(', ', map "$_ => ". $options->{$_}, keys %$options)
@@ -257,15 +252,13 @@ sub replace {
}
#remove extraneous old options
- if ( $options_supplied ) {
- foreach my $opt (
- grep { !exists $options->{$_->$namecol()} } $old->option_objects
- ) {
- my $error = $opt->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
+ foreach my $opt (
+ grep { !exists $options->{$_->$namecol()} } $old->option_objects
+ ) {
+ my $error = $opt->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
}
}
diff --git a/FS/FS/part_event/Condition/cust_status.pm b/FS/FS/part_event/Condition/cust_status.pm
index 066ee48..fbdff25 100644
--- a/FS/FS/part_event/Condition/cust_status.pm
+++ b/FS/FS/part_event/Condition/cust_status.pm
@@ -29,12 +29,4 @@ sub condition {
$hashref->{ $cust_main->status };
}
-sub condition_sql {
- my( $self, $table ) = @_;
-
- '('.FS::cust_main->cust_status_sql . ') IN '.
- $self->condition_sql_option_option('status');
-}
-
-
1;
diff --git a/FS/FS/part_event/Condition/has_referral_custnum.pm b/FS/FS/part_event/Condition/has_referral_custnum.pm
index 70c9c7f..61a8155 100644
--- a/FS/FS/part_event/Condition/has_referral_custnum.pm
+++ b/FS/FS/part_event/Condition/has_referral_custnum.pm
@@ -38,13 +38,11 @@ sub condition {
}
sub condition_sql {
- my( $class, $table ) = @_;
+ #my( $class, $table ) = @_;
- my $sql = FS::cust_main->active_sql;
- $sql =~ s/cust_main.custnum/cust_main.referral_custnum/;
- $sql = 'cust_main.referral_custnum IS NOT NULL AND ('.
- $class->condition_sql_option('active') . ' IS NULL OR '.$sql.')';
- return $sql;
+ "cust_main.referral_custnum IS NOT NULL";
+
+ #XXX a bit harder to check active status here
}
1;
diff --git a/FS/FS/part_event/Condition/pkg_age.pm b/FS/FS/part_event/Condition/pkg_age.pm
index 4a85387..8b3b4c9 100644
--- a/FS/FS/part_event/Condition/pkg_age.pm
+++ b/FS/FS/part_event/Condition/pkg_age.pm
@@ -49,18 +49,10 @@ sub condition {
}
-sub condition_sql {
- my( $class, $table, %opt ) = @_;
- my $age = $class->condition_sql_option_age_from('age', $opt{'time'});
- my $field = $class->condition_sql_option('field');
-#amazingly, this is actually faster
- my $sql = '( CASE';
- foreach( qw(setup last_bill bill adjourn susp expire cancel) ) {
- $sql .= " WHEN $field = '$_' THEN (cust_pkg.$_ IS NOT NULL AND cust_pkg.$_ <= $age)";
- }
- $sql .= ' END )';
- return $sql;
-}
+#XXX write me for efficiency
+#sub condition_sql {
+#
+#}
1;
diff --git a/FS/FS/part_event/Condition/pkg_recurring.pm b/FS/FS/part_event/Condition/pkg_recurring.pm
index 1a08869..1b66821 100644
--- a/FS/FS/part_event/Condition/pkg_recurring.pm
+++ b/FS/FS/part_event/Condition/pkg_recurring.pm
@@ -20,9 +20,12 @@ sub condition {
}
-sub condition_sql {
- FS::cust_pkg->recurring_sql()
-}
+
+#XXX join part_pkg USING (pkgpart)
+# part_pkg.freq != '0'
+#sub condition_sql {
+#
+#}
1;
diff --git a/FS/FS/part_event/Condition/pkg_status.pm b/FS/FS/part_event/Condition/pkg_status.pm
index 3fb374e..6c1c9cc 100644
--- a/FS/FS/part_event/Condition/pkg_status.pm
+++ b/FS/FS/part_event/Condition/pkg_status.pm
@@ -34,11 +34,4 @@ sub condition {
$hashref->{ $cust_pkg->status };
}
-sub condition_sql {
- my( $self, $table ) = @_;
-
- '('.FS::cust_pkg->status_sql . ') IN '.
- $self->condition_sql_option_option('status');
-}
-
1;
diff --git a/FS/FS/part_export/acct_http.pm b/FS/FS/part_export/acct_http.pm
deleted file mode 100644
index b4c64ac..0000000
--- a/FS/FS/part_export/acct_http.pm
+++ /dev/null
@@ -1,63 +0,0 @@
-package FS::part_export::acct_http;
-
-use vars qw( @ISA %info );
-use FS::part_export::http;
-use Tie::IxHash;
-
-@ISA = qw( FS::part_export::http );
-
-tie %options, 'Tie::IxHash',
- 'method' => { label =>'Method',
- type =>'select',
- #options =>[qw(POST GET)],
- options =>[qw(POST)],
- default =>'POST' },
- 'url' => { label => 'URL', default => 'http://', },
- 'insert_data' => {
- label => 'Insert data',
- type => 'textarea',
- default => join("\n",
- "action 'add'",
- "username \$svc_x->username",
- "password \$svc_x->_password",
- "prismid \$cust_main->agent_custid ? \$cust_main->agent_custid : \$cust_main->custnum ",
- "name \$cust_main->first.' '.\$cust_main->last",
- ),
- },
- 'delete_data' => {
- label => 'Delete data',
- type => 'textarea',
- default => join("\n",
- "action 'remove'",
- "username \$svc_x->username",
- ),
- },
- 'replace_data' => {
- label => 'Replace data',
- type => 'textarea',
- default => join("\n",
- "action 'update'",
- "username \$old->username",
- "password \$new->_password",
- ),
- },
- 'success_regexp' => {
- label => 'Success Regexp',
- default => '',
- },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Send an HTTP or HTTPS GET or POST request, for accounts.',
- 'options' => \%options,
- 'notes' => <<'END'
-Send an HTTP or HTTPS GET or POST to the specified URL on account addition,
-modification and deletion. For HTTPS support,
-<a href="http://search.cpan.org/dist/Crypt-SSLeay">Crypt::SSLeay</a>
-or <a href="http://search.cpan.org/dist/IO-Socket-SSL">IO::Socket::SSL</a>
-is required.
-END
-);
-
-1;
diff --git a/FS/FS/part_export/cust_http.pm b/FS/FS/part_export/cust_http.pm
index e8b677b..59503e8 100644
--- a/FS/FS/part_export/cust_http.pm
+++ b/FS/FS/part_export/cust_http.pm
@@ -6,50 +6,28 @@ use Tie::IxHash;
@ISA = qw( FS::part_export::http );
-tie %options, 'Tie::IxHash',
- 'method' => { label =>'Method',
- type =>'select',
- #options =>[qw(POST GET)],
- options =>[qw(POST)],
- default =>'POST' },
- 'url' => { label => 'URL', default => 'http://', },
- 'insert_data' => {
- label => 'Insert data',
- type => 'textarea',
- default => join("\n",
- "action 'insert'",
- "custnum \$cust_main->custnum",
- "first \$cust_main->first",
- "last \$cust_main->get('last')",
- ( map "$_ \$cust_main->$_", qw( company address1 address2 city county state zip country daytime night fax last ) ),
- "email \$cust_main->invoicing_list_emailonly_scalar",
- ),
- },
- 'delete_data' => {
- label => 'Delete data',
- type => 'textarea',
- default => join("\n",
- "action 'delete'",
- "custnum \$cust_main->custnum",
- ),
- },
- 'replace_data' => {
- label => 'Replace data',
- type => 'textarea',
- default => join("\n",
- "action 'replace'",
- "custnum \$new_cust_main->custnum",
- "first \$new_cust_main->first",
- "last \$new_cust_main->get('last')",
- ( map "$_ \$cust_main->$_", qw( company address1 address2 city county state zip country daytime night fax last ) ),
- "email \$new_cust_main->invoicing_list_emailonly_scalar",
- ),
- },
- 'success_regexp' => {
- label => 'Success Regexp',
- default => '',
- },
-;
+tie my %options, 'Tie::IxHash', %FS::part_export::http::options;
+
+$options{'insert_data'}->{'default'} = join("\n",
+ "action 'insert'",
+ "custnum \$cust_main->custnum",
+ "first \$cust_main->first",
+ "last \$cust_main->get('last')",
+ ( map "$_ \$cust_main->$_", qw( company address1 address2 city county state zip country daytime night fax last ) ),
+ "email \$cust_main->invoicing_list_emailonly_scalar",
+);
+$options{'delete_data'}->{'default'} = join("\n",
+ "action 'delete'",
+ "custnum \$cust_main->custnum",
+);
+$options{'replace_data'}->{'default'} = join("\n",
+ "action 'replace'",
+ "custnum \$new_cust_main->custnum",
+ "first \$new_cust_main->first",
+ "last \$new_cust_main->get('last')",
+ ( map "$_ \$cust_main->$_", qw( company address1 address2 city county state zip country daytime night fax last ) ),
+ "email \$new_cust_main->invoicing_list_emailonly_scalar",
+);
%info = (
'svc' => 'cust_main',
diff --git a/FS/FS/part_export/http.pm b/FS/FS/part_export/http.pm
index 3749224..e5e5a5c 100644
--- a/FS/FS/part_export/http.pm
+++ b/FS/FS/part_export/http.pm
@@ -33,10 +33,6 @@ tie %options, 'Tie::IxHash',
default => join("\n",
),
},
- 'success_regexp' => {
- label => 'Success Regexp',
- default => '',
- },
;
%info = (
@@ -75,7 +71,6 @@ sub _export_command {
$self->http_queue( $svc_x->svcnum,
$self->option('method'),
$self->option('url'),
- $self->option('success_regexp'),
map {
/^\s*(\S+)\s+(.*)$/ or /()()/;
my( $field, $value_expression ) = ( $1, $2 );
@@ -100,7 +95,6 @@ sub _export_replace {
$self->http_queue( $new->svcnum,
$self->option('method'),
$self->option('url'),
- $self->option('success_regexp'),
map {
/^\s*(\S+)\s+(.*)$/ or /()()/;
my( $field, $value_expression ) = ( $1, $2 );
@@ -120,7 +114,7 @@ sub http_queue {
}
sub http {
- my($method, $url, $success_regexp, @data) = @_;
+ my($method, $url, @data) = @_;
$method = lc($method);
@@ -140,11 +134,6 @@ sub http {
die $response->error_as_HTML if $response->is_error;
- if(length($success_regexp) > 1) {
- my $response_content = $response->content;
- die $response_content unless $response_content =~ /$success_regexp/;
- }
-
}
1;
diff --git a/FS/FS/part_export/rt_ticket.pm b/FS/FS/part_export/rt_ticket.pm
deleted file mode 100644
index 13a0367..0000000
--- a/FS/FS/part_export/rt_ticket.pm
+++ /dev/null
@@ -1,214 +0,0 @@
-package FS::part_export::rt_ticket;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-use FS::Record qw(qsearch qsearchs);
-use FS::Conf;
-use FS::TicketSystem;
-
-@ISA = qw(FS::part_export);
-
-my %templates;
-my %queues;
-my %template_select = (
- type => 'select',
- freeform => 1,
- option_label => sub {
- $templates{$_[0]};
- },
- option_values => sub {
- %templates = (0 => '',
- map { $_->msgnum, $_->msgname }
- qsearch({ table => 'msg_template',
- hashref => {},
- order_by => 'ORDER BY msgnum ASC'
- })
- );
- sort keys (%templates);
- },
-);
-
-my %queue_select = (
- type => 'select',
- freeform => 1,
- option_label => sub {
- $queues{$_[0]};
- },
- option_values => sub {
- %queues = (0 => '', FS::TicketSystem->queues());
- sort {$queues{$a} cmp $queues{$b}} keys %queues;
- },
-);
-
-tie my %options, 'Tie::IxHash', (
- 'insert_queue' => {
- before => '
-<TR><TD COLSPAN=2>
-<TABLE>
- <TR><TH></TH><TH>Queue</TH><TH>Template</TH></TR>
- <TR><TD>New service</TD><TD>',
- %queue_select,
- after => '</TD>'
- },
- 'insert_template' => {
- before => '<TD>',
- %template_select,
- after => '</TD></TR>
-',
- },
- 'delete_queue' => {
- before => '
- <TR><TD>Delete</TD><TD>',
- %queue_select,
- after => '</TD>',
- },
- 'delete_template' => {
- before => '<TD>',
- %template_select,
- after => '</TD></TR>
-',
- },
- 'replace_queue' => {
- before => '
- <TR><TD>Modify</TD><TD>',
- %queue_select,
- after => '</TD>',
- },
- 'replace_template' => {
- before => '<TD>',
- %template_select,
- after => '</TD></TR>
-',
- },
- 'suspend_queue' => {
- before => '
- <TR><TD>Suspend</TD><TD>',
- %queue_select,
- after => '</TD>',
- },
- 'suspend_template' => {
- before => '<TD>',
- %template_select,
- after => '</TD></TR>
-',
- },
- 'unsuspend_queue' => {
- before => '
- <TR><TD>Unsuspend</TD><TD>',
- %queue_select,
- after => '</TD>',
- },
- 'unsuspend_template' => {
- before => '<TD>',
- %template_select,
- after => '</TD></TR>
- </TABLE>
-</TD></TR>',
- },
- 'requestor' => {
- freeform => 0,
- label => 'Requestor',
- 'type' => 'select',
- option_label => sub {
- my @labels = (
- 'Template From: address',
- 'Customer\'s invoice address',
- );
- $labels[shift];
- },
- option_values => sub { (0, 1) },
- },
-);
-
-%info = (
- 'svc' => [qw( svc_acct )], #others?
- 'desc' =>
- 'Create an RT ticket',
- 'options' => \%options,
- 'nodomain' => '',
- 'notes' => <<'END'
-Create a ticket in RT. The subject and body of the ticket
-will be generated from a message template.
-END
-);
-
-sub _export_ticket {
- my( $self, $action, $svc ) = (shift, shift, shift);
- my $msgnum = $self->option($action.'_template');
- return if !$msgnum;
-
- my $queue = $self->option($action.'_queue');
- return if !$queue;
-
- my $msg_template = FS::msg_template->by_key($msgnum);
- return "Template $msgnum not found\n" if !$msg_template;
-
- my $cust_pkg = $svc->cust_svc->cust_pkg;
- my $cust_main = $svc->cust_svc->cust_pkg->cust_main if $cust_pkg;
- my $custnum = $cust_main->custnum if $cust_main;
- my $svcnum = $svc->svcnum if $action ne 'delete';
-
- my %msg;
- if ( $action eq 'replace' ) {
- my $old = shift;
- %msg = $msg_template->prepare(
- 'cust_main' => $cust_main,
- 'object' => [ $svc, $old ],
- );
-
- }
- else {
- %msg = $msg_template->prepare(
- 'cust_main' => $cust_main,
- 'object' => $svc,
- );
- }
- my $requestor = $msg{'from'};
- $requestor = [ $cust_main->invoicing_list_emailonly ]
- if $cust_main and $self->option('requestor') == 1;
-
- my $err_or_ticket = FS::TicketSystem->create_ticket(
- '', #session should already exist
- 'queue' => $queue,
- 'subject' => $msg{'subject'},
- 'requestor' => $requestor,
- 'message' => $msg{'html_body'},
- 'mime_type' => 'text/html',
- 'custnum' => $custnum,
- 'svcnum' => $svcnum,
- );
- if( ref($err_or_ticket) ) {
- return '';
- }
- else {
- return $err_or_ticket;
- }
-}
-
-sub _export_insert {
- my($self, $svc) = (shift, shift);
- $self->_export_ticket('insert', $svc);
-}
-
-sub _export_replace {
- my($self, $new, $old) = (shift, shift, shift);
- $self->_export_ticket('replace', $new, $old);
-}
-
-sub _export_delete {
- my($self, $svc) = (shift, shift);
- $self->_export_ticket('delete', $svc);
-}
-
-sub _export_suspend {
- my($self, $svc) = (shift, shift);
- $self->_export_ticket('suspend', $svc);
-}
-
-sub _export_unsuspend {
- my($self, $svc) = (shift, shift);
- $self->_export_ticket('unsuspend', $svc);
-}
-
-1;
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index 15aa986..f1ba3d2 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -18,10 +18,6 @@ tie %options, 'Tie::IxHash',
'datasrc' => { label=>'DBI data source ' },
'username' => { label=>'Database username' },
'password' => { label=>'Database password' },
- 'usergroup' => { label => 'Group table',
- type => 'select',
- options => [qw( usergroup radusergroup ) ],
- },
'ignore_accounting' => {
type => 'checkbox',
label => 'Ignore accounting records from this database'
@@ -56,7 +52,7 @@ tie %options, 'Tie::IxHash',
;
$notes1 = <<'END';
-Real-time export of <b>radcheck</b>, <b>radreply</b> and <b>usergroup</b>/<b>radusergroup</b>
+Real-time export of <b>radcheck</b>, <b>radreply</b> and <b>usergroup</b>
tables to any SQL database for
<a href="http://www.freeradius.org/">FreeRADIUS</a>
or <a href="http://radius.innercite.com/">ICRADIUS</a>.
@@ -125,10 +121,9 @@ sub _export_insert {
cluck localtime(). ": queuing usergroup_insert for ". $svc_x->svcnum.
" (". $self->export_username($svc_x). " with ". join(", ", @groups)
if $DEBUG;
- my $usergroup = $self->option('usergroup') || 'usergroup';
my $err_or_queue = $self->sqlradius_queue(
$svc_x->svcnum, 'usergroup_insert',
- $self->export_username($svc_x), $usergroup, @groups );
+ $self->export_username($svc_x), @groups );
return $err_or_queue unless ref($err_or_queue);
}
'';
@@ -150,9 +145,8 @@ sub _export_replace {
my $jobnum = '';
if ( $self->export_username($old) ne $self->export_username($new) ) {
- my $usergroup = $self->option('usergroup') || 'usergroup';
my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'rename',
- $self->export_username($new), $self->export_username($old), $usergroup );
+ $self->export_username($new), $self->export_username($old) );
unless ( ref($err_or_queue) ) {
$dbh->rollback if $oldAutoCommit;
return $err_or_queue;
@@ -301,9 +295,8 @@ sub _export_unsuspend {
sub _export_delete {
my( $self, $svc_x ) = (shift, shift);
- my $usergroup = $self->option('usergroup') || 'usergroup';
my $err_or_queue = $self->sqlradius_queue( $svc_x->svcnum, 'delete',
- $self->export_username($svc_x), $usergroup );
+ $self->export_username($svc_x) );
ref($err_or_queue) ? '' : $err_or_queue;
}
@@ -394,16 +387,14 @@ sub sqlradius_insert { #subroutine, not method
sub sqlradius_usergroup_insert { #subroutine, not method
my $dbh = sqlradius_connect(shift, shift, shift);
- my $username = shift;
- my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup';
- my @groups = @_;
+ my( $username, @groups ) = @_;
my $s_sth = $dbh->prepare(
- "SELECT COUNT(*) FROM $usergroup WHERE UserName = ? AND GroupName = ?"
+ "SELECT COUNT(*) FROM usergroup WHERE UserName = ? AND GroupName = ?"
) or die $dbh->errstr;
my $sth = $dbh->prepare(
- "INSERT INTO $usergroup ( UserName, GroupName ) VALUES ( ?, ? )"
+ "INSERT INTO usergroup ( UserName, GroupName ) VALUES ( ?, ? )"
) or die $dbh->errstr;
foreach my $group ( @groups ) {
@@ -430,12 +421,10 @@ sub sqlradius_usergroup_insert { #subroutine, not method
sub sqlradius_usergroup_delete { #subroutine, not method
my $dbh = sqlradius_connect(shift, shift, shift);
- my $username = shift;
- my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup';
- my @groups = @_;
+ my( $username, @groups ) = @_;
my $sth = $dbh->prepare(
- "DELETE FROM $usergroup WHERE UserName = ? AND GroupName = ?"
+ "DELETE FROM usergroup WHERE UserName = ? AND GroupName = ?"
) or die $dbh->errstr;
foreach my $group ( @groups ) {
$sth->execute( $username, $group )
@@ -446,9 +435,8 @@ sub sqlradius_usergroup_delete { #subroutine, not method
sub sqlradius_rename { #subroutine, not method
my $dbh = sqlradius_connect(shift, shift, shift);
- my($new_username, $old_username) = (shift, shift);
- my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup';
- foreach my $table (qw(radreply radcheck), $usergroup ) {
+ my($new_username, $old_username) = @_;
+ foreach my $table (qw(radreply radcheck usergroup )) {
my $sth = $dbh->prepare("UPDATE $table SET Username = ? WHERE UserName = ?")
or die $dbh->errstr;
$sth->execute($new_username, $old_username)
@@ -474,9 +462,8 @@ sub sqlradius_attrib_delete { #subroutine, not method
sub sqlradius_delete { #subroutine, not method
my $dbh = sqlradius_connect(shift, shift, shift);
my $username = shift;
- my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup';
- foreach my $table (qw( radcheck radreply), $usergroup ) {
+ foreach my $table (qw( radcheck radreply usergroup )) {
my $sth = $dbh->prepare( "DELETE FROM $table WHERE UserName = ?" );
$sth->execute($username)
or die "can't delete from $table table: ". $sth->errstr;
@@ -505,11 +492,9 @@ sub sqlreplace_usergroups {
push @delgroups, $oldgroup;
}
- my $usergroup = $self->option('usergroup') || 'usergroup';
-
if ( @delgroups ) {
my $err_or_queue = $self->sqlradius_queue( $svcnum, 'usergroup_delete',
- $username, $usergroup, @delgroups );
+ $username, @delgroups );
return $err_or_queue
unless ref($err_or_queue);
if ( $jobnum ) {
@@ -523,7 +508,7 @@ sub sqlreplace_usergroups {
"with ". join(", ", @newgroups)
if $DEBUG;
my $err_or_queue = $self->sqlradius_queue( $svcnum, 'usergroup_insert',
- $username, $usergroup, @newgroups );
+ $username, @newgroups );
return $err_or_queue
unless ref($err_or_queue);
if ( $jobnum ) {
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index a073cf2..85269c5 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -941,8 +941,6 @@ sub _part_pkg_link {
qsearch({ table => 'part_pkg_link',
hashref => { 'src_pkgpart' => $self->pkgpart,
'link_type' => $type,
- #protection against infinite recursive links
- 'dst_pkgpart' => { op=>'!=', value=> $self->pkgpart },
},
order_by => "ORDER BY hidden",
});
diff --git a/FS/FS/part_pkg/agent.pm b/FS/FS/part_pkg/agent.pm
index 69ecf77..e5bd163 100644
--- a/FS/FS/part_pkg/agent.pm
+++ b/FS/FS/part_pkg/agent.pm
@@ -38,10 +38,6 @@ $me = '[FS::part_pkg::agent]';
'cutoff_day' => { 'name' => 'Billing Day (1 - 28)',
'default' => '1',
},
- 'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
- 'for one full period after that',
- 'type' => 'checkbox',
- },
'no_pkg_prorate' => { 'name' => 'Disable prorating bulk packages (charge full price for packages active only a portion of the month)',
'type' => 'checkbox',
@@ -50,7 +46,7 @@ $me = '[FS::part_pkg::agent]';
},
#'fieldorder' => [qw( setup_fee recur_fee recur_method cutoff_day ) ],
- 'fieldorder' => [qw( setup_fee recur_fee cutoff_day add_full_period no_pkg_prorate ) ],
+ 'fieldorder' => [qw( setup_fee recur_fee cutoff_day no_pkg_prorate ) ],
'weight' => 51,
diff --git a/FS/FS/part_pkg/bulk.pm b/FS/FS/part_pkg/bulk.pm
index b28fd30..69fe98e 100644
--- a/FS/FS/part_pkg/bulk.pm
+++ b/FS/FS/part_pkg/bulk.pm
@@ -7,7 +7,7 @@ use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
-$DEBUG = 0;
+$DEBUG = 1;
$me = '[FS::part_pkg::bulk]';
%info = (
@@ -29,17 +29,9 @@ $me = '[FS::part_pkg::bulk]';
' of service at cancellation',
'type' => 'checkbox',
},
- 'summarize_svcs'=> { 'name' => 'Show a count of services on the invoice, '.
- 'instead of a detailed list',
- 'type' => 'checkbox',
- },
- 'no_prorate' => { 'name' => 'Don\'t prorate recurring fees on services '.
- 'active for a partial month',
- 'type' => 'checkbox',
- },
},
'fieldorder' => [ 'setup_fee', 'recur_fee', 'svc_setup_fee', 'svc_recur_fee',
- 'unused_credit', 'summarize_svcs', 'no_prorate' ],
+ 'unused_credit', ],
'weight' => 50,
);
@@ -58,11 +50,6 @@ sub calc_recur {
unless $$sdate > $last_bill;
my $total_svc_charge = 0;
- my %n_setup = ();
- my %n_recur = ();
- my %part_svc_label = ();
-
- my $summarize = $self->option('summarize_svcs',1);
warn "$me billing for bulk services from ". time2str('%x', $last_bill).
" to ". time2str('%x', $$sdate). "\n"
@@ -74,7 +61,6 @@ sub calc_recur {
my @label = $h_cust_svc->label_long( $$sdate, $last_bill );
die "fatal: no historical label found, wtf?" unless scalar(@label); #?
my $svc_details = $label[0]. ': '. $label[1]. ': ';
- $part_svc_label{$h_cust_svc->svcpart} ||= $label[0];
my $svc_charge = 0;
@@ -84,21 +70,14 @@ sub calc_recur {
} elsif ( $svc_setup_fee ) {
$svc_charge += $svc_setup_fee;
$svc_details .= $money_char. sprintf('%.2f setup, ', $svc_setup_fee);
- $n_setup{$h_cust_svc->svcpart}++;
}
my $svc_end = $h_cust_svc->date_deleted;
$svc_end = ( !$svc_end || $svc_end > $$sdate ) ? $$sdate : $svc_end;
- my $recur_charge;
- if ( $self->option('no_prorate',1) ) {
- $recur_charge = $self->option('svc_recur_fee');
- }
- else {
- $recur_charge = $self->option('svc_recur_fee')
- * ( $svc_end - $svc_start )
+ my $recur_charge =
+ $self->option('svc_recur_fee') * ( $svc_end - $svc_start )
/ ( $$sdate - $last_bill );
- }
$svc_details .= $money_char. sprintf('%.2f', $recur_charge ).
' ('. time2str('%x', $svc_start).
@@ -106,21 +85,11 @@ sub calc_recur {
if $recur_charge;
$svc_charge += $recur_charge;
- $n_recur{$h_cust_svc->svcpart}++;
- push @$details, $svc_details if !$summarize;
+
+ push @$details, $svc_details;
$total_svc_charge += $svc_charge;
}
- if ( $summarize ) {
- foreach my $svcpart (keys %part_svc_label) {
- push @$details, sprintf('Setup fee: %d @ '.$money_char.'%.2f',
- $n_setup{$svcpart}, $svc_setup_fee )
- if $svc_setup_fee and $n_setup{$svcpart};
- push @$details, sprintf('%d services @ '.$money_char.'%.2f',
- $n_recur{$svcpart}, $self->option('svc_recur_fee') )
- if $n_recur{$svcpart};
- }
- }
sprintf('%.2f', $self->base_recur($cust_pkg) + $total_svc_charge );
}
diff --git a/FS/FS/part_pkg/cdr_termination.pm b/FS/FS/part_pkg/cdr_termination.pm
index 0666d79..cfd6b4e 100644
--- a/FS/FS/part_pkg/cdr_termination.pm
+++ b/FS/FS/part_pkg/cdr_termination.pm
@@ -58,10 +58,6 @@ tie my %temporalities, 'Tie::IxHash',
'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',
@@ -94,7 +90,6 @@ tie my %temporalities, 'Tie::IxHash',
'fieldorder' => [qw(
setup_fee recur_fee
recur_temporality unused_credit recur_method cutoff_day
- add_full_period
output_format usage_section summarize_usage usage_mandate
)
],
diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm
deleted file mode 100644
index df65e97..0000000
--- a/FS/FS/part_pkg/discount_Mixin.pm
+++ /dev/null
@@ -1,128 +0,0 @@
-package FS::part_pkg::discount_Mixin;
-
-use strict;
-use vars qw(@ISA %info);
-use FS::part_pkg;
-use FS::cust_pkg;
-use FS::cust_bill_pkg_discount;
-use Time::Local qw(timelocal);
-use List::Util 'min';
-
-@ISA = qw(FS::part_pkg);
-%info = ( 'disabled' => 1 );
-
-=head1 NAME
-
-FS::part_pkg::discount_Mixin - Mixin class for part_pkg:: classes that
-can be discounted.
-
-=head1 SYNOPSIS
-
-package FS::part_pkg::...;
-use base qw( FS::part_pkg::discount_Mixin );
-
-sub calc_recur {
- ...
- my $discount = $self->calc_discount($cust_pkg, $$sdate, $details, $param);
- $charge -= $discount;
- ...
-}
-
-=head METHODS
-
-=item calc_discount
-
-Takes all the arguments of calc_recur. Calculates and returns the amount
-by which to reduce the recurring fee; also increments months used on the
-discount and generates an invoice detail describing it.
-
-=cut
-
-sub calc_discount {
- my($self, $cust_pkg, $sdate, $details, $param ) = @_;
-
- my $br = $self->base_recur($cust_pkg);
-
- my $tot_discount = 0;
- #UI enforces just 1 for now, will need ordering when they can be stacked
-
- if ( $param->{freq_override} ) {
- # When a customer pays for more than one month at a time to receive a
- # term discount, freq_override is set to the number of months.
- my $real_part_pkg = new FS::part_pkg { $self->hash };
- $real_part_pkg->pkgpart($param->{real_pkgpart} || $self->pkgpart);
- # Find a discount with that duration...
- my @discount = grep { $_->months == $param->{freq_override} }
- map { $_->discount } $real_part_pkg->part_pkg_discount;
- my $discount = shift @discount;
- # and default to bill that many months at once.
- $param->{months} = $param->{freq_override} unless $param->{months};
- my $error;
- if ($discount) {
- # Then set the cust_pkg discount.
- if ($discount->months == $param->{months}) {
- $cust_pkg->discountnum($discount->discountnum);
- $error = $cust_pkg->insert_discount;
- } else {
- $cust_pkg->discountnum(-1);
- foreach ( qw( amount percent months ) ) {
- my $method = "discountnum_$_";
- $cust_pkg->$method($discount->$_);
- }
- $error = $cust_pkg->insert_discount;
- }
- die "error discounting using part_pkg_discount: $error" if $error;
- }
- }
-
- my @cust_pkg_discount = $cust_pkg->cust_pkg_discount_active;
- foreach my $cust_pkg_discount ( @cust_pkg_discount ) {
- my $discount = $cust_pkg_discount->discount;
- #UI enforces one or the other (for now? probably for good)
- my $amount = 0;
- $amount += $discount->amount
- if $cust_pkg->pkgpart == $param->{real_pkgpart};
- $amount += sprintf('%.2f', $discount->percent * $br / 100 );
- my $chg_months = $param->{'months'} || $cust_pkg->part_pkg->freq;
-
- my $months = $discount->months
- ? min( $chg_months,
- $discount->months - $cust_pkg_discount->months_used )
- : $chg_months;
-
- my $error = $cust_pkg_discount->increment_months_used($months)
- if $cust_pkg->pkgpart == $param->{real_pkgpart};
- die "error discounting: $error" if $error;
-
- $amount *= $months;
- $amount = sprintf('%.2f', $amount);
-
- next unless $amount > 0;
-
- #record details in cust_bill_pkg_discount
- my $cust_bill_pkg_discount = new FS::cust_bill_pkg_discount {
- 'pkgdiscountnum' => $cust_pkg_discount->pkgdiscountnum,
- 'amount' => $amount,
- 'months' => $months,
- };
- push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
-
- #add details on discount to invoice
- my $conf = new FS::Conf;
- my $money_char = $conf->config('money_char') || '$';
- $months = sprintf('%.2f', $months) if $months =~ /\./;
-
- my $d = 'Includes ';
- $d .= $discount->name. ' ' if $discount->name;
- $d .= 'discount of '. $discount->description_short;
- $d .= " for $months month". ( $months!=1 ? 's' : '' );
- $d .= ": $money_char$amount" if $months != 1 || $discount->percent;
- push @$details, $d;
-
- $tot_discount += $amount;
- }
-
- sprintf('%.2f', $tot_discount);
-}
-
-1;
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index a17813b..975e80a 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -11,21 +11,15 @@ use List::Util qw(min); # max);
use FS::UI::bytecount;
use FS::Conf;
use FS::part_pkg;
+use FS::cust_bill_pkg_discount;
-@ISA = qw(FS::part_pkg
- FS::part_pkg::prorate_Mixin
- FS::part_pkg::discount_Mixin);
+@ISA = qw(FS::part_pkg FS::part_pkg::prorate_Mixin);
tie my %temporalities, 'Tie::IxHash',
'upcoming' => "Upcoming (future)",
'preceding' => "Preceding (past)",
;
-tie my %contract_years, 'Tie::IxHash', (
- '' => '(none)',
- map { $_*12 => $_ } (1..5),
-);
-
%usage_fields = (
'seconds' => { 'name' => 'Time limit for this package',
@@ -123,11 +117,6 @@ tie my %contract_years, 'Tie::IxHash', (
},
'adjourn_months'=> { 'name' => 'Auto-add a suspension date this number of months out',
},
- 'contract_end_months'=> {
- 'name' => 'Auto-add a contract end date this number of years out',
- 'type' => 'select',
- 'select_options' => \%contract_years,
- },
#used in cust_pkg.pm so could add to any price plan where it made sense
'start_1st' => { 'name' => 'Auto-add a start date to the 1st, ignoring the current month.',
'type' => 'checkbox',
@@ -136,9 +125,6 @@ tie my %contract_years, 'Tie::IxHash', (
'with the customer\'s other packages',
'type' => 'checkbox',
},
- 'suspend_bill' => { 'name' => 'Continue recurring billing while suspended',
- 'type' => 'checkbox',
- },
'unsuspend_adjust_bill' =>
{ 'name' => 'Adjust next bill date forward when '.
'unsuspending',
@@ -155,9 +141,8 @@ tie my %contract_years, 'Tie::IxHash', (
'fieldorder' => [ qw( setup_fee recur_fee
recur_temporality unused_credit
expire_months adjourn_months
- contract_end_months
start_1st sync_bill_date
- suspend_bill unsuspend_adjust_bill
+ unsuspend_adjust_bill
),
@usage_fieldorder, @usage_recharge_fieldorder,
qw( externalid ),
@@ -195,23 +180,100 @@ sub calc_recur {
return 0
if $self->option('recur_temporality', 1) eq 'preceding' && $last_bill == 0;
- my $charge = $self->base_recur($cust_pkg);
- if ( $self->option('sync_bill_date',1) ) {
- my $next_bill = $cust_pkg->cust_main->next_bill_date;
- if ( defined($next_bill) and $next_bill != $$sdate ) {
- my $cutoff_day = (localtime($next_bill))[3];
- $charge = $self->calc_prorate(@_, $cutoff_day);
- }
+ if( $self->option('sync_bill_date',1) ) {
+ return $self->calc_prorate(@_);
}
- elsif ( $param->{freq_override} ) {
- # XXX not sure if this should be mutually exclusive with sync_bill_date.
- # Given the very specific problem that freq_override is meant to 'solve',
- # it probably should.
+ else {
+ my $charge = $self->base_recur($cust_pkg);
$charge *= $param->{freq_override} if $param->{freq_override};
+ my $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param);
+
+ return sprintf('%.2f', $charge - $discount);
+ }
+}
+
+sub calc_discount {
+ my($self, $cust_pkg, $sdate, $details, $param ) = @_;
+
+ my $br = $self->base_recur($cust_pkg);
+
+ my $tot_discount = 0;
+ #UI enforces just 1 for now, will need ordering when they can be stacked
+
+ if ( $param->{freq_override} ) {
+ my $real_part_pkg = new FS::part_pkg { $self->hash };
+ $real_part_pkg->pkgpart($param->{real_pkgpart} || $self->pkgpart);
+ my @discount = grep { $_->months == $param->{freq_override} }
+ map { $_->discount }
+ $real_part_pkg->part_pkg_discount;
+ my $discount = shift @discount;
+ $param->{months} = $param->{freq_override} unless $param->{months};
+ my $error;
+ if ($discount) {
+ if ($discount->months == $param->{months}) {
+ $cust_pkg->discountnum($discount->discountnum);
+ $error = $cust_pkg->insert_discount;
+ } else {
+ $cust_pkg->discountnum(-1);
+ foreach ( qw( amount percent months ) ) {
+ my $method = "discountnum_$_";
+ $cust_pkg->$method($discount->$_);
+ }
+ $error = $cust_pkg->insert_discount;
+ }
+ die "error discounting using part_pkg_discount: $error" if $error;
+ }
+ }
+
+ my @cust_pkg_discount = $cust_pkg->cust_pkg_discount_active;
+ foreach my $cust_pkg_discount ( @cust_pkg_discount ) {
+ my $discount = $cust_pkg_discount->discount;
+ #UI enforces one or the other (for now? probably for good)
+ my $amount = 0;
+ $amount += $discount->amount
+ if $cust_pkg->pkgpart == $param->{real_pkgpart};
+ $amount += sprintf('%.2f', $discount->percent * $br / 100 );
+
+ my $chg_months = $param->{'months'} || $cust_pkg->part_pkg->freq;
+
+ my $months = $discount->months
+ ? min( $chg_months,
+ $discount->months - $cust_pkg_discount->months_used )
+ : $chg_months;
+
+ my $error = $cust_pkg_discount->increment_months_used($months)
+ if $cust_pkg->pkgpart == $param->{real_pkgpart};
+ die "error discounting: $error" if $error;
+
+ $amount *= $months;
+ $amount = sprintf('%.2f', $amount);
+
+ next unless $amount > 0;
+
+ #record details in cust_bill_pkg_discount
+ my $cust_bill_pkg_discount = new FS::cust_bill_pkg_discount {
+ 'pkgdiscountnum' => $cust_pkg_discount->pkgdiscountnum,
+ 'amount' => $amount,
+ 'months' => $months,
+ };
+ push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
+
+ #add details on discount to invoice
+ my $conf = new FS::Conf;
+ my $money_char = $conf->config('money_char') || '$';
+ $months = sprintf('%.2f', $months) if $months =~ /\./;
+
+ my $d = 'Includes ';
+ $d .= $discount->name. ' ' if $discount->name;
+ $d .= 'discount of '. $discount->description_short;
+ $d .= " for $months month". ( $months!=1 ? 's' : '' );
+ $d .= ": $money_char$amount" if $months != 1 || $discount->percent;
+ push @$details, $d;
+
+ $tot_discount += $amount;
}
- my $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param);
- return sprintf('%.2f', $charge - $discount);
+ sprintf('%.2f', $tot_discount);
}
sub base_recur {
diff --git a/FS/FS/part_pkg/prorate.pm b/FS/FS/part_pkg/prorate.pm
index 4abdb8d..918b910 100644
--- a/FS/FS/part_pkg/prorate.pm
+++ b/FS/FS/part_pkg/prorate.pm
@@ -79,15 +79,6 @@ use FS::part_pkg::flat;
'package recharge',
'type' => 'checkbox',
},
- 'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
- 'for one full period after that',
- 'type' => 'checkbox',
- },
- 'prorate_round_day'=> {
- 'name' => 'When prorating first month, round to '.
- 'the nearest full day',
- 'type' => 'checkbox',
- },
#it would be better if this had to be turned on, its confusing
'externalid' => { 'name' => 'Optional External ID',
@@ -98,16 +89,14 @@ use FS::part_pkg::flat;
'seconds', 'upbytes', 'downbytes', 'totalbytes',
'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
'recharge_downbytes', 'recharge_totalbytes',
- 'usage_rollover', 'recharge_reset', 'add_full_period',
- 'prorate_round_day', 'externalid', ],
+ 'usage_rollover', 'recharge_reset', 'externalid', ],
'freq' => 'm',
'weight' => 20,
);
sub calc_recur {
my $self = shift;
- my $cutoff_day = $self->option('cutoff_day') || 1;
- return $self->calc_prorate(@_, $cutoff_day) - $self->calc_discount(@_);
+ $self->calc_prorate(@_);
}
1;
diff --git a/FS/FS/part_pkg/prorate_Mixin.pm b/FS/FS/part_pkg/prorate_Mixin.pm
index 9c0c266..2adf2f1 100644
--- a/FS/FS/part_pkg/prorate_Mixin.pm
+++ b/FS/FS/part_pkg/prorate_Mixin.pm
@@ -5,9 +5,7 @@ use vars qw(@ISA %info);
use Time::Local qw(timelocal);
@ISA = qw(FS::part_pkg);
-%info = (
- 'disabled' => 1,
-);
+%info = ( 'disabled' => 1 );
=head1 NAME
@@ -30,34 +28,44 @@ sub calc_recur {
=head METHODS
-=item calc_prorate CUST_PKG
+=item calc_prorate
-Takes all the arguments of calc_recur, followed by a day of the month
-to prorate to. Calculates a prorated charge from the $sdate to that day,
-and sets the $sdate and $param->{months} accordingly.
+Takes all the arguments of calc_recur, and calculates a prorated charge
+in one of two ways:
-Options:
-- recur_fee: The charge to use for a complete billing period.
-- add_full_period: Bill for the time up to the prorate day plus one full
-billing period after that.
-- prorate_round_day: Round the current time to the nearest full day,
-instead of using the exact time.
+- If 'sync_bill_date' is set: Charge for a number of days to synchronize
+ this package to the customer's next bill date. If this is their only
+ package (or they're already synchronized), that will take them through
+ one billing cycle.
+- If 'cutoff_day' is set: Prorate this package so that its next bill date
+ falls on that day of the month.
=cut
sub calc_prorate {
my $self = shift;
- my ($cust_pkg, $sdate, $details, $param, $cutoff_day) = @_;
+ my ($cust_pkg, $sdate, $details, $param) = @_;
- my $charge = $self->option('recur_fee',1) || 0;
+ my $charge = $self->option('recur_fee') || 0;
+ my $cutoff_day;
+ if( $self->option('sync_bill_date',1) ) {
+ my $next_bill = $cust_pkg->cust_main->next_bill_date;
+ if( defined($next_bill) and $next_bill != $$sdate ) {
+ $cutoff_day = (localtime($next_bill))[3];
+ }
+ else {
+ # don't prorate, assume a full month
+ $param->{'months'} = $self->freq;
+ }
+ }
+ else { # no sync, use cutoff_day or day 1
+ $cutoff_day = $self->option('cutoff_day') || 1;
+ }
+
if($cutoff_day) {
# only works for freq >= 1 month; probably can't be fixed
my $mnow = $$sdate;
my ($sec, $min, $hour, $mday, $mon, $year) = (localtime($mnow))[0..5];
- if( $self->option('prorate_round_day',1) ) {
- $mday++ if $hour >= 12;
- $mnow = timelocal(0,0,0,$mday,$mon,$year);
- }
my $mend;
my $mstart;
if ( $mday >= $cutoff_day ) {
@@ -72,23 +80,17 @@ sub calc_prorate {
$mstart =
timelocal(0,0,0,$cutoff_day,$mon == 0 ? 11 : $mon - 1,$year-($mon==11));
}
-
- # next bill date will be figured as $$sdate + one period
+
$$sdate = $mstart;
- my $permonth = $charge / $self->freq;
+ my $permonth = $self->option('recur_fee', 1) / $self->freq;
my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) );
-
- if ( $self->option('add_full_period',1) ) {
- # charge a full period in addition to the partial month
- $months += $self->freq;
- $$sdate = $self->add_freq($mstart);
- }
-
+
$param->{'months'} = $months;
$charge = sprintf('%.2f', $permonth * $months);
}
- return $charge;
+ my $discount = $self->calc_discount(@_);
+ return ($charge - $discount);
}
1;
diff --git a/FS/FS/part_pkg/recur_Common.pm b/FS/FS/part_pkg/recur_Common.pm
index 7614d7a..ec17c16 100644
--- a/FS/FS/part_pkg/recur_Common.pm
+++ b/FS/FS/part_pkg/recur_Common.pm
@@ -4,9 +4,9 @@ use strict;
use vars qw( @ISA %info %recur_method );
use Tie::IxHash;
use Time::Local;
-use FS::part_pkg::flat;
+use FS::part_pkg::prorate;
-@ISA = qw(FS::part_pkg::flat);
+@ISA = qw(FS::part_pkg::prorate);
%info = ( 'disabled' => 1 ); #recur_Common not a usable price plan directly
@@ -16,11 +16,6 @@ tie %recur_method, 'Tie::IxHash',
'subscription' => 'Charge the full fee for the first partial period (selectable billing date)',
;
-sub base_recur {
- my $self = shift;
- $self->option('recur_fee', 1) || 0;
-}
-
sub calc_recur_Common {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_; #only need $sdate & $param
@@ -30,37 +25,32 @@ sub calc_recur_Common {
if ( $param->{'increment_next_bill'} ) {
my $recur_method = $self->option('recur_method', 1) || 'anniversary';
-
- $charges = $self->base_recur;
-
- if ( $recur_method eq 'prorate' ) {
- my $cutoff_day = $self->option('cutoff_day') || 1;
- $charges = $self->calc_prorate(@_, $cutoff_day);
- }
- elsif ( $recur_method eq 'anniversary' and
- $self->option('sync_bill_date',1) ) {
- my $next_bill = $cust_pkg->cust_main->next_bill_date;
- if ( defined($next_bill) ) {
- my $cutoff_day = (localtime($next_bill))[3];
- $charges = $self->calc_prorate(@_, $cutoff_day);
- }
+
+ if ( $recur_method eq 'prorate'
+ or ($recur_method eq 'anniversary' and $self->option('sync_bill_date',1))
+ ) {
+ $charges = $self->calc_prorate(@_);
}
- elsif ( $recur_method eq 'subscription' ) {
+ else {
+
+ $charges = $self->option('recur_fee');
- my $cutoff_day = $self->option('cutoff_day', 1) || 1;
- my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
+ if ( $recur_method eq 'subscription' ) {
- if ( $day < $cutoff_day ) {
- if ( $mon == 0 ) { $mon=11; $year--; }
- else { $mon--; }
- }
+ my $cutoff_day = $self->option('cutoff_day', 1) || 1;
+ my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
- $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
+ if ( $day < $cutoff_day ) {
+ if ( $mon == 0 ) { $mon=11; $year--; }
+ else { $mon--; }
+ }
- }#$recur_method eq 'subscription'
+ $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
+ }#$recur_method eq 'subscription'
$charges -= $self->calc_discount( $cust_pkg, $sdate, $details, $param );
+ }#$recur_method eq 'prorate' or ...
}#increment_next_bill
return $charges;
diff --git a/FS/FS/part_pkg/sql_external.pm b/FS/FS/part_pkg/sql_external.pm
index 8e803f9..3cf2064 100644
--- a/FS/FS/part_pkg/sql_external.pm
+++ b/FS/FS/part_pkg/sql_external.pm
@@ -24,10 +24,6 @@ use DBI;
'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',
@@ -49,7 +45,7 @@ use DBI;
},
},
'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_method cutoff_day
- add_full_period datasrc db_username db_password query
+ datasrc db_username db_password query
)],
'weight' => '58',
);
diff --git a/FS/FS/part_pkg/subscription.pm b/FS/FS/part_pkg/subscription.pm
index 5495e3a..a5e0262 100644
--- a/FS/FS/part_pkg/subscription.pm
+++ b/FS/FS/part_pkg/subscription.pm
@@ -18,7 +18,7 @@ use FS::part_pkg::flat;
'recur_fee' => { 'name' => 'Recurring fee for this package',
'default' => 0,
},
- 'cutoff_day' => { 'name' => 'Billing day',
+ 'cutoff_day' => { 'name' => 'billing day',
'default' => 1,
},
'seconds' => { 'name' => 'Time limit for this package',
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 768f894..005009a 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -22,7 +22,6 @@ $DEBUG = 0;
tie my %cdr_svc_method, 'Tie::IxHash',
'svc_phone.phonenum' => 'Phone numbers (svc_phone.phonenum)',
'svc_pbx.title' => 'PBX name (svc_pbx.title)',
- 'svc_pbx.svcnum' => 'Freeside service # (svc_pbx.svcnum)',
;
tie my %rating_method, 'Tie::IxHash',
@@ -71,10 +70,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
'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',
#'options' => \%recur_method,
@@ -222,14 +218,10 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
},
#eofalse
- 'bill_every_call' => { 'name' => 'Generate an invoice immediately for every call (as well any setup fee, upon first payment). Useful for prepaid.',
+ 'bill_every_call' => { 'name' => 'Generate an invoice immediately for every call. Useful for prepaid.',
'type' => 'checkbox',
},
- 'bill_inactive_svcs' => { 'name' => 'Bill for all phone numbers that were active during the billing period',
- 'type' => 'checkbox',
- },
-
'count_available_phones' => { 'name' => 'Consider for tax purposes the number of lines to be svc_phones that may be provisioned rather than those that actually are.',
'type' => 'checkbox',
},
@@ -261,7 +253,6 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
'fieldorder' => [qw(
setup_fee recur_fee recur_temporality unused_credit
recur_method cutoff_day
- add_full_period
cdr_svc_method
rating_method ratenum min_charge sec_granularity
ignore_unrateable
@@ -282,7 +273,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
use_duration
411_rewrite
output_format usage_mandate summarize_usage usage_section
- bill_every_call bill_inactive_svcs
+ bill_every_call
count_available_phones
)
],
@@ -369,35 +360,18 @@ sub calc_usage {
my($svc_table, $svc_field) = split('\.', $cdr_svc_method);
- my @cust_svc;
- if( $self->option('bill_inactive_svcs',1) ) {
- #XXX in this mode do we need to restrict the set of CDRs by date also?
- @cust_svc = $cust_pkg->h_cust_svc($$sdate, $last_bill);
- }
- else {
- @cust_svc = $cust_pkg->cust_svc;
- }
- @cust_svc = grep { $_->part_svc->svcdb eq $svc_table } @cust_svc;
-
- foreach my $cust_svc (@cust_svc) {
+ foreach my $cust_svc (
+ grep { $_->part_svc->svcdb eq $svc_table } $cust_pkg->cust_svc
+ ) {
- my $svc_x;
- if( $self->option('bill_inactive_svcs',1) ) {
- $svc_x = $cust_svc->h_svc_x($$sdate, $last_bill);
- }
- else {
- $svc_x = $cust_svc->svc_x;
- }
- my %options = (
+ my $svc_x = $cust_svc->svc_x;
+ foreach my $cdr (
+ $svc_x->get_cdrs(
'disable_src' => $self->option('disable_src'),
'default_prefix' => $self->option('default_prefix'),
'status' => '',
'for_update' => 1,
- ); # $last_bill, $$sdate )
- $options{'by_svcnum'} = 1 if $svc_field eq 'svcnum';
-
- foreach my $cdr (
- $svc_x->get_cdrs( %options )
+ ) # $last_bill, $$sdate )
) {
if ( $DEBUG > 1 ) {
warn "rating CDR $cdr\n".
@@ -727,7 +701,7 @@ sub calc_usage {
if ( $charge > 0 ) {
#just use FS::cust_bill_pkg_detail objects?
my $call_details;
- my $phonenum = $svc_x->phonenum;
+ my $phonenum = $cust_svc->svc_x->phonenum;
if ( scalar(@call_details) == 1 ) {
$call_details =
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index 8b1844a..4937bb8 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -47,10 +47,6 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
'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' => 'select',
@@ -156,7 +152,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
},
'fieldorder' => [qw(
setup_fee recur_fee recur_temporality unused_credit
- recur_method cutoff_day add_full_period
+ recur_method cutoff_day
min_charge sec_granularity
default_prefix
disable_tollfree
diff --git a/FS/FS/part_pkg_option.pm b/FS/FS/part_pkg_option.pm
index 142622b..3cb330b 100644
--- a/FS/FS/part_pkg_option.pm
+++ b/FS/FS/part_pkg_option.pm
@@ -137,10 +137,6 @@ sub _upgrade_data { # class method
$sth = dbh->prepare($sql) or die dbh->errstr;
$sth->execute or die $sth->errstr;
- $sql = "UPDATE part_pkg_option SET optionvalue = NULL WHERE ".
- "optionname = 'contract_end_months' AND optionvalue = '(none)'";
- $sth = dbh->prepare($sql) or die dbh->errstr;
- $sth->execute or die $sth->errstr;
'';
}
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index e0f1e33..71290f4 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -1013,42 +1013,6 @@ sub clone_kludge_unsuspend {
shift;
}
-=item find_duplicates MODE FIELDS...
-
-Method used by _check_duplicate routines to find services with duplicate
-values in specified fields. Set MODE to 'global' to search across all
-services, or 'export' to limit to those that share one or more exports
-with this service. FIELDS is a list of field names; only services
-matching in all fields will be returned. Empty fields will be skipped.
-
-=cut
-
-sub find_duplicates {
- my $self = shift;
- my $mode = shift;
- my @fields = @_;
-
- my %search = map { $_ => $self->getfield($_) }
- grep { length($self->getfield($_)) } @fields;
- return () if !%search;
- my @dup = grep { ! $self->svcnum or $_->svcnum != $self->svcnum }
- qsearch( $self->table, \%search );
- return () if !@dup;
- return @dup if $mode eq 'global';
- die "incorrect find_duplicates mode '$mode'" if $mode ne 'export';
-
- my $exports = FS::part_export::export_info($self->table);
- my %conflict_svcparts;
- my $part_svc = $self->part_svc;
- foreach my $part_export ( $part_svc->part_export ) {
- %conflict_svcparts = map { $_->svcpart => 1 } $part_export->export_svc;
- }
- return grep { $conflict_svcparts{$_->cust_svc->svcpart} } @dup;
-}
-
-
-
-
=back
=head1 BUGS
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 94a839b..d401e1d 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -9,7 +9,6 @@ use vars qw( $DEBUG $me $conf $skip_fuzzyfiles
$username_ampersand $username_letter $username_letterfirst
$username_noperiod $username_nounderscore $username_nodash
$username_uppercase $username_percent $username_colon
- $username_slash $username_equals
$password_noampersand $password_noexclamation
$warning_template $warning_from $warning_subject $warning_mimetype
$warning_cc
@@ -75,8 +74,6 @@ FS::UID->install_callback( sub {
$username_ampersand = $conf->exists('username-ampersand');
$username_percent = $conf->exists('username-percent');
$username_colon = $conf->exists('username-colon');
- $username_slash = $conf->exists('username-slash');
- $username_equals = $conf->exists('username-equals');
$password_noampersand = $conf->exists('password-noexclamation');
$password_noexclamation = $conf->exists('password-noexclamation');
$dirhash = $conf->config('dirhash') || 0;
@@ -1243,14 +1240,16 @@ sub check {
}
my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
-
- $recref->{username} =~ /^([a-z0-9_\-\.\&\%\:\/\=]{$usernamemin,$ulen})$/i
- or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
- $recref->{username} = $1;
-
- unless ( $username_uppercase ) {
- $recref->{username} =~ /[A-Z]/ and return gettext('illegal_username');
+ if ( $username_uppercase ) {
+ $recref->{username} =~ /^([a-z0-9_\-\.\&\%\:]{$usernamemin,$ulen})$/i
+ or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
+ $recref->{username} = $1;
+ } else {
+ $recref->{username} =~ /^([a-z0-9_\-\.\&\%\:]{$usernamemin,$ulen})$/
+ or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
+ $recref->{username} = $1;
}
+
if ( $username_letterfirst ) {
$recref->{username} =~ /^[a-z]/ or return gettext('illegal_username');
} elsif ( $username_letter ) {
@@ -1274,12 +1273,6 @@ sub check {
unless ( $username_colon ) {
$recref->{username} =~ /\:/ and return gettext('illegal_username');
}
- unless ( $username_slash ) {
- $recref->{username} =~ /\// and return gettext('illegal_username');
- }
- unless ( $username_equals ) {
- $recref->{username} =~ /\=/ and return gettext('illegal_username');
- }
$recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
$recref->{popnum} = $1;
@@ -1359,7 +1352,7 @@ sub check {
}
}
$self->getfield('finger') =~
- /^([µ_0123456789aAáÁàÀâÂåÅäÄãêæÆbBcCçÇdDðÐeEéÉèÈêÊëËfFgGhHiIíÍìÌîÎïÏjJkKlLmMnNñÑoOóÓòÒôÔöÖõÕøغpPqQrRsSßtTuUúÚùÙûÛüÜvVwWxXyYýÝÿzZþÞ \t\!\@\#\$\%\&\(\)\-\+\;\'\"\,\.\?\/\*\<\>]*)$/
+ /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\'\"\,\.\?\/\*\<\>]*)$/
or return "Illegal finger: ". $self->getfield('finger');
$self->setfield('finger', $1);
diff --git a/FS/FS/svc_pbx.pm b/FS/FS/svc_pbx.pm
index 0eb5443..d2760a5 100644
--- a/FS/FS/svc_pbx.pm
+++ b/FS/FS/svc_pbx.pm
@@ -253,27 +253,22 @@ sub check {
$self->SUPER::check;
}
+#XXX this is a way-too simplistic implementation
+# at the very least, title should be unique across exports that need that or
+# controlled by a conf setting or something
sub _check_duplicate {
my $self = shift;
my $conf = new FS::Conf;
-
+ return '' if $conf->config('global_unique-pbx_title') eq 'disabled';
+
$self->lock_table;
- foreach my $field ('title', 'id') {
- my $global_unique = $conf->config("global_unique-pbx_$field");
- # can be 'disabled', 'enabled', or empty.
- # if empty, check per exports; if not empty or disabled, check
- # globally.
- next if $global_unique eq 'disabled';
- my @dup = $self->find_duplicates(
- ($global_unique ? 'global' : 'export') , $field
- );
- next if !@dup;
- return "duplicate $field '".$self->getfield($field).
- "': conflicts with svcnum ".$dup[0]->svcnum;
+ if ( qsearchs( 'svc_pbx', { 'title' => $self->title } ) ) {
+ return "Name in use";
+ } else {
+ return '';
}
- return '';
}
=item get_cdrs
@@ -297,9 +292,6 @@ with the chosen prefix.
=item disable_src => 1: No-op for svc_pbx CDR processing.
-=item by_svcnum => 1: Select CDRs where the svcnum field matches, instead of
-title/charged_party. Normally this field is set after processing.
-
=back
=cut
@@ -315,25 +307,19 @@ sub get_cdrs {
my $for_update = $options{'for_update'} ? 'FOR UPDATE' : '';
- if ( $options{'by_svcnum'} ) {
- $hash{'svcnum'} = $self->svcnum;
- }
- else {
- #matching by title
- my $title = $self->title;
+ my $title = $self->title;
- my $prefix = $options{'default_prefix'};
+ my $prefix = $options{'default_prefix'};
- my @orwhere = map " $_ = '$title' ", @fields;
- push @orwhere, map " $_ = '$prefix$title' ", @fields
- if length($prefix);
- if ( $prefix =~ /^\+(\d+)$/ ) {
- push @orwhere, map " $_ = '$1$title' ", @fields
- }
-
- push @where, ' ( '. join(' OR ', @orwhere ). ' ) ';
+ my @orwhere = map " $_ = '$title' ", @fields;
+ push @orwhere, map " $_ = '$prefix$title' ", @fields
+ if length($prefix);
+ if ( $prefix =~ /^\+(\d+)$/ ) {
+ push @orwhere, map " $_ = '$1$title' ", @fields
}
+ push @where, ' ( '. join(' OR ', @orwhere ). ' ) ';
+
if ( $options{'begin'} ) {
push @where, 'startdate >= '. $options{'begin'};
}
@@ -341,8 +327,7 @@ sub get_cdrs {
push @where, 'startdate < '. $options{'end'};
}
- my $extra_sql = ( keys(%hash) ? ' AND ' : ' WHERE ' ). join(' AND ', @where )
- if @where;
+ my $extra_sql = ( keys(%hash) ? ' AND ' : ' WHERE ' ). join(' AND ', @where );
my @cdrs =
qsearch( {
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index a599ea2..a0a2c3e 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -547,8 +547,6 @@ with the chosen prefix.
=item disable_src => 1: Only match on "charged_party", not "src".
-=item by_svcnum: not supported for svc_phone
-
=back
=cut
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index 6a542c7..e16cc5c 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -99,7 +99,7 @@ the bill and collect methods of a cust_main object. See L<FS::cust_main>.
with today's date, irregardless of the pretend date used to pre-generate
the invoices.
- -p: Only process customers with the specified payby (CARD, DCRD, CHEK, DCHK, BILL, COMP, LECB)
+ -p: Only process customers with the specified payby (I<CARD>, I<DCRD>, I<CHEK>, I<DCHK>, I<BILL>, I<COMP>, I<LECB>)
-a: Only process customers with the specified agentnum. Multiple agentnums can be specified, separated with commas.
diff --git a/FS/bin/freeside-monthly b/FS/bin/freeside-monthly
index 0d6ea14..a81e3e9 100755
--- a/FS/bin/freeside-monthly
+++ b/FS/bin/freeside-monthly
@@ -64,7 +64,7 @@ the bill and collect methods of a cust_main object. See L<FS::cust_main>.
"pretend date" 15 days from whatever was specified by the -d switch
(or now, if no -d switch was given).
- -p: Only process customers with the specified payby (CARD, DCRD, CHEK, DCHK, BILL, COMP, LECB)
+ -p: Only process customers with the specified payby (I<CARD>, I<DCRD>, I<CHEK>, I<DCHK>, I<BILL>, I<COMP>, I<LECB>)
-a: Only process customers with the specified agentnum
diff --git a/FS/bin/freeside-radgroup b/FS/bin/freeside-radgroup
index 3326329..ed85626 100644
--- a/FS/bin/freeside-radgroup
+++ b/FS/bin/freeside-radgroup
@@ -52,13 +52,13 @@ freeside-radgroup - Command line utility to manipulate radius groups
=head1 DESCRIPTION
-B<user> is a freeside user as added with freeside-adduser.
+ B<user> is a freeside user as added with freeside-adduser.
-B<command> is the action to take. Available actions are: I<add>
+ B<command> is the action to take. Available actions are: I<add>
-B<groupname> is the group to add (or remove, etc.)
+ B<groupname> is the group to add (or remove, etc.)
-B<svcpart> specifies which accounts will be updated.
+ B<svcpart> specifies which accounts will be updated.
=head1 EXAMPLES
diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade
index aca545b..d3723a1 100755
--- a/FS/bin/freeside-upgrade
+++ b/FS/bin/freeside-upgrade
@@ -71,21 +71,6 @@ if ( dbdef->table('cgp_rule_condition') &&
}
-# RT required field flag
-# for consistency with RT schema: mysql is in CamelCase,
-# pg is in lowercase, and they use different data types.
-my ($t, $creq, $cdis) =
- map { driver_name =~ /^mysql/i ? $_ : lc($_) }
- ('CustomFields','Required','Disabled');
-
-if ( dbdef->table($t) &&
- ! dbdef->table($t)->column($creq) ) {
- push @bugfix,
- "ALTER TABLE $t ADD COLUMN $creq ".
- dbdef->table($t)->column($cdis)->type .
- ' NOT NULL DEFAULT 0';
-}
-
if ( $DRY_RUN ) {
print
join(";\n", @bugfix ). ";\n";