X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fbill_batch.pm;h=ec5c194562c9e204817eca8e029106ccc3670bdf;hb=982ded2d929bdcdfa72efa810273f3bc753bf036;hp=3afe20915907f3b294e70ea93c6445cff14e3c22;hpb=214f0bb42fc4b59d9111274b6255ebaafaac35ef;p=freeside.git diff --git a/FS/FS/bill_batch.pm b/FS/FS/bill_batch.pm index 3afe20915..ec5c19456 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) + =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) 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