[freeside-commits] branch master updated. d2eeb4a5d310fe5eb1b16ada10b57e01511122f9

Ivan ivan at 420.am
Sun Feb 3 19:45:08 PST 2013


The branch, master has been updated
       via  d2eeb4a5d310fe5eb1b16ada10b57e01511122f9 (commit)
      from  55152935236dd33b72214a8fb7260e71d2ce9ca2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d2eeb4a5d310fe5eb1b16ada10b57e01511122f9
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Feb 3 19:45:05 2013 -0800

    add location to credit application detail, RT#21054

diff --git a/FS/FS/cust_bill_pkg_tax_location.pm b/FS/FS/cust_bill_pkg_tax_location.pm
index 723d6e0..140982e 100644
--- a/FS/FS/cust_bill_pkg_tax_location.pm
+++ b/FS/FS/cust_bill_pkg_tax_location.pm
@@ -215,10 +215,8 @@ sub cust_credit_bill_pkg {
 
 sub cust_main_county {
   my $self = shift;
-  my $result;
-  if ( $self->taxtype eq 'FS::cust_main_county' ) {
-    $result = qsearchs( 'cust_main_county', { 'taxnum' => $self->taxnum } );
-  }
+  return '' unless $self->taxtype eq 'FS::cust_main_county';
+  qsearchs( 'cust_main_county', { 'taxnum' => $self->taxnum } );
 }
 
 sub _upgrade_data {
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index b86529b..b25163f 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -479,6 +479,20 @@ sub location_label {
   $prefix . $self->SUPER::location_label(%opt);
 }
 
+=item county_state_county
+
+Returns a string consisting of just the county, state and country.
+
+=cut
+
+sub county_state_country {
+  my $self = shift;
+  my $label = $self->country;
+  $label = $self->state.", $label" if $self->state;
+  $label = $self->county." County, $label" if $self->county;
+  $label;
+}
+
 =back
 
 =head1 CLASS METHODS
diff --git a/httemplate/search/cust_credit_bill_pkg.html b/httemplate/search/cust_credit_bill_pkg.html
index 06fd881..8b21f37 100644
--- a/httemplate/search/cust_credit_bill_pkg.html
+++ b/httemplate/search/cust_credit_bill_pkg.html
@@ -16,6 +16,7 @@
 
                    # line item
                    'Description',
+                   'Location',
                    @post_desc_header,
 
                    #invoice
@@ -35,6 +36,7 @@
                            ? $_[0]->get('pkg')      # possibly use override.pkg
                            : $_[0]->get('itemdesc') # but i think this correct
                        },
+                   $location_sub,
                    @post_desc,
                    'invnum',
                    sub { time2str('%b %d %Y', shift->_date ) },
@@ -46,6 +48,7 @@
                    '', #'otaker',
                    '', #reason
                    '', #line item description
+                   '', #location
                    @post_desc_null,
                    'invnum',
                    '_date',
@@ -57,6 +60,7 @@
                    '',
                    '',
                    '',
+                   '',
                    @post_desc_null,
                    $ilink,
                    $ilink,
@@ -64,7 +68,7 @@
                          FS::UI::Web::cust_header()
                    ),
                ],
-               'align' => 'rrlll'.
+               'align' => 'rrllll'.
                           $post_desc_align.
                           'rr'.
                           FS::UI::Web::cust_aligns(),
@@ -74,6 +78,7 @@
                               '',
                               '',
                               '',
+                              '',
                               @post_desc_null,
                               '',
                               '',
@@ -85,6 +90,7 @@
                               '',
                               '',
                               '',
+                              '',
                               @post_desc_null,
                               '',
                               '',
@@ -425,8 +431,7 @@ if ( $cgi->param('nottax') ) {
 
 } else { 
 
-  #die?
-  warn "neiether nottax nor istax parameters specified";
+  #warn "neither nottax nor istax parameters specified";
   #same as before?
   $join_pkg =  ' LEFT JOIN cust_pkg USING ( pkgnum )
                  LEFT JOIN part_pkg USING ( pkgpart ) ';
@@ -485,4 +490,57 @@ my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
 my $conf = new FS::Conf;
 my $money_char = $conf->config('money_char') || '$';
 
+my $tax_pkg_address = $conf->exists('tax-pkg_address');
+my $tax_ship_address = $conf->exists('tax-ship_address');
+
+my $location_sub = sub {
+  #my $cust_credit_bill_pkg = shift;
+  my $self = shift;
+  my $tax_Xlocation = $self->cust_bill_pkg_tax_Xlocation;
+  if ( defined($tax_Xlocation) && $tax_Xlocation ) {
+
+    if ( ref($tax_Xlocation) eq 'FS::cust_bill_pkg_tax_location' ) {
+
+      if ( $tax_Xlocation->taxtype eq 'FS::cust_main_county' ) {
+        my $cust_main_county = $tax_Xlocation->cust_main_county;
+        if ( $cust_main_county ) {
+          $cust_main_county->label;
+        } else {
+          ''; #cust_main_county record is gone... history?  yuck.
+        }
+      } else {
+        '(CCH tax_rate)'; #XXX FS::tax_rate.. vendor taxes not yet handled here
+      }
+
+    } elsif ( ref($tax_Xlocation) eq 'FS::cust_bill_pkg_tax_rate_location' ) {
+      '(CCH)'; #XXX vendor taxes not yet handled here
+    } else {
+      'unknown tax_Xlocation '. ref($tax_Xlocation);
+    }
+
+  } else {
+
+    my $cust_bill_pkg = $self->cust_bill_pkg;
+    if ( $cust_bill_pkg->pkgnum > 0 ) {
+      my $cust_pkg = $cust_bill_pkg->cust_pkg;
+      if ( $tax_pkg_address && (my $cust_location = $cust_pkg->cust_location) ){
+        $cust_location->county_state_country;
+      } else {
+        my $cust_main = $cust_pkg->cust_main;
+        if ( $tax_ship_address && $cust_main->has_ship_address ) {
+          $cust_main->county_state_country('ship_');
+        } else {
+          $cust_main->county_state_country;
+        }
+      }
+
+    } else {
+      #tax?  we shouldn't have wound up here then...
+      ''; #return customer ship or bill address? (depending on tax-ship_address)
+    }
+
+  }
+
+};
+
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_bill_pkg_tax_location.pm         |    6 +--
 FS/FS/cust_location.pm                      |   14 ++++++
 httemplate/search/cust_credit_bill_pkg.html |   64 +++++++++++++++++++++++++-
 3 files changed, 77 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list