+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 '';
+}