[freeside-commits] branch master updated. c5310e027f5d7264b22640f72c3f1744148045ff

Mark Wells mark at 420.am
Wed Mar 27 12:34:59 PDT 2013


The branch, master has been updated
       via  c5310e027f5d7264b22640f72c3f1744148045ff (commit)
      from  3ee7348febaf61d9662b463aad3053210593b06b (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 c5310e027f5d7264b22640f72c3f1744148045ff
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Mar 27 12:34:22 2013 -0700

    cust_bill_owed_percent condition, #611

diff --git a/FS/FS/part_event/Condition/cust_bill_owed_percent.pm b/FS/FS/part_event/Condition/cust_bill_owed_percent.pm
new file mode 100644
index 0000000..e06b511
--- /dev/null
+++ b/FS/FS/part_event/Condition/cust_bill_owed_percent.pm
@@ -0,0 +1,50 @@
+package FS::part_event::Condition::cust_bill_owed_percent;
+
+use strict;
+use FS::cust_bill;
+
+use base qw( FS::part_event::Condition );
+
+sub description {
+  'Percentage owed on specific invoice';
+}
+
+sub eventtable_hashref {
+    { 'cust_main' => 0,
+      'cust_bill' => 1,
+      'cust_pkg'  => 0,
+    };
+}
+
+sub option_fields {
+  (
+    'owed' => { 'label'      => 'Percentage of invoice owed over',
+                'type'       => 'percentage',
+                'value'      => '0', #default
+              },
+  );
+}
+
+sub condition {
+  #my($self, $cust_bill, %opt) = @_;
+  my($self, $cust_bill) = @_;
+
+  my $percent = $self->option('owed') || 0;
+  my $over = sprintf('%.2f',
+      $cust_bill->charged * $percent / 100);
+
+  $cust_bill->owed > $over;
+}
+
+sub condition_sql {
+  my( $class, $table ) = @_;
+
+  # forces the option to be an integer--do we care?
+  my $percent = $class->condition_sql_option_integer('owed');
+
+  my $owed_sql = FS::cust_bill->owed_sql;
+
+  "$owed_sql > CAST( cust_bill.charged * $percent / 100 AS DECIMAL(10,2) )";
+}
+
+1;
diff --git a/httemplate/elements/selectlayers.html b/httemplate/elements/selectlayers.html
index 01fd590..cb1d2d6 100644
--- a/httemplate/elements/selectlayers.html
+++ b/httemplate/elements/selectlayers.html
@@ -236,7 +236,7 @@ sub layer_callback {
       $date_noinit = 1;
     }
     else {
-      $include = "input-$include" if $include =~ /^(text|money)$/;
+      $include = "input-$include" if $include =~ /^(text|money|percentage)$/;
       $include = "tr-$include" unless $include eq 'hidden';
       $html .= include( "/elements/$include.html",
                         %$lf,

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

Summary of changes:
 .../part_event/Condition/cust_bill_owed_percent.pm |   50 ++++++++++++++++++++
 httemplate/elements/selectlayers.html              |    2 +-
 2 files changed, 51 insertions(+), 1 deletions(-)
 create mode 100644 FS/FS/part_event/Condition/cust_bill_owed_percent.pm




More information about the freeside-commits mailing list