diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-08-18 14:36:08 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-08-18 14:36:08 -0700 |
commit | 08f3345fd90fa5b21aab49545bfe6ed0ff880673 (patch) | |
tree | a3c5b787dd71acaf0654418e5d4b04042f8a5fc6 /FS | |
parent | 5c0cfcb8dec7c4f3a7aecea4c550ffb4bfb774c3 (diff) |
continue sales person work: customer and package selection, commissions, reporting. RT#23402
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_pkg.pm | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 676757ece..dedc6374a 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -1840,6 +1840,7 @@ sub change { $hash{$date} = $self->getfield($date); } } + # allow $opt->{'locationnum'} = '' to specifically set it to null # (i.e. customer default location) $opt->{'locationnum'} = $self->locationnum if !exists($opt->{'locationnum'}); @@ -1864,7 +1865,6 @@ sub change { } $hash{'contactnum'} = $opt->{'contactnum'} if $opt->{'contactnum'}; - $hash{'quantity'} = $opt->{'quantity'} || $self->quantity; my $cust_pkg; if ( $opt->{'cust_pkg'} ) { @@ -1881,10 +1881,11 @@ sub change { } else { # Create the new package. $cust_pkg = new FS::cust_pkg { - custnum => $custnum, - pkgpart => ( $opt->{'pkgpart'} || $self->pkgpart ), - refnum => ( $opt->{'refnum'} || $self->refnum ), - locationnum => ( $opt->{'locationnum'} ), + custnum => $custnum, + locationnum => $opt->{'locationnum'}, + ( map { $_ => ( $opt->{$_} || $self->$_() ) } + qw( pkgpart quantity refnum salesnum ) + ), %hash, }; $error = $cust_pkg->insert( 'change' => 1, @@ -2177,14 +2178,17 @@ sub change_later { return '' unless $new_pkgpart or $new_locationnum or $new_quantity; # wouldn't do anything - my %hash = ( - 'custnum' => $self->custnum, - 'pkgpart' => ($opt->{'pkgpart'} || $self->pkgpart), - 'locationnum' => ($opt->{'locationnum'} || $self->locationnum), - 'quantity' => ($opt->{'quantity'} || $self->quantity), - 'start_date' => $date, - ); - my $new = FS::cust_pkg->new(\%hash); + # allow $opt->{'locationnum'} = '' to specifically set it to null + # (i.e. customer default location) + $opt->{'locationnum'} = $self->locationnum if !exists($opt->{'locationnum'}); + + my $new = FS::cust_pkg->new( { + custnum => $self->custnum, + locationnum => $opt->{'locationnum'}, + start_date => $date, + map { $_ => ( $opt->{$_} || $self->$_() ) } + qw( pkgpart quantity refnum salesnum ) + } ); $error = $new->insert('change' => 1, 'allow_pkgpart' => ($new_pkgpart ? 0 : 1)); if ( !$error ) { |