Email::Sender::Transport::SMTP::TLS no longer needed
[freeside.git] / FS / FS / cust_bill.pm
index 38b1d5c..459206b 100644 (file)
@@ -41,6 +41,7 @@ use FS::cust_bill_void;
 use FS::reason;
 use FS::reason_type;
 use FS::L10N;
 use FS::reason;
 use FS::reason_type;
 use FS::L10N;
+use FS::Misc::Savepoint;
 
 $DEBUG = 0;
 $me = '[FS::cust_bill]';
 
 $DEBUG = 0;
 $me = '[FS::cust_bill]';
@@ -890,7 +891,7 @@ sub owed {
 Returns the amount to be displayed as the "Balance Due" on this
 invoice.  Amount returned depends on conf flags for invoicing
 
 Returns the amount to be displayed as the "Balance Due" on this
 invoice.  Amount returned depends on conf flags for invoicing
 
-See L<FS::cust_bill::owed> for the true amount currently owed
+See L<FS::cust_bill/owed> for the true amount currently owed
 
 =cut
 
 
 =cut
 
@@ -974,6 +975,9 @@ sub apply_payments_and_credits {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
+  my $savepoint_label = 'cust_bill__apply_payments_and_credits';
+  savepoint_create( $savepoint_label );
+
   $self->select_for_update; #mutex
 
   my @payments = grep { $_->unapplied > 0 }
   $self->select_for_update; #mutex
 
   my @payments = grep { $_->unapplied > 0 }
@@ -1062,6 +1066,7 @@ sub apply_payments_and_credits {
 
     my $error = $app->insert(%options);
     if ( $error ) {
 
     my $error = $app->insert(%options);
     if ( $error ) {
+      savepoint_rollback_and_release( $savepoint_label );
       $dbh->rollback if $oldAutoCommit;
       return "Error inserting ". $app->table. " record: $error";
     }
       $dbh->rollback if $oldAutoCommit;
       return "Error inserting ". $app->table. " record: $error";
     }
@@ -1069,6 +1074,7 @@ sub apply_payments_and_credits {
 
   }
 
 
   }
 
+  savepoint_release( $savepoint_label );
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
   ''; #no error
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
   ''; #no error
 
@@ -1366,7 +1372,7 @@ sub ftp_invoice {
 
 =item spool_invoice [ TEMPLATENAME ]
 
 
 =item spool_invoice [ TEMPLATENAME ]
 
-Spools this invoice data (see L<FS::spool_csv>)
+Spools this invoice data (see L<FS::cust_bill/spool_csv>)
 
 TEMPLATENAME is unused?
 
 
 TEMPLATENAME is unused?
 
@@ -1405,6 +1411,11 @@ See L</print_csv> for a description of the output format.
 sub send_csv {
   my($self, %opt) = @_;
 
 sub send_csv {
   my($self, %opt) = @_;
 
+  if ( $FS::Misc::DISABLE_ALL_NOTICES ) {
+    warn 'send_csv() disabled by $FS::Misc::DISABLE_ALL_NOTICES' if $DEBUG;
+    return;
+  }
+
   #create file(s)
 
   my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/cust_bill";
   #create file(s)
 
   my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/cust_bill";
@@ -1481,6 +1492,11 @@ in the ICS format.
 sub spool_csv {
   my($self, %opt) = @_;
 
 sub spool_csv {
   my($self, %opt) = @_;
 
+  if ( $FS::Misc::DISABLE_ALL_NOTICES ) {
+    warn 'spool_csv() disabled by $FS::Misc::DISABLE_ALL_NOTICES' if $DEBUG;
+    return;
+  }
+
   my $time = $opt{'time'} || time;
   my $cust_main = $self->cust_main;
 
   my $time = $opt{'time'} || time;
   my $cust_main = $self->cust_main;
 
@@ -2716,7 +2732,7 @@ sub _items_svc_phone_sections {
 
 }
 
 
 }
 
-=sub _items_usage_class_summary OPTIONS
+=item _items_usage_class_summary OPTIONS
 
 Returns a list of detail items summarizing the usage charges on this
 invoice.  Each one will have 'amount', 'description' (the usage charge name),
 
 Returns a list of detail items summarizing the usage charges on this
 invoice.  Each one will have 'amount', 'description' (the usage charge name),
@@ -2765,7 +2781,7 @@ sub _items_usage_class_summary {
   return @l;
 }
 
   return @l;
 }
 
-=sub _items_previous()
+=item _items_previous()
 
   Returns an array of hashrefs, each hashref representing a line-item on
   the current bill for previous unpaid invoices.
 
   Returns an array of hashrefs, each hashref representing a line-item on
   the current bill for previous unpaid invoices.
@@ -2899,7 +2915,7 @@ sub _items_previous {
 
 }
 
 
 }
 
-=sub _items_previous_total
+=item _items_previous_total
 
   Return sum of amounts from all items returned by _items_previous
   Results will vary based on invoicing conf flags
 
   Return sum of amounts from all items returned by _items_previous
   Results will vary based on invoicing conf flags
@@ -2949,7 +2965,7 @@ sub __items_previous_map_invoice {
   }
 }
 
   }
 }
 
-=sub _items_credits()
+=item _items_credits()
 
   Return array of hashrefs containing credits to be shown as line-items
   when rendering this bill.
 
   Return array of hashrefs containing credits to be shown as line-items
   when rendering this bill.
@@ -3088,7 +3104,7 @@ sub _items_credits {
   @return;
 }
 
   @return;
 }
 
-=sub _items_credits_total
+=item _items_credits_total
 
   Return the total of al items from _items_credits
   Will vary based on invoice display conf flag
 
   Return the total of al items from _items_credits
   Will vary based on invoice display conf flag
@@ -3104,7 +3120,7 @@ sub _items_credits_total {
 
 
 
 
 
 
-=sub _items_credits_postbill()
+=item _items_credits_postbill()
 
   Returns an array of hashrefs for credits where
   - Credit issued after this invoice
 
   Returns an array of hashrefs for credits where
   - Credit issued after this invoice
@@ -3146,7 +3162,7 @@ sub _items_credits_postbill {
   }} @cust_credit_bill;
 }
 
   }} @cust_credit_bill;
 }
 
-=sub _items_payments_postbill()
+=item _items_payments_postbill()
 
   Returns an array of hashrefs for payments where
   - Payment occured after this invoice
 
   Returns an array of hashrefs for payments where
   - Payment occured after this invoice
@@ -3182,7 +3198,7 @@ sub _items_payments_postbill {
   }} @cust_bill_pay;
 }
 
   }} @cust_bill_pay;
 }
 
-=sub _items_payments()
+=item _items_payments()
 
   Return array of hashrefs containing payments to be shown as line-items
   when rendering this bill.
 
   Return array of hashrefs containing payments to be shown as line-items
   when rendering this bill.
@@ -3243,7 +3259,6 @@ sub _items_payments {
 
   if ($self->conf->exists('previous_balance-payments_since')) {
     if ($template eq 'statement') {
 
   if ($self->conf->exists('previous_balance-payments_since')) {
     if ($template eq 'statement') {
-print "\nCASE 3\n";
       # Case 3 (see above)
       # Return payments timestamped between the previous and following bills
 
       # Case 3 (see above)
       # Return payments timestamped between the previous and following bills
 
@@ -3267,7 +3282,7 @@ print "\nCASE 3\n";
     } else {
       # Case 2 (see above)
       # Return payments timestamped between this and the previous bill
     } else {
       # Case 2 (see above)
       # Return payments timestamped between this and the previous bill
-print "\nCASE 2\n";
+
       my $date_start = 0;
       my $date_end = $self->_date;
 
       my $date_start = 0;
       my $date_end = $self->_date;
 
@@ -3301,7 +3316,7 @@ print "\nCASE 2\n";
   return @{ $self->get('_items_payments') };
 }
 
   return @{ $self->get('_items_payments') };
 }
 
-=sub _items_payments_total
+=item _items_payments_total
 
   Return a total of all records returned by _items_payments
   Results vary based on invoicing conf flags
 
   Return a total of all records returned by _items_payments
   Results vary based on invoicing conf flags
@@ -3358,7 +3373,7 @@ sub __items_payments_make_hashref {
   return @return;
 }
 
   return @return;
 }
 
-=sub _items_total()
+=item _items_total()
 
   Generate the line-items to be shown on the bill in the "Totals" section
 
 
   Generate the line-items to be shown on the bill in the "Totals" section
 
@@ -3815,7 +3830,7 @@ The delete method.
 =head1 SEE ALSO
 
 L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill_pay>, L<FS::cust_pay>,
 =head1 SEE ALSO
 
 L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill_pay>, L<FS::cust_pay>,
-L<FS::cust_bill_pkg>, L<FS::cust_bill_credit>, schema.html from the base
+L<FS::cust_bill_pkg>, L<FS::cust_credit>, schema.html from the base
 documentation.
 
 =cut
 documentation.
 
 =cut