-use vars qw(@ISA %info $DEBUG $me);
-#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg::flat;
-
-use Date::Manip qw(DateCalc UnixDate ParseDate);
-
-@ISA = qw(FS::part_pkg::flat);
-$me = '[' . __PACKAGE__ . ']';
-$DEBUG = 0;
-
-(%info) = (%FS::part_pkg::flat::info);
-$info{name} = 'Introductory price for X months, then flat rate,'.
- 'relative to setup date (anniversary billing)';
-$info{shortname} = 'Anniversary, with intro price';
-$info{fields} = { %{$info{fields}} };
-$info{fields}{intro_fee} =
- { 'name' => 'Introductory recurring fee for this package',
+use vars qw( %info );
+
+use FS::Log;
+
+# mostly false laziness with FS::part_pkg::global_Mixin::validate_moneyn,
+# except for blank string handling...
+sub validate_money {
+ my ($option, $valref) = @_;
+ if ( $$valref eq '' ) {
+ $$valref = '0';
+ } elsif ( $$valref =~ /^\s*(\d*)(\.\d{1})\s*$/ ) {
+ #handle one decimal place without barfing out
+ $$valref = ( ($1||''). ($2.'0') ) || 0;
+ } elsif ( $$valref =~ /^\s*(\d*)(\.\d{2})?\s*$/ ) {
+ $$valref = ( ($1||''). ($2||'') ) || 0;
+ } else {
+ return "Illegal (money) $option: ". $$valref;
+ }
+ return '';
+}
+
+sub validate_number {
+ my ($option, $valref) = @_;
+ $$valref = 0 unless $$valref;
+ return "Invalid $option"
+ unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/);
+ return '';
+}
+
+%info = (
+ 'name' => 'Introductory price for X months, then flat rate,'.
+ 'relative to setup date (anniversary billing)',
+ 'shortname' => 'Anniversary, with intro price',
+ 'inherit_fields' => [ 'flat', 'usage_Mixin', 'global_Mixin' ],
+ 'fields' => {
+ 'intro_fee' => { 'name' => 'Introductory recurring fee for this package',