summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2008-08-28 21:32:26 +0000
committerjeff <jeff>2008-08-28 21:32:26 +0000
commit42132c9a86d36d7fefa7ba5f058f764ba6e7ad5b (patch)
treecc02b304e583dd1a10d09f300cc15c56e5863a65 /FS
parentf0d52fc82b138598228c401d99b56e88366c6945 (diff)
taxproduct selection for one time charges
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_main.pm22
-rw-r--r--FS/FS/part_pkg.pm20
2 files changed, 34 insertions, 8 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index b72079cf1..9e501238c 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4892,6 +4892,7 @@ the error, otherwise returns false.
sub charge {
my $self = shift;
my ( $amount, $quantity, $pkg, $comment, $taxclass, $additional, $classnum );
+ my ( $taxproduct, $override );
if ( ref( $_[0] ) ) {
$amount = $_[0]->{amount};
$quantity = exists($_[0]->{quantity}) ? $_[0]->{quantity} : 1;
@@ -4901,6 +4902,8 @@ sub charge {
$taxclass = exists($_[0]->{taxclass}) ? $_[0]->{taxclass} : '';
$classnum = exists($_[0]->{classnum}) ? $_[0]->{classnum} : '';
$additional = $_[0]->{additional};
+ $taxproduct = $_[0]->{taxproductnum};
+ $override = { '' => $_[0]->{tax_override} };
}else{
$amount = shift;
$quantity = 1;
@@ -4922,13 +4925,14 @@ sub charge {
my $dbh = dbh;
my $part_pkg = new FS::part_pkg ( {
- 'pkg' => $pkg,
- 'comment' => $comment,
- 'plan' => 'flat',
- 'freq' => 0,
- 'disabled' => 'Y',
- 'classnum' => $classnum ? $classnum : '',
- 'taxclass' => $taxclass,
+ 'pkg' => $pkg,
+ 'comment' => $comment,
+ 'plan' => 'flat',
+ 'freq' => 0,
+ 'disabled' => 'Y',
+ 'classnum' => $classnum ? $classnum : '',
+ 'taxclass' => $taxclass,
+ 'taxproductnum' => $taxproduct,
} );
my %options = ( ( map { ("additional_info$_" => $additional->[$_] ) }
@@ -4938,7 +4942,9 @@ sub charge {
'setup_fee' => $amount,
);
- my $error = $part_pkg->insert( options => \%options );
+ my $error = $part_pkg->insert( options => \%options,
+ tax_overrides => $override,
+ );
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 57145fdd9..3eb3bc139 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -144,6 +144,10 @@ record itself), the object will be updated to point to this package definition.
In conjunction with I<cust_pkg>, if I<custnum_ref> is set to a scalar reference,
the scalar will be updated with the custnum value from the cust_pkg record.
+If I<tax_overrides> is set to a hashref with usage classes as keys and comma
+separated tax class numbers as values, appropriate FS::part_pkg_taxoverride
+records will be inserted.
+
If I<options> is set to a hashref of options, appropriate FS::part_pkg_option
records will be inserted.
@@ -191,6 +195,22 @@ sub insert {
}
}
+ warn " inserting part_pkg_taxoverride records" if $DEBUG;
+ my %overrides = %{ $options{'tax_overrides'} || {} };
+ foreach my $usage_class ( keys %overrides ) {
+ my @overrides = (grep "$_", split (',', $overrides{$usage_class}) );
+ my $error = $self->process_m2m (
+ 'link_table' => 'part_pkg_taxoverride',
+ 'target_table' => 'tax_class',
+ 'hashref' => { 'usage_class' => $usage_class },
+ 'params' => \@overrides,
+ );
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
warn " inserting pkg_svc records" if $DEBUG;
my $pkg_svc = $options{'pkg_svc'} || {};
foreach my $part_svc ( qsearch('part_svc', {} ) ) {