X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main.cgi;h=f72ca0a819471afc6fdebd353bb5087c39e014c1;hb=c183de0b7e942672cafdc1c14a203e389ffd2c43;hp=2e58315d4d0ca592cc97f876733e5d5ab17efd78;hpb=8fb243091939f37e24163925be78f4e9f3485978;p=freeside.git diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 2e58315d4..f72ca0a81 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -19,6 +19,8 @@ my $DEBUG = 0; die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Edit customer'); +my $conf = new FS::Conf; + my $error = ''; #unmunge stuff @@ -36,6 +38,8 @@ my %noauto = ( $payby = $noauto{$payby} if ! $cgi->param('payauto') && exists $noauto{$payby}; +$cgi->param('payby', $payby); + if ( $payby ) { if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { $cgi->param('payinfo', @@ -69,26 +73,49 @@ if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { ); } -if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/) { - my $conf = new FS::Conf; - my $format = $conf->config('date_format') || "%m/%d/%Y"; - my $parser = DateTime::Format::Strptime->new(pattern => $format, - time_zone => 'floating', - ); - my $dt = $parser->parse_datetime($1); - if ($dt) { - $new->setfield('birthdate', $dt->epoch); - $cgi->param('birthdate', $dt->epoch); - } else { -# $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg; - $error ||= "Invalid birthdate: " . $cgi->param('birthdate') . "."; - $cgi->param('birthdate', ''); +my %usedatetime = ( 'birthdate' => 1 ); + +foreach my $dfield (qw( birthdate signupdate )) { + + if ( $cgi->param($dfield) && $cgi->param($dfield) =~ /^([ 0-9\-\/]{0,10})$/) { + + my $value = $1; + my $parsed = ''; + + if ( exists $usedatetime{$dfield} && $usedatetime{$dfield} ) { + + my $format = $conf->config('date_format') || "%m/%d/%Y"; + my $parser = DateTime::Format::Strptime->new( pattern => $format, + time_zone => 'floating', + ); + my $dt = $parser->parse_datetime($value); + if ( $dt ) { + $parsed = $dt->epoch; + } else { + # $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg; + $error ||= "Invalid $dfield: $value"; + } + + } else { + + $parsed = str2time($value) + or $error ||= "Invalid $dfield: $value"; + + } + + $new->setfield( $dfield, $parsed ); + $cgi->param( $dfield, $parsed ); + } + } $new->setfield('paid', $cgi->param('paid') ) if $cgi->param('paid'); +my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); +my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups; + #perhaps this stuff should go to cust_main.pm if ( $new->custnum eq '' ) { @@ -177,7 +204,9 @@ if ( $new->custnum eq '' ) { use Tie::RefHash; tie my %hash, 'Tie::RefHash'; %hash = ( $cust_pkg => [ $svc ] ) if $cust_pkg; - $error ||= $new->insert( \%hash, \@invoicing_list ); + $error ||= $new->insert( \%hash, \@invoicing_list, + 'tax_exemption' => \@tax_exempt, + ); my $conf = new FS::Conf; if ( $conf->exists('backend-realtime') && ! $error ) { @@ -220,7 +249,9 @@ if ( $new->custnum eq '' ) { local($FS::cust_main::DEBUG) = $DEBUG if $DEBUG; local($FS::Record::DEBUG) = $DEBUG if $DEBUG; - $error ||= $new->replace($old, \@invoicing_list); + $error ||= $new->replace( $old, \@invoicing_list, + 'tax_exemption' => \@tax_exempt, + ); warn "$me returned from replace" if $DEBUG;