summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-02-16 13:53:36 -0600
committerJonathan Prykop <jonathan@freeside.biz>2015-02-16 13:53:36 -0600
commit7b40e0e045368d350529d78208be0e6124f94b5a (patch)
tree00fc2ac0eef5e2849f19e30c7347c444fbd7fee5 /FS/FS
parent251d07aa41b6830a0a2f2a51c14fa94586d843c2 (diff)
parentfa0e442fa889a49a0b7517567cb20beedc31c5aa (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/API.pm41
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--FS/FS/Conf.pm5
-rw-r--r--FS/FS/Cron/bill.pm2
-rw-r--r--FS/FS/Cron/breakage.pm2
-rw-r--r--FS/FS/Mason.pm1
-rw-r--r--FS/FS/Schema.pm52
-rw-r--r--FS/FS/Setup.pm12
-rw-r--r--FS/FS/Upgrade.pm3
-rw-r--r--FS/FS/cust_bill.pm48
-rw-r--r--FS/FS/cust_bill/Search.pm12
-rw-r--r--FS/FS/cust_bill_event.pm378
-rw-r--r--FS/FS/cust_event.pm4
-rw-r--r--FS/FS/cust_main/API.pm6
-rw-r--r--FS/FS/cust_main/Billing.pm2
-rw-r--r--FS/FS/cust_main/Billing_Realtime.pm30
-rw-r--r--FS/FS/cust_pay.pm5
-rw-r--r--FS/FS/cust_pay_batch.pm37
-rw-r--r--FS/FS/cust_payby.pm21
-rw-r--r--FS/FS/part_bill_event.pm368
-rw-r--r--FS/FS/part_event.pm16
-rw-r--r--FS/FS/part_event/Action/realtime_auto.pm41
-rw-r--r--FS/FS/pay_batch/RBC.pm2
-rw-r--r--FS/FS/tax_rate.pm3
24 files changed, 116 insertions, 976 deletions
diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index c49fb20..f848361 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -365,26 +365,6 @@ comma-separated list of email addresses for email invoices. The special value 'P
postal_invoicing
Set to 1 to enable postal invoicing
-=item payby
-
-CARD, DCRD, CHEK, DCHK, LECB, BILL, COMP or PREPAY
-
-=item payinfo
-
-Card number for CARD/DCRD, account_number@aba_number for CHEK/DCHK, prepaid "pin" for PREPAY, purchase order number for BILL
-
-=item paycvv
-
-Credit card CVV2 number (1.5+ or 1.4.2 with CVV schema patch)
-
-=item paydate
-
-Expiration date for CARD/DCRD
-
-=item payname
-
-Exact name on credit card for CARD/DCRD, bank name for CHEK/DCHK
-
=item referral_custnum
Referring customer number
@@ -505,27 +485,6 @@ addition to email addresses),
postal_invoicing
Set to 1 to enable postal invoicing
-=item payby
-
-CARD, DCRD, CHEK, DCHK, LECB, BILL, COMP or PREPAY
-
-=item payinfo
-
-Card number for CARD/DCRD, account_number@aba_number for CHEK/DCHK, prepaid
-"pin" for PREPAY, purchase order number for BILL
-
-=item paycvv
-
-Credit card CVV2 number (1.5+ or 1.4.2 with CVV schema patch)
-
-=item paydate
-
-Expiration date for CARD/DCRD
-
-=item payname
-
-Exact name on credit card for CARD/DCRD, bank name for CHEK/DCHK
-
=item referral_custnum
Referring customer number
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index f395dea..82423d8 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -53,7 +53,6 @@ assigned to users and/or groups.
# 'billing' => [
# '_desc' => 'Access to billing configuration',
# 'payment_gateway' => {},
-# 'part_bill_event' => {},
# 'prepay_credit' => {},
# 'rate' => {},
# 'cust_main_county' => {},
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 091070e..bb04d94 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2147,11 +2147,6 @@ and customer address. Include units.',
},
{
- 'key' => 'safe-part_bill_event',
- 'section' => 'UI',
- 'description' => 'Validates invoice event expressions against a preset list. Useful for webdemos, annoying to powerusers.',
- 'type' => 'checkbox',
- },
{
'key' => 'show_ship_company',
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 98f1c2e..a822654 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -190,8 +190,6 @@ sub bill_where {
push @search, "( cust_main.archived != 'Y' OR archived IS NULL )"; #disable?
- push @search, "cust_main.payby = '". $opt{'p'}. "'"
- if $opt{'p'};
push @search, "cust_main.agentnum IN ( ". $opt{'a'}. " ) "
if $opt{'a'};
diff --git a/FS/FS/Cron/breakage.pm b/FS/FS/Cron/breakage.pm
index 6dd904d..56a9df4 100644
--- a/FS/FS/Cron/breakage.pm
+++ b/FS/FS/Cron/breakage.pm
@@ -47,7 +47,7 @@ sub reconcile_breakage {
my @customers = qsearch({
'table' => 'cust_main',
'hashref' => { 'agentnum' => $agent->agentnum,
- 'payby' => { op=>'!=', value=>'COMP', },
+ 'complimentary' => { op=>'!=', value=>'Y', },
},
'extra_sql' => $extra_sql,
});
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 37e3ad2..81671ff 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -180,7 +180,6 @@ if ( -e $addl_handler_use_file ) {
use FS::cust_pay_refund;
use FS::cust_svc;
use FS::nas;
- use FS::part_bill_event;
use FS::part_event;
use FS::part_event_condition;
use FS::part_pkg;
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 5333b1a..db2d3cf 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -794,58 +794,6 @@ sub tables_hashref {
],
},
- #old "invoice" events, deprecated
- 'cust_bill_event' => {
- 'columns' => [
- 'eventnum', 'serial', '', '', '', '',
- 'invnum', 'int', '', '', '', '',
- 'eventpart', 'int', '', '', '', '',
- '_date', @date_type, '', '',
- 'status', 'varchar', '', $char_d, '', '',
- 'statustext', 'text', 'NULL', '', '', '',
- ],
- 'primary_key' => 'eventnum',
- #no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ],
- 'unique' => [],
- 'index' => [ ['invnum'], ['status'], ['eventpart'],
- ['statustext'], ['_date'],
- ],
- 'foreign_keys' => [
- { columns => [ 'invnum' ],
- table => 'cust_bill',
- },
- { columns => [ 'eventpart' ],
- table => 'part_bill_event',
- },
- ],
- },
-
- #old "invoice" events, deprecated
- 'part_bill_event' => {
- 'columns' => [
- 'eventpart', 'serial', '', '', '', '',
- 'freq', 'varchar', 'NULL', $char_d, '', '',
- 'payby', 'char', '', 4, '', '',
- 'event', 'varchar', '', $char_d, '', '',
- 'eventcode', @perl_type, '', '',
- 'seconds', 'int', 'NULL', '', '', '',
- 'weight', 'int', '', '', '', '',
- 'plan', 'varchar', 'NULL', $char_d, '', '',
- 'plandata', 'text', 'NULL', '', '', '',
- 'reason', 'int', 'NULL', '', '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
- ],
- 'primary_key' => 'eventpart',
- 'unique' => [],
- 'index' => [ ['payby'], ['disabled'], ],
- 'foreign_keys' => [
- { columns => [ 'reason' ],
- table => 'reason',
- references => [ 'reasonnum' ],
- },
- ],
- },
-
'part_event' => {
'columns' => [
'eventpart', 'serial', '', '', '', '',
diff --git a/FS/FS/Setup.pm b/FS/FS/Setup.pm
index 5528c89..f26e50e 100644
--- a/FS/FS/Setup.pm
+++ b/FS/FS/Setup.pm
@@ -363,13 +363,11 @@ sub initial_data {
#with billing type Complimentary. Leave the First package dropdown set to
#(none).
'cust_main' => [
- { 'agentnum' => 1, #XXX
- 'refnum' => 1, #XXX
- 'first' => 'System',
- 'last' => 'Accounts',
- 'payby' => 'COMP',
- 'payinfo' => 'system', #or something
- 'paydate' => '1/2037',
+ { 'agentnum' => 1, #XXX
+ 'refnum' => 1, #XXX
+ 'first' => 'System',
+ 'last' => 'Accounts',
+ 'complimentary' => 'Y',
'bill_location' => $cust_location,
'ship_location' => $cust_location,
},
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 263be80..35a1e19 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -312,6 +312,9 @@ sub upgrade_data {
#payby conditions to new ones
'part_event_condition' => [],
+ #payby actions to new ones
+ 'part_event' => [],
+
#cust_main (remove paycvv from history, locations, cust_payby, etc)
'cust_main' => [],
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 068d0d1..8d69661 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -6,6 +6,7 @@ use base qw( FS::cust_bill::Search FS::Template_Mixin
use strict;
use vars qw( $DEBUG $me );
# but NOT $conf
+use Carp;
use Fcntl qw(:flock); #for spool_csv
use Cwd;
use List::Util qw(min max sum);
@@ -26,11 +27,9 @@ use FS::cust_pay;
use FS::cust_pkg;
use FS::cust_credit_bill;
use FS::pay_batch;
-use FS::cust_bill_event;
use FS::cust_event;
use FS::part_pkg;
use FS::cust_bill_pay;
-use FS::part_bill_event;
use FS::payby;
use FS::bill_batch;
use FS::cust_bill_batch;
@@ -285,7 +284,6 @@ sub delete {
my $dbh = dbh;
foreach my $table (qw(
- cust_bill_event
cust_event
cust_credit_bill
cust_bill_pay
@@ -565,32 +563,6 @@ sub open_cust_bill_pkg {
@open;
}
-=item cust_bill_event
-
-Returns the completed invoice events (deprecated, old-style events - see L<FS::cust_bill_event>) for this invoice.
-
-=cut
-
-sub cust_bill_event {
- my $self = shift;
- qsearch( 'cust_bill_event', { 'invnum' => $self->invnum } );
-}
-
-=item num_cust_bill_event
-
-Returns the number of completed invoice events (deprecated, old-style events - see L<FS::cust_bill_event>) for this invoice.
-
-=cut
-
-sub num_cust_bill_event {
- my $self = shift;
- my $sql =
- "SELECT COUNT(*) FROM cust_bill_event WHERE invnum = ?";
- my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql";
- $sth->execute($self->invnum) or die $sth->errstr. " executing $sql";
- $sth->fetchrow_arrayref->[0];
-}
-
=item cust_event
Returns the new-style customer billing events (see L<FS::cust_event>) for this invoice.
@@ -1982,24 +1954,8 @@ sub print_csv {
}
-=item comp
-
-Pays this invoice with a compliemntary payment. If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
sub comp {
- my $self = shift;
- my $cust_pay = new FS::cust_pay ( {
- 'invnum' => $self->invnum,
- 'paid' => $self->owed,
- '_date' => '',
- 'payby' => 'COMP',
- 'payinfo' => $self->cust_main->payinfo,
- 'paybatch' => '',
- } );
- $cust_pay->insert;
+ croak 'cust_bill->comp is deprecated (COMP payments are deprecated)';
}
=item realtime_card
diff --git a/FS/FS/cust_bill/Search.pm b/FS/FS/cust_bill/Search.pm
index 1fc818d..2a67529 100644
--- a/FS/FS/cust_bill/Search.pm
+++ b/FS/FS/cust_bill/Search.pm
@@ -128,10 +128,6 @@ Return only invoices belonging to that customer.
Limit to that customer class (single value or arrayref).
-=item payby
-
-Limit to customers with that payment method (single value or arrayref).
-
=item refnum
Limit to customers with that advertising source.
@@ -194,14 +190,6 @@ sub search_sql_where {
}
- #payby
- if ( $param->{payby} ) {
- my $payby = $param->{payby};
- $payby = [ $payby ] unless ref $payby;
- my $payby_in = join(',', map {dbh->quote($_)} @$payby);
- push @search, "cust_main.payby IN($payby_in)" if length($payby_in);
- }
-
#_date
if ( $param->{_date} ) {
my($beginning, $ending) = @{$param->{_date}};
diff --git a/FS/FS/cust_bill_event.pm b/FS/FS/cust_bill_event.pm
deleted file mode 100644
index adaa13e..0000000
--- a/FS/FS/cust_bill_event.pm
+++ /dev/null
@@ -1,378 +0,0 @@
-package FS::cust_bill_event;
-
-use strict;
-use vars qw( @ISA $DEBUG );
-use FS::Record qw( qsearch qsearchs );
-use FS::cust_main_Mixin;
-use FS::cust_bill;
-use FS::part_bill_event;
-
-@ISA = qw(FS::cust_main_Mixin FS::Record);
-
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::cust_bill_event - Object methods for cust_bill_event records
-
-=head1 SYNOPSIS
-
- use FS::cust_bill_event;
-
- $record = new FS::cust_bill_event \%hash;
- $record = new FS::cust_bill_event { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_bill_event object represents an complete invoice event.
-FS::cust_bill_event inherits from FS::Record. The following fields are
-currently supported:
-
-=over 4
-
-=item eventnum
-
-Primary key
-
-=item invnum
-
-Invoice (see L<FS::cust_bill>)
-
-=item eventpart
-
-Event definition (see L<FS::part_bill_event>)
-
-=item _date
-
-Specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=item status
-
-Event status: B<done> or B<failed>
-
-=item statustext
-
-Additional status detail (i.e. error message)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new completed invoice event. To add the compelted invoice event to
-the database, see L<"insert">.
-
-Note that this stores the hash reference, not a distinct copy of the hash it
-points to. You can ask the object for a copy with the I<hash> method.
-
-=cut
-
-# the new method can be inherited from FS::Record, if a table method is defined
-
-sub table { 'cust_bill_event'; }
-
-sub cust_linked { $_[0]->cust_main_custnum || $_[0]->custnum }
-sub cust_unlinked_msg {
- my $self = shift;
- "WARNING: can't find cust_main.custnum ". $self->custnum.
- ' (cust_bill.invnum '. $self->invnum. ')';
-}
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-# the insert method can be inherited from FS::Record
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-# the delete method can be inherited from FS::Record
-
-=item replace OLD_RECORD
-
-Replaces the OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
-# the replace method can be inherited from FS::Record
-
-=item check
-
-Checks all fields to make sure this is a valid completed invoice event. If
-there is an error, returns the error, otherwise returns false. Called by the
-insert and replace methods.
-
-=cut
-
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
-sub check {
- my $self = shift;
-
- my $error = $self->ut_numbern('eventnum')
- || $self->ut_number('invnum')
- || $self->ut_number('eventpart')
- || $self->ut_number('_date')
- || $self->ut_enum('status', [qw( done failed )])
- || $self->ut_anything('statustext')
- ;
-
- return "Unknown eventpart ". $self->eventpart
- unless my $part_bill_event =
- qsearchs( 'part_bill_event' ,{ 'eventpart' => $self->eventpart } );
-
- return "Unknown invnum ". $self->invnum
- unless qsearchs( 'cust_bill' ,{ 'invnum' => $self->invnum } );
-
- $self->SUPER::check;
-}
-
-=item part_bill_event
-
-Returns the invoice event definition (see L<FS::part_bill_event>) for this
-completed invoice event.
-
-=cut
-
-sub part_bill_event {
- my $self = shift;
- qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } );
-}
-
-=item cust_bill
-
-Returns the invoice (see L<FS::cust_bill>) for this completed invoice event.
-
-=cut
-
-sub cust_bill {
- my $self = shift;
- qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
-}
-
-=item retry
-
-Changes the status of this event from B<done> to B<failed>, allowing it to be
-retried.
-
-=cut
-
-sub retry {
- my $self = shift;
- return '' unless $self->status eq 'done';
- my $old = ref($self)->new( { $self->hash } );
- $self->status('failed');
- $self->replace($old);
-}
-
-=item retryable
-
-Changes the statustext of this event to B<retriable>, rendering it
-retriable (should retry be called).
-
-=cut
-
-sub retriable {
- my $self = shift;
- return '' unless $self->status eq 'done';
- my $old = ref($self)->new( { $self->hash } );
- $self->statustext('retriable');
- $self->replace($old);
-}
-
-=item search_sql_where HASHREF
-
-Class method which returns an SQL WHERE fragment to search for parameters
-specified in HASHREF. Valid parameters are
-
-=over 4
-
-=item agentnum
-
-=item beginning
-
-An epoch date setting a lower bound for _date values
-
-=item ending
-
-An epoch date setting a upper bound for _date values
-
-=item failed
-
-Limits the search to failed events if true
-
-=item payby
-
-Requires that the search be JOIN'd to part_bill_event # Bug?
-
-=item invnum
-
-=item currentuser
-
-Specifies the user for agent virtualization
-
-=back
-
-=cut
-
-sub search_sql_where {
- my ($class, $params) = @_;
- my @search = ();
-
- push @search, "agentnum = ". $params->{agentnum} if $params->{agentnum};
-
- push @search, "cust_bill_event._date >= ". $params->{beginning}
- if $params->{beginning};
- push @search, "cust_bill_event._date <= ". $params->{ending}
- if $params->{ending};
-
- push @search, "statustext != ''",
- "statustext IS NOT NULL",
- "statustext != 'N/A'"
- if $params->{failed};
-
- push @search, "part_bill_event.payby = '". $params->{payby}. "'"
- if $params->{payby};
-
- push @search, "cust_bill_event.invnum = '". $params->{invnum}. "'"
- if $params->{invnum};
-
- my $currentuser = $params->{currentuser} || $params->{CurrentUser};
- if ($currentuser) {
- my $access_user = qsearchs('access_user', { username => $currentuser });
- if ($access_user) {
- push @search, $access_user->agentnums_sql;
- }else{
- push @search, "1=0";
- }
- }else{
- push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
- }
-
- join(' AND ', @search );
-
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item reprint
-
-=cut
-
-sub process_reprint {
- process_re_X('print', @_);
-}
-
-=item reemail
-
-=cut
-
-sub process_reemail {
- process_re_X('email', @_);
-}
-
-=item refax
-
-=cut
-
-sub process_refax {
- process_re_X('fax', @_);
-}
-
-use Data::Dumper;
-sub process_re_X {
- my( $method, $job ) = ( shift, shift );
-
- my $param = shift;
- warn Dumper($param) if $DEBUG;
-
- re_X(
- $method,
- $param,
- $job,
- );
-
-}
-
-sub re_X {
- my($method, $param, $job) = @_;
-
- my $where = FS::cust_bill_event->search_sql_where($param);
- $where = " WHERE plan LIKE 'send%'". ( $where ? " AND $where" : "" );
-
- my $from = 'LEFT JOIN part_bill_event USING ( eventpart )'.
- 'LEFT JOIN cust_bill USING ( invnum )'.
- 'LEFT JOIN cust_main USING ( custnum )';
-
- my @cust_bill_event = qsearch( 'cust_bill_event', {}, '', $where, '', $from );
-
- my( $num, $last, $min_sec ) = (0, time, 5); #progresbar foo
- foreach my $cust_bill_event ( @cust_bill_event ) {
-
- $cust_bill_event->cust_bill->$method(
- $cust_bill_event->part_bill_event->templatename
- );
-
- if ( $job ) { #progressbar foo
- $num++;
- if ( time - $min_sec > $last ) {
- my $error = $job->update_statustext(
- int( 100 * $num / scalar(@cust_bill_event) )
- );
- die $error if $error;
- $last = time;
- }
- }
-
- }
-
- #this doesn't work, but it would be nice
- #if ( $job ) { #progressbar foo
- # my $error = $job->update_statustext(
- # scalar(@cust_bill_event). " invoices re-${method}ed"
- # );
- # die $error if $error;
- #}
-
-}
-
-=back
-
-=head1 BUGS
-
-Far too early in the morning.
-
-=head1 SEE ALSO
-
-L<FS::part_bill_event>, L<FS::cust_bill>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_event.pm b/FS/FS/cust_event.pm
index d7a35a7..f299f93 100644
--- a/FS/FS/cust_event.pm
+++ b/FS/FS/cust_event.pm
@@ -337,10 +337,6 @@ specified in HASHREF. Valid parameters are
=item ending
-=item payby
-
-=item
-
=back
=cut
diff --git a/FS/FS/cust_main/API.pm b/FS/FS/cust_main/API.pm
index 158b5cf..2d6da9e 100644
--- a/FS/FS/cust_main/API.pm
+++ b/FS/FS/cust_main/API.pm
@@ -21,8 +21,7 @@ use vars qw(
first last company daytime night fax mobile
);
# locale
-# payby payinfo payname paystart_month paystart_year payissue payip
-# ss paytype paystate stateid stateid_state
+# ss stateid stateid_state
@location_editable_fields = qw(
address1 address2 city county state zip country
);
@@ -106,14 +105,12 @@ sub API_insert {
#same for refnum like signup_server-default_refnum?
my $cust_main = new FS::cust_main ( { # $class->new( {
- 'payby' => 'BILL',
'tagnum' => [ FS::part_tag->default_tags ],
map { $_ => $opt{$_} } qw(
agentnum salesnum refnum agent_custid referral_custnum
last first company
daytime night fax mobile
- payby payinfo paydate paycvv payname
),
} );
@@ -176,7 +173,6 @@ sub API_update {
agentnum salesnum refnum agent_custid referral_custnum
last first company
daytime night fax mobile
- payby payinfo paydate paycvv payname
),
my @invoicing_list;
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index 9e2082f..b3d4e70 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -390,7 +390,7 @@ terms or the default terms are used.
sub bill {
my( $self, %options ) = @_;
- return '' if $self->payby eq 'COMP';
+ return '' if $self->complimentary eq 'Y';
local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
my $log = FS::Log->new('FS::cust_main::Billing::bill');
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 20698fb..1f6a9e9 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -45,6 +45,36 @@ These methods are available on FS::cust_main objects.
=over 4
+=item realtime_cust_payby
+
+=cut
+
+sub realtime_cust_payby {
+ my( $self, %options ) = @_;
+
+ local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
+
+ $options{amount} = $self->balance unless exists( $options{amount} );
+
+ my @cust_payby = qsearch({
+ 'table' => 'cust_payby',
+ 'hashref' => { 'custnum' => $self->custnum, },
+ 'extra_sql' => " AND payby IN ( 'CARD', 'CHEK' ) ",
+ 'order_by' => 'ORDER BY weight ASC',
+ });
+
+ my $error;
+ foreach my $cust_payby (@cust_payby) {
+ $error = $cust_payby->realtime_bop( %options, );
+ last unless $error;
+ }
+
+ #XXX what about the earlier errors?
+
+ $error;
+
+}
+
=item realtime_collect [ OPTION => VALUE ... ]
Attempt to collect the customer's current balance with a realtime credit
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 139d2ff..e8f9aee 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -978,7 +978,6 @@ sub _upgrade_data { #class method
$cust_pay->set('otaker', 'legacy');
}
- delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge
my $error = $cust_pay->replace;
if ( $error ) {
@@ -987,8 +986,6 @@ sub _upgrade_data { #class method
next;
}
- $FS::payby::hash{'COMP'}->{cust_pay} = ''; #restore it
-
$count++;
if ( $DEBUG > 1 && $lastprog + 30 < time ) {
warn "$me $count/$total (".sprintf('%.2f',100*$count/$total). '%)'."\n";
@@ -1042,9 +1039,7 @@ sub _upgrade_data { #class method
# otaker->usernum upgrade
###
- delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge
$class->_upgrade_otaker(%opt);
- $FS::payby::hash{'COMP'}->{cust_pay} = ''; #restore it
# if we do this anywhere else, it should become an FS::Upgrade method
my $num_to_upgrade = $class->count('paybatch is not null');
diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm
index d4d40b5..a4b4957 100644
--- a/FS/FS/cust_pay_batch.pm
+++ b/FS/FS/cust_pay_batch.pm
@@ -49,7 +49,7 @@ following fields are currently supported:
=item batchnum - indentifies group in batch
-=item payby - CARD/CHEK/LECB/BILL/COMP
+=item payby - CARD/CHEK
=item payinfo
@@ -154,7 +154,7 @@ sub check {
if ( $self->exp eq '' ) {
return "Expiration date required"
- unless $self->payby =~ /^(CHEK|DCHK|LECB|WEST)$/;
+ unless $self->payby =~ /^(CHEK|DCHK|WEST)$/;
$self->exp('');
} else {
if ( $self->exp =~ /^(\d{4})[\/\-](\d{1,2})[\/\-](\d{1,2})$/ ) {
@@ -246,39 +246,6 @@ sub retriable {
confess "deprecated method cust_pay_batch->retriable called; try removing ".
"the once condition and adding an every condition?";
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE'; #Hmm
- 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_bill = qsearchs('cust_bill', { 'invnum' => $self->invnum } )
- or return "event $self->eventnum references nonexistant invoice $self->invnum";
-
- warn "cust_pay_batch->retriable working with self of " . $self->paybatchnum . " and invnum of " . $self->invnum;
- my @cust_bill_event =
- sort { $a->part_bill_event->seconds <=> $b->part_bill_event->seconds }
- grep {
- $_->part_bill_event->eventcode =~ /\$cust_bill->batch_card/
- && $_->status eq 'done'
- && ! $_->statustext
- }
- $cust_bill->cust_bill_event;
- # complain loudly if scalar(@cust_bill_event) > 1 ?
- my $error = $cust_bill_event[0]->retriable;
- if ($error ) {
- # gah, even with transactions.
- $dbh->commit if $oldAutoCommit; #well.
- return "error marking invoice event retriable: $error";
- }
- '';
}
=item approve OPTIONS
diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm
index a65a171..b1a7ddb 100644
--- a/FS/FS/cust_payby.pm
+++ b/FS/FS/cust_payby.pm
@@ -427,12 +427,16 @@ sub check {
}
- if ( $self->paydate eq '' || $self->paydate eq '-' ) {
- return "Expiration date required"
- # shouldn't payinfo_check do this?
- unless $self->payby =~ /^(CHEK|DCHK)$/;
+ if ( $self->payby =~ /^(CHEK|DCHK)$/ ) {
+
$self->paydate('');
- } else {
+
+ } elsif ( $self->payby =~ /^(CARD|DCRD)$/ ) {
+
+ # shouldn't payinfo_check do this?
+ return "Expiration date required"
+ if $self->paydate eq '' || $self->paydate eq '-';
+
my( $m, $y );
if ( $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ ) {
( $m, $y ) = ( $1, length($2) == 4 ? $2 : "20$2" );
@@ -451,6 +455,7 @@ sub check {
#&&
!$ignore_expired_card
&& ( $y<$nowy || ( $y==$nowy && $1<$nowm ) );
+
}
if ( $self->payname eq '' && $self->payby !~ /^(CHEK|DCHK)$/ &&
@@ -560,7 +565,7 @@ Returns the field names used in the web interface (including some pseudo-fields)
sub cgi_cust_payby_fields {
#my $class = shift;
[qw( payby payinfo paydate_month paydate_year paycvv payname weight
- payinfo1 payinfo2 payinfo3 paytype paystate )];
+ payinfo1 payinfo2 payinfo3 paytype paystate payname_CHEK )];
}
=item cgi_hash_callback HASHREF
@@ -582,7 +587,7 @@ sub cgi_hash_callback {
if ( $hashref->{payby} =~ /^(CHEK|DCHK)$/ ) {
- unless ( grep $hashref->{$_}, qw( payinfo1 payinfo2 payinfo3 payname ) ) {
+ unless ( grep $hashref->{$_}, qw(payinfo1 payinfo2 payinfo3 payname_CHEK)) {
%$hashref = ();
return;
}
@@ -592,7 +597,7 @@ sub cgi_hash_callback {
if $conf->config('echeck-country') eq 'CA';
$hashref->{payinfo} .= $hashref->{'payinfo2'};
- $hashref->{payname} .= $hashref->{'payname_CHEK'};
+ $hashref->{payname} = $hashref->{'payname_CHEK'};
} elsif ( $hashref->{payby} =~ /^(CARD|DCRD)$/ ) {
diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm
deleted file mode 100644
index 4e7aa52..0000000
--- a/FS/FS/part_bill_event.pm
+++ /dev/null
@@ -1,368 +0,0 @@
-package FS::part_bill_event;
-
-use strict;
-use vars qw( @ISA $DEBUG @EXPORT_OK );
-use Carp qw(cluck confess);
-use FS::Record qw( dbh qsearch qsearchs );
-use FS::Conf;
-use FS::cust_main;
-use FS::cust_bill;
-
-@ISA = qw( FS::Record );
-@EXPORT_OK = qw( due_events );
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::part_bill_event - Object methods for part_bill_event records
-
-=head1 SYNOPSIS
-
- use FS::part_bill_event;
-
- $record = new FS::part_bill_event \%hash;
- $record = new FS::part_bill_event { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $error = $record->do_event( $direct_object );
-
- @events = due_events ( { 'record' => $event_triggering_record,
- 'payby' => $payby,
- 'event_time => $_date,
- 'extra_sql => $extra } );
-
-=head1 DESCRIPTION
-
-An FS::part_bill_event object represents a deprecated, old-style invoice event
-definition - a callback which is triggered when an invoice is a certain amount
-of time overdue. FS::part_bill_event inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item eventpart - primary key
-
-=item payby - CARD, DCRD, CHEK, DCHK, LECB, BILL, or COMP
-
-=item event - event name
-
-=item eventcode - event action
-
-=item seconds - how long after the invoice date events of this type are triggered
-
-=item weight - ordering for events with identical seconds
-
-=item plan - eventcode plan
-
-=item plandata - additional plan data
-
-=item reason - an associated reason for this event to fire
-
-=item disabled - Disabled flag, empty or `Y'
-
-=back
-
-=head1 NOTE
-
-Old-style invoice events are only useful for legacy migrations - if you are
-looking for current events see L<FS::part_event>.
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new invoice event definition. To add the invoice event definition to
-the database, see L<"insert">.
-
-Note that this stores the hash reference, not a distinct copy of the hash it
-points to. You can ask the object for a copy with the I<hash> method.
-
-=cut
-
-# the new method can be inherited from FS::Record, if a table method is defined
-
-sub table { 'part_bill_event'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-# the insert method can be inherited from FS::Record
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-# the delete method can be inherited from FS::Record
-
-=item replace OLD_RECORD
-
-Replaces the OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
-# the replace method can be inherited from FS::Record
-
-=item check
-
-Checks all fields to make sure this is a valid invoice event definition. If
-there is an error, returns the error, otherwise returns false. Called by the
-insert and replace methods.
-
-=cut
-
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
-sub check {
- my $self = shift;
-
- $self->weight(0) unless $self->weight;
-
- my $conf = new FS::Conf;
- if ( $conf->exists('safe-part_bill_event') ) {
- my $error = $self->ut_anything('eventcode');
- return $error if $error;
-
- my $c = $self->eventcode;
-
- #yay, these regexen will go away with the event refactor
-
- $c =~ /^\s*\$cust_main\->(suspend|cancel|invoicing_list_addpost|bill|collect)\(\);\s*("";)?\s*$/
-
- or $c =~ /^\s*\$cust_bill\->(comp|realtime_(card|ach|lec)|batch_card|send)\((%options)*\);\s*$/
-
- or $c =~ /^\s*\$cust_bill\->send(_if_newest)?\(\'[\w\-\s]+\'\s*(,\s*(\d+|\[\s*\d+(,\s*\d+)*\s*\])\s*,\s*'[\w\@\.\-\+]*'\s*)?\);\s*$/
-
-# or $c =~ /^\s*\$cust_main\->apply_payments; \$cust_main->apply_credits; "";\s*$/
- or $c =~ /^\s*\$cust_main\->apply_payments_and_credits; "";\s*$/
-
- or $c =~ /^\s*\$cust_main\->charge\( \s*\d*\.?\d*\s*,\s*\'[\w \!\@\#\$\%\&\(\)\-\+\;\:\"\,\.\?\/]*\'\s*\);\s*$/
-
- or $c =~ /^\s*\$cust_main\->suspend_(if|unless)_pkgpart\([\d\,\s]*\);\s*$/
-
- or $c =~ /^\s*\$cust_bill\->cust_suspend_if_balance_over\([\d\.\s]*\);\s*$/
-
- or do {
- #log
- return "illegal eventcode: $c";
- };
-
- }
-
- my $error = $self->ut_numbern('eventpart')
- || $self->ut_enum('payby', [qw( CARD DCLN DCRD CHEK DCHK LECB BILL COMP )] )
- || $self->ut_text('event')
- || $self->ut_anything('eventcode')
- || $self->ut_number('seconds')
- || $self->ut_enum('disabled', [ '', 'Y' ] )
- || $self->ut_number('weight')
- || $self->ut_textn('plan')
- || $self->ut_anything('plandata')
- || $self->ut_numbern('reason')
- ;
- #|| $self->ut_snumber('seconds')
- return $error if $error;
-
- #quelle kludge
- if ( $self->plandata =~ /^(agent_)?templatename\s+(.*)$/m ) {
- my $name= $2;
-
- foreach my $file (qw( template
- latex latexnotes latexreturnaddress latexfooter
- latexsmallfooter
- html htmlnotes htmlreturnaddress htmlfooter
- ))
- {
- unless ( $conf->exists("invoice_${file}_$name") ) {
- $conf->set(
- "invoice_${file}_$name" =>
- join("\n", $conf->config("invoice_$file") )
- );
- }
- }
- }
-
- if ($self->reason){
- my $reasonr = qsearchs('reason', {'reasonnum' => $self->reason});
- return "Unknown reason" unless $reasonr;
- }
-
- $self->SUPER::check;
-}
-
-=item templatename
-
-Returns the alternate invoice template name, if any, or false if there is
-no alternate template for this invoice event.
-
-=cut
-
-sub templatename {
- my $self = shift;
- if ( $self->plan =~ /^send_(alternate|agent)$/
- && $self->plandata =~ /^(agent_)?templatename (.*)$/m
- )
- {
- $2;
- } else {
- '';
- }
-}
-
-=item due_events
-
-Returns the list of events due, if any, or false if there is none.
-Requires record and payby, but event_time and extra_sql are optional.
-
-=cut
-
-sub due_events {
- my ($record, $payby, $event_time, $extra_sql) = @_;
-
- #cluck "DEPRECATED: FS::part_bill_event::due_events called on $record";
- confess "DEPRECATED: FS::part_bill_event::due_events called on $record";
-
- my $interval = 0;
- if ($record->_date){
- $event_time = time unless $event_time;
- $interval = $event_time - $record->_date;
- }
- sort { $a->seconds <=> $b->seconds
- || $a->weight <=> $b->weight
- || $a->eventpart <=> $b->eventpart }
- grep { ref($record) ne 'FS::cust_bill' || $_->eventcode !~ /honor_dundate/
- || $event_time > $record->cust_main->dundate
- }
- grep { $_->seconds <= ( $interval )
- && ! qsearch( 'cust_bill_event', {
- 'invnum' => $record->get($record->dbdef_table->primary_key),
- 'eventpart' => $_->eventpart,
- 'status' => 'done',
- } )
- }
- qsearch( {
- 'table' => 'part_bill_event',
- 'hashref' => { 'payby' => $payby,
- 'disabled' => '', },
- 'extra_sql' => $extra_sql,
- } );
-
-
-}
-
-=item do_event
-
-Performs the event and returns any errors that occur.
-Requires a record on which to perform the event.
-Should only be performed inside a transaction.
-
-=cut
-
-sub do_event {
- my ($self, $object, %options) = @_;
-
- #cluck "DEPRECATED: FS::part_bill_event::do_event called on $self";
- confess "DEPRECATED: FS::part_bill_event::do_event called on $self";
-
- warn " calling event (". $self->eventcode. ") for " . $object->table . " " ,
- $object->get($object->dbdef_table->primary_key) . "\n" if $DEBUG > 1;
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
-
- # for "callback" -- heh
- my $cust_main = $object->cust_main;
- my $cust_bill;
- if ($object->table eq 'cust_bill'){
- $cust_bill = $object;
- }
- my $cust_pay_batch;
- if ($object->table eq 'cust_pay_batch'){
- $cust_pay_batch = $object;
- }
-
- my $error;
- {
- local $SIG{__DIE__}; # don't want Mason __DIE__ handler active
- $error = eval $self->eventcode;
- }
-
- my $status = '';
- my $statustext = '';
- if ( $@ ) {
- $status = 'failed';
- $statustext = $@;
- } elsif ( $error ) {
- $status = 'done';
- $statustext = $error;
- } else {
- $status = 'done';
- }
-
- #add cust_bill_event
- my $cust_bill_event = new FS::cust_bill_event {
-# 'invnum' => $object->get($object->dbdef_table->primary_key),
- 'invnum' => $object->invnum,
- 'eventpart' => $self->eventpart,
- '_date' => time,
- 'status' => $status,
- 'statustext' => $statustext,
- };
- $error = $cust_bill_event->insert;
- if ( $error ) {
- my $e = 'WARNING: Event run but database not updated - '.
- 'error inserting cust_bill_event, invnum #'. $object->invnum .
- ', eventpart '. $self->eventpart.": $error";
- warn $e;
- return $e;
- }
- '';
-}
-
-=item reasontext
-
-Returns the text of any reason associated with this event.
-
-=cut
-
-sub reasontext {
- my $self = shift;
- my $r = qsearchs('reason', { 'reasonnum' => $self->reason });
- if ($r){
- $r->reason;
- }else{
- '';
- }
-}
-
-=back
-
-=head1 BUGS
-
-The whole "eventcode" idea is bunk. This should be refactored with subclasses
-like part_pkg/ and part_export/
-
-=head1 SEE ALSO
-
-L<FS::cust_bill>, L<FS::cust_bill_event>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_event.pm b/FS/FS/part_event.pm
index e7acf5a..d15f35b 100644
--- a/FS/FS/part_event.pm
+++ b/FS/FS/part_event.pm
@@ -604,6 +604,22 @@ sub process_initialize {
$part_event->initialize;
}
+sub _upgrade_data { #class method
+ my ($class, %opts) = @_;
+
+ foreach my $part_event (
+ qsearch('part_event', { 'action' => 'cust_bill_realtime_card' }),
+ qsearch('part_event', { 'action' => 'cust_bill_realtime_check' }),
+ ) {
+
+ $part_event->action('realtime_auto');
+ my $error = $part_event->replace;
+ die $error if $error;
+
+ }
+
+}
+
=back
=head1 SEE ALSO
diff --git a/FS/FS/part_event/Action/realtime_auto.pm b/FS/FS/part_event/Action/realtime_auto.pm
new file mode 100644
index 0000000..3902319
--- /dev/null
+++ b/FS/FS/part_event/Action/realtime_auto.pm
@@ -0,0 +1,41 @@
+package FS::part_event::Action::realtime_auto;
+
+use strict;
+use base qw( FS::part_event::Action );
+
+sub description {
+ #'Run card with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
+ 'Run card or check with a Business::OnlinePayment realtime gateway';
+}
+
+sub eventtable_hashref {
+ { 'cust_bill' => 1,
+ 'cust_main' => 1,
+ };
+}
+
+sub default_weight { 30; }
+
+sub do_action {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my %opt = ('cc_surcharge_from_event' => 1);
+
+ my $amount;
+ my $balance = $cust_main->balance;
+ if ( ref($object) eq 'FS::cust_main' ) {
+ $amount = $balance;
+ } elsif ( ref($object) eq 'FS::cust_bill' ) {
+ $amount = ( $balance < $object->owed ) ? $balance : $object->owed;
+ $opt{'invnum'} = $object->invnum;
+ } else {
+ die 'guru meditation #5454.au';
+ }
+
+ $cust_main->realtime_cust_payby( 'amount' => $amount, %opt, );
+
+}
+
+1;
diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm
index a5c4683..4b11fdb 100644
--- a/FS/FS/pay_batch/RBC.pm
+++ b/FS/FS/pay_batch/RBC.pm
@@ -108,7 +108,7 @@ $name = 'RBC';
sprintf("%3s",$trans_code).
sprintf("%10s",$client_num).
' '.
- sprintf("%-19s", $cust_pay_batch->cust_main->custnum).
+ sprintf("%-19s", $cust_pay_batch->paybatchnum).
'00'.
sprintf("%04s", $bankno).
sprintf("%05s", $branch).
diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm
index ec3bb12..0047f9d 100644
--- a/FS/FS/tax_rate.pm
+++ b/FS/FS/tax_rate.pm
@@ -2055,9 +2055,6 @@ sub generate_liability_report {
join(';', map { "$_=". uri_escape($t->$_) } @params);
my $itemdesc_loc =
- # " payby != 'COMP' ". # breaks the entire report under 4.x
- # # and unnecessary since COMP accounts don't
- # # get taxes calculated in the first place
" ( itemdesc = ? OR ? = '' AND itemdesc IS NULL ) ".
"AND ". FS::tax_rate_location->location_sql( map { $_ => $t->$_ }
@taxparams