[freeside-commits] branch master updated. 627b53dd54c81b8bf16bf4c6b53184a0b76011a8

Ivan ivan at 420.am
Mon Mar 11 02:17:17 PDT 2013


The branch, master has been updated
       via  627b53dd54c81b8bf16bf4c6b53184a0b76011a8 (commit)
       via  53a1130923c4905b267239c369949aadde657c7c (commit)
      from  a2ff7564f36a5db81bdba053ff70017b8f438904 (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 627b53dd54c81b8bf16bf4c6b53184a0b76011a8
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Mar 11 02:17:13 2013 -0700

    fix quotations, RT#21103

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 2a32534..7d8135d 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -122,7 +122,9 @@ sub print_latex {
     UNLINK   => 0,
   ) or die "can't open temp file: $!\n";
 
-  my $agentnum = $self->cust_main->agentnum;
+  my $cust_main = $self->cust_main;
+  my $prospect_main = $self->prospect_main;
+  my $agentnum = $cust_main ? $cust_main->agentnum : $prospect_main->agentnum;
 
   if ( $template && $conf->exists("logo_${template}.eps", $agentnum) ) {
     print $lh $conf->config_binary("logo_${template}.eps", $agentnum)
diff --git a/httemplate/view/quotation-pdf.cgi b/httemplate/view/quotation-pdf.cgi
new file mode 100755
index 0000000..7f62ce1
--- /dev/null
+++ b/httemplate/view/quotation-pdf.cgi
@@ -0,0 +1,29 @@
+<% $content %>\
+<%init>
+
+#false laziness w/elements/cust_bill-typeset
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Generate quotation'); #View quotations ?
+
+my $quotationnum = $cgi->param('quotationnum');
+
+my $conf = new FS::Conf;
+
+my $quotation = qsearchs({
+  'select'    => 'quotation.*',
+  'table'     => 'quotation',
+  #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+  'hashref'   => { 'quotationnum' => $quotationnum },
+  #'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+});
+die "Quotation #$quotationnum not found!" unless $quotation;
+
+my $content = $quotation->print_pdf(); #\%opt);
+
+http_header('Content-Type' => 'application/pdf');
+http_header('Content-Disposition' => "filename=$quotationnum.pdf" );
+http_header('Content-Length' => length($content) );
+http_header('Cache-control' => 'max-age=60' );
+
+</%init>

commit 53a1130923c4905b267239c369949aadde657c7c
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Mar 11 02:13:24 2013 -0700

    fix quotations, RT#21103

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 717e498..29f8ea4 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1225,6 +1225,8 @@ sub tables_hashref {
     'quotation_pkg' => {
       'columns' => [
         'quotationpkgnum',   'serial',     '', '', '', '', 
+        'quotationnum',         'int', 'NULL', '', '', '', #shouldn't be null,
+                                                           # but history...
         'pkgpart',              'int',     '', '', '', '', 
         'locationnum',          'int', 'NULL', '', '', '',
         'start_date',      @date_type,             '', '', 
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 0d0fbfb..2a32534 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -2049,6 +2049,11 @@ separate quantities, for some reason).
 
 =cut
 
+sub _items_nontax {
+  my $self = shift;
+  grep { $_->pkgnum } $self->cust_bill_pkg;
+}
+
 sub _items_pkg {
   my $self = shift;
   my %options = @_;
@@ -2056,7 +2061,7 @@ sub _items_pkg {
   warn "$me _items_pkg searching for all package line items\n"
     if $DEBUG > 1;
 
-  my @cust_bill_pkg = grep { $_->pkgnum } $self->cust_bill_pkg;
+  my @cust_bill_pkg = $self->_items_nontax;
 
   warn "$me _items_pkg filtering line items\n"
     if $DEBUG > 1;
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index bf2711b..6d36f19 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -176,6 +176,15 @@ sub _total {
 
 }
 
+#prevent things from falsely showing up as taxes, at least until we support
+# quoting tax amounts..
+sub _items_tax {
+  return ();
+}
+sub _items_nontax {
+  shift->cust_bill_pkg;
+}
+
 =item enable_previous
 
 =cut
diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index 47045cd..b5823f4 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -5,6 +5,7 @@ use base qw( FS::TemplateItem_Mixin FS::Record );
 use FS::Record qw( qsearchs ); #qsearch
 use FS::part_pkg;
 use FS::cust_location;
+use FS::quotation;
 use FS::quotation_pkg_discount; #so its loaded when TemplateItem_Mixin needs it
 
 =head1 NAME
@@ -82,8 +83,11 @@ points to.  You can ask the object for a copy with the I<hash> method.
 sub table { 'quotation_pkg'; }
 
 sub display_table         { 'quotation_pkg'; }
-sub display_table_orderby { 'quotationpkgnum'; } # something else?
-                                                 #  (for invoice display order)
+
+#forget it, just overriding cust_bill_pkg_display entirely
+#sub display_table_orderby { 'quotationpkgnum'; } # something else?
+#                                                 #  (for invoice display order)
+
 sub discount_table        { 'quotation_pkg_discount'; }
 
 =item insert
@@ -113,8 +117,9 @@ sub check {
 
   my $error = 
     $self->ut_numbern('quotationpkgnum')
-    || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' )
-    || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum' )
+    || $self->ut_foreign_key(  'quotationnum', 'quotation',    'quotationnum' )
+    || $self->ut_foreign_key(  'pkgpart',      'part_pkg',     'pkgpart'      )
+    || $self->ut_foreign_keyn( 'locationnum', 'cust_location', 'locationnum'  )
     || $self->ut_numbern('start_date')
     || $self->ut_numbern('contract_end')
     || $self->ut_numbern('quantity')
@@ -137,7 +142,7 @@ sub desc {
 
 sub setup {
   my $self = shift;
-  return '0.00' if $self->waive_setup eq 'Y';
+  return '0.00' if $self->waive_setup eq 'Y' || $self->{'_NO_SETUP_KLUDGE'};
   my $part_pkg = $self->part_pkg;
   #my $setup = $part_pkg->can('base_setup') ? $part_pkg->base_setup
   #                                         : $part_pkg->option('setup_fee');
@@ -150,6 +155,7 @@ sub setup {
 
 sub recur {
   my $self = shift;
+  return '0.00' if $self->{'_NO_RECUR_KLUDGE'};
   my $part_pkg = $self->part_pkg;
   my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur
                                            : $part_pkg->option('recur_fee');
@@ -158,6 +164,42 @@ sub recur {
   sprintf('%.2f', $recur);
 }
 
+=item cust_bill_pkg_display [ type => TYPE ]
+
+=cut
+
+sub cust_bill_pkg_display {
+  my ( $self, %opt ) = @_;
+
+  my $type = $opt{type} if exists $opt{type};
+  return () if $type eq 'U'; #quotations don't have usage
+
+  if ( $self->get('display') ) {
+    return ( grep { defined($type) ? ($type eq $_->type) : 1 }
+               @{ $self->get('display') }
+           );
+  } else {
+
+    #??
+    my $setup = $self->new($self->hashref);
+    $setup->{'_NO_RECUR_KLUDGE'} = 1;
+    $setup->{'type'} = 'S';
+    my $recur = $self->new($self->hashref);
+    $recur->{'_NO_SETUP_KLUDGE'} = 1;
+    $recur->{'type'} = 'R';
+
+    if ( $type eq 'S' ) {
+      return ($setup);
+    } elsif ( $type eq 'R' ) {
+      return ($recur);
+    } else {
+      return ($setup, $recur);
+    }
+
+  }
+
+}
+
 =back
 
 =head1 BUGS

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

Summary of changes:
 FS/FS/Schema.pm                   |    2 +
 FS/FS/Template_Mixin.pm           |   11 ++++++-
 FS/FS/quotation.pm                |    9 ++++++
 FS/FS/quotation_pkg.pm            |   52 +++++++++++++++++++++++++++++++++---
 httemplate/view/quotation-pdf.cgi |   29 ++++++++++++++++++++
 5 files changed, 96 insertions(+), 7 deletions(-)
 create mode 100755 httemplate/view/quotation-pdf.cgi




More information about the freeside-commits mailing list