[freeside-commits] branch FREESIDE_3_BRANCH updated. 04d785086c73796a05596cb9789d323b5e144752

Jonathan Prykop jonathan at 420.am
Fri Mar 13 20:13:59 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  04d785086c73796a05596cb9789d323b5e144752 (commit)
       via  144292b2e08dc97bf76b0df6a4ee73c3fe8eaa96 (commit)
      from  85d05fd938528eb1d49a9a634575da6b19eb5b53 (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 04d785086c73796a05596cb9789d323b5e144752
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Mar 13 21:54:34 2015 -0500

    RT#25563 [documentation]

diff --git a/FS/FS/part_event/Action/Mixin/credit_bill.pm b/FS/FS/part_event/Action/Mixin/credit_bill.pm
index 694f965..5a26d2e 100644
--- a/FS/FS/part_event/Action/Mixin/credit_bill.pm
+++ b/FS/FS/part_event/Action/Mixin/credit_bill.pm
@@ -50,6 +50,7 @@ our %part_pkg_cache;
 # 2. the recipient of the commission; may be FS::sales, FS::agent, 
 # FS::access_user, etc. Here we don't use it, but it will be passed through
 # to _calc_credit_percent.
+# 3. optional scalar reference for recording a warning message
 
 sub _calc_credit {
   my $self = shift;

commit 144292b2e08dc97bf76b0df6a4ee73c3fe8eaa96
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Mar 9 20:57:30 2015 -0500

    RT#25563: Better handling of commissions which do not have rates configured

diff --git a/FS/FS/part_event/Action/Mixin/credit_bill.pm b/FS/FS/part_event/Action/Mixin/credit_bill.pm
index 82b215d..694f965 100644
--- a/FS/FS/part_event/Action/Mixin/credit_bill.pm
+++ b/FS/FS/part_event/Action/Mixin/credit_bill.pm
@@ -54,6 +54,9 @@ our %part_pkg_cache;
 sub _calc_credit {
   my $self = shift;
   my $cust_bill_pkg = shift;
+  my $who = shift;
+  my $warnref = shift;
+  my $warning = '';
 
   my $what = $self->option('what');
   my $cost = ($what =~ /_cost/ ? 1 : 0);
@@ -64,9 +67,11 @@ sub _calc_credit {
 
   my $percent;
   if ( $self->can('_calc_credit_percent') ) {
-    $percent = $self->_calc_credit_percent($cust_pkg, @_);
+    $percent = $self->_calc_credit_percent($cust_pkg, $who);
+    $warning = 'Percent calculated to zero ' unless $percent+0;
   } else {
     $percent = $self->option('percent') || 0;
+    $warning = 'Percent set to zero ' unless $percent+0;
   }
 
   my $charge = 0;
@@ -83,20 +88,26 @@ sub _calc_credit {
     }
 
     $charge = ($charge || 0) * ($cust_pkg->quantity || 1);
+    $warning .= 'Charge calculated to zero ' unless $charge+0;
 
   } else { # setup, recur, or setuprecur
 
     if ( $what eq 'setup' ) {
       $charge = $cust_bill_pkg->get('setup');
+      $warning .= 'Setup is zero ' unless $charge+0;
     } elsif ( $what eq 'recur' ) {
       $charge = $cust_bill_pkg->get('recur');
+      $warning .= 'Recur is zero ' unless $charge+0;
     } elsif ( $what eq 'setuprecur' ) {
       $charge = $cust_bill_pkg->get('setup') + $cust_bill_pkg->get('recur');
+      $warning .= 'Setup and recur are zero ' unless $charge+0;
     }
 
     # don't multiply by quantity here; it's already included
   }
 
+  $$warnref .= $warning if ref($warnref);
+
   $charge = 0 if $charge < 0; # e.g. prorate
   return ($percent * $charge / 100);
 }
diff --git a/FS/FS/part_event/Action/bill_sales_credit.pm b/FS/FS/part_event/Action/bill_sales_credit.pm
index 3193a81..ab69375 100644
--- a/FS/FS/part_event/Action/bill_sales_credit.pm
+++ b/FS/FS/part_event/Action/bill_sales_credit.pm
@@ -38,6 +38,7 @@ sub do_action {
                                          pkgnum => { op => '>', value => '0' }
                                        });
 
+  my $warning = '';
   foreach my $cust_bill_pkg (@items) {
     my $pkgnum = $cust_bill_pkg->pkgnum;
     my $cust_pkg = $pkgnum_pkg{$pkgnum} ||= $cust_bill_pkg->cust_pkg;
@@ -50,7 +51,7 @@ sub do_action {
 
     next if !$sales; #no sales person, no credit
 
-    my $amount = $self->_calc_credit($cust_bill_pkg, $sales);
+    my $amount = $self->_calc_credit($cust_bill_pkg, $sales, \$warning);
 
     if ($amount > 0) {
       $salesnum_amount{$salesnum} ||= 0;
@@ -86,6 +87,8 @@ sub do_action {
       if $error;
   } # foreach $salesnum
 
+  return $warning;
+
 }
 
 1;

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

Summary of changes:
 FS/FS/part_event/Action/Mixin/credit_bill.pm |   14 +++++++++++++-
 FS/FS/part_event/Action/bill_sales_credit.pm |    5 ++++-
 2 files changed, 17 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list