From 6991d4986df7fb3a6c7c49b5ae1b3713e87a16c4 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 29 Jan 2002 16:33:16 +0000 Subject: - web interface for hourly account charges! (FS::cust_pkg, FS::cust_svc and FS::svc_acct seconds_since methods) - Makefile target to regenerate HTML manpages on install - FS.pm doc update - $FS::Record::Debug now dumps all SQL - new FS::cust_main methods: ->cancel, ->invoicing_list_addpost - start of a billing event web interface - cust_pay::upgrade_replace doesn't error out if history includes overapplied payments --- httemplate/edit/part_bill_event.cgi | 131 ++++++++++++++++++++++++++++ httemplate/edit/part_pkg.cgi | 71 ++++++++++++--- httemplate/edit/process/part_bill_event.cgi | 32 +++++++ 3 files changed, 224 insertions(+), 10 deletions(-) create mode 100755 httemplate/edit/part_bill_event.cgi create mode 100755 httemplate/edit/process/part_bill_event.cgi (limited to 'httemplate/edit') diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi new file mode 100755 index 000000000..41d6666dc --- /dev/null +++ b/httemplate/edit/part_bill_event.cgi @@ -0,0 +1,131 @@ + + +<% + +if ( $cgi->param('eventnum') && $cgi->param('eventnum') =~ /^(\d+)$/ ) { + $cgi->param('eventnum', $1); +} else { + $cgi->param('eventnum', ''); +} + +my ($query) = $cgi->keywords; +my $action = ''; +my $part_bill_event = ''; +if ( $cgi->param('error') ) { + $part_bill_event = new FS::part_bill_event ( { + map { $_, scalar($cgi->param($_)) } fields('part_bill_event') + } ); +} +if ( $query && $query =~ /^(\d+)$/ ) { + $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1}); +} else { + $part_bill_event ||= new FS::part_bill_event {}; +} +$action ||= $part_bill_event->pkgpart ? 'Edit' : 'Add'; +my $hashref = $part_bill_event->hashref; + +print header("$action Invoice Event Definition", menubar( + 'Main Menu' => popurl(2), + 'View all invoice events' => popurl(2). 'browse/part_bill_event.cgi', +)); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print '
'; + +print "Invoice Event #", $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)"; + +print ntable("#cccccc",2), <Payby +After days +END + +print 'Disabled'; +print '{disabled} eq "Y"; +print '>'; +print ''; + +print 'Action'; + +#print ntable(); + +#this is pretty kludgy right here. +tie my %events, 'Tie::IxHash', + + 'Charge a fee' => { + 'code' => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\' );', + 'html' => 'Amount
'. + 'Reason ', + }, + 'Suspend accounts' => { + 'code' => '$cust_main->suspend();', + }, + 'Cancel accounts' => { + 'code' => '$cust_main->cancel();', + }, + + 'Add postal invoicing' => { + 'code' => '$cust_main->invoicing_list_addpost();', + 'pad' => 10, + }, + + 'Generate invoices' => { + 'code' => '$cust_main->bill();', + 'pad' => 20, + }, + + 'Apply unapplied payments and credits' => { + 'code' => '$cust_main->apply_payments; $cust_main->apply_credits;', + 'pad' => 30, + }, + + 'Collect on invoices' => { + 'code' => '$cust_main->collect();', + 'pad' => 40, + }, + +; + +foreach my $event ( keys %events ) { + print ntable( "#cccccc", 2). qq!$event!; + print ''. $events{$event}{html}. '' if exists $events{$event}{html}; + print qq!!; + print ''; +} + +#print ''; + +print < + +END + +print qq!!; +%> + + + + + diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 735f4f269..ea3f62aa2 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,4 +1,4 @@ - + <% @@ -158,8 +158,8 @@ unless ( $cgi->param('clone') ) { } # prolly should be in database -my %plans = ( - +use Tie::IxHash; +tie my %plans, 'Tie::IxHash', 'flat' => { 'name' => 'Flat rate', 'fields' => { @@ -170,6 +170,7 @@ my %plans = ( 'default' => 0, }, }, + 'fieldorder' => [ 'setup_fee', 'recur_fee' ], 'setup' => 'what.setup_fee.value', 'recur' => 'what.recur_fee.value', }, @@ -190,11 +191,55 @@ my %plans = ( 'default' => 1, }, }, + 'fieldorder' => [ 'setup_fee', 'recur_fee', 'comission_depth', 'comission_amount' ], 'setup' => 'what.setup_fee.value', 'recur' => '\'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'', }, -); + 'sesmon_hour' => { + 'name' => 'Base charge plus charge per-hour from the session monitor', + 'fields' => { + 'setup_fee' => { 'name' => 'Setup fee for this package', + 'default' => 0, + }, + 'recur_flat' => { 'name' => 'Base monthly charge for this package', + 'default' => 0, + }, + 'recur_included_hours' => { 'name' => 'Hours included', + 'default' => 0, + }, + 'recur_hourly_charge' => { 'name' => 'Additional charge per hour', + 'default' => 0, + }, + }, + 'fieldorder' => [ 'setup_fee', 'recur_flat', 'recur_included_hours', 'recur_hourly_charge' ], + 'setup' => 'what.setup_fee.value', + 'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_bkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'', + }, + + 'sesmon_minute' => { + 'name' => 'Base charge plus charge per-minute from the session monitor', + 'fields' => { + 'setup_fee' => { 'name' => 'Setup fee for this package', + 'default' => 0, + }, + 'recur_flat' => { 'name' => 'Base monthly charge for this package', + 'default' => 0, + }, + 'recur_included_min' => { 'name' => 'Minutes included', + 'default' => 0, + }, + 'recur_minly_charge' => { 'name' => 'Additional charge per minute', + 'default' => 0, + }, + }, + 'fieldorder' => [ 'setup_fee', 'recur_flat', 'recur_included_min', 'recur_minly_charge' ], + 'setup' => 'what.setup_fee.value', + 'recur' => '\'my $min = $cust_pkg->seconds_since($cust_bkg->bill || 0) / 60 - \' + what.recur_included_min.value + \'; $min = 0 if $min < 0; \' + what.recur_flat.value + \' + \' + what.recur_minly_charge.value + \' * $min;\'', + + }, + +; %> @@ -295,24 +340,30 @@ if ( $cgi->param('pkgnum') ) { <%= ntable("#cccccc",2) %> <% my $href = $plans{$layer}->{'fields'}; - foreach my $field ( keys %{ $href } ) { %> + foreach my $field ( exists($plans{$layer}->{'fieldorder'}) + ? @{$plans{$layer}->{'fieldorder'}} + : keys %{ $href } + ) { +%> <%= $href->{$field}{'name'} %> <% } %> -

-Setup expression

-Recurring espression

-
<% -print qq!
!; %> +

don't edit this unless you know what you're doing <%= ntable("#cccccc",2) %> +Setup expression

+Recurring espression
+ + +