[freeside-commits] freeside/FS/FS Conf.pm, 1.180.2.22, 1.180.2.23 cust_bill.pm, 1.163.2.21, 1.163.2.22

Jeff Finucane,420,, jeff at wavetail.420.am
Wed May 14 14:21:20 PDT 2008


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv27145/FS/FS

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	Conf.pm cust_bill.pm 
Log Message:
config option to omit statement type items from invoices

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.180.2.22
retrieving revision 1.180.2.23
diff -u -d -r1.180.2.22 -r1.180.2.23
--- Conf.pm	14 Mar 2008 02:10:13 -0000	1.180.2.22
+++ Conf.pm	14 May 2008 21:21:17 -0000	1.180.2.23
@@ -2254,6 +2254,13 @@
                      ],
   },
 
+  {
+    'key'         => 'disable_previous_balance',
+    'section'     => 'billing',
+    'description' => 'Disable inclusion of previous balance, payment, and credit lines on invoices',
+    'type'        => 'checkbox',
+  },
+
 );
 
 1;

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.163.2.21
retrieving revision 1.163.2.22
diff -u -d -r1.163.2.21 -r1.163.2.22
--- cust_bill.pm	1 Apr 2008 09:19:36 -0000	1.163.2.21
+++ cust_bill.pm	14 May 2008 21:21:17 -0000	1.163.2.22
@@ -1496,18 +1496,20 @@
   @buf = ();
 
   #previous balance
-  foreach ( @pr_cust_bill ) {
-    push @buf, [
-      "Previous Balance, Invoice #". $_->invnum. 
-                 " (". time2str("%x",$_->_date). ")",
-      $money_char. sprintf("%10.2f",$_->owed)
-    ];
-  }
-  if (@pr_cust_bill) {
-    push @buf,['','-----------'];
-    push @buf,[ 'Total Previous Balance',
-                $money_char. sprintf("%10.2f",$pr_total ) ];
-    push @buf,['',''];
+  unless ($conf->exists('disable_previous_balance')) {
+    foreach ( @pr_cust_bill ) {
+      push @buf, [
+        "Previous Balance, Invoice #". $_->invnum. 
+                   " (". time2str("%x",$_->_date). ")",
+        $money_char. sprintf("%10.2f",$_->owed)
+      ];
+    }
+    if (@pr_cust_bill) {
+      push @buf,['','-----------'];
+      push @buf,[ 'Total Previous Balance',
+                  $money_char. sprintf("%10.2f",$pr_total ) ];
+      push @buf,['',''];
+    }
   }
 
   #new charges
@@ -1566,53 +1568,57 @@
   }
 
   push @buf,['','-----------'];
-  push @buf,['Total New Charges',
+  push @buf,[ ( $conf->exists('disable_previous_balance')
+                ? 'Total Charges'
+                : 'Total New Charges'),
              $money_char. sprintf("%10.2f",$self->charged) ];
   push @buf,['',''];
 
-  push @buf,['','-----------'];
-  push @buf,['Total Charges',
-             $money_char. sprintf("%10.2f",$self->charged + $pr_total) ];
-  push @buf,['',''];
+  unless ($conf->exists('disable_previous_balance')) {
+    push @buf,['','-----------'];
+    push @buf,['Total Charges',
+               $money_char. sprintf("%10.2f",$self->charged + $pr_total) ];
+    push @buf,['',''];
 
-  #credits
-  foreach ( $self->cust_credited ) {
+    #credits
+    foreach ( $self->cust_credited ) {
 
-    #something more elaborate if $_->amount ne $_->cust_credit->credited ?
+      #something more elaborate if $_->amount ne $_->cust_credit->credited ?
 
-    my $reason = substr($_->cust_credit->reason,0,32);
-    $reason .= '...' if length($reason) < length($_->cust_credit->reason);
-    $reason = " ($reason) " if $reason;
-    push @buf,[
-      "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")".
-        $reason,
-      $money_char. sprintf("%10.2f",$_->amount)
-    ];
-  }
-  #foreach ( @cr_cust_credit ) {
-  #  push @buf,[
-  #    "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")",
-  #    $money_char. sprintf("%10.2f",$_->credited)
-  #  ];
-  #}
+      my $reason = substr($_->cust_credit->reason,0,32);
+      $reason .= '...' if length($reason) < length($_->cust_credit->reason);
+      $reason = " ($reason) " if $reason;
+      push @buf,[
+        "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")".
+          $reason,
+        $money_char. sprintf("%10.2f",$_->amount)
+      ];
+    }
+    #foreach ( @cr_cust_credit ) {
+    #  push @buf,[
+    #    "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")",
+    #    $money_char. sprintf("%10.2f",$_->credited)
+    #  ];
+    #}
 
-  #get & print payments
-  foreach ( $self->cust_bill_pay ) {
+    #get & print payments
+    foreach ( $self->cust_bill_pay ) {
 
-    #something more elaborate if $_->amount ne ->cust_pay->paid ?
+      #something more elaborate if $_->amount ne ->cust_pay->paid ?
 
-    push @buf,[
-      "Payment received ". time2str("%x",$_->cust_pay->_date ),
-      $money_char. sprintf("%10.2f",$_->amount )
-    ];
-  }
+      push @buf,[
+        "Payment received ". time2str("%x",$_->cust_pay->_date ),
+        $money_char. sprintf("%10.2f",$_->amount )
+      ];
+    }
 
-  #balance due
-  my $balance_due_msg = $self->balance_due_msg;
+    #balance due
+    my $balance_due_msg = $self->balance_due_msg;
 
-  push @buf,['','-----------'];
-  push @buf,[$balance_due_msg, $money_char. 
-    sprintf("%10.2f", $balance_due ) ];
+    push @buf,['','-----------'];
+    push @buf,[$balance_due_msg, $money_char. 
+      sprintf("%10.2f", $balance_due ) ];
+  }
 
   #create the template
   $template ||= $self->_agent_template;
@@ -1943,7 +1949,7 @@
     $invoice_data{'detail_items'} = \@detail_items;
     $invoice_data{'total_items'} = \@total_items;
   
-    foreach my $line_item ( $self->_items ) {
+    foreach my $line_item ( $self->_items($conf->exists('disable_previous_balance') ? qw( _items_pkg ) : () ) ) {
       my $detail = {
         ext_description => [],
       };
@@ -1983,36 +1989,45 @@
       my $total = {};
       $total->{'total_item'} = '\textbf{Total}';
       $total->{'total_amount'} =
-        '\textbf{\dollar '. sprintf('%.2f', $self->charged + $pr_total ). '}';
+        '\textbf{\dollar '.
+        sprintf( '%.2f',
+                 $self->charged + ( $conf->exists('disable_previous_balance')
+                                    ? 0
+                                    : $pr_total
+                                  )
+               ).
+      '}';
       push @total_items, $total;
     }
   
-    #foreach my $thing ( sort { $a->_date <=> $b->_date } $self->_items_credits, $self->_items_payments
+    unless ($conf->exists('disable_previous_balance')) {
+      #foreach my $thing ( sort { $a->_date <=> $b->_date } $self->_items_credits, $self->_items_payments
   
-    # credits
-    foreach my $credit ( $self->_items_credits ) {
-      my $total;
-      $total->{'total_item'} = _latex_escape($credit->{'description'});
-      #$credittotal
-      $total->{'total_amount'} = '-\dollar '. $credit->{'amount'};
-      push @total_items, $total;
-    }
+      # credits
+      foreach my $credit ( $self->_items_credits ) {
+        my $total;
+        $total->{'total_item'} = _latex_escape($credit->{'description'});
+        #$credittotal
+        $total->{'total_amount'} = '-\dollar '. $credit->{'amount'};
+        push @total_items, $total;
+      }
   
-    # payments
-    foreach my $payment ( $self->_items_payments ) {
-      my $total = {};
-      $total->{'total_item'} = _latex_escape($payment->{'description'});
-      #$paymenttotal
-      $total->{'total_amount'} = '-\dollar '. $payment->{'amount'};
-      push @total_items, $total;
-    }
+      # payments
+      foreach my $payment ( $self->_items_payments ) {
+        my $total = {};
+        $total->{'total_item'} = _latex_escape($payment->{'description'});
+        #$paymenttotal
+        $total->{'total_amount'} = '-\dollar '. $payment->{'amount'};
+        push @total_items, $total;
+      }
   
-    { 
-      my $total;
-      $total->{'total_item'} = '\textbf{'. $self->balance_due_msg. '}';
-      $total->{'total_amount'} =
-        '\textbf{\dollar '. sprintf('%.2f', $self->owed + $pr_total ). '}';
-      push @total_items, $total;
+      { 
+        my $total;
+        $total->{'total_item'} = '\textbf{'. $self->balance_due_msg. '}';
+        $total->{'total_amount'} =
+          '\textbf{\dollar '. sprintf('%.2f', $self->owed + $pr_total ). '}';
+        push @total_items, $total;
+      }
     }
 
   } else {
@@ -2251,7 +2266,7 @@
 
   my $money_char = $conf->config('money_char') || '$';
 
-  foreach my $line_item ( $self->_items ) {
+  foreach my $line_item ( $self->_items($conf->exists('disable_previous_balance') ? qw( _items_pkg ) : () ) ) {
     my $detail = {
       ext_description => [],
     };
@@ -2291,36 +2306,45 @@
     my $total = {};
     $total->{'total_item'} = '<b>Total</b>';
     $total->{'total_amount'} =
-      "<b>$money_char".  sprintf('%.2f', $self->charged + $pr_total ). '</b>';
+      "<b>$money_char".
+      sprintf( '%.2f',
+               $self->charged + ( $conf->exists('disable_previous_balance')
+                                  ? 0
+                                  : $pr_total
+                                )
+             ).
+      '</b>';
     push @{$invoice_data{'total_items'}}, $total;
   }
 
-  #foreach my $thing ( sort { $a->_date <=> $b->_date } $self->_items_credits, $self->_items_payments
+  unless ($conf->exists('disable_previous_balance')) {
+    #foreach my $thing ( sort { $a->_date <=> $b->_date } $self->_items_credits, $self->_items_payments
 
-  # credits
-  foreach my $credit ( $self->_items_credits ) {
-    my $total;
-    $total->{'total_item'} = encode_entities($credit->{'description'});
-    #$credittotal
-    $total->{'total_amount'} = "-$money_char". $credit->{'amount'};
-    push @{$invoice_data{'total_items'}}, $total;
-  }
+    # credits
+    foreach my $credit ( $self->_items_credits ) {
+      my $total;
+      $total->{'total_item'} = encode_entities($credit->{'description'});
+      #$credittotal
+      $total->{'total_amount'} = "-$money_char". $credit->{'amount'};
+      push @{$invoice_data{'total_items'}}, $total;
+    }
 
-  # payments
-  foreach my $payment ( $self->_items_payments ) {
-    my $total = {};
-    $total->{'total_item'} = encode_entities($payment->{'description'});
-    #$paymenttotal
-    $total->{'total_amount'} = "-$money_char". $payment->{'amount'};
-    push @{$invoice_data{'total_items'}}, $total;
-  }
+    # payments
+    foreach my $payment ( $self->_items_payments ) {
+      my $total = {};
+      $total->{'total_item'} = encode_entities($payment->{'description'});
+      #$paymenttotal
+      $total->{'total_amount'} = "-$money_char". $payment->{'amount'};
+      push @{$invoice_data{'total_items'}}, $total;
+    }
 
-  { 
-    my $total;
-    $total->{'total_item'} = '<b>'. $self->balance_due_msg. '</b>';
-    $total->{'total_amount'} =
-      "<b>$money_char".  sprintf('%.2f', $self->owed + $pr_total ). '</b>';
-    push @{$invoice_data{'total_items'}}, $total;
+    { 
+      my $total;
+      $total->{'total_item'} = '<b>'. $self->balance_due_msg. '</b>';
+      $total->{'total_amount'} =
+        "<b>$money_char".  sprintf('%.2f', $self->owed + $pr_total ). '</b>';
+      push @{$invoice_data{'total_items'}}, $total;
+    }
   }
 
   $html_template->fill_in( HASH => \%invoice_data);



More information about the freeside-commits mailing list