don't want a fatal error when we can't fetch the name for a queue...
[freeside.git] / FS / FS / part_pkg.pm
index e4c13aa..fad7af2 100644 (file)
@@ -588,23 +588,27 @@ sub freqs_href {
   #method, class method or sub? #my $self = shift;
 
   tie my %freq, 'Tie::IxHash', 
-    '0'   => '(no recurring fee)',
-    '1h'  => 'hourly',
-    '1d'  => 'daily',
-    '2d'  => 'every two days',
-    '1w'  => 'weekly',
-    '2w'  => 'biweekly (every 2 weeks)',
-    '1'   => 'monthly',
-    '45d' => 'every 45 days',
-    '2'   => 'bimonthly (every 2 months)',
-    '3'   => 'quarterly (every 3 months)',
-    '6'   => 'semiannually (every 6 months)',
-    '12'  => 'annually',
-    '24'  => 'biannually (every 2 years)',
-    '36'  => 'triannually (every 3 years)',
-    '48'  => '(every 4 years)',
-    '60'  => '(every 5 years)',
-    '120' => '(every 10 years)',
+    '0'    => '(no recurring fee)',
+    '1h'   => 'hourly',
+    '1d'   => 'daily',
+    '2d'   => 'every two days',
+    '3d'   => 'every three days',
+    '1w'   => 'weekly',
+    '2w'   => 'biweekly (every 2 weeks)',
+    '1'    => 'monthly',
+    '45d'  => 'every 45 days',
+    '2'    => 'bimonthly (every 2 months)',
+    '3'    => 'quarterly (every 3 months)',
+    '4'    => 'every 4 months',
+    '137d' => 'every 4 1/2 months (137 days)',
+    '6'    => 'semiannually (every 6 months)',
+    '12'   => 'annually',
+    '13'   => 'every 13 months (annually +1 month)',
+    '24'   => 'biannually (every 2 years)',
+    '36'   => 'triannually (every 3 years)',
+    '48'   => '(every 4 years)',
+    '60'   => '(every 5 years)',
+    '120'  => '(every 10 years)',
   ;
 
   \%freq;
@@ -816,6 +820,39 @@ sub plan_info {
   \%plans;
 }
 
+=item format OPTION DATA
+
+Returns data formatted according to the function 'format' described
+in the plan info.  Returns DATA if no such function exists.
+
+=cut
+
+sub format {
+  my ($self, $option, $data) = (shift, shift, shift);
+  if (exists($plans{$self->plan}->{fields}->{$option}{format})) {
+    &{$plans{$self->plan}->{fields}->{$option}{format}}($data);
+  }else{
+    $data;
+  }
+}
+
+=item parse OPTION DATA
+
+Returns data parsed according to the function 'parse' described
+in the plan info.  Returns DATA if no such function exists.
+
+=cut
+
+sub parse {
+  my ($self, $option, $data) = (shift, shift, shift);
+  if (exists($plans{$self->plan}->{fields}->{$option}{parse})) {
+    &{$plans{$self->plan}->{fields}->{$option}{parse}}($data);
+  }else{
+    $data;
+  }
+}
+
+
 =back
 
 =head1 NEW PLAN CLASSES