+
+=item find_or_insert
+
+Finds an existing tax definition matching the data_vendor, taxname,
+taxclassnum, and geocode of this one, if one exists, and sets the contents of
+this tax rate equal to that one (including its taxnum). If an existing
+definition is not found, inserts this one. Returns an error string if
+inserting a record failed.
+
+=cut
+
+sub find_or_insert {
+ my $self = shift;
+ # this doesn't uniquely identify CCH taxes (kinda goofy, I know)
+ die "find_or_insert is not compatible with CCH taxes\n"
+ if $self->data_vendor eq 'cch';
+
+ my @keys = (qw(data_vendor taxname taxclassnum geocode));
+ my %hash = map { $_ => $self->get($_) } @keys;
+ my $existing = qsearchs('tax_rate', \%hash);
+ if ($existing) {
+ foreach ($self->fields) {
+ $self->set($_, $existing->get($_));
+ }
+ return;
+ } else {
+ return $self->insert;
+ }
+}
+