X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_refund.pm;h=abc131e4492f78be01dea0281434d21c33bd02a8;hb=22ca0c30a201124201836f6c6394dad06c2a11c1;hp=9cd9bf845347b5c6a5458d84080cc7299dcf67fb;hpb=b89c7f126690704c8d1558dba06d5fabd7470528;p=freeside.git diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 9cd9bf845..abc131e44 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -3,15 +3,16 @@ package FS::cust_refund; use strict; use vars qw( @ISA @encrypted_fields ); use Business::CreditCard; -use FS::Record qw( qsearch qsearchs dbh ); use FS::UID qw(getotaker); +use FS::Record qw( qsearch qsearchs dbh ); +use FS::cust_main_Mixin; +use FS::payinfo_transaction_Mixin; use FS::cust_credit; use FS::cust_credit_refund; use FS::cust_pay_refund; use FS::cust_main; -use FS::payinfo_Mixin; -@ISA = qw( FS::Record FS::payinfo_Mixin ); +@ISA = qw( FS::payinfo_transaction_Mixin FS::cust_main_Mixin FS::Record ); @encrypted_fields = ('payinfo'); @@ -216,12 +217,13 @@ sub delete { =item replace OLD_RECORD -Currently unimplemented (accounting reasons). +Modifying a refund? Well, don't say I didn't warn you. =cut sub replace { - return "Can't (yet?) modify cust_refund records!"; + my $self = shift; + $self->SUPER::replace(@_); } =item check @@ -234,10 +236,13 @@ returns the error, otherwise returns false. Called by the insert method. sub check { my $self = shift; + $self->otaker(getotaker) unless ($self->otaker); + my $error = $self->ut_numbern('refundnum') || $self->ut_numbern('custnum') || $self->ut_money('refund') + || $self->ut_alpha('otaker') || $self->ut_text('reason') || $self->ut_numbern('_date') || $self->ut_textn('paybatch') @@ -256,8 +261,6 @@ sub check { $error = $self->payinfo_check; return $error if $error; - $self->otaker(getotaker); - $self->SUPER::check; } @@ -307,6 +310,36 @@ sub unapplied { =back +=head1 CLASS METHODS + +=over 4 + +=item unapplied_sql + +Returns an SQL fragment to retreive the unapplied amount. + +=cut + +sub unapplied_sql { + #my $class = shift; + + "refund + - COALESCE( + ( SELECT SUM(amount) FROM cust_credit_refund + WHERE cust_refund.refundnum = cust_credit_refund.refundnum ) + ,0 + ) + - COALESCE( + ( SELECT SUM(amount) FROM cust_pay_refund + WHERE cust_refund.refundnum = cust_pay_refund.refundnum ) + ,0 + ) + "; + +} + +=back + =head1 BUGS Delete and replace methods.