From: ivan Date: Fri, 22 Oct 2010 06:14:24 +0000 (+0000) Subject: display both original usernum and void usernum vfor voided payments, RT#10280 X-Git-Tag: TORRUS_1_0_9~204 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=3e8635e9b88abdd5da862870184d9318c076933c display both original usernum and void usernum vfor voided payments, RT#10280 --- diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index a4c12aaff..183803664 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1194,10 +1194,11 @@ sub tables_hashref { 'reason', 'varchar', 'NULL', $char_d, '', '', 'otaker', 'varchar', 'NULL', 32, '', '', 'usernum', 'int', 'NULL', '', '', '', + 'void_usernum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'paynum', 'unique' => [], - 'index' => [ [ 'custnum' ], [ 'usernum' ], ], + 'index' => [ [ 'custnum' ], [ 'usernum' ], [ 'void_usernum' ] ], }, 'cust_bill_pay' => { @@ -2969,7 +2970,18 @@ sub tables_hashref { 'index' => [ ['agentnum'], ] }, - + 'svc_cert' => { + 'columns' => [ + 'svcnum', 'int', '', '', '', '', + 'recnum', 'int', '', '', '', '', + 'something', 'text', '', '', '', '', + #XXX more fields + ], + 'primary_key' => 'svcnum', + 'unique' => [], + 'index' => [], #recnum + }, + # name type nullability length default local diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm index 45287a41b..1a298ba2c 100644 --- a/FS/FS/cust_pay_void.pm +++ b/FS/FS/cust_pay_void.pm @@ -1,12 +1,14 @@ package FS::cust_pay_void; use strict; -use base qw( FS::otaker_Mixin FS::payinfo_Mixin FS::Record ); +use base qw( FS::otaker_Mixin FS::payinfo_Mixin FS::cust_main_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::Record qw(qsearch qsearchs dbh fields); use FS::CurrentUser; +use FS::access_user; use FS::cust_pay; #use FS::cust_bill; #use FS::cust_bill_pay; @@ -219,7 +221,8 @@ sub check { return $error if $error; } - $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; + $self->void_usernum($FS::CurrentUser::CurrentUser->usernum) + unless $self->void_usernum; $self->SUPER::check; } @@ -235,11 +238,41 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } +=item void_access_user + +Returns the voiding employee object (see L). + +=cut + +sub void_access_user { + my $self = shift; + qsearchs('access_user', { 'usernum' => $self->void_usernum } ); +} + # Used by FS::Upgrade to migrate to a new database. sub _upgrade_data { # class method my ($class, %opts) = @_; + + my $sql = "SELECT usernum FROM access_user WHERE username = ( SELECT history_user FROM h_cust_pay_void WHERE paynum = ? AND history_action = 'insert' ) "; + my $sth = dbh->prepare($sql) or die dbh->errstr; + + foreach my $cust_pay_void (qsearch('cust_pay_void', {'void_usernum' => ''})) { + $sth->execute($cust_pay_void->paynum) or die $sth->errstr; + my $usernum = $sth->fetchrow_arrayref->[0] or next; + if ( $usernum ) { + $cust_pay_void->void_usernum($usernum); + my $error = $cust_pay_void->replace; + die $error if $error; + } else { + warn "cust_pay_void upgrade: can't find access_user record for ". $cust_pay_void->paynum. "\n"; + } + } + local($otaker_upgrade_kludge) = 1; $class->_upgrade_otaker(%opts); + + #XXX look for the h_cust_pay delete records and when that's a different + # usernum, set usernum } =back diff --git a/httemplate/view/cust_main/payment_history/voided_payment.html b/httemplate/view/cust_main/payment_history/voided_payment.html index be68ff091..5d7f60cf5 100644 --- a/httemplate/view/cust_main/payment_history/voided_payment.html +++ b/httemplate/view/cust_main/payment_history/voided_payment.html @@ -1,6 +1,10 @@ -Payment <% $info %> +Payment <% $info %> by <% $cust_pay_void->otaker %> voided <% time2str($date_format, $cust_pay_void->void_date) %> -by <% $cust_pay_void->otaker %><% $unvoid %> +% my $void_user = $cust_pay_void->void_access_user; +% if ($void_user) { + by <% $void_user->username %> +% } +<% $unvoid %> <%init> my( $cust_pay_void, %opt ) = @_;