communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / FS / FS / cust_pay_void.pm
index 946d69f..e18a4f6 100644 (file)
@@ -1,6 +1,8 @@
 package FS::cust_pay_void; 
+
 use strict;
-use vars qw( @ISA );
+use base qw( FS::otaker_Mixin FS::payinfo_Mixin FS::Record );
+use vars qw( @encrypted_fields $otaker_upgrade_kludge );
 use Business::CreditCard;
 use FS::UID qw(getotaker);
 use FS::Record qw(qsearchs dbh fields); # qsearch );
@@ -9,8 +11,10 @@ use FS::cust_pay;
 #use FS::cust_bill_pay;
 #use FS::cust_pay_refund;
 #use FS::cust_main;
+use FS::cust_pkg;
 
-@ISA = qw( FS::Record );
+@encrypted_fields = ('payinfo');
+$otaker_upgrade_kludge = 0;
 
 =head1 NAME
 
@@ -38,24 +42,48 @@ are currently supported:
 
 =over 4
 
-=item paynum - primary key (assigned automatically for new payments)
+=item paynum
+
+primary key (assigned automatically for new payments)
+
+=item custnum
+
+customer (see L<FS::cust_main>)
+
+=item paid
 
-=item custnum - customer (see L<FS::cust_main>)
+Amount of this payment
 
-=item paid - Amount of this payment
+=item _date
 
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">.  Also see
+specified as a UNIX timestamp; see L<perlfunc/"time">.  Also see
 L<Time::Local> and L<Date::Parse> for conversion functions.
 
-=item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH),
+=item otaker
+
+order taker (see L<FS::access_user>)
+
+=item payby
+
+`CARD' (credit cards), `CHEK' (electronic check/ACH),
 `LECB' (phone bill billing), `BILL' (billing), `CASH' (cash),
 `WEST' (Western Union), `MCRD' (Manual credit card), or `COMP' (free)
 
-=item payinfo - card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively
+=item payinfo
+
+card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively
 
-=item paybatch - text field for tracking card processing
+=item paybatch
 
-=item closed - books closed flag, empty or `Y'
+text field for tracking card processing
+
+=item closed
+
+books closed flag, empty or `Y'
+
+=item pkgnum
+
+Desired pkgnum when using experimental package balances.
 
 =item void_date
 
@@ -133,7 +161,8 @@ Currently unimplemented.
 =cut
 
 sub replace {
-   return "Can't modify voided payments!";
+   return "Can't modify voided payments!" unless $otaker_upgrade_kludge;
+   shift->SUPER::replace(@_);
 }
 
 =item check
@@ -154,6 +183,7 @@ sub check {
     || $self->ut_number('_date')
     || $self->ut_textn('paybatch')
     || $self->ut_enum('closed', [ '', 'Y' ])
+    || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
     || $self->ut_numbern('void_date')
     || $self->ut_textn('reason')
   ;
@@ -191,7 +221,7 @@ sub check {
     return $error if $error;
   }
 
-  $self->otaker(getotaker);
+  $self->otaker(getotaker) unless $self->otaker;
 
   $self->SUPER::check;
 }
@@ -207,17 +237,11 @@ sub cust_main {
   qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
 }
 
-=item payinfo_masked
-
-Returns a "masked" payinfo field with all but the last four characters replaced
-by 'x'es.  Useful for displaying credit cards.
-
-=cut
-
-sub payinfo_masked {
-  my $self = shift;
-  my $payinfo = $self->payinfo;
-  'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4));
+# Used by FS::Upgrade to migrate to a new database.
+sub _upgrade_data {  # class method
+  my ($class, %opts) = @_;
+  local($otaker_upgrade_kludge) = 1;
+  $class->_upgrade_otaker(%opts);
 }
 
 =back