summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2007-04-05 02:04:21 +0000
committerivan <ivan>2007-04-05 02:04:21 +0000
commitf3c4bc88460be7576d81b9ca234b421950f48c01 (patch)
tree350d09578975ad8a4be06aec2a2792c0ba38c377 /FS
parent16527189e68b0636f4b39849f45063422ac47ba5 (diff)
per-customer invoice terms override
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_bill.pm48
-rw-r--r--FS/FS/cust_main.pm11
3 files changed, 38 insertions, 22 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 85ad94531..2c26ba271 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -454,6 +454,7 @@ sub tables_hashref {
'referral_custnum', 'int', 'NULL', '', '', '',
'comments', 'text', 'NULL', '', '', '',
'spool_cdr','char', 'NULL', 1, '', '',
+ 'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'custnum',
'unique' => [ [ 'agentnum', 'agent_custid' ] ],
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 82b5e0c1e..d39e6ddc1 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1193,11 +1193,7 @@ sub print_csv {
my $taxtotal = 0;
$taxtotal += $_->{'amount'} foreach $self->_items_tax;
- my $duedate = '';
- if ( $conf->exists('invoice_default_terms')
- && $conf->config('invoice_default_terms')=~ /^\s*Net\s*(\d+)\s*$/ ) {
- $duedate = time2str("%m/%d/%Y", $self->_date + ($1*86400) );
- }
+ my $duedate = $self->due_date2str('%m/%d/%Y'); #date_format?
my( $previous_balance, @unused ) = $self->previous; #previous balance
@@ -1908,7 +1904,7 @@ sub print_latex {
'smallfooter' => join("\n", $conf->config_orbase('invoice_latexsmallfooter', $template) ),
'returnaddress' => $returnaddress,
'quantity' => 1,
- 'terms' => $conf->config('invoice_default_terms') || 'Payable upon receipt',
+ 'terms' => $self->terms,
#'notes' => join("\n", $conf->config('invoice_latexnotes') ),
# better hang on to conf_dir for a while
'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
@@ -2324,8 +2320,7 @@ sub print_html {
'city' => encode_entities($cust_main->city),
'state' => encode_entities($cust_main->state),
'zip' => encode_entities($cust_main->zip),
- 'terms' => $conf->config('invoice_default_terms')
- || 'Payable upon receipt',
+ 'terms' => $self->terms,
'cid' => $cid,
'template' => $template,
# 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc",
@@ -2501,14 +2496,41 @@ sub _latex_escape {
#utility methods for print_*
+sub terms {
+ my $self = shift;
+
+ #check for an invoice- specific override (eventually)
+
+ #check for a customer- specific override
+ return $self->cust_main->invoice_terms
+ if $self->cust_main->invoice_terms;
+
+ #use configured default or default default
+ $conf->config('invoice_default_terms') || 'Payable upon receipt';
+}
+
+sub due_date {
+ my $self = shift;
+ my $duedate = '';
+ if ( $self->terms =~ /^\s*Net\s*(\d+)\s*$/ ) {
+ $duedate = $self->_date() + ( $1 * 86400 );
+ }
+ $duedate;
+}
+
+sub due_date2str {
+ my $self = shift;
+ $self->due_date ? time2str(shift, $self->due_date) : '';
+}
+
sub balance_due_msg {
my $self = shift;
my $msg = 'Balance Due';
- return $msg unless $conf->exists('invoice_default_terms');
- if ( $conf->config('invoice_default_terms') =~ /^\s*Net\s*(\d+)\s*$/ ) {
- $msg .= ' - Please pay by '. time2str("%x", $self->_date + ($1*86400) );
- } elsif ( $conf->config('invoice_default_terms') ) {
- $msg .= ' - '. $conf->config('invoice_default_terms');
+ return $msg unless $self->terms;
+ if ( $self->due_date ) {
+ $msg .= ' - Please pay by '. $self->due_date2str('%x');
+ } elsif ( $self->terms ) {
+ $msg .= ' - '. $self->terms;
}
$msg;
}
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 80111da0e..f6867224a 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1221,6 +1221,7 @@ sub check {
|| $self->ut_numbern('referral_custnum')
|| $self->ut_textn('stateid')
|| $self->ut_textn('stateid_state')
+ || $self->ut_textn('invoice_terms')
;
#barf. need message catalogs. i18n. etc.
$error .= "Please select an advertising source."
@@ -2773,15 +2774,7 @@ sub realtime_bop {
unless ( $transaction->error_message ) {
my $t_response;
- #this should be normalized :/
- #
- # bad, ad-hoc B:OP:PayflowPro "transaction_response" BS
- if ( $transaction->can('param')
- && $transaction->param('transaction_response') ) {
- $t_response = $transaction->param('transaction_response')
-
- # slightly better, ad-hoc B:OP:TransactionCentral without "param"
- } elsif ( $transaction->can('response_page') ) {
+ if ( $transaction->can('response_page') ) {
$t_response = {
'page' => ( $transaction->can('response_page')
? $transaction->response_page