From 0610c50fd0786e2e6ccc850d68b6e865eba86541 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 6 Jul 2012 12:30:38 -0700 Subject: sales by ad source report, #17971 --- httemplate/elements/menu.html | 1 + httemplate/search/cust_bill_pkg_referral.html | 287 +++++++++++++++++++++ httemplate/search/elements/search-xls.html | 20 ++ .../search/report_cust_bill_pkg_referral.html | 55 ++++ 4 files changed, 363 insertions(+) create mode 100644 httemplate/search/cust_bill_pkg_referral.html create mode 100644 httemplate/search/report_cust_bill_pkg_referral.html (limited to 'httemplate') diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 938303521..019afe94e 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -314,6 +314,7 @@ if($curuser->access_right('Financial reports')) { 'Daily Sales, Credits and Receipts' => [ $fsurl.'graph/report_money_time_daily.html', 'Sales, credits and receipts (broken down by day) summary graph' ], 'Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg.html', 'Sales report and graph (by agent, package class and/or date range)' ], 'Rated Call Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg_detail.html', 'Sales report and graph (by agent, package class, usage class and/or date range)' ], + 'Sales With Advertising Source' => [ $fsurl.'search/report_cust_bill_pkg_referral.html' ], 'Employee Commission Report' => [ $fsurl.'search/report_employee_commission.html', '' ], 'Credit Report' => [ $fsurl.'search/report_cust_credit.html', 'Credit report (by employee and/or date range)' ], 'Unapplied Credits' => [ $fsurl.'search/report_cust_credit.html?unapplied=1', 'Unapplied credit report (by type and/or date range)' ], diff --git a/httemplate/search/cust_bill_pkg_referral.html b/httemplate/search/cust_bill_pkg_referral.html new file mode 100644 index 000000000..f17cea3d9 --- /dev/null +++ b/httemplate/search/cust_bill_pkg_referral.html @@ -0,0 +1,287 @@ +<& elements/search.html, + 'title' => emt('Sales with advertising source'), + 'name' => emt('line items'), + 'query' => $query, + 'count_query' => $count_query, + 'count_addl' => [ + ($setup ? $money_char. '%.2f setup' : ()), + ($recur ? $money_char. '%.2f recurring' : ()), + ($usage ? $money_char. '%.2f usage' : ()), + ], + 'header' => [ + emt('Description'), + ($setup ? emt('Setup') : ()), + ($recur ? emt('Recurring') : ()), + ($usage ? emt('Usage') : ()), + emt('Invoice'), + emt('Invoice date'), + emt('Paid'), + emt('Payment date'), + emt('Pkg. status'), + emt('Pkg. class'), + '', #report class + emt('Cust#'), + emt('Customer'), + emt('Ad source'), + emt('Agent'), + ], + 'fields' => [ + 'pkg', + ($setup ? money_sub('setup') : ()), + ($recur ? money_sub('recur_no_usage') : ()), + ($usage ? money_sub('recur_usage') : ()), + 'invnum', + date_sub('_date'), + money_sub('paid'), + date_sub('last_pay'), + sub { + my $cust_pkg = shift->cust_pkg; + $cust_pkg ? ucfirst($cust_pkg->status) : ''; + }, + 'classname', + sub { # report_option + my $cust_bill_pkg = shift; + my $pkgpart = $cust_bill_pkg->pkgpart_override + || $cust_bill_pkg->cust_pkg->pkgpart; + if ( !exists($report_classes{$pkgpart}) ) { + my $part_pkg = FS::part_pkg->by_key($pkgpart); + my %opts = $part_pkg->options; + $report_classes{$pkgpart} = [ + map { /^report_option_(\d+)/ ? + $report_option_name{$1} : + () } + keys %opts + ]; + } + join( '
', @{ $report_classes{$pkgpart} }); + }, + 'custnum', + 'name', + 'referral', # from query + 'agent', + ], + 'sort_fields' => [ + '', + ($setup ? 'setup' : ()), + ($recur ? 'recur_no_usage' : ()), + ($usage ? 'recur_usage' : ()), + 'invnum', + '_date', + 'paid', + 'last_pay', + '', #package status + 'classname', + '', #report_option + 'custnum', + '', + 'referral', + 'agent', + ], + 'links' => [ + '', #package/item desc + ('') x $x, #setup/recur/usage + $ilink, #invnum + $ilink, #invoice date + '', #paid amt + '', #payment date + '', #pkg status + '', #classnum + '', #report class + $clink, #custnum + $clink, #customer name + '', #referral + '', #agent + ], + #'align' => 'rlrrrc'.FS::UI::Web::cust_aligns(), + 'align' => 'l' . ('r' x $x) . 'rcrccccrlll', + 'color' => [ ('') x (5 + $x), + sub { + my $cust_pkg = shift->cust_pkg; + $cust_pkg ? ucfirst($cust_pkg->statuscolor) : ''; + }, + ('') x 6, + ], + 'style' => [ + ('') x (5 + $x), + 'b', + ('') x 6 + ], +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); + +my $conf = new FS::Conf; + +my $setup = $cgi->param('setup') ? 1 : 0; +my $recur = $cgi->param('recur') ? 1 : 0; +my $usage = $cgi->param('usage') ? 1 : 0; + +my $x = $setup + $recur + $usage; + +my @select = ( 'cust_bill_pkg.*', 'cust_bill._date' ); +my ($join_cust, $join_pkg ) = ('', ''); + +#here is the agent virtualization +my $agentnums_sql = + $FS::CurrentUser::CurrentUser->agentnums_sql( 'table' => 'cust_main' ); + +my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); + +my @where = ( $agentnums_sql, + 'cust_bill_pkg.pkgnum != 0', # exclude taxes + "cust_bill._date >= $beginning", + "cust_bill._date <= $ending", + ); + +if ( $cgi->param('status') =~ /^([a-z]+)$/ ) { + push @where, FS::cust_pkg->cust_status_sql . " = '$1'"; +} + +if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { + push @where, "cust_main.agentnum = $1"; +} + +#classnum +# not specified: all classes +# 0: empty class +# N: classnum +my $use_override = 1; #$cgi->param('use_override'); +if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { + my $comparison = ''; + if ( $1 == 0 ) { + $comparison = "IS NULL"; + } else { + $comparison = "= $1"; + } + + if ( $use_override ) { + push @where, "( + part_pkg.classnum $comparison AND pkgpart_override IS NULL OR + override.classnum $comparison AND pkgpart_override IS NOT NULL + )"; + } else { + push @where, "part_pkg.classnum $comparison"; + } +} + +# report option +my @report_option = grep /^\d+$/, ( $cgi->param('report_option') ); +if ( @report_option ) { + @report_option = map { "'report_option_$_'" } @report_option; + push @where, "EXISTS( + SELECT 1 FROM part_pkg_option WHERE optionname IN (". + join(',', @report_option).") AND ( + part_pkg_option.pkgpart = cust_pkg.pkgpart AND pkgpart_override IS NULL + OR part_pkg_option.pkgpart = pkgpart_override + ) + )"; +} + +my $setup_sql = + FS::cust_bill_pkg->charged_sql('', '', setuprecur => 'setup'); +my $recur_sql = + FS::cust_bill_pkg->charged_sql('', '', setuprecur => 'recur', no_usage => 1); +my $usage_sql = FS::cust_bill_pkg->usage_sql; + +# exclude zero-amount items +my @orwhere; +push @orwhere, "(cust_bill_pkg.setup > 0)" if $setup; +push @orwhere, "($recur_sql > 0)" if $recur; +push @orwhere, "($usage_sql > 0)" if $usage; +push @where, join(' OR ', @orwhere); + +$join_cust = ' JOIN cust_bill USING ( invnum ) + LEFT JOIN cust_main USING ( custnum ) + LEFT JOIN part_referral USING ( refnum ) + LEFT JOIN agent ON cust_main.agentnum = agent.agentnum + '; + +$join_pkg .= ' LEFT JOIN cust_pkg USING ( pkgnum ) + LEFT JOIN part_pkg USING ( pkgpart ) + LEFT JOIN part_pkg AS override + ON pkgpart_override = override.pkgpart + LEFT JOIN pkg_class ON '; #... + +if ( $use_override ) { + # join to whichever pkgpart is appropriate + $join_pkg .= ' + ( pkgpart_override IS NULL AND part_pkg.classnum = pkg_class.classnum ) + OR ( pkgpart_override IS NOT NULL AND override.classnum = pkg_class.classnum )'; +} else { + $join_pkg .= 'part_pkg.classnum = pkg_class.classnum'; +} + +my $where = ' WHERE '. join(' AND ', @where); + +# setup and recurring only +my $count_query = "SELECT + COUNT(billpkgnum)". + ($setup ? ", SUM($setup_sql)" : ''). + ($recur ? ", SUM($recur_sql)" : ''). + ($usage ? ", SUM($usage_sql)" : ''). + " FROM cust_bill_pkg + $join_cust + $join_pkg + $where + "; + +my $paid_sql = FS::cust_bill_pkg->paid_sql('', ''); +my $last_pay_sql = "SELECT MAX(_date) + FROM cust_bill_pay JOIN cust_bill_pay_pkg USING (billpaynum) + WHERE cust_bill_pay_pkg.billpkgnum = cust_bill_pkg.billpkgnum"; + +push @select, 'part_pkg.pkg', + 'part_pkg.freq', + 'cust_main.custnum', + 'cust_main.first', + 'cust_main.last', + 'cust_main.company', + 'part_referral.referral', + "($paid_sql) AS paid", + "($last_pay_sql) AS last_pay", + "($recur_sql) AS recur_no_usage", + "($usage_sql) AS recur_usage", + 'pkg_class.classname', + 'agent.agent', + ; + +my $query = { + 'table' => 'cust_bill_pkg', + 'addl_from' => "$join_cust $join_pkg", + 'hashref' => {}, + 'select' => join(",\n", @select ), + 'extra_sql' => $where, + 'order_by' => 'ORDER BY cust_bill._date, billpkgnum', +}; + +my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ]; +my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + +my %report_classes; #cache +my %report_option_name = + map { $_->num => $_->name } qsearch('part_pkg_report_option', {}); + +# should this be in Mason.pm or something? +sub money_sub { + $conf ||= new FS::Conf; + $money_char ||= $conf->config('money_char') || '$'; + my $field = shift; + sub { + $money_char . sprintf('%.2f', $_[0]->get($field)); + }; +} + +sub date_sub { + my $field = shift; + sub { + my $value = $_[0]->get($field); + $value ? time2str('%b %d %Y', $value) : ''; + }; +} + + diff --git a/httemplate/search/elements/search-xls.html b/httemplate/search/elements/search-xls.html index 0b5636c0e..6a19cf2f5 100644 --- a/httemplate/search/elements/search-xls.html +++ b/httemplate/search/elements/search-xls.html @@ -42,6 +42,9 @@ my $default_format = $workbook->add_format(locked => 0); my %money_format; my $money_char = FS::Conf->new->config('money_char') || '$'; +my %date_format; +xl_parse_date_init(); + my $writer = sub { # Wrapper for $worksheet->write. # Do any massaging of the value/format here. @@ -50,6 +53,7 @@ my $writer = sub { # Currency: strip the symbol, clone the requested format, # and format it for currency $value = $1; +# warn "formatting $value as money\n"; if ( !exists($money_format{$format}) ) { $money_format{$format} = $workbook->add_format(); $money_format{$format}->copy($format); @@ -57,6 +61,22 @@ my $writer = sub { } $format = $money_format{$format}; } + elsif ( $value =~ /^([A-Z][a-z]{2}) (\d{2}) (\d{4})$/ ) { + # Date: convert the value to an Excel date number and set + # the format + $value = xl_parse_date($value); +# warn "formatting $value as date\n"; + if ( !exists($date_format{$format}) ) { + $date_format{$format} = $workbook->add_format(); + $date_format{$format}->copy($format); + $date_format{$format}->set_num_format('mmm dd yyyy'); + } + $format = $date_format{$format}; + } + else { + # String: replace line breaks with newlines + $value =~ s/
/\n/gi; + } $worksheet->write($r, $c, $value, $format); }; diff --git a/httemplate/search/report_cust_bill_pkg_referral.html b/httemplate/search/report_cust_bill_pkg_referral.html new file mode 100644 index 000000000..1fbb13d4f --- /dev/null +++ b/httemplate/search/report_cust_bill_pkg_referral.html @@ -0,0 +1,55 @@ +<% include('/elements/header.html', 'Sales Report with Advertising Source' ) %> + +
+ + + +<& /elements/tr-input-beginning_ending.html &> + +<& /elements/tr-select-agent.html, + 'label' => 'For agent: ', + 'disable_empty' => 0, + 'empty_label' => 'all', +&> + +<& /elements/tr-select-pkg_class.html, + 'pre_options' => [ '' => 'all', '0' => '(empty class)' ], + 'disable_empty' => 1, +&> + +<& /elements/tr-select-table.html, + 'label' => 'Report classes', + 'table' => 'part_pkg_report_option', + 'name_col' => 'name', + 'hashref' => { disabled => '' }, + 'element_name' => 'report_option', + 'multiple' => 1, +&> + + + + + + + + + + + + + + + + +
Show setup/one-time fees
Show recurring fees
Show usage charges
+ +
+
+ +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); + + -- cgit v1.2.1 From 005424d0c899aa899f43f583a6c74deb13ea4be1 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 6 Jul 2012 13:00:17 -0700 Subject: excel number format fix, #17971 --- httemplate/search/cust_bill_pkg_referral.html | 2 +- httemplate/search/elements/search-xls.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate') diff --git a/httemplate/search/cust_bill_pkg_referral.html b/httemplate/search/cust_bill_pkg_referral.html index f17cea3d9..1bb6b9179 100644 --- a/httemplate/search/cust_bill_pkg_referral.html +++ b/httemplate/search/cust_bill_pkg_referral.html @@ -190,7 +190,7 @@ my @orwhere; push @orwhere, "(cust_bill_pkg.setup > 0)" if $setup; push @orwhere, "($recur_sql > 0)" if $recur; push @orwhere, "($usage_sql > 0)" if $usage; -push @where, join(' OR ', @orwhere); +push @where, '('.join(' OR ', @orwhere).')' if @orwhere; $join_cust = ' JOIN cust_bill USING ( invnum ) LEFT JOIN cust_main USING ( custnum ) diff --git a/httemplate/search/elements/search-xls.html b/httemplate/search/elements/search-xls.html index 6a19cf2f5..a3a8226c5 100644 --- a/httemplate/search/elements/search-xls.html +++ b/httemplate/search/elements/search-xls.html @@ -49,7 +49,7 @@ my $writer = sub { # Wrapper for $worksheet->write. # Do any massaging of the value/format here. my ($r, $c, $value, $format) = @_; - if ( $value =~ /^\Q$money_char\E(\d+\.?\d*)$/ ) { + if ( $value =~ /^\Q$money_char\E(-?\d+\.?\d*)$/ ) { # Currency: strip the symbol, clone the requested format, # and format it for currency $value = $1; -- cgit v1.2.1 From 4db3780dd49caf7b84e48fe1cfc72f1d13f1282c Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sun, 8 Jul 2012 22:43:27 -0700 Subject: per-package flags to override package def level suspend_bill flag, RT#18376 --- httemplate/misc/cancel_pkg.html | 14 +++++++++++++- httemplate/misc/process/cancel_pkg.html | 11 +++++++++-- httemplate/view/cust_main/packages/status.html | 7 ++++++- 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'httemplate') diff --git a/httemplate/misc/cancel_pkg.html b/httemplate/misc/cancel_pkg.html index 4b5df8654..42cc56dfe 100755 --- a/httemplate/misc/cancel_pkg.html +++ b/httemplate/misc/cancel_pkg.html @@ -31,7 +31,19 @@ &> % } -% if ( ( $method eq 'adjourn' or $method eq 'suspend' ) and +% if ( $method eq 'adjourn' || $method eq 'suspend' ) { + +% if ( $part_pkg->option('suspend_bill', 1) ) { + <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &> + Disable recurring billing while suspended +% } else { + <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &> + Continue recurring billing while suspended +% } + +% } + +% if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and % $curuser->access_right('Unsuspend customer package') ) { #later? % my $resume_date = $cgi->param('error') % ? str2time($cgi->param('resume_date')) diff --git a/httemplate/misc/process/cancel_pkg.html b/httemplate/misc/process/cancel_pkg.html index 662a77670..4f8e11b7f 100755 --- a/httemplate/misc/process/cancel_pkg.html +++ b/httemplate/misc/process/cancel_pkg.html @@ -49,10 +49,15 @@ if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume'){ $method = 'unsuspend' if $method eq 'resume'; } -my $resume_date; +my $resume_date = ''; +my $options = ''; if ( $method eq 'suspend' ) { #or 'adjourn' $resume_date = parse_datetime($cgi->param('resume_date')) if $cgi->param('resume_date'); + + $options = { map scalar($cgi->param($_)), + suspend_bill no_suspend_bill + }; } my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} ); @@ -73,7 +78,9 @@ if ( $method ne 'unsuspend' ) { #i.e. 'resume' my $error = $cust_pkg->$method( 'reason' => $reasonnum, 'date' => $date, - 'resume_date' => $resume_date ); + 'resume_date' => $resume_date, + 'options' => $options, + ); if ($error) { $cgi->param('error', $error); diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html index 28df9da95..47ef1bcb7 100644 --- a/httemplate/view/cust_main/packages/status.html +++ b/httemplate/view/cust_main/packages/status.html @@ -58,7 +58,12 @@ <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %> <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %> -% if ( $part_pkg->option('suspend_bill', 1) ) { +% if ( $cust_pkg->option('suspend_bill', 1) +% || ( $part_pkg->option('suspend_bill', 1) +% && ! $cust_pkg->option('no_suspend_bill',1) +% ) +% ) +% { <% pkg_status_row_if( $cust_pkg, emt('Next bill'), 'bill', %opt, curuser=>$curuser ) %> % } <% pkg_status_row_if( $cust_pkg, emt('Will resume'), 'resume', %opt, curuser=>$curuser ) %> -- cgit v1.2.1 From 73c83632921705248b1ebf68c561852b5e0e7144 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 11 Jul 2012 02:09:16 -0700 Subject: Vendor Qualification ID is now editable if empty, RT#18405, RT#18313 --- httemplate/edit/svc_dsl.cgi | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'httemplate') diff --git a/httemplate/edit/svc_dsl.cgi b/httemplate/edit/svc_dsl.cgi index 1aeadb376..36345b9c5 100644 --- a/httemplate/edit/svc_dsl.cgi +++ b/httemplate/edit/svc_dsl.cgi @@ -52,12 +52,24 @@ my $edit_cb = sub { elsif($export->exporttype eq 'ikano') { @fields = ( 'password', 'monitored', ); - foreach my $hf ( keys %$ti_fields ) { - push @fields, { - field => $hf, - type => 'hidden', - value => $svc_x->$hf, - } unless ( $hf eq 'password' || $hf eq 'monitored' ); + if ( $svc_x->vendor_qual_id ) { + push @fields, { field => 'vendor_qual_id', + type => 'hidden', + value => $svc_x->vendor_qual_id, + }; + } else { + push @fields, 'vendor_qual_id'; + } + + foreach my $hf ( + grep { $_ !~ /^(password|monitored|vendor_qual_id)$/ } + keys %$ti_fields + ) { + push @fields, { + field => $hf, + type => 'hidden', + value => $svc_x->$hf, + }; } } # else add any other export-specific stuff here -- cgit v1.2.1 From f27da610fe9dabe8c7319f1935abd1a8cc7b2e90 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 11 Jul 2012 21:39:00 -0700 Subject: fix accidental fallout from premature commit of RT#18376, RT#18499 --- httemplate/misc/process/cancel_pkg.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate') diff --git a/httemplate/misc/process/cancel_pkg.html b/httemplate/misc/process/cancel_pkg.html index 79e489c70..a106b845a 100755 --- a/httemplate/misc/process/cancel_pkg.html +++ b/httemplate/misc/process/cancel_pkg.html @@ -58,8 +58,8 @@ if ( $method eq 'suspend' ) { #or 'adjourn' $resume_date = parse_datetime($cgi->param('resume_date')) if $cgi->param('resume_date'); - $options = { map scalar($cgi->param($_)), - suspend_bill no_suspend_bill + $options = { map { $_ => scalar($cgi->param($_)) } + qw( suspend_bill no_suspend_bill ) }; } -- cgit v1.2.1 From 26004f55ce70242d07fc8de51e24439e783e9e49 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 13 Jul 2012 00:49:12 -0700 Subject: abstract out the amount + fee + input, javascript, display so it can be reused by self-service without code duplication --- httemplate/elements/tr-amount_fee.html | 98 ++++++++++++++++++++++++++++ httemplate/misc/payment.cgi | 115 +++++++-------------------------- 2 files changed, 121 insertions(+), 92 deletions(-) create mode 100644 httemplate/elements/tr-amount_fee.html (limited to 'httemplate') diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html new file mode 100644 index 000000000..a1a9e3433 --- /dev/null +++ b/httemplate/elements/tr-amount_fee.html @@ -0,0 +1,98 @@ + + <% mt('Payment amount') |h %> + +
+ <% $money_char %> + +% if ( $fee ) { + + + <% $fee_op %> + <% $money_char . $fee %> + + <% $fee_pkg->pkg |h %> + = + + <% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %> + +% } +
+ + + +% if ( $fee ) { + + + +% } + +<%init> + +my %opt = @_; + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + +my $fee = ''; +my $fee_pkg = ''; +my $fee_display = ''; +my $fee_op = ''; + +if ( $opt{'process-pkgpart'} + and ! $opt{'process-skip_first'} || $opt{'num_payments'} + ) +{ + + $fee_display = $opt{'process-display'} || 'add'; + $fee_op = $fee_display eq 'add' ? '+' : '-'; + + $fee_pkg = + qsearchs('part_pkg', { pkgpart=>$opt{'process-pkgpart'} } ); + + #well ->unit_setup or ->calc_setup both call for a $cust_pkg + # (though ->unit_setup doesn't use it...) + $fee = $fee_pkg->option('setup_fee') + if $fee_pkg; #in case.. better than dying with a perl traceback + +} + +my $amount = $opt{'amount'}; +if ( $amount > 0 ) { + $amount += $fee + if $fee && $fee_display eq 'subtract'; + + &{ $opt{post_fee_callback} }( \$amount ) if $opt{post_fee_callback}; + + $amount = sprintf("%.2f", $amount); +} + + diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 093494a06..1ae15b930 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -9,67 +9,20 @@ <& /elements/init_overlib.html &> <% ntable('#cccccc') %> - - <% mt('Payment amount') |h %> - -
- <% $money_char %> - -% if ( $fee ) { - - - <% $fee_op %> - <% $money_char . $fee %> - - <% $fee_pkg->pkg |h %> - = - - <% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %> - -% } -
- - - -% if ( $fee ) { - - -% } + <& /elements/tr-amount_fee.html, + 'amount' => $amount, + 'process-pkgpart' => scalar($conf->config('manual_process-pkgpart')), + 'process-display' => scalar($conf->config('manual_process-display')), + 'process-skip-first' => $conf->exists('manual_process-skip_first'), + 'num_payments' => scalar($cust_main->cust_pay), + 'post_fee_callback' => $post_fee_callback, + &> -<& /elements/tr-select-discount_term.html, - 'custnum' => $custnum, - 'amount_id' => 'amount', -&> + <& /elements/tr-select-discount_term.html, + 'custnum' => $custnum, + 'amount_id' => 'amount', + &> % if ( $payby eq 'CARD' ) { % @@ -304,8 +257,6 @@ my $payinfo = ''; my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - #false laziness w/selfservice make_payment.html shortcut for one-country my %states = map { $_->state => 1 } qsearch('cust_main_county', { @@ -313,43 +264,23 @@ my %states = map { $_->state => 1 } } ); my @states = sort { $a cmp $b } keys %states; -my $fee = ''; -my $fee_pkg = ''; -my $fee_display = ''; -my $fee_op = ''; -my $num_payments = scalar($cust_main->cust_pay); -#handle old cust_main.pm (remove...) -$num_payments = scalar( @{ [ $cust_main->cust_pay ] } ) - unless defined $num_payments; -if ( $conf->config('manual_process-pkgpart') - and ! $conf->exists('manual_process-skip_first') || $num_payments - ) -{ - - $fee_display = $conf->config('manual_process-display') || 'add'; - $fee_op = $fee_display eq 'add' ? '+' : '-'; - - $fee_pkg = - qsearchs('part_pkg', { pkgpart=>$conf->config('manual_process-pkgpart') } ); - - #well ->unit_setup or ->calc_setup both call for a $cust_pkg - # (though ->unit_setup doesn't use it...) - $fee = $fee_pkg->option('setup_fee') - if $fee_pkg; #in case.. better than dying with a perl traceback - -} - my $amount = ''; if ( $balance > 0 ) { $amount = $balance; - $amount += $fee - if $fee && $fee_display eq 'subtract'; +} + +my $post_fee_callback = sub { + my( $amountref ) = @_; + + return unless $$amountref > 0; + + my $conf = new FS::Conf; my $cc_surcharge_pct = $conf->config('credit-card-surcharge-percentage'); - $amount += $amount * $cc_surcharge_pct/100 if $cc_surcharge_pct > 0; + $$amountref += $$amountref * $cc_surcharge_pct/100 if $cc_surcharge_pct > 0; - $amount = sprintf("%.2f", $amount); -} + $$amountref = sprintf("%.2f", $$amountref); +}; my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; -- cgit v1.2.1 From 0ad946f751d3a953c8a41eea1d30ad362ba38ace Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 13 Jul 2012 10:56:10 -0700 Subject: one-way check batches, #17623 --- httemplate/edit/payment_gateway.html | 7 +- httemplate/search/elements/cust_pay_batch_top.html | 2 +- httemplate/search/elements/cust_pay_or_refund.html | 9 +++ httemplate/search/pay_batch.cgi | 92 ++++++++++++++++------ 4 files changed, 84 insertions(+), 26 deletions(-) (limited to 'httemplate') diff --git a/httemplate/edit/payment_gateway.html b/httemplate/edit/payment_gateway.html index 2840df35b..e5897b035 100644 --- a/httemplate/edit/payment_gateway.html +++ b/httemplate/edit/payment_gateway.html @@ -19,8 +19,7 @@