summaryrefslogtreecommitdiff
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
parent16527189e68b0636f4b39849f45063422ac47ba5 (diff)
per-customer invoice terms override
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_bill.pm48
-rw-r--r--FS/FS/cust_main.pm11
-rwxr-xr-xhttemplate/edit/cust_main.cgi2
-rw-r--r--httemplate/edit/cust_main/billing.html17
-rw-r--r--httemplate/view/cust_main/billing.html24
6 files changed, 69 insertions, 34 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
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index a843772d2..2c3123ccb 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -313,6 +313,7 @@ function bottomfixup(what) {
var billing_bottomvars = new Array(
'tax',
'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
+ 'invoice_terms',
'spool_cdr'
);
@@ -392,6 +393,7 @@ function copyelement(from, to) {
%
% 'tax',
% 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
+% 'invoice_terms',
% 'spool_cdr'
% ) {
%
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index ba10929ed..65b4400a4 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -408,8 +408,22 @@
<TD ALIGN="right" WIDTH="200">Email invoice </TD>
<TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD>
</TR>
-% if ( $conf->exists('voip-cust_cdr_spools') ) {
+ <TR>
+ <TD ALIGN="right" WIDTH="200">Invoice terms </TD>
+ <TD WIDTH="408">
+ <SELECT NAME="invoice_terms">
+ <OPTION VALUE="">Default (<% $conf->config('invoice_default_terms') || 'Payable upon receipt' %>)
+% foreach my $term ( 'Payable upon receipt',
+% ( map "Net $_", 0, 10, 15, 30, 45, 60 ),
+% ) {
+ <OPTION VALUE="<% $term %>" <% $cust_main->invoice_terms eq $term ? ' SELECTED' : '' %>><% $term %>
+% }
+ </SELECT>
+ </TD>
+ </TR>
+
+% if ( $conf->exists('voip-cust_cdr_spools') ) {
<TR>
<TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> Spool CDRs</TD>
</TR>
@@ -418,7 +432,6 @@
<INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
% }
-
</TABLE>
</FORM>
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index 1f80dc5bc..b73270c6c 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -1,11 +1,3 @@
-%
-% my( $cust_main ) = @_;
-% my @invoicing_list = $cust_main->invoicing_list;
-% my $conf = new FS::Conf;
-% my $money_char = $conf->config('money_char') || '$';
-%
-
-
Billing information
% # If we can't see the unencrypted card, then bill now is an exercise in frustration
%if ( ! $cust_main->is_encrypted($cust_main->payinfo) ) {
@@ -179,14 +171,26 @@ Billing information
<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
</TD>
</TR>
-% if ( $conf->exists('voip-cust_cdr_spools') ) {
+<TR>
+ <TD ALIGN="right">Invoice&nbsp;terms</TD>
+ <TD BGCOLOR="#ffffff">
+ <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
+ </TD>
+</TR>
+% if ( $conf->exists('voip-cust_cdr_spools') ) {
<TR>
<TD ALIGN="right">Spool&nbsp;CDRs</TD>
<TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
</TR>
% }
-
</TABLE></TD></TR></TABLE>
+<%init>
+
+my( $cust_main ) = @_;
+my @invoicing_list = $cust_main->invoicing_list;
+my $conf = new FS::Conf;
+my $money_char = $conf->config('money_char') || '$';
+</%init>