summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2011-03-30 19:55:35 +0000
committerivan <ivan>2011-03-30 19:55:35 +0000
commit19b0c403fbf697a1de92f12abc8a2104daca07bc (patch)
tree315b18157952d6e265ac17d68ba237d53b2a4e17
parent242170bb599b909f801144bfc814d5ee6d649c00 (diff)
useful
-rw-r--r--bin/test-event64
1 files changed, 64 insertions, 0 deletions
diff --git a/bin/test-event b/bin/test-event
new file mode 100644
index 000000000..061e00061
--- /dev/null
+++ b/bin/test-event
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+
+use strict;
+use FS::UID qw( adminsuidsetup );
+use FS::Schema qw( dbdef );
+use FS::Record qw(qsearchs);
+use FS::part_event;
+#XXX all event tables
+use FS::cust_main;
+use FS::cust_bill;
+
+my $user = shift or die &usage;
+adminsuidsetup($user);
+
+my $eventpart = shift or die &usage;
+my $table = shift or die &usage;
+my $tablenum = shift or die &usage;
+
+my $part_event = qsearchs('part_event', { 'eventpart' => $eventpart } )
+ or die "unknown eventpart $eventpart";
+
+my $pkey = dbdef->table($table)->primary_key;
+
+my $object = qsearchs($table, { $pkey => $tablenum } )
+ or die "can't find $pkey $tablenum in $table";
+
+my $cust_event = $part_event->new_cust_event($object);
+
+###
+# specifics
+###
+
+my @conditions = $part_event->part_event_condition;
+foreach my $condition ( @conditions ) {
+ my $sat = $condition->condition( $object, 'cust_event' => $cust_event );
+ print $condition->conditionname. '.pm: '.
+ ( $sat ? "satisfied\n" : "NOT SATISFIED\n" );
+
+}
+
+###
+# random shit to test pkg_balance_under.pm
+###
+
+#my $cust_main = $object->cust_main;
+#my $pkg_balance = $cust_main->balance_pkgnum($tablenum);
+#print "\nbalance for cust_pkg $tablenum: $pkg_balance\n";
+
+###
+# overall
+###
+
+print "\n";
+
+my $run = $cust_event->test_conditions;
+
+print "\n". $part_event->eventpart.': '. $part_event->event.
+ " for $table $tablenum: ". ( $run ? "RUN\n" : "DON'T RUN\n" );
+
+sub usage {
+ die "Usage:\n test-event user eventpart table tablenum\n";
+}
+
+