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);
35 my @conditions = $part_event->part_event_condition;
36 foreach my $condition ( @conditions ) {
37 my $sat = $condition->condition( $object, 'cust_event' => $cust_event );
39 my $sql = $condition->condition_sql();
42 print $condition->conditionname. '.pm: '.
43 ( $sat ? "satisfied\n" : "NOT SATISFIED\n" );
48 # random shit to test pkg_balance_under.pm
51 #my $cust_main = $object->cust_main;
52 #my $pkg_balance = $cust_main->balance_pkgnum($tablenum);
53 #print "\nbalance for cust_pkg $tablenum: $pkg_balance\n";
59 my $run = $cust_event->test_conditions;
61 print "\n". $part_event->eventpart.': '. $part_event->event.
62 " for $table $tablenum: ". ( $run ? "RUN\n" : "DON'T RUN\n" );
65 die "Usage:\n test-event user eventpart table tablenum\n";