diff options
author | ivan <ivan> | 2011-07-20 18:34:19 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-07-20 18:34:19 +0000 |
commit | 982ded2d929bdcdfa72efa810273f3bc753bf036 (patch) | |
tree | ef7de9d452ecc530ede09fb590adba5d0bb59961 /FS/FS/bill_batch.pm | |
parent | 214f0bb42fc4b59d9111274b6255ebaafaac35ef (diff) |
per-agent invoice PDF batches, RT#13727
Diffstat (limited to 'FS/FS/bill_batch.pm')
-rw-r--r-- | FS/FS/bill_batch.pm | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/FS/FS/bill_batch.pm b/FS/FS/bill_batch.pm index 3afe209..ec5c194 100644 --- a/FS/FS/bill_batch.pm +++ b/FS/FS/bill_batch.pm @@ -2,9 +2,11 @@ package FS::bill_batch; use strict; use vars qw( @ISA $me $DEBUG ); +use CAM::PDF; +use FS::Conf; use FS::Record qw( qsearch qsearchs dbh ); +use FS::agent; use FS::cust_bill_batch; -use CAM::PDF; @ISA = qw( FS::Record ); $me = '[ FS::bill_batch ]'; @@ -37,6 +39,8 @@ inherits from FS::Record. The following fields are currently supported: =item batchnum - primary key +=item agentnum - empty for global batches or agent (see L<FS::agent>) + =item status - either 'O' (open) or 'R' (resolved/closed). =item pdf - blob field for temporarily storing the invoice as a PDF. @@ -96,26 +100,38 @@ sub close { return $self->replace; } -=back +sub check { + my $self = shift; + + my $error = + $self->ut_numbern('batchnum') + || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum') + || $self->ut_enum('status', [ 'O', 'R' ] ) + ; + return $error if $error; -=head1 CLASS METHODS + $self->SUPER::check; +} -=item get_open_batch +=item agent -Returns the currently open batch. There should only be one at a time. +Returns the agent (see L<FS::agent>) for this invoice batch. =cut -sub get_open_batch { - my $class = shift; - my $batch = qsearchs('bill_batch', { status => 'O' }); - return $batch if $batch; - $batch = FS::bill_batch->new({status => 'O'}); - my $error = $batch->insert; - die $error if $error; - return $batch; +sub agent { + my $self = shift; + qsearchs( 'agent', { 'agentnum' => $self->agentnum } ); } +=back + +=head1 SUBROUTINES + +=item process_print_pdf + +=cut + use Storable 'thaw'; use Data::Dumper; use MIME::Base64; @@ -134,7 +150,6 @@ sub process_print_pdf { die $error if $error; } - =back =head1 BUGS |