[freeside-commits] freeside/FS/FS cust_bill.pm, 1.275, 1.276 cust_location.pm, 1.3, 1.4 cust_main.pm, 1.484, 1.485 cust_pkg.pm, 1.148, 1.149
Jeff Finucane,420,,
jeff at wavetail.420.am
Wed Dec 23 13:21:17 PST 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv22254/FS/FS
Modified Files:
cust_bill.pm cust_location.pm cust_main.pm cust_pkg.pm
Log Message:
correct invoice package address display and reduce false laziness
Index: cust_location.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_location.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cust_location.pm 16 Dec 2009 15:03:16 -0000 1.3
+++ cust_location.pm 23 Dec 2009 21:21:14 -0000 1.4
@@ -158,58 +158,71 @@
code2country($self->country);
}
-=item line
+=item location_label [ OPTION => VALUE ... ]
-Returns this location on one line
+Returns the label of the service location for this customer.
-=cut
+Options are
-sub line {
- my $self = shift;
- my $cydefault = FS::conf->new->config('countrydefault') || 'US';
+=over 4
- my $line = $self->address1;
- $line .= ', '. $self->address2 if $self->address2;
- $line .= ', '. $self->city;
- $line .= ' ('. $self->county. ' county)' if $self->county;
- $line .= ', '. $self->state if $self->state;
- $line .= ' '. $self->zip if $self->zip;
- $line .= ' '. code2country($self->country) if $self->country ne $cydefault;
+=item join_string
- $line;
-}
+used to separate the address elements (defaults to ', ')
-=item line_short
+=item escape_function
-Returns this location on one line in a shortened form
+
+a callback used for escaping the text of the address elements
+
+=back
=cut
-# configurable?
+# false laziness with FS::cust_main::location_label
-sub line_short {
+sub location_label {
my $self = shift;
+ my %opt = @_;
+
+ my $separator = $opt{join_string} || ', ';
+ my $escape = $opt{escape_function} || sub{ shift };
+ my $line = '';
my $cydefault = FS::conf->new->config('countrydefault') || 'US';
+ my $prefix = '';
- my $line = $self->address1;
- #$line .= ', '. $self->address2 if $self->address2;
- $line .= ', '. $self->city;
- $line .= ', '. $self->state if $self->state;
- $line .= ' '. $self->zip if $self->zip;
- $line .= ' '. code2country($self->country) if $self->country ne $cydefault;
+ my $notfirst = 0;
+ foreach (qw ( address1 address2 ) ) {
+ my $method = "$prefix$_";
+ $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
+ if $self->$method;
+ $notfirst++;
+ }
+ $notfirst = 0;
+ foreach (qw ( city county state zip ) ) {
+ my $method = "$prefix$_";
+ if ( $self->$method ) {
+ $line .= '(' if $method eq 'county';
+ $line .= ($notfirst ? ' ' : $separator). &$escape($self->$method);
+ $line .= ')' if $method eq 'county';
+ $notfirst++;
+ }
+ }
+ $line .= $separator. &$escape(code2country($self->country))
+ if $self->country ne $cydefault;
$line;
}
-=item location_label_short
+=item line
-Synonym for line_short
+Synonym for location_label
=cut
-sub location_label_short {
+sub line {
my $self = shift;
- $self->line_short;
+ $self->location_label;
}
=back
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.275
retrieving revision 1.276
diff -u -d -r1.275 -r1.276
--- cust_bill.pm 16 Dec 2009 15:03:16 -0000 1.275
+++ cust_bill.pm 23 Dec 2009 21:21:13 -0000 1.276
@@ -3956,9 +3956,12 @@
{
push @d, map &{$escape_function}($_),
$cust_pkg->h_labels_short($self->_date);
- push @d, map &{$escape_function}($_),
- $cust_pkg->location_label_short
- if $multilocation;
+ if ( $multilocation ) {
+ my $loc = $cust_pkg->location_label;
+ $loc = substr($desc, 0, 50). '...'
+ if $format eq 'latex' && length($loc) > 50;
+ push @d, &{$escape_function}($loc);
+ }
}
push @d, $cust_bill_pkg->details(%details_opt)
if $cust_bill_pkg->recur == 0;
@@ -4013,9 +4016,12 @@
#$cust_bill_pkg->edate,
#$cust_bill_pkg->sdate)
;
- push @d, map &{$escape_function}($_),
- $cust_pkg->location_label_short
- if $multilocation;
+ if ( $multilocation ) {
+ my $loc = $cust_pkg->location_label;
+ $loc = substr($desc, 0, 50). '...'
+ if $format eq 'latex' && length($loc) > 50;
+ push @d, &{$escape_function}($loc);
+ }
}
push @d, $cust_bill_pkg->details(%details_opt)
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.484
retrieving revision 1.485
diff -u -d -r1.484 -r1.485
--- cust_main.pm 21 Dec 2009 02:00:54 -0000 1.484
+++ cust_main.pm 23 Dec 2009 21:21:14 -0000 1.485
@@ -1955,24 +1955,57 @@
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
-=item location_label_short
+=item location_label [ OPTION => VALUE ... ]
-Returns the short label of the service location (see analog in L<FS::cust_location>) for this customer.
+Returns the label of the service location (see analog in L<FS::cust_location>) for this customer.
+
+Options are
+
+=over 4
+
+=item join_string
+
+used to separate the address elements (defaults to ', ')
+
+=item escape_function
+
+a callback used for escaping the text of the address elements
+
+=back
=cut
-# false laziness with FS::cust_location::line_short
+# false laziness with FS::cust_location::line
-sub location_label_short {
+sub location_label {
my $self = shift;
+ my %opt = @_;
+
+ my $separator = $opt{join_string} || ', ';
+ my $escape = $opt{escape_function} || sub{ shift };
+ my $line = '';
my $cydefault = FS::conf->new->config('countrydefault') || 'US';
+ my $prefix = length($self->ship_last) ? 'ship_' : '';
- my $line = $self->address1;
- #$line .= ', '. $self->address2 if $self->address2;
- $line .= ', '. $self->city;
- $line .= ', '. $self->state if $self->state;
- $line .= ' '. $self->zip if $self->zip;
- $line .= ' '. code2country($self->country) if $self->country ne $cydefault;
+ my $notfirst = 0;
+ foreach (qw ( address1 address2 ) ) {
+ my $method = "$prefix$_";
+ $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
+ if $self->$method;
+ $notfirst++;
+ }
+ $notfirst = 0;
+ foreach (qw ( city county state zip ) ) {
+ my $method = "$prefix$_";
+ if ( $self->$method ) {
+ $line .= '(' if $method eq 'county';
+ $line .= ($notfirst ? ' ' : $separator). &$escape($self->$method);
+ $line .= ')' if $method eq 'county';
+ $notfirst++;
+ }
+ }
+ $line .= $separator. &$escape(code2country($self->country))
+ if $self->country ne $cydefault;
$line;
}
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- cust_pkg.pm 20 Dec 2009 02:51:41 -0000 1.148
+++ cust_pkg.pm 23 Dec 2009 21:21:14 -0000 1.149
@@ -1946,16 +1946,16 @@
$self->cust_location || $self->cust_main;
}
-=item location_label_short
+=item location_label [ OPTION => VALUE ... ]
-Returns the short label of the location object (see L<FS::cust_location>).
+Returns the label of the location object (see L<FS::cust_location>).
=cut
-sub location_label_short {
+sub location_label {
my $self = shift;
my $object = $self->cust_location_or_main;
- $object->location_label_short;
+ $object->location_label(@_);
}
=item seconds_since TIMESTAMP
More information about the freeside-commits
mailing list