X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=d131af974334940251e6ff41921af3660327941a;hb=cccd0b7cd38a88c131e19981be38434f87abe194;hp=fc6a927ee169aeb92c9e2f0c7ea737817bbc77e1;hpb=672f360a644d12d7eab223fd00cd3426b00756cd;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index fc6a927ee..d131af974 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -244,7 +244,7 @@ sub paymask { if ( defined($value) && !$self->is_encrypted($value)) { my $payinfo = $value; my $payby = $self->payby; - if ($payby eq 'CARD' || $payby eq 'DCARD') { # Credit Cards (Show last four) + if ($payby eq 'CARD' || $payby eq 'DCRD') { # Credit Cards (Show last four) $paymask = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); } elsif ($payby eq 'CHEK' || $payby eq 'DCHK' ) { # Checks (Show last 2 @ bank) @@ -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 ); @@ -1633,6 +1672,9 @@ sub bill { } elsif ( $part_pkg->freq =~ /^(\d+)d$/ ) { my $days = $1; $mday += $days; + } elsif ( $part_pkg->freq =~ /^(\d+)h$/ ) { + my $hours = $1; + $hour += $hours; } else { $dbh->rollback if $oldAutoCommit; return "unparsable frequency: ". $part_pkg->freq;