4 use FS::UID qw( adminsuidsetup );
5 use FS::Schema qw( dbdef );
6 use FS::Record qw(qsearchs);
12 my $user = shift or die &usage;
13 adminsuidsetup($user);
15 my $eventpart = shift or die &usage;
16 my $table = shift or die &usage;
17 my $tablenum = shift or die &usage;
19 my $part_event = qsearchs('part_event', { 'eventpart' => $eventpart } )
20 or die "unknown eventpart $eventpart";
22 my $pkey = dbdef->table($table)->primary_key;
24 my $object = qsearchs($table, { $pkey => $tablenum } )
25 or die "can't find $pkey $tablenum in $table";
27 my $cust_event = $part_event->new_cust_event($object);
33 my @conditions = $part_event->part_event_condition;
34 foreach my $condition ( @conditions ) {
35 my $sat = $condition->condition( $object, 'cust_event' => $cust_event );
36 print $condition->conditionname. '.pm: '.
37 ( $sat ? "satisfied\n" : "NOT SATISFIED\n" );
42 # random shit to test pkg_balance_under.pm
45 #my $cust_main = $object->cust_main;
46 #my $pkg_balance = $cust_main->balance_pkgnum($tablenum);
47 #print "\nbalance for cust_pkg $tablenum: $pkg_balance\n";
55 my $run = $cust_event->test_conditions;
57 print "\n". $part_event->eventpart.': '. $part_event->event.
58 " for $table $tablenum: ". ( $run ? "RUN\n" : "DON'T RUN\n" );
61 die "Usage:\n test-event user eventpart table tablenum\n";