add a reset feature to manual recharges (#1858)
authorjeff <jeff>
Sun, 23 Dec 2007 22:05:54 +0000 (22:05 +0000)
committerjeff <jeff>
Sun, 23 Dec 2007 22:05:54 +0000 (22:05 +0000)
FS/FS/part_pkg/flat.pm
FS/FS/part_pkg/prorate.pm
FS/FS/part_pkg/subscription.pm
httemplate/misc/process/recharge_svc.html

index f5ccd01..92e72cf 100644 (file)
@@ -76,12 +76,16 @@ use FS::part_pkg;
                                     ' over into current period',
                           'type' => 'checkbox',
                         },
+    'recharge_reset' => { 'name' => 'Reset usage to these values on manual '.
+                                    'package recharge',
+                          'type' => 'checkbox',
+                        },
   },
   'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 
                     'seconds', 'upbytes', 'downbytes', 'totalbytes',
                     'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
                     'recharge_downbytes', 'recharge_totalbytes',
-                    'usage_rollover', 'externalid' ],
+                    'usage_rollover', 'recharge_reset', 'externalid' ],
   'weight' => 10,
 );
 
index 3dfab37..45bbf01 100644 (file)
@@ -74,6 +74,11 @@ use FS::part_pkg::flat;
                                    'over into current period',
                          'type' => 'checkbox',
                         },
+    'recharge_reset' => { 'name' => 'Reset usage to these values on manual '.
+                                    'package recharge',
+                          'type' => 'checkbox',
+                        },
+
     #it would be better if this had to be turned on, its confusing
     'externalid' => { 'name'   => 'Optional External ID',
                       'default' => '',
@@ -83,7 +88,7 @@ use FS::part_pkg::flat;
                     'seconds', 'upbyte', 'downbytes', 'totalbytes',
                     'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
                     'recharge_downbytes', 'recharge_totalbytes',
-                    'usage_rollover', 'externalid', ],
+                    'usage_rollover', 'recharge_reset', 'externalid', ],
   'freq' => 'm',
   'weight' => 20,
 );
index 3e5a416..c9c472c 100644 (file)
@@ -70,6 +70,11 @@ use FS::part_pkg::flat;
                                    'over into current period',
                          'type' => 'checkbox',
                         },
+    'recharge_reset' => { 'name' => 'Reset usage to these values on manual '.
+                                    'package recharge',
+                          'type' => 'checkbox',
+                        },
+
     #it would be better if this had to be turned on, its confusing
     'externalid' => { 'name'   => 'Optional External ID',
                       'default' => '',
@@ -79,13 +84,7 @@ use FS::part_pkg::flat;
                     'upbytes', 'downbytes', 'totalbytes',
                     'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
                     'recharge_downbytes', 'recharge_totalbytes',
-                    'externalid' ],
-  'fieldorder' => [ 'setup_fee', 'recur_fee','cutoff_day', 'seconds',
-                    'upbytes', 'downbytes', 'totalbytes',
-                    'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
-                    'recharge_downbytes', 'recharge_totalbytes',
-                    'usage_rollover',
-                   ],
+                    'usage_rollover', 'recharge_reset', 'externalid' ],
   'freq' => 'm',
   'weight' => 30,
 );
index bc916e5..e540c38 100755 (executable)
@@ -40,7 +40,8 @@
 %  } elsif ( $payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP)$/ ) {
 %    my $part_pkg = $svc_acct->cust_svc->cust_pkg->part_pkg;
 %    $amount = $part_pkg->option('recharge_amount', 1);
-%    my %rhash = map { $_ =~ /^recharge_(.*)$/; $1, $part_pkg->option($_, 1) }
+%    my %rhash = map { $_ =~ /^recharge_(.*)$/; $1, $part_pkg->option($_) }
+%      grep { $part_pkg->option($_, 1) }
 %      qw ( recharge_seconds recharge_upbytes recharge_downbytes
 %           recharge_totalbytes );
 %
 %    $error = $cust_main->charge($amount, "Recharge " . $svc_acct->label,
 %                                $description, $part_pkg->taxclass);
 %
-%    $error ||= $svc_acct->recharge(\%rhash);
+%    if ($part_pkg->option('recharge_reset', 1)) {
+%      $error ||= $svc_acct->set_usage(\%rhash);
+%    }else{
+%      $error ||= $svc_acct->recharge(\%rhash);
+%    }
 %
 %    my $old_balance = $cust_main->balance;
 %    $error ||= $cust_main->bill;