diff options
author | Ivan Kohler <ivan@freeside.biz> | 2018-11-27 15:20:05 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2018-11-27 15:20:05 -0800 |
commit | 219c811aa5ee634bb17e1fa19a2d75351949b8d4 (patch) | |
tree | 166a474c65ae62ca20ab5b5ab0d22d478c0fdaa0 /FS/FS | |
parent | 3e6b291920daf5546efa5355e3ea6199e875d9db (diff) | |
parent | 4466b9790181b76b2955cf522562231228047054 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 65 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 21 | ||||
-rw-r--r-- | FS/FS/pay_batch/RBC.pm | 9 |
3 files changed, 63 insertions, 32 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index bb3ca12..de35c51 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -745,8 +745,15 @@ sub edit_info { 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" }; + + if ($p->{payby}) { + return { 'error' => "You do not have authority to add a bank account" } + if (($p->{payby} eq "CHEK" || $p->{payby} eq "DCHEK") && $conf->exists('selfservice-ACH_info_readonly')); + + ## get default cust_payby and change it. For old v3 selfservice that upgraded to v4. this is for v4 only + my ($cust_payby) = $cust_main->cust_payby(); + $p->{'custpaybynum'} = $cust_payby->custpaybynum; + update_payby($p); } my $new = new FS::cust_main { $cust_main->hash }; @@ -876,38 +883,35 @@ sub payment_info { $return{$_} = $cust_main->bill_location->get($_) for qw(address1 address2 city state zip); - $p->{'payment_payby'} = $payment_info->{paybys} if !$p->{'payment_payby'}; - # look for stored cust_payby info - # only if we've been given a clear payment_payby (to avoid payname conflicts) - if ($p->{'payment_payby'} =~ /^(CARD|CHEK)$/ || (ref($p->{'payment_payby'}))) { - my @search_payby = (); - if ($p->{'payment_payby'} eq 'CARD') { @search_payby = ('CARD','DCRD'); } - elsif ($p->{'payment_payby'} eq 'CHEK') { @search_payby = ('CHEK','DCHK'); } - elsif (ref($p->{'payment_payby'}) eq 'ARRAY') { @search_payby = @{$payment_info->{paybys}}; } - my ($cust_payby) = $cust_main->cust_payby(@search_payby); - if ($cust_payby) { - $return{payby} = $cust_payby->payby; - $return{payname} = $cust_payby->payname + # v3 to v4 upgrade would break change_pay because change_pay does not send payment_payby + # so for change_pay to work need to search for all allowed paybys and grab default payment account + my @search_payby = (); + @search_payby = ($p->{'payment_payby'} eq 'CARD') ? ('CARD','DCRD') : ('CHEK','DCHK') + if ($p->{'payment_payby'} =~ /^(CARD|CHEK)$/); + + my ($cust_payby) = $cust_main->cust_payby(@search_payby); + if ($cust_payby) { + $return{payby} = $cust_payby->payby; + $return{payname} = $cust_payby->payname || ( $cust_main->first. ' '. $cust_main->get('last') ); - $return{custpaybynum} = $cust_payby->custpaybynum; + $return{custpaybynum} = $cust_payby->custpaybynum; - if ( $cust_payby->payby =~ /^(CARD|DCRD)$/ ) { - $return{card_type} = cardtype($cust_payby->payinfo); - $return{payinfo} = $cust_payby->paymask; + if ( $cust_payby->payby =~ /^(CARD|DCRD)$/ ) { + $return{card_type} = cardtype($cust_payby->payinfo); + $return{payinfo} = $cust_payby->paymask; - @return{'month', 'year'} = $cust_payby->paydate_monthyear; + @return{'month', 'year'} = $cust_payby->paydate_monthyear; - } + } - if ( $cust_payby->payby =~ /^(CHEK|DCHK)$/ ) { - my ($payinfo1, $payinfo2) = split '@', $cust_payby->paymask; - $return{payinfo1} = $payinfo1; - $return{payinfo2} = $payinfo2; - $return{paytype} = $cust_payby->paytype; - $return{paystate} = $cust_payby->paystate; - $return{payname} = $cust_payby->payname; # override 'first/last name' default from above, if any. Is instution-name here. (#15819) - } + if ( $cust_payby->payby =~ /^(CHEK|DCHK)$/ ) { + my ($payinfo1, $payinfo2) = split '@', $cust_payby->paymask; + $return{payinfo1} = $payinfo1; + $return{payinfo2} = $payinfo2; + $return{paytype} = $cust_payby->paytype; + $return{paystate} = $cust_payby->paystate; + $return{payname} = $cust_payby->payname; # override 'first/last name' default from above, if any. Is instution-name here. (#15819) } } @@ -1724,7 +1728,10 @@ sub update_payby { or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; my $payinfo2 = $1; $p->{'payinfo'} = $payinfo1. '@'. $payinfo2; - } + } + elsif ($p->{'payby'} eq 'CARD') { + $p->{paydate} = $p->{year} . '-' . $p->{month} . '-01' unless $p->{paydate}; + } my $cust_payby = qsearchs('cust_payby', { 'custnum' => $custnum, diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index f29ab9f..d39dbbb 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -5614,6 +5614,8 @@ sub _X_show_zero { =item order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF [ REFNUM ] ] ] +=item order \%PARAMS + Bulk cancel + order subroutine. Perhaps slightly deprecated, only used by the bulk cancel+order in the web UI and nowhere else (edit/process/cust_pkg.cgi) @@ -5638,10 +5640,25 @@ setting I<refnum> to an array reference of refnums or a hash reference with refnums as keys. If no I<refnum> is defined, a default FS::pkg_referral record will be created corresponding to cust_main.refnum. +LOCATIONNUM, if specified, will be set on newly created cust_pkg records + =cut sub order { - my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum) = @_; + my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum, + $locationnum); + + if ( ref $_[0] ) { + my $args = $_[0]; + $custnum = $args->{custnum}; + $pkgparts = $args->{pkgparts}; + $remove_pkgnum = $args->{remove_pkgnum}; + $return_cust_pkg = $args->{return_cust_pkg}; + $refnum = $args->{refnum}; + $locationnum = $args->{locationnum}; + } else { + ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum) = @_; + } my $conf = new FS::Conf; @@ -5685,6 +5702,8 @@ sub order { } + $hash{locationnum} = $locationnum if $locationnum; + # Create the new packages. foreach my $pkgpart (@$pkgparts) { diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm index 3d1d98b..22521e0 100644 --- a/FS/FS/pay_batch/RBC.pm +++ b/FS/FS/pay_batch/RBC.pm @@ -3,6 +3,7 @@ package FS::pay_batch::RBC; use strict; use vars qw(@ISA %import_info %export_info $name); use Date::Format 'time2str'; +use Date::Parse; use FS::Conf; use Encode 'encode'; use feature 'state'; @@ -31,7 +32,7 @@ $name = 'RBC'; 'filetype' => 'fixed', #this only really applies to Debit Detail, but we otherwise only need first char 'formatre' => - '^(.).{3}(.{10}).{5}(.{4}).{3}(.).{11}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}\r?$', + '^(.).{3}(.{10}).{5}(.{4}).{3}(.).{11}(.{19}).{6}(.{30})(.{2})(.{2})(.{4}).{9}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}\r?$', 'fields' => [ qw( recordtype clientnum @@ -39,6 +40,9 @@ $name = 'RBC'; subtype paybatchnum custname + paydate_month + paydate_day + paydate_year bank payinfo paid @@ -54,7 +58,8 @@ $name = 'RBC'; my $hash = shift; $hash->{'paid'} = sprintf("%.2f", $hash->{'paid'} / 100 ); - $hash->{'_date'} = time; + my $paydate = $hash->{'paydate_year'} . $hash->{'paydate_month'} . $hash->{'paydate_day'}; + $hash->{'_date'} = str2time($paydate, 'local'); $hash->{'payinfo'} =~ s/^(\S+).*/$1/; # these often have trailing spaces $hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'}; |