very basic start at adding quantities
authorivan <ivan>
Tue, 3 Jun 2008 21:06:39 +0000 (21:06 +0000)
committerivan <ivan>
Tue, 3 Jun 2008 21:06:39 +0000 (21:06 +0000)
FS/FS/Schema.pm
FS/FS/cust_bill.pm
FS/FS/cust_bill_pkg.pm
FS/FS/cust_pkg.pm
httemplate/search/cust_pkg.cgi
httemplate/view/cust_main/packages.html

index ed65201..3df62f7 100644 (file)
@@ -414,6 +414,9 @@ sub tables_hashref {
         'sdate',   @date_type, '', '', 
         'edate',   @date_type, '', '', 
         'itemdesc', 'varchar', 'NULL', $char_d, '', '', 
+        'quantity',  'int', 'NULL', '', '', '',
+        'unitsetup', @money_type, '', '', 
+        'unitrecur', @money_type, '', '', 
       ],
       'primary_key' => 'billpkgnum',
       'unique' => [],
@@ -763,6 +766,7 @@ sub tables_hashref {
         'change_pkgnum',  'int', 'NULL', '', '', '',
         'change_pkgpart', 'int', 'NULL', '', '', '',
         'manual_flag',    'char', 'NULL', 1, '', '', 
+        'quantity',       'int', 'NULL', '', '', '',
       ],
       'primary_key' => 'pkgnum',
       'unique' => [],
index db811c5..8c53e7f 100644 (file)
@@ -1802,6 +1802,7 @@ sub print_latex {
     'address2'     => _latex_escape($cust_main->address2),
     'city'         => _latex_escape($cust_main->city),
     'state'        => _latex_escape($cust_main->state),
+    #'quantity'     => 1,
     'zip'          => _latex_escape($cust_main->zip),
     'footer'       => join("\n", $conf->config_orbase('invoice_latexfooter', $template) ),
     'smallfooter'  => join("\n", $conf->config_orbase('invoice_latexsmallfooter', $template) ),
@@ -1886,7 +1887,9 @@ sub print_latex {
                     map _latex_escape($_), @{$line_item->{'ext_description'}}
                   );
           }
-          $invoice_data{'amount'} = $line_item->{'amount'};
+          $invoice_data{'amount'}       = $line_item->{'amount'};
+          $invoice_data{'unit_amount'}  = $line_item->{'unit_amount'};
+          $invoice_data{'quantity'}     = $line_item->{'quantity'};
           $invoice_data{'product_code'} = $line_item->{'pkgpart'} || 'N/A';
           push @filled_in,
             map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b } @line_item;
@@ -1992,6 +1995,7 @@ sub print_latex {
         @{$detail->{'ext_description'}} = @{$line_item->{'ext_description'}};
       }
       $detail->{'amount'} = $line_item->{'amount'};
+      $detail->{'unit_amount'} = $line_item->{'unit_amount'};
       $detail->{'product_code'} = $line_item->{'pkgpart'} || 'N/A';
   
       push @detail_items, $detail;
@@ -2483,6 +2487,8 @@ sub _items_cust_bill_pkg {
           #pkgpart         => $part_pkg->pkgpart,
           pkgnum          => $cust_bill_pkg->pkgnum,
           amount          => sprintf("%.2f", $cust_bill_pkg->setup),
+          unit_amount     => sprintf("%.2f", $cust_bill_pkg->unitsetup),
+          quantity        => $cust_bill_pkg->quantity,
           ext_description => \@d,
         };
       }
@@ -2508,8 +2514,9 @@ sub _items_cust_bill_pkg {
           #pkgpart         => $part_pkg->pkgpart,
           pkgnum          => $cust_bill_pkg->pkgnum,
           amount          => sprintf("%.2f", $cust_bill_pkg->recur),
+          unit_amount     => sprintf("%.2f", $cust_bill_pkg->unitrecur),
+          quantity        => $cust_bill_pkg->quantity,
           ext_description => \@d,
-
         };
 
       }
index 091d344..7651f90 100644 (file)
@@ -55,6 +55,12 @@ supported:
 
 =item itemdesc - Line item description (currentlty used only when pkgnum is 0 or -1)
 
+=item quantity - If not set, defaults to 1
+
+=item unitsetup - If not set, defaults to setup
+
+=item unitrecur - If not set, defaults to recur
+
 =back
 
 sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">.  Also
@@ -338,6 +344,46 @@ sub cust_credit_bill_pkg {
          );
 }
 
+=item quantity
+
+=cut
+
+sub quantity {
+  my( $self, $value ) = @_;
+  if ( defined($value) ) {
+    $self->setfield('quantity', $value);
+  }
+  $self->getfield('quantity') || 1;
+}
+
+=item unitsetup
+
+=cut
+
+sub unitsetup {
+  my( $self, $value ) = @_;
+  if ( defined($value) ) {
+    $self->setfield('unitsetup', $value);
+  }
+  $self->getfield('unitsetup') eq ''
+    ? $self->getfield('setup')
+    : $self->getfield('unitsetup');
+}
+
+=item unitrecur
+
+=cut
+
+sub unitrecur {
+  my( $self, $value ) = @_;
+  if ( defined($value) ) {
+    $self->setfield('unitrecur', $value);
+  }
+  $self->getfield('unitrecur') eq ''
+    ? $self->getfield('recur')
+    : $self->getfield('unitrecur');
+}
+
 =back
 
 =head1 BUGS
index 2e23cce..c638a13 100644 (file)
@@ -125,6 +125,8 @@ inherits from FS::Record.  The following fields are currently supported:
 =item manual_flag - If this field is set to 1, disables the automatic
 unsuspension of this package when using the B<unsuspendauto> config file.
 
+=item quantity - If not set, defaults to 1
+
 =back
 
 Note: setup, bill, adjourn, susp, expire and cancel are specified as UNIX timestamps;
@@ -1241,6 +1243,18 @@ sub attribute_since_sqlradacct {
 
 }
 
+=item quantity
+
+=cut
+
+sub quantity {
+  my( $self, $value ) = @_;
+  if ( defined($value) ) {
+    $self->setfield('quantity', $value);
+  }
+  $self->getfield('quantity') || 1;
+}
+
 =item transfer DEST_PKGNUM | DEST_CUST_PKG, [ OPTION => VALUE ... ]
 
 Transfers as many services as possible from this package to another package.
index 799ed96..d9ed391 100755 (executable)
@@ -6,6 +6,7 @@
                   'count_query' => $count_query,
                   #'redirect'    => $link,
                   'header'      => [ '#',
+                                     'Quan.',
                                      'Package',
                                      'Class',
                                      'Status',
@@ -25,6 +26,7 @@
                                    ],
                   'fields'      => [
                     'pkgnum',
+                    'quantity',
                     sub { #my $part_pkg = $part_pkg{shift->pkgpart};
                           #$part_pkg->pkg; # ' - '. $part_pkg->comment;
                           $_[0]->pkg; # ' - '. $_[0]->comment;
@@ -87,6 +89,7 @@
                     '',
                     '',
                     '',
+                    '',
                     sub { shift->statuscolor; },
                     '',
                     '',
                     FS::UI::Web::cust_colors(),
                     '',
                   ],
-                  'style' => [ '', '', '', 'b', '', '', '', '', '', '', '', '', '',
+                  'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '',
                                FS::UI::Web::cust_styles() ],
-                  'size'  => [ '', '', '', '-1' ],
-                  'align' => 'rlcclrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
+                  'size'  => [ '', '', '', '', '-1' ],
+                  'align' => 'rrlcclrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
                   'links' => [
                     $link,
                     $link,
+                    $link,
                     '',
                     '',
                     '',
index 0ef9e6c..cc2c3ac 100755 (executable)
@@ -78,7 +78,13 @@ Current packages
 <TR>
   <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
     <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
-    <% $part_pkg->pkg %> - <% $part_pkg->comment %><BR>
+    <% $part_pkg->pkg %> - <% $part_pkg->comment %>
+    <BR>
+
+%   if ( $cust_pkg->quantity > 1 ) {
+        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Quantity: <B><% $cust_pkg->quantity %></B><BR>
+%   }
+
     <FONT SIZE=-1>
 % unless ( $cust_pkg->get('cancel') ) { 
 % if ( $curuser->access_right('Change customer package') ) {