use utf8;
use strict;
use warnings; no warnings qw(redefine);
use Dbase::Help qw(DoFn);
use Fehler qw(problem);
use Loader qw(valid_kunde strip_kn);

sub valid_tarifacct($$;$$) {
	my($idx,$id,$flag,$kn) = @_;
	$flag = 0 unless $flag;
	my $err;
 
	return problem $kn,"ID '$idx' ist nicht numerisch!\n" unless $idx =~ /^\d+$/;
	return undef if $id and not valid_kunde($id,1);

	my $ksel;
    if($id) {
        $ksel="kunde = $id";
    } else {
        $ksel="kunde IS NULL";
        $id=0;
    }
	return problem $kn,"TarifAcct '$idx/$id' gibt es nicht."
		unless DoFn("select count(*) from tarifacct where id = $idx and $ksel");

	$kn = strip_kn($kn)."TarifAcct_${idx}_$id";

	unless($flag & 1) {
	}

	$err ? undef : wantarray ? ($id,$id) : $id ? $id : "0E0";
}
1;
