X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=5c86b7820ba0a2032321fda82587ba2d8467e6c4;hb=fed350a1aa758b095ca220a798939733b774dcc5;hp=e69122bcf6da66a8752c94a4475299fc7f80fb03;hpb=d841bcfd09c9fa3047c4a179889b2b1e13f8ee8e;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index e69122bcf..5c86b7820 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -593,6 +593,7 @@ sub customer_info_short { or return { 'error' => "customer_info_short: unknown custnum $custnum" }; $return{display_custnum} = $cust_main->display_custnum; + $return{max_invnum} = $cust_main->max_invnum; if ( $session->{'pkgnum'} ) { $return{balance} = $cust_main->balance_pkgnum( $session->{'pkgnum'} ); @@ -741,6 +742,11 @@ sub edit_info { my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) or return { 'error' => "unknown custnum $custnum" }; + my $conf = new FS::Conf; + if (($p->{payby} eq "CHEK" || $p->{payby} eq "DCHEK") && $conf->exists('selfservice-ACH_info_readonly')) { + return { 'error' => "You do not have authority to add a bank account" }; + } + my $new = new FS::cust_main { $cust_main->hash }; $new->set( $_ => $p->{$_} ) @@ -768,8 +774,6 @@ sub edit_info { # but if it hasn't been passed in at all, leave ship_location alone-- # DON'T change it to match bill_location. - my $conf = new FS::Conf; - my @invoicing_list; if ( exists $p->{'invoicing_list'} || exists $p->{'postal_invoicing'} ) { #false laziness with httemplate/edit/process/cust_main.cgi @@ -839,6 +843,7 @@ sub payment_info { 'show_paystate' => $conf->exists('show_bankstate'), 'save_unchecked' => $conf->exists('selfservice-save_unchecked'), + 'ach_read_only' => $conf->exists('selfservice-ACH_info_readonly'), }; @@ -985,12 +990,18 @@ sub validate_payment { my $payinfo2 = $1; $payinfo = $payinfo1. '@'. $payinfo2; + my $achonfile = 0; foreach my $cust_payby ($cust_main->cust_payby('CHEK','DCHK')) { if ( $cust_payby->paymask eq $payinfo ) { $payinfo = $cust_payby->payinfo; + $achonfile = 1; last; } } + + if ($conf->exists('selfservice-ACH_info_readonly') && !$achonfile) { + return { 'error' => "You are not allowed to change your payment information." }; + } } elsif ( $payby eq 'CARD' || $payby eq 'DCRD' ) { @@ -1588,6 +1599,42 @@ sub list_invoices { }; } +sub list_payments { + my $p = shift; + my $session = _cache->get($p->{'session_id'}) + or return { 'error' => "Can't resume session" }; #better error message + + my $custnum = $session->{'custnum'}; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return { 'error' => "unknown custnum $custnum" }; + + return { 'error' => '', + 'balance' => $cust_main->balance, + 'money_char' => FS::Conf->new->config("money_char") || '$', + 'payments' => [ map $_->SSAPI_getinfo, $cust_main->cust_pay ], + }; +} + +sub payment_receipt { + my $p = shift; + my $session = _cache->get($p->{'session_id'}) + or return { 'error' => "Can't resume session" }; #better error message + + my $custnum = $session->{'custnum'}; + + my $cust_pay = qsearchs('cust_pay', { 'custnum' => $custnum, + 'paynum' => $p->{'paynum'}, + } + ) + or return { 'error' => "unknown payment ". $p->{'paynum'} }; + + return { + 'error' => '', + %{ $cust_pay->SSAPI_getinfo }, + }; +} + sub list_payby { my $p = shift; @@ -1701,8 +1748,13 @@ sub delete_payby { }) or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} }; - return { 'error' => $cust_payby->delete }; - + my $conf = new FS::Conf; + if (($cust_payby->payby eq "DCHK" || $cust_payby->payby eq "CHEK") && $conf->exists('selfservice-ACH_info_readonly')) { + return { 'error' => "Sorry you do not have permission to delete bank information." }; + } + else { + return { 'error' => $cust_payby->delete }; + } } sub cancel { @@ -1723,6 +1775,30 @@ sub cancel { } +sub pkg_info { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $pkg = qsearchs({ + 'table' => 'cust_pkg', + 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )', + 'hashref' => { + 'custnum' => $custnum, + 'pkgnum' => $p->{'pkgnum'}, + }, + }) + or return {'error' => 'unknown pkg num $pkgnum'}; + + return { + pkg_label => $pkg->pkg, + pkgpart => $pkg->pkgpart, + classnum => $pkg->classnum, + }; + +} + sub list_pkgs { my $p = shift; @@ -2544,10 +2620,14 @@ sub change_pkg { my $err_or_cust_pkg = $cust_pkg->change( 'pkgpart' => $p->{'pkgpart'}, 'quantity' => $p->{'quantity'} || 1, ); + + my $new_pkg = qsearchs('part_pkg', { 'pkgpart' => $p->{pkgpart} } ) + or return { 'error' => "unknown package $p->{pkgpart}" }; return { error=>$err_or_cust_pkg, pkgnum=>$cust_pkg->pkgnum } unless ref($err_or_cust_pkg); + if ( $conf->exists('signup_server-realtime') ) { my $bill_error = _do_bop_realtime( $cust_main, $status, 'no_invoice_void'=>1 ); @@ -2563,7 +2643,7 @@ sub change_pkg { $err_or_cust_pkg->reexport; } - return { error => '', pkgnum => $cust_pkg->pkgnum }; + return { error => '', pkg => $new_pkg->pkg, pkgnum => $err_or_cust_pkg->pkgnum }; }