adding svc_mailinglist for communigate "groups" (mailing lists), RT#7514
[freeside.git] / FS / FS / part_pkg / flat.pm
index e5fc089..e25c28c 100644 (file)
@@ -11,6 +11,7 @@ use List::Util qw(min); # max);
 use FS::UI::bytecount;
 use FS::Conf;
 use FS::part_pkg;
+use FS::cust_bill_pkg_discount;
 
 @ISA = qw(FS::part_pkg);
 
@@ -106,19 +107,30 @@ tie my %temporalities, 'Tie::IxHash',
                              'type' => 'select',
                              'select_options' => \%temporalities,
                            },
-
-    %usage_fields,
-    %usage_recharge_fields,
-
     'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
                                    ' of service at cancellation',
                          'type' => 'checkbox',
                        },
+
+    #used in cust_pkg.pm so could add to any price plan
+    'expire_months' => { 'name' => 'Auto-add an expiration date this number of months out',
+                       },
+    #used in cust_pkg.pm so could add to any price plan where it made sense
+    'start_1st'     => { 'name' => 'Auto-add a start date to the 1st, ignoring the current month.',
+                         'type' => 'checkbox',
+                       },
+
+    %usage_fields,
+    %usage_recharge_fields,
+
     'externalid' => { 'name'   => 'Optional External ID',
                       'default' => '',
                     },
   },
-  'fieldorder' => [ qw( setup_fee recur_fee recur_temporality unused_credit ),
+  'fieldorder' => [ qw( setup_fee recur_fee
+                        recur_temporality unused_credit
+                        expire_months start_1st
+                      ),
                     @usage_fieldorder, @usage_recharge_fieldorder,
                     qw( externalid ),
                   ],
@@ -190,6 +202,16 @@ sub calc_discount {
      $amount *= $months;
      $amount = sprintf('%.2f', $amount);
 
+     next unless $amount > 0;
+
+     #record details in cust_bill_pkg_discount
+     my $cust_bill_pkg_discount = new FS::cust_bill_pkg_discount {
+       'pkgdiscountnum' => $cust_pkg_discount->pkgdiscountnum,
+       'amount'         => $amount,
+       'months'         => $months,
+     };
+     push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
+
      #add details on discount to invoice
      my $conf = new FS::Conf;
      my $money_char = $conf->config('money_char') || '$';