X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=c2491774959147b284c38c861ceac11536a4ef9f;hb=4e35589e637aa3a3615a780d4086085c5ecb1782;hp=8b6a466be57cbd80642f9039bc5f6167240d66a4;hpb=66bf9d2b3998894588d73a10a459aa1453283ef1;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 8b6a466be..c24917749 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -9,6 +9,7 @@ use Business::CreditCard; use Time::Duration; use FS::CGI qw(small_custview); #doh use FS::UI::Web; +use FS::UI::bytecount; use FS::Conf; use FS::Record qw(qsearch qsearchs); use FS::Msgcat qw(gettext); @@ -326,17 +327,15 @@ sub process_payment { return { 'error' => gettext('unknown_card_type') } if cardtype($payinfo) eq "Unknown"; - if ( defined $cust_main->dbdef_table->column('paycvv') ) { - if ( length($p->{'paycvv'} ) ) { - if ( cardtype($payinfo) eq 'American Express card' ) { - $p->{'paycvv'} =~ /^(\d{4})$/ - or return { 'error' => "CVV2 (CID) for American Express cards is four digits." }; - $paycvv = $1; - } else { - $p->{'paycvv'} =~ /^(\d{3})$/ - or return { 'error' => "CVV2 (CVC2/CID) is three digits." }; - $paycvv = $1; - } + if ( length($p->{'paycvv'}) && $p->{'paycvv'} !~ /^\s*$/ ) { + if ( cardtype($payinfo) eq 'American Express card' ) { + $p->{'paycvv'} =~ /^\s*(\d{4})\s*$/ + or return { 'error' => "CVV2 (CID) for American Express cards is four digits." }; + $paycvv = $1; + } else { + $p->{'paycvv'} =~ /^\s*(\d{3})\s*$/ + or return { 'error' => "CVV2 (CVC2/CID) is three digits." }; + $paycvv = $1; } } @@ -404,11 +403,11 @@ sub process_prepay { 'seconds' => $seconds, 'duration' => duration_exact($seconds), 'upbytes' => $upbytes, - 'upload' => FS::UI::Web::bytecount_unexact($upbytes), + 'upload' => FS::UI::bytecount::bytecount_unexact($upbytes), 'downbytes' => $downbytes, - 'download' => FS::UI::Web::bytecount_unexact($downbytes), + 'download' => FS::UI::bytecount::bytecount_unexact($downbytes), 'totalbytes'=> $totalbytes, - 'totalload' => FS::UI::Web::bytecount_unexact($totalbytes), + 'totalload' => FS::UI::bytecount::bytecount_unexact($totalbytes), }; } @@ -581,14 +580,14 @@ sub list_svcs { 'username' => $svc_x->username, 'email' => $svc_x->email, 'seconds' => $svc_x->seconds, - 'upbytes' => $svc_x->upbytes, - 'downbytes' => $svc_x->downbytes, - 'totalbytes'=> $svc_x->totalbytes, + 'upbytes' => FS::UI::bytecount::display_bytecount($svc_x->upbytes), + 'downbytes' => FS::UI::bytecount::display_bytecount($svc_x->downbytes), + 'totalbytes'=> FS::UI::bytecount::display_bytecount($svc_x->totalbytes), 'recharge_amount' => $part_pkg->option('recharge_amount', 1), 'recharge_seconds' => $part_pkg->option('recharge_seconds', 1), - 'recharge_upbytes' => $part_pkg->option('recharge_upbytes', 1), - 'recharge_downbytes' => $part_pkg->option('recharge_downbytes', 1), - 'recharge_totalbytes' => $part_pkg->option('recharge_totalbytes', 1), + 'recharge_upbytes' => FS::UI::bytecount::display_bytecount($part_pkg->option('recharge_upbytes', 1)), + 'recharge_downbytes' => FS::UI::bytecount::display_bytecount($part_pkg->option('recharge_downbytes', 1)), + 'recharge_totalbytes' => FS::UI::bytecount::display_bytecount($part_pkg->option('recharge_totalbytes', 1)), # more... }; } @@ -612,7 +611,8 @@ sub list_svc_usage { my $freq = $svc_acct->cust_svc->cust_pkg->part_pkg->freq; my $start = $svc_acct->cust_svc->cust_pkg->setup; - my $end = $svc_acct->cust_svc->cust_pkg->bill; # or time? + #my $end = $svc_acct->cust_svc->cust_pkg->bill; # or time? + my $end = time; unless($p->{beginning}){ $p->{beginning} = $svc_acct->cust_svc->cust_pkg->last_bill; @@ -713,7 +713,7 @@ sub order_pkg { $svcpart ||= $cust_pkg->part_pkg->svcpart($svcdb); my %fields = ( - 'svc_acct' => [ qw( username _password sec_phrase popnum ) ], + 'svc_acct' => [ qw( username domsvc _password sec_phrase popnum ) ], 'svc_domain' => [ qw( domain ) ], 'svc_external' => [ qw( id title ) ], ); @@ -877,8 +877,7 @@ sub _do_bop_realtime { my $bill_error = $cust_main->bill; - $cust_main->apply_payments; - $cust_main->apply_credits; + $cust_main->apply_payments_and_credits; $bill_error = $cust_main->collect('realtime' => 1); if ( $cust_main->balance > $old_balance