die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');
+my $conf = new FS::Conf;
+
my $error = '';
#unmunge stuff
$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',
);
}
-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', '');
+$new->tagnum( [ $cgi->param('tagnum') ] );
+
+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 = parse_datetime($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 '' ) {
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 ) {
$new->payinfo($new_account.'@'.$new_aba);
}
+ if ( ! $conf->exists('cust_main-edit_signupdate') or
+ ! $new->signupdate ) {
+ $new->signupdate($old->signupdate);
+ }
+
warn "$me calling $new -> replace( $old, \ @invoicing_list )" if $DEBUG;
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;