auto-conversion of answerdate too
[freeside.git] / FS / FS / cust_pay_void.pm
index 86fbbe5..45287a4 100644 (file)
@@ -1,9 +1,12 @@
 package FS::cust_pay_void; 
+
 use strict;
-use vars qw( @ISA @encrypted_fields );
+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 );
+use FS::CurrentUser;
 use FS::cust_pay;
 #use FS::cust_bill;
 #use FS::cust_bill_pay;
@@ -11,9 +14,8 @@ use FS::cust_pay;
 #use FS::cust_main;
 use FS::cust_pkg;
 
-@ISA = qw( FS::Record FS::payinfo_Mixin );
-
 @encrypted_fields = ('payinfo');
+$otaker_upgrade_kludge = 0;
 
 =head1 NAME
 
@@ -58,6 +60,10 @@ Amount of this payment
 specified as a UNIX timestamp; see L<perlfunc/"time">.  Also see
 L<Time::Local> and L<Date::Parse> for conversion functions.
 
+=item otaker
+
+order taker (see L<FS::access_user>)
+
 =item payby
 
 `CARD' (credit cards), `CHEK' (electronic check/ACH),
@@ -149,15 +155,13 @@ sub unvoid {
 Deletes this voided payment.  You probably don't want to use this directly; see
 the B<unvoid> method to add the original payment back.
 
-=item replace OLD_RECORD
+=item replace [ OLD_RECORD ]
 
-Currently unimplemented.
+You can, but probably shouldn't modify voided payments...
 
-=cut
-
-sub replace {
-   return "Can't modify voided payments!";
-}
+Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not
+supplied, replaces this record.  If there is an error, returns the error,
+otherwise returns false.
 
 =item check
 
@@ -215,7 +219,7 @@ sub check {
     return $error if $error;
   }
 
-  $self->otaker(getotaker);
+  $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum;
 
   $self->SUPER::check;
 }
@@ -231,6 +235,13 @@ sub cust_main {
   qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
 }
 
+# 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
 
 =head1 BUGS