diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-08-20 01:42:15 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-08-24 17:31:58 -0500 |
commit | 415583a28981b3ce76344f583d8cb71ab847be25 (patch) | |
tree | f28ba01b23d00ff1f8c417a5360af6b7dbca2b86 /FS/FS | |
parent | e4f07ef831954aab40e8f5d97d3361ee34aaf2c5 (diff) |
RT#14829: automatic payments triggered by bill now show up as Payment by fs_queue
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/Schema.pm | 4 | ||||
-rw-r--r-- | FS/FS/queue.pm | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 184c6c951..2ff92eb2c 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -4332,6 +4332,7 @@ sub tables_hashref { 'custnum', 'int', 'NULL', '', '', '', 'secure', 'char', 'NULL', 1, '', '', 'priority', 'int', 'NULL', '', '', '', + 'usernum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'jobnum', 'unique' => [], @@ -4345,6 +4346,9 @@ sub tables_hashref { { columns => [ 'custnum' ], table => 'cust_main', }, + { columns => [ 'usernum' ], + table => 'access_user', + }, ], }, diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 1b52ac4fc..f7f09485d 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -97,6 +97,10 @@ Optional link to customer (see L<FS::cust_main>). Secure flag, 'Y' indicates that when using encryption, the job needs to be run on a machine with the private key. +=item usernum + +For access_user that created the job + =cut =back @@ -151,6 +155,8 @@ sub insert { $self->custnum( $args{'custnum'} ) if $args{'custnum'}; + $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; + my $error = $self->SUPER::insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -235,6 +241,7 @@ sub check { || $self->ut_enum('status',['', qw( new locked failed done )]) || $self->ut_anything('statustext') || $self->ut_numbern('svcnum') + || $self->ut_foreign_keyn('usernum', 'access_user', 'usernum') ; return $error if $error; @@ -357,6 +364,20 @@ sub update_statustext { #''; } +=item access_user + +Returns FS::access_user object (if any) associated with this user. + +Returns nothing if not found. + +=cut + +sub access_user { + my $self = shift; + my $usernum = $self->usernum || return (); + return qsearchs('access_user',{ 'usernum' => $usernum }) || (); +} + =back =head1 SUBROUTINES |