[freeside-commits] freeside/FS/FS Conf.pm, 1.180.2.37, 1.180.2.38 cust_main.pm, 1.271.2.59, 1.271.2.60 cust_bill.pm, 1.163.2.42, 1.163.2.43
Ivan,,,
ivan at wavetail.420.am
Tue Jan 6 09:49:23 PST 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv32551
Modified Files:
Tag: FREESIDE_1_7_BRANCH
Conf.pm cust_main.pm cust_bill.pm
Log Message:
add invoice_subject config with some subsitution vars, RT#4481
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.180.2.37
retrieving revision 1.180.2.38
diff -u -d -r1.180.2.37 -r1.180.2.38
--- Conf.pm 16 Oct 2008 05:35:36 -0000 1.180.2.37
+++ Conf.pm 6 Jan 2009 17:49:20 -0000 1.180.2.38
@@ -641,6 +641,13 @@
},
{
+ 'key' => 'invoice_subject',
+ 'section' => 'billing',
+ 'description' => 'Subject: header on email invoices. Defaults to "Invoice". The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.',
+ 'type' => 'text',
+ },
+
+ {
'key' => 'invoice_template',
'section' => 'required',
'description' => 'Required template file for invoices. See the <a href="http://www.sisd.com/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Plaintext_invoice_templates">billing documentation</a> for details.',
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.271.2.59
retrieving revision 1.271.2.60
diff -u -d -r1.271.2.59 -r1.271.2.60
--- cust_main.pm 26 Sep 2008 03:56:40 -0000 1.271.2.59
+++ cust_main.pm 6 Jan 2009 17:49:21 -0000 1.271.2.60
@@ -4379,6 +4379,35 @@
}
}
+=item name_short
+
+Returns a name string for this customer, either "Company" or "First Last".
+
+=cut
+
+sub name_short {
+ my $self = shift;
+ $self->company !~ /^\s*$/ ? $self->company : $self->contact_firstlast;
+}
+
+=item ship_name_short
+
+Returns a name string for this (service/shipping) contact, either "Company"
+or "First Last".
+
+=cut
+
+sub ship_name_short {
+ my $self = shift;
+ if ( $self->get('ship_last') ) {
+ $self->ship_company !~ /^\s*$/
+ ? $self->ship_company
+ : $self->ship_contact_firstlast;
+ } else {
+ $self->name_company_or_firstlast;
+ }
+}
+
=item contact
Returns this customer's full (billing) contact name only, "Last, First"
@@ -4403,6 +4432,30 @@
: $self->contact;
}
+=item contact_firstlast
+
+Returns this customers full (billing) contact name only, "First Last".
+
+=cut
+
+sub contact_firstlast {
+ my $self = shift;
+ $self->first. ' '. $self->get('last');
+}
+
+=item ship_contact_firstlast
+
+Returns this customer's full (shipping) contact name only, "First Last".
+
+=cut
+
+sub ship_contact_firstlast {
+ my $self = shift;
+ $self->get('ship_last')
+ ? $self->first. ' '. $self->get('ship_last')
+ : $self->contact_firstlast;
+}
+
=item country_full
Returns this customer's full country name
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.163.2.42
retrieving revision 1.163.2.43
diff -u -d -r1.163.2.42 -r1.163.2.43
--- cust_bill.pm 23 Dec 2008 00:52:03 -0000 1.163.2.42
+++ cust_bill.pm 6 Jan 2009 17:49:21 -0000 1.163.2.43
@@ -845,10 +845,13 @@
#better to notify this person than silence
@invoicing_list = ($invoice_from) unless @invoicing_list;
+ my $subject = $self->email_subject($template);
+
my $error = send_email(
$self->generate_email(
'from' => $invoice_from,
'to' => [ grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ],
+ 'subject' => $subject,
'template' => $template,
)
);
@@ -857,6 +860,23 @@
}
+sub email_subject {
+ my $self = shift;
+
+ #my $template = scalar(@_) ? shift : '';
+ #per-template?
+
+ my $subject = $conf->config('invoice_subject') || 'Invoice';
+
+ my $cust_main = $self->cust_main;
+ my $name = $cust_main->name;
+ my $name_short = $cust_main->name_short;
+ my $invoice_number = $self->invnum;
+ my $invoice_date = $self->_date_pretty;
+
+ eval qq("$subject");
+}
+
=item lpr_data [ TEMPLATENAME ]
Returns the postscript or plaintext for this invoice as an arrayref.
@@ -2472,7 +2492,18 @@
sub invnum_date_pretty {
my $self = shift;
- 'Invoice #'. $self->invnum. ' ('. time2str('%x', $self->_date). ')';
+ 'Invoice #'. $self->invnum. ' ('. $self->_date_pretty. ')';
+}
+
+=item _date_pretty
+
+Returns a string with the date, for example: "3/20/2008"
+
+=cut
+
+sub _date_pretty {
+ my $self = shift;
+ time2str('%x', $self->_date);
}
sub _items {
More information about the freeside-commits
mailing list