[freeside-commits]
freeside/FS/FS Schema.pm, 1.49, 1.50 cust_main.pm,
1.279, 1.280 cust_bill.pm, 1.166, 1.167
Ivan,,,
ivan at wavetail.420.am
Wed Apr 4 19:04:23 PDT 2007
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv22070/FS/FS
Modified Files:
Schema.pm cust_main.pm cust_bill.pm
Log Message:
per-customer invoice terms override
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- Schema.pm 2 Apr 2007 15:49:36 -0000 1.49
+++ Schema.pm 5 Apr 2007 02:04:21 -0000 1.50
@@ -454,6 +454,7 @@
'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' ] ],
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -d -r1.279 -r1.280
--- cust_main.pm 2 Apr 2007 15:49:36 -0000 1.279
+++ cust_main.pm 5 Apr 2007 02:04:21 -0000 1.280
@@ -1221,6 +1221,7 @@
|| $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 @@
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
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -d -r1.166 -r1.167
--- cust_bill.pm 4 Apr 2007 15:30:34 -0000 1.166
+++ cust_bill.pm 5 Apr 2007 02:04:21 -0000 1.167
@@ -1193,11 +1193,7 @@
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 @@
'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 @@
'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 @@
#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;
}
More information about the freeside-commits
mailing list