diff options
author | ivan <ivan> | 2006-10-08 08:17:06 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-10-08 08:17:06 +0000 |
commit | 22c70177969f30e2e419b32cb5d475c143f10b12 (patch) | |
tree | 575464d297893db89f4452e85d3d5b3a92c89974 /FS | |
parent | 1530e25643850b0cd6e59332c79c8760243b5d5e (diff) |
add menu items for credit card batching, debug last-minute changes to payby.pm, add ACL for re-processing batches, separate CARD and CHEK batches, fixed defaults for batch formats
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/AccessRight.pm | 8 | ||||
-rw-r--r-- | FS/FS/Conf.pm | 25 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/Setup.pm | 61 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 44 | ||||
-rw-r--r-- | FS/FS/pay_batch.pm | 5 | ||||
-rw-r--r-- | FS/FS/payby.pm | 29 |
7 files changed, 123 insertions, 50 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index aa4586688..6fdb0b0ce 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -165,9 +165,11 @@ assigned to users and/or groups. ### # misc rights ### - 'Job queue', # these are not currently agent-virtualized - 'Import', # - 'Export', # + 'Job queue', # these are not currently agent-virtualized + 'Process batches', # + 'Reprocess batches', # + 'Import', # + 'Export', # ### # setup/config rights diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 7f77e000f..c956b5b0c 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1729,11 +1729,34 @@ httemplate/docs/config.html }, { + 'key' => 'batch-enable', + 'section' => 'billing', + 'description' => 'Enable credit card batching - leave disabled for real-time installations.', + 'type' => 'checkbox', + }, + + { 'key' => 'batch-default_format', 'section' => 'billing', 'description' => 'Default format for batches.', 'type' => 'select', - 'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM' ] + 'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ] + }, + + { + 'key' => 'batch-fixed_format-CARD', + 'section' => 'billing', + 'description' => 'Fixed (unchangeable) format for credit card batches.', + 'type' => 'select', + 'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ] + }, + + { + 'key' => 'batch-fixed_format-CHEK', + 'section' => 'billing', + 'description' => 'Fixed (unchangeable) format for electronic check batches.', + 'type' => 'select', + 'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ] }, { diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index ea02dfebf..607b2d9f3 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -592,6 +592,7 @@ sub tables_hashref { 'pay_batch' => { #batches of payments to an external processor 'columns' => [ 'batchnum', 'serial', '', '', '', '', + 'payby', 'char', '', 4, '', '', # CARD/CHEK 'status', 'char', 'NULL', 1, '', '', 'download', @date_type, '', '', 'upload', @date_type, '', '', diff --git a/FS/FS/Setup.pm b/FS/FS/Setup.pm index fff8256b4..c92ea41da 100644 --- a/FS/FS/Setup.pm +++ b/FS/FS/Setup.pm @@ -71,13 +71,8 @@ sub populate_locales { my @states = $subcountry ? $subcountry->all_codes : undef; if ( !scalar(@states) || ( scalar(@states)==1 && !defined($states[0]) ) ) { - - my $cust_main_county = new FS::cust_main_county({ - 'tax' => 0, - 'country' => $country, - }); - my $error = $cust_main_county->insert; - die $error if $error; + + _add_locale( 'country'=>$country ); } else { @@ -86,15 +81,7 @@ sub populate_locales { } foreach my $state ( @states ) { - - my $cust_main_county = new FS::cust_main_county({ - 'state' => $state, - 'tax' => 0, - 'country' => $country, - }); - my $error = $cust_main_county->insert; - die $error if $error; - + _add_locale( 'country'=>$country, 'state'=>$state); } } @@ -102,6 +89,34 @@ sub populate_locales { } +sub populate_addl_locales { + + my %addl = ( + 'US' => { + 'FM' => 'Federated States of Micronesia', + 'MH' => 'Federated States of Micronesia', + 'PW' => 'Federated States of Micronesia', + 'AA' => "Armed Forces Americas (except Canada)", + 'AE' => "Armed Forces Europe / Canada / Middle East / Africa", + 'AP' => "Armed Forces Pacific", + }, + ); + + foreach my $country ( keys %addl ) { + foreach my $state ( keys %{ $addl{$country} } ) { + # $longname = $addl{$country}{$state}; + _add_locale( 'country'=>$country, 'state'=>$state); + } + } + +} + +sub _add_locale { + my $cust_main_county = new FS::cust_main_county( { 'tax'=>0, @_ }); + my $error = $cust_main_county->insert; + die $error if $error; +} + sub populate_initial_data { my %opt = @_; @@ -175,13 +190,13 @@ sub initial_data { 'weight' => 40, 'plan' => 'suspend', }, - { 'payby' => 'DCLN', - 'event' => 'Retriable', - 'seconds' => 0, - 'eventcode' => '$cust_bill_event->retriable();', - 'weight' => 60, - 'plan' => 'retriable', - }, + #{ 'payby' => 'DCLN', + # 'event' => 'Retriable', + # 'seconds' => 0, + # 'eventcode' => '$cust_bill_event->retriable();', + # 'weight' => 60, + # 'plan' => 'retriable', + #}, ], #you must create a service definition. An example of a service definition diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index edb951d2c..704df25a7 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1319,9 +1319,10 @@ sub batch_card { return '' unless $amount > 0; if ($options{'realtime'}) { - return $cust_main->realtime_bop ( $FS::payby::payby2bop{$cust_main->payby}, $amount, - %options, - ); + return $cust_main->realtime_bop( FS::payby->payby2bop($cust_main->payby), + $amount, + %options, + ); } my $oldAutoCommit = $FS::UID::AutoCommit; @@ -1331,11 +1332,15 @@ sub batch_card { $dbh->do("LOCK TABLE pay_batch IN SHARE ROW EXCLUSIVE MODE") or return "Cannot lock pay_batch: " . $dbh->errstr; - my $pay_batch = qsearchs('pay_batch', {'status' => 'O'}); + my %pay_batch = ( + 'status' => 'O', + 'payby' => FS::payby->payby2payment($cust_main->payby), + ); + + my $pay_batch = qsearchs( 'pay_batch', \%pay_batch ); unless ( $pay_batch ) { - $pay_batch = new FS::pay_batch; - $pay_batch->setfield('status' => 'O'); + $pay_batch = new FS::pay_batch \%pay_batch; my $error = $pay_batch->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -1344,26 +1349,29 @@ sub batch_card { } my $old_cust_pay_batch = qsearchs('cust_pay_batch', { - 'batchnum' => $pay_batch->getfield('batchnum'), - 'custnum' => $cust_main->getfield('custnum'), + 'batchnum' => $pay_batch->batchnum, + 'custnum' => $cust_main->custnum, } ); my $cust_pay_batch = new FS::cust_pay_batch ( { - 'batchnum' => $pay_batch->getfield('batchnum'), + 'batchnum' => $pay_batch->batchnum, 'invnum' => $self->getfield('invnum'), # is there a better value? - 'custnum' => $cust_main->getfield('custnum'), + # this field should be + # removed... + # cust_bill_pay_batch now + 'custnum' => $cust_main->custnum, 'last' => $cust_main->getfield('last'), 'first' => $cust_main->getfield('first'), - 'address1' => $cust_main->getfield('address1'), - 'address2' => $cust_main->getfield('address2'), - 'city' => $cust_main->getfield('city'), - 'state' => $cust_main->getfield('state'), - 'zip' => $cust_main->getfield('zip'), - 'country' => $cust_main->getfield('country'), + 'address1' => $cust_main->address1, + 'address2' => $cust_main->address2, + 'city' => $cust_main->city, + 'state' => $cust_main->state, + 'zip' => $cust_main->zip, + 'country' => $cust_main->country, 'payby' => $cust_main->payby, 'payinfo' => $cust_main->payinfo, - 'exp' => $cust_main->getfield('paydate'), - 'payname' => $cust_main->getfield('payname'), + 'exp' => $cust_main->paydate, + 'payname' => $cust_main->payname, 'amount' => $amount, # consolidating } ); diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index 7d9d9fb09..2bf307c06 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -34,7 +34,9 @@ FS::Record. The following fields are currently supported: =item batchnum - primary key -=item status - +=item payby - CARD or CHEK + +=item status - O (Open), I (In-transit), or R (Resolved) =item download - @@ -102,6 +104,7 @@ sub check { my $error = $self->ut_numbern('batchnum') + || $self->ut_enum('payby', [ 'CARD', 'CHEK' ]) || $self->ut_enum('status', [ 'O', 'I', 'R' ]) ; return $error if $error; diff --git a/FS/FS/payby.pm b/FS/FS/payby.pm index 54e4092a5..42328b429 100644 --- a/FS/FS/payby.pm +++ b/FS/FS/payby.pm @@ -3,6 +3,7 @@ package FS::payby; use strict; use vars qw(%hash %payby2bop); use Tie::IxHash; +use Business::CreditCard; =head1 NAME @@ -98,11 +99,11 @@ tie %hash, 'Tie::IxHash', }, 'DCLN' => { # This is only an event. tinyname => 'declined', - shortname => 'Declined payment', - longname => 'Declined payment', + shortname => 'Batch declined payment', + longname => 'Batch declined payment', #its neither of these.. - cust_main => '', + #cust_main => '', cust_pay => '', }, @@ -117,11 +118,31 @@ sub payby2longname { map { $_ => $hash{$_}->{longname} } $self->payby; } +sub shortname { + my( $self, $payby ) = @_; + $hash{$payby}->{shortname}; +} + +sub longname { + my( $self, $payby ) = @_; + $hash{$payby}->{longname}; +} + %payby2bop = ( 'CARD' => 'CC', 'CHEK' => 'ECHECK', ); +sub payby2bop { + my( $self, $payby ) = @_; + $payby2bop{ $self->payby2payment($payby) }; +} + +sub payby2payment { + my( $self, $payby ) = @_; + $hash{$payby}{'cust_pay'} || $payby; +} + sub cust_payby { my $self = shift; grep { ! exists $hash{$_}->{cust_main} } $self->payby; @@ -142,7 +163,7 @@ sub payinfo_check{ or return "Illegal (mistyped?) credit card number (payinfo)"; $$payinforef = $1; validate($$payinforef) or return "Illegal credit card number"; - return "Unknown card type" if cardype($$payinforef) eq "Unknown"; + return "Unknown card type" if cardtype($$payinforef) eq "Unknown"; } else { $$payinforef="N/A"; } |