fix race condition where ->apply_payments_and_credits could double-apply in rare...
[freeside.git] / httemplate / misc / bill.cgi
1 %
2 %#untaint custnum
3 %my($query) = $cgi->keywords;
4 %$query =~ /^(\d*)$/;
5 %my $custnum = $1;
6 %my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
7 %die "Can't find customer!\n" unless $cust_main;
8 %
9 %my $conf = new FS::Conf;
10 %
11 %my $error = $cust_main->bill(
12 %#                          'time'=>$time
13 %                         );
14 %#&eidiot($error) if $error;
15 %
16 %unless ( $error ) {
17 %  $error = $cust_main->apply_payments_and_credits
18 %           || $cust_main->collect(
19 %                                  #'invoice-time'=>$time,
20 %                                  #'batch_card'=> 'yes',
21 %                                  #'batch_card'=> 'no',
22 %                                  #'report_badcard'=> 'yes',
23 %                                  #'retry_card' => 'yes',
24 %
25 %                                  'retry' => 'yes',
26 %                                   
27 %                                  #this is used only by cust_main::batch_card
28 %                                  #need to pick & create an actual config
29 %                                  #value if we're going to turn this on
30 %                                  #("realtime-backend" doesn't exist,
31 %                                  # "backend-realtime" is for something
32 %                                  #  entirely different)
33 %                                  #'realtime' => $conf->exists('realtime-backend'),
34 %                                 );
35 %}
36 %#&eidiot($error) if $error;
37 %
38 %if ( $error ) {
39 %
40
41 <!-- mason kludge -->
42 %
43 %  &idiot($error);
44 %} else {
45 %  print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum");
46 %}
47 %