[freeside-commits] branch master updated. 6f254619bd2cc7e7b3cc94f90b6a33c568db974e

Ivan ivan at 420.am
Sun Jan 20 11:43:00 PST 2013


The branch, master has been updated
       via  6f254619bd2cc7e7b3cc94f90b6a33c568db974e (commit)
      from  795aa783f79e6d286ffcbd8ce4d00ede5aa5c003 (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 6f254619bd2cc7e7b3cc94f90b6a33c568db974e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Jan 20 11:42:56 2013 -0800

    commissions based on actual invoiced amounts, RT#21002

diff --git a/FS/FS/part_event/Action/Mixin/credit_pkg.pm b/FS/FS/part_event/Action/Mixin/credit_pkg.pm
index 9dcd701..a3c1d6e 100644
--- a/FS/FS/part_event/Action/Mixin/credit_pkg.pm
+++ b/FS/FS/part_event/Action/Mixin/credit_pkg.pm
@@ -16,18 +16,24 @@ sub option_fields {
                      'type'    => 'input-percentage',
                      'default' => '100',
                    },
-    'what' => { 'label'   => 'Of',
-                'type'    => 'select',
-                #add additional ways to specify in the package def
-                'options' => [ qw( base_recur_permonth unit_setup recur_cost_permonth setup_cost ) ],
-                'labels'  => { 'base_recur_permonth' => 'Base monthly fee',
-                               'unit_setup'          => 'Setup fee',
-                               'recur_cost_permonth' => 'Monthly cost',
-                               'setup_cost'          => 'Setup cost',
-                             },
-              },
+    'what' => {
+      'label'   => 'Of',
+      'type'    => 'select',
+      #add additional ways to specify in the package def
+      'options' => [qw(
+        base_recur_permonth cust_bill_pkg_recur recur_cost_permonth
+        unit_setup setup_cost
+      )],
+      'labels'  => {
+        'base_recur_permonth' => 'Base monthly fee',
+        'cust_bill_pkg_recur' => 'Actual invoiced amount of most recent'.
+                                 ' recurring charge',
+        'recur_cost_permonth' => 'Monthly cost',
+        'unit_setup'          => 'Setup fee',
+        'setup_cost'          => 'Setup cost',
+      },
+    },
   );
-
 }
 
 #my %no_cust_pkg = ( 'setup_cost' => 1 );
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index d4c420f..0d6f8a1 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -1450,6 +1450,29 @@ sub recur_cost_permonth {
   sprintf('%.2f', $self->recur_cost / $self->freq );
 }
 
+=item cust_bill_pkg_recur CUST_PKG
+
+Actual recurring charge for the specified customer package from customer's most
+recent invoice
+
+=cut
+
+sub cust_bill_pkg_recur {
+  my($self, $cust_pkg) = @_;
+  my $cust_bill_pkg = qsearchs({
+    'table'     => 'cust_bill_pkg',
+    'addl_from' => 'LEFT JOIN cust_bill USING ( invnum )',
+    'hashref'   => { 'pkgnum' => $cust_pkg->pkgnum,
+                     'recur'  => { op=>'>', value=>'0' },
+                   },
+    'order_by'  => 'ORDER BY cust_bill._date     DESC,
+                             cust_bill_pkg.sdate DESC
+                     LIMIT 1
+                   ',
+  }) or return 0; #die "use cust_bill_pkg_recur credits with once_perinv condition";
+  $cust_bill_pkg->recur;
+}
+
 =item format OPTION DATA
 
 Returns data formatted according to the function 'format' described

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

Summary of changes:
 FS/FS/part_event/Action/Mixin/credit_pkg.pm |   28 ++++++++++++++++----------
 FS/FS/part_pkg.pm                           |   23 ++++++++++++++++++++++
 2 files changed, 40 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list