X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch%2Feft_canada.pm;h=2e89322f587dca705ece7ec8451a350f0e70784c;hb=e35cfefb4b71342ec99384d8301e7e3f4a90a55f;hp=3c1d219865424be3356bc8585045336ee99755fb;hpb=5587d058a0fc74e92836ad5715c99003314da4d5;p=freeside.git diff --git a/FS/FS/pay_batch/eft_canada.pm b/FS/FS/pay_batch/eft_canada.pm index 3c1d21986..2e89322f5 100644 --- a/FS/FS/pay_batch/eft_canada.pm +++ b/FS/FS/pay_batch/eft_canada.pm @@ -15,7 +15,7 @@ $name = 'eft_canada'; %import_info = ( filetype => 'NONE' ); # see FS/bin/freeside-eftca-download -my ($trans_code, $process_date); +my ($business_trans_code, $personal_trans_code, $trans_code, $process_date); #ref http://gocanada.about.com/od/canadatravelplanner/a/canada_holidays.htm my %holiday_yearly = ( @@ -25,24 +25,6 @@ my %holiday_yearly = ( 12 => { map {$_=>1} 26 }, #boxing day ); my %holiday = ( - 2013 => { 2 => { map {$_=>1} 18 }, #family day - 3 => { map {$_=>1} 29 }, #good friday - 4 => { map {$_=>1} 1 }, #easter monday - 5 => { map {$_=>1} 20 }, #victoria day - 7 => { map {$_=>1} 1 }, #canada day - 8 => { map {$_=>1} 5 }, #First Monday of August Civic Holiday - 9 => { map {$_=>1} 2 }, #labour day - 10 => { map {$_=>1} 14 }, #thanksgiving - }, - 2014 => { 2 => { map {$_=>1} 17 }, #family day - 4 => { map {$_=>1} 18 }, #good friday - 4 => { map {$_=>1} 21 }, #easter monday - 5 => { map {$_=>1} 19 }, #victoria day - 7 => { map {$_=>1} 1 }, #canada day - 8 => { map {$_=>1} 4 }, #First Monday of August Civic Holiday - 9 => { map {$_=>1} 1 }, #labour day - 10 => { map {$_=>1} 13 }, #thanksgiving - }, 2015 => { 2 => { map {$_=>1} 16 }, #family day 4 => { map {$_=>1} 3 }, #good friday 4 => { map {$_=>1} 6 }, #easter monday @@ -52,6 +34,15 @@ my %holiday = ( 9 => { map {$_=>1} 7 }, #labour day 10 => { map {$_=>1} 12 }, #thanksgiving }, + 2016 => { 2 => { map {$_=>1} 15 }, #family day + 3 => { map {$_=>1} 25 }, #good friday + 3 => { map {$_=>1} 28 }, #easter monday + 5 => { map {$_=>1} 23 }, #victoria day + 7 => { map {$_=>1} 1 }, #canada day + 8 => { map {$_=>1} 1 }, #First Monday of August Civic Holiday + 9 => { map {$_=>1} 5 }, #labour day + 10 => { map {$_=>1} 10 }, #thanksgiving + }, ); %export_info = ( @@ -66,7 +57,8 @@ my %holiday = ( @config = $conf->config('batchconfig-eft_canada'); } # SFTP login, password, trans code, delay time - ($trans_code) = $config[2]; + ($business_trans_code) = $config[2]; + ($personal_trans_code) = $config[3]; $process_date = time2str('%D', process_date($conf, $agentnum)); }, @@ -81,11 +73,15 @@ my %holiday = ( # company + empty or first + last my $company = sprintf('%.64s', $cust_pay_batch->cust_main->company); if ( $company ) { - push @fields, $company, '' + push @fields, 'Business'; + push @fields, $company, ''; + $trans_code = $business_trans_code; } else { + push @fields, 'Personal'; push @fields, map { sprintf('%.64s', $_) } $cust_pay_batch->first, $cust_pay_batch->last; + $trans_code = $personal_trans_code; } my ($account, $aba) = split('@', $cust_pay_batch->payinfo); my($bankno, $branch); @@ -116,16 +112,23 @@ sub download_note { # is a class method my $conf = FS::Conf->new; my $agentnum = $pay_batch->agentnum; my $tomorrow = (localtime(time))[2] >= 10; - my $upload_date = time; - $upload_date += 86400 if $tomorrow; my $process_date = process_date($conf, $agentnum); + my $upload_date = $process_date - 86400; my $date_format = $conf->config('date_format') || '%D'; - 'Upload this file before 11:00 AM '. - ($tomorrow ? 'tomorrow' : 'today') . - ' (' . time2str($date_format, $upload_date) . '). '. - 'Payments will be processed on '. + my $note = ''; + if ( $process_date - time < 86400*2 ) { + $note = 'Upload this file before 11:00 AM '. + ($tomorrow ? 'tomorrow' : 'today') . + ' (' . time2str($date_format, $upload_date) . '). '; + } else { + $note = 'Upload this file before 11:00 AM on '. + time2str($date_format, $upload_date) . '. '; + } + $note .= 'Payments will be processed on '. time2str($date_format, $process_date) . '.'; + + $note; } sub process_date { @@ -137,9 +140,9 @@ sub process_date { @config = $conf->config('batchconfig-eft_canada'); } - my $process_delay = $config[3] || 1; + my $process_delay = $config[4] || 1; - if ( (localtime(time))[2] >= 10 ) { + if ( (localtime(time))[2] >= 10 and $process_delay == 1 ) { # If downloading the batch after 10:00 local time, it likely won't make # the cutoff for next-day turnaround, and EFT will reject it. $process_delay++;