[freeside-commits] branch master updated. 3f77bb21dfb560a6a91d828f7af9844f80d0d914

Mark Wells mark at 420.am
Thu Sep 5 14:56:12 PDT 2013


The branch, master has been updated
       via  3f77bb21dfb560a6a91d828f7af9844f80d0d914 (commit)
      from  9327f3d24c49da3200413966d153e8415c26e744 (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 3f77bb21dfb560a6a91d828f7af9844f80d0d914
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Sep 5 14:49:32 2013 -0700

    move a2billing tariff and prepaid options to package def, #24572, #24574

diff --git a/FS/FS/part_export/a2billing.pm b/FS/FS/part_export/a2billing.pm
index 52680dc..dc152e4 100644
--- a/FS/FS/part_export/a2billing.pm
+++ b/FS/FS/part_export/a2billing.pm
@@ -21,7 +21,6 @@ tie %options, 'Tie::IxHash',
   'username'    => { label=>'Database username' },
   'password'    => { label=>'Database password' },
   'didgroup'    => { label=>'DID group ID', default=>1 },
-  'tariffgroup' => { label=>'Tariff group ID', default=>1 },
   'credit'      => { label=>'Default credit limit' },
   'billtype'    => {label=>'Billing type',
                     type => 'select',
@@ -112,6 +111,7 @@ sub export_insert {
   my $cust_pkg = $svc->cust_svc->cust_pkg;
   my $cust_main = $cust_pkg->cust_main;
   my $location = $cust_pkg->cust_location;
+  my $part_pkg = $cust_pkg->part_pkg;
 
   my $error;
   $DEBUG ||= $self->option('debug');
@@ -131,9 +131,8 @@ sub export_insert {
       username  => $username,
       useralias => $username,
       uipass    => $svc->_password,
-      # XXX these options may move to a part_pkg at some point
       credit    => $self->option('credit') || 0,
-      tariff    => $self->option('tariffgroup'),
+      tariff    => $part_pkg->option('a2billing_tariff'),
       status    => 1,
       lastname  => $cust_main->last, # $svc->finger?
       firstname => $cust_main->first,
@@ -143,9 +142,10 @@ sub export_insert {
       state     => $location->state,
       country   => $country3,
       zipcode   => $location->zip,
-      typepaid  => 1,
+      typepaid  => $part_pkg->option('a2billing_type'),
       sip_buddy => 1,
       company_name => $cust_main->company,
+      activated => 't',
     );
     warn "creating A2B cc_card record for $username\n" if $DEBUG;
     $error = $self->a2b_insert_or_replace('cc_card', 'svcnum', \%cc_card);
diff --git a/FS/FS/part_pkg/global_Mixin.pm b/FS/FS/part_pkg/global_Mixin.pm
index 137db1c..2dad511 100644
--- a/FS/FS/part_pkg/global_Mixin.pm
+++ b/FS/FS/part_pkg/global_Mixin.pm
@@ -3,6 +3,12 @@ package FS::part_pkg::global_Mixin;
 use strict;
 use vars qw(%info);
 
+use Tie::IxHash;
+tie my %a2billing_types, 'Tie::IxHash', (
+  0 => 'Prepaid',
+  1 => 'Postpaid',
+);
+
 %info = (
   'disabled' => 1,
   'fields' => {
@@ -29,6 +35,24 @@ use vars qw(%info);
                 'changing packages',
       'type' => 'checkbox',
     },
+
+    # miscellany--maybe put this in a separate module?
+
+    'a2billing_tariff' => {
+      'name'        => 'A2Billing tariff group ID',
+      'display_if'  => sub {
+        FS::part_export->count("exporttype = 'a2billing'") > 0;
+      }
+    },
+    'a2billing_type' => {
+      'name'        => 'A2Billing card type',
+      'display_if'  => sub {
+        FS::part_export->count("exporttype = 'a2billing'") > 0;
+      },
+      'type'        => 'select',
+      'select_options' => \%a2billing_types,
+    },
+
   },
   'fieldorder' => [ qw(
     setup_fee
@@ -36,6 +60,9 @@ use vars qw(%info);
     unused_credit_cancel
     unused_credit_suspend
     unused_credit_change
+
+    a2billing_tariff
+    a2billing_type
   )],
 );
 
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 7e67c83..7f8a707 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -888,11 +888,16 @@ my $html_bottom = sub {
   
     foreach my $field ( grep $_ !~ /^(setup|recur)_fee$/, @fields ) {
   
-       if(!exists($href->{$field})) {
+      if(!exists($href->{$field})) {
         # shouldn't happen
         warn "nonexistent part_pkg option: '$field'\n";
         next;
       }
+      if ( exists($href->{$field}->{display_if}) ) {
+        my %args = ( 'plan' => $layer ); # anything else?
+        my $display = &{ $href->{$field}->{display_if} }(%args);
+        next if !$display;
+      }
 
       $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>';
   

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

Summary of changes:
 FS/FS/part_export/a2billing.pm |    8 ++++----
 FS/FS/part_pkg/global_Mixin.pm |   27 +++++++++++++++++++++++++++
 httemplate/edit/part_pkg.cgi   |    7 ++++++-
 3 files changed, 37 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list