X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pay_pending.pm;h=d1083411c0031cfbcaf928beb96f647ea1c0c206;hp=dfb07b84d50cef0d27e4be72efffa1649c179e0a;hb=a36e0f8a0f69349dafaa16d1d2d57dfb6e5dbc85;hpb=d22baa4e71bfa9e153c1fe1152ff4c748f1d935c diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index dfb07b84d..d1083411c 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -215,7 +215,7 @@ sub check { my $error = $self->ut_numbern('paypendingnum') - || $self->ut_foreign_key('custnum', 'cust_main', 'custnum') + || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum') || $self->ut_money('paid') || $self->ut_numbern('_date') || $self->ut_textn('payunique') @@ -235,6 +235,10 @@ sub check { ; return $error if $error; + if (!$self->custnum and !$self->get('custnum_pending')) { + return 'custnum required'; + } + $self->_date(time) unless $self->_date; # UNIQUE index should catch this too, without race conditions, but this @@ -455,6 +459,26 @@ sub decline { $self->replace; } +=item reverse [ STATUSTEXT ] + +Sets the status of this pending payment to "done" (with statustext +"reversed (manual)" unless otherwise specified). + +Currently only used when resolving pending payments manually. + +=cut + +# almost complete false laziness with decline, +# but want to avoid confusion, in case any additional steps/defaults are ever added to either +sub reverse { + my $self = shift; + my $statustext = shift || "reversed (manual)"; + + $self->status('done'); + $self->statustext($statustext); + $self->replace; +} + # _upgrade_data # # Used by FS::Upgrade to migrate to a new database.