diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-12-12 19:20:22 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-12-12 19:20:22 -0800 |
commit | 2457752a82358108aa078f175a4e866f1786299a (patch) | |
tree | 549de3733498a617765abaa38d7ec877c79c1bbd /FS | |
parent | e2213aaeab76983c26d92c1e1d928fe4e062accf (diff) |
costs for one-time charges, RT#31429
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 26 |
2 files changed, 22 insertions, 9 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index f446b88..9370460 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -3476,7 +3476,7 @@ Old-style: sub charge { my $self = shift; - my ( $amount, $quantity, $start_date, $classnum ); + my ( $amount, $setup_cost, $quantity, $start_date, $classnum ); my ( $pkg, $comment, $additional ); my ( $setuptax, $taxclass ); #internal taxes my ( $taxproduct, $override ); #vendor (CCH) taxes @@ -3486,6 +3486,7 @@ sub charge { my $locationnum; if ( ref( $_[0] ) ) { $amount = $_[0]->{amount}; + $setup_cost = $_[0]->{setup_cost}; $quantity = exists($_[0]->{quantity}) ? $_[0]->{quantity} : 1; $start_date = exists($_[0]->{start_date}) ? $_[0]->{start_date} : ''; $no_auto = exists($_[0]->{no_auto}) ? $_[0]->{no_auto} : ''; @@ -3504,6 +3505,7 @@ sub charge { $locationnum = $_[0]->{locationnum} || $self->ship_locationnum; } else { $amount = shift; + $setup_cost = ''; $quantity = 1; $start_date = ''; $pkg = @_ ? shift : 'One-time charge'; @@ -3534,6 +3536,7 @@ sub charge { 'setuptax' => $setuptax, 'taxclass' => $taxclass, 'taxproductnum' => $taxproduct, + 'setup_cost' => $setup_cost, } ); my %options = ( ( map { ("additional_info$_" => $additional->[$_] ) } diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index a810f5a..d8fda3e 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -2362,27 +2362,37 @@ sub modify_charge { } if ( !$self->get('setup') ) { - # not yet billed, so allow amount and quantity + # not yet billed, so allow amount, setup_cost, quantity and start_date + + if ( exists($opt{'amount'}) + and $part_pkg->option('setup_fee') != $opt{'amount'} + and $opt{'amount'} > 0 ) { + + $pkg_opt{'setup_fee'} = $opt{'amount'}; + $pkg_opt_modified = 1; + } + + if ( exists($opt{'setup_cost'}) + and $part_pkg->setup_cost != $opt{'setup_cost'} + and $opt{'setup_cost'} > 0 ) { + + $part_pkg->set('setup_cost', $opt{'setup_cost'}); + } + if ( exists($opt{'quantity'}) and $opt{'quantity'} != $self->quantity and $opt{'quantity'} > 0 ) { $self->set('quantity', $opt{'quantity'}); } + if ( exists($opt{'start_date'}) and $opt{'start_date'} != $self->start_date ) { $self->set('start_date', $opt{'start_date'}); } - if ( exists($opt{'amount'}) - and $part_pkg->option('setup_fee') != $opt{'amount'} - and $opt{'amount'} > 0 ) { - - $pkg_opt{'setup_fee'} = $opt{'amount'}; - $pkg_opt_modified = 1; - } } # else simply ignore them; the UI shouldn't allow editing the fields my $error; |