X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg_taxproduct.pm;h=c66fb8c901ddaa2912b29eb811e3ad9fdc0a6660;hb=106d0163556c31a3b2cf9c065ec6d9d6ded0ce64;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..c66fb8c90 100644 --- a/FS/FS/part_pkg_taxproduct.pm +++ b/FS/FS/part_pkg_taxproduct.pm @@ -2,7 +2,7 @@ package FS::part_pkg_taxproduct; use strict; use vars qw( @ISA ); -use FS::Record; +use FS::Record qw( qsearch ); @ISA = qw(FS::Record); @@ -79,6 +79,18 @@ 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 } ); + + 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,