diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-12-12 19:20:24 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-12-12 19:20:24 -0800 |
commit | 52bea6aecfcc8274fd852f626a0f751e1b5bd6a8 (patch) | |
tree | ada11b424b4963c843538ebac8d47855a98f19a8 /FS | |
parent | da0d59f239e7116893cf3249792e7c572bc8bf84 (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 57abc18ab..d7d5869b0 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -3461,7 +3461,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 @@ -3471,6 +3471,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} : ''; @@ -3489,6 +3490,7 @@ sub charge { $locationnum = $_[0]->{locationnum} || $self->ship_locationnum; } else { $amount = shift; + $setup_cost = ''; $quantity = 1; $start_date = ''; $pkg = @_ ? shift : 'One-time charge'; @@ -3519,6 +3521,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 01ee36f53..195ce3dce 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -2400,27 +2400,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; |