X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg_taxproduct.pm;h=56e63b668716a31ed3ad6e66930f0906a49b17da;hb=5af515ac6bdc6ff88860c618207660eac48c276a;hp=000d0d46b591eb4d82bce0e2dccbb49dc33bfe45;hpb=4104f4e3d1b387296b16b4a035b4b7f42e0c5977;p=freeside.git diff --git a/FS/FS/part_pkg_taxproduct.pm b/FS/FS/part_pkg_taxproduct.pm index 000d0d46b..56e63b668 100644 --- a/FS/FS/part_pkg_taxproduct.pm +++ b/FS/FS/part_pkg_taxproduct.pm @@ -1,10 +1,11 @@ package FS::part_pkg_taxproduct; use strict; -use vars qw( @ISA ); -use FS::Record; +use vars qw( @ISA $delete_kludge ); +use FS::Record qw( qsearch ); @ISA = qw(FS::Record); +$delete_kludge = 0; =head1 NAME @@ -79,6 +80,20 @@ Delete this record from the database. =cut +sub delete { + my $self = shift; + + return "Can't delete a tax product which has attached package tax rates!" + if qsearch( 'part_pkg_taxrate', { 'taxproductnum' => $self->taxproductnum } ); + + unless ( $delete_kludge ) { + return "Can't delete a tax product which has attached packages!" + if qsearch( 'part_pkg', { 'taxproductnum' => $self->taxproductnum } ); + } + + $self->SUPER::delete(@_); +} + =item replace OLD_RECORD Replaces the OLD_RECORD with this one in the database. If there is an error,