diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 10 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 51 | ||||
-rw-r--r-- | FS/FS/cust_pay.pm | 6 | ||||
-rw-r--r-- | FS/FS/cust_pay_void.pm | 6 | ||||
-rw-r--r-- | FS/FS/cust_refund.pm | 6 |
5 files changed, 66 insertions, 13 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 7ba0f35be..4edcb99c7 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1294,11 +1294,19 @@ httemplate/docs/config.html }, { + 'key' => 'payby', + 'section' => 'billing', + 'description' => 'Available payment types.', + 'type' => 'selectmultiple', + 'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP) ], + }, + + { 'key' => 'payby-default', 'section' => 'UI', 'description' => 'Default payment type. HIDE disables display of billing information and sets customers to BILL.', 'type' => 'select', - 'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL COMP HIDE) ], + 'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP HIDE) ], }, { diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index b85dff4a5..d131af974 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -360,6 +360,7 @@ sub insert { my $prepay_identifier = ''; my( $amount, $seconds ) = ( 0, 0 ); + my $payby = ''; if ( $self->payby eq 'PREPAY' ) { $self->payby('BILL'); @@ -373,6 +374,14 @@ sub insert { return $error; } + $payby = 'PREP' if $amount; + + } elsif ( $self->payby =~ /^(CASH|WEST)$/ ) { + + $payby = $1; + $self->payby('BILL'); + $amount = $self->paid; + } my $error = $self->SUPER::insert; @@ -405,13 +414,15 @@ sub insert { } if ( $amount ) { - $error = $self->insert_cust_pay_prepay($amount, $prepay_identifier); + $error = $self->insert_cust_pay($payby, $amount, $prepay_identifier); if ( $error ) { $dbh->rollback if $oldAutoCommit; - return "inserting prepayment (transaction rolled back): $error"; + return "inserting payment (transaction rolled back): $error"; } } + + unless ( $import || $skip_fuzzyfiles ) { $error = $self->queue_fuzzyfiles_update; if ( $error ) { @@ -691,14 +702,42 @@ If there is an error, returns the error, otherwise returns false. =cut sub insert_cust_pay_prepay { - my( $self, $amount ) = splice(@_, 0, 2); + shift->insert_cust_pay('PREP', @_); +} + +=item insert_cust_pay_cash AMOUNT [ PAYINFO ] + +Inserts a cash payment in the specified amount for this customer. An optional +second argument can specify the payment identifier for tracking purposes. +If there is an error, returns the error, otherwise returns false. + +=cut + +sub insert_cust_pay_cash { + shift->insert_cust_pay('CASH', @_); +} + +=item insert_cust_pay_prepay AMOUNT [ PAYINFO ] + +Inserts a Western Union payment in the specified amount for this customer. An +optional second argument can specify the prepayment identifier for tracking +purposes. If there is an error, returns the error, otherwise returns false. + +=cut + +sub insert_cust_pay_west { + shift->insert_cust_pay('WEST', @_); +} + +sub insert_cust_pay { + my( $self, $payby, $amount ) = splice(@_, 0, 3); my $payinfo = scalar(@_) ? shift : ''; my $cust_pay = new FS::cust_pay { 'custnum' => $self->custnum, 'paid' => sprintf('%.2f', $amount), #'_date' => #date the prepaid card was purchased??? - 'payby' => 'PREP', + 'payby' => $payby, 'payinfo' => $payinfo, }; $cust_pay->insert; @@ -1105,7 +1144,7 @@ sub check { } } - $self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY)$/ + $self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY|CASH|WEST)$/ or return "Illegal payby: ". $self->payby; $error = $self->ut_numbern('paystart_month') @@ -1242,7 +1281,7 @@ sub check { if ( $self->paydate eq '' || $self->paydate eq '-' ) { return "Expriation date required" - unless $self->payby =~ /^(BILL|PREPAY|CHEK|LECB)$/; + unless $self->payby =~ /^(BILL|PREPAY|CHEK|LECB|CASH|WEST)$/; $self->paydate(''); } else { my( $m, $y ); diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index a7d69901f..3772473bc 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -61,7 +61,8 @@ currently supported: L<Time::Local> and L<Date::Parse> for conversion functions. =item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH), -`LECB' (phone bill billing), `BILL' (billing), or `COMP' (free) +`LECB' (phone bill billing), `BILL' (billing), `PREP` (prepaid card), +`CASH' (cash), `WEST' (Western Union) or `COMP' (free) =item payinfo - card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively @@ -373,7 +374,8 @@ sub check { $self->_date(time) unless $self->_date; - $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREP)$/ or return "Illegal payby"; + $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREP|CASH|WEST)$/ + or return "Illegal payby"; $self->payby($1); #false laziness with cust_refund::check diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm index 7267929c8..6437163ad 100644 --- a/FS/FS/cust_pay_void.pm +++ b/FS/FS/cust_pay_void.pm @@ -47,7 +47,8 @@ are currently supported: L<Time::Local> and L<Date::Parse> for conversion functions. =item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH), -`LECB' (phone bill billing), `BILL' (billing), or `COMP' (free) +`LECB' (phone bill billing), `BILL' (billing), `CASH' (cash), +`WEST' (Western Union) or `COMP' (free) =item payinfo - card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively @@ -128,7 +129,8 @@ sub check { $self->void_date(time) unless $self->void_date; - $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby"; + $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREP|CASH|WEST)$/ + or return "Illegal payby"; $self->payby($1); #false laziness with cust_refund::check diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 106ccd3c3..48cc7cc7a 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -51,7 +51,8 @@ inherits from FS::Record. The following fields are currently supported: L<Time::Local> and L<Date::Parse> for conversion functions. =item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH), -`LECB' (Phone bill billing), `BILL' (billing), or `COMP' (free) +`LECB' (Phone bill billing), `BILL' (billing), `CASH' (cash), +`WEST' (Western Union), or `COMP' (free) =item payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username) @@ -211,7 +212,8 @@ sub check { unless $self->crednum || qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); - $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby"; + $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|CASH|WEST)$/ + or return "Illegal payby"; $self->payby($1); #false laziness with cust_pay::check |