[freeside-commits] freeside/FS/FS Conf.pm, 1.467, 1.468 AccessRight.pm, 1.62, 1.63 bill_batch.pm, 1.2, 1.3 cust_bill.pm, 1.349, 1.350 Schema.pm, 1.316, 1.317
Ivan,,,
ivan at wavetail.420.am
Wed Jul 20 11:34:21 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv12005/FS/FS
Modified Files:
Conf.pm AccessRight.pm bill_batch.pm cust_bill.pm Schema.pm
Log Message:
per-agent invoice PDF batches, RT#13727
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.316
retrieving revision 1.317
diff -u -w -d -r1.316 -r1.317
--- Schema.pm 20 Jul 2011 13:46:10 -0000 1.316
+++ Schema.pm 20 Jul 2011 18:34:19 -0000 1.317
@@ -3340,12 +3340,13 @@
'bill_batch' => {
'columns' => [
'batchnum', 'serial', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
'status', 'char', 'NULL','1', '', '',
'pdf', 'blob', 'NULL', '', '', '',
],
'primary_key' => 'batchnum',
'unique' => [],
- 'index' => [],
+ 'index' => [ ['agentnum'] ],
},
'cust_bill_batch' => {
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.467
retrieving revision 1.468
diff -u -w -d -r1.467 -r1.468
--- Conf.pm 15 Jul 2011 21:10:05 -0000 1.467
+++ Conf.pm 20 Jul 2011 18:34:19 -0000 1.468
@@ -1258,7 +1258,14 @@
{
'key' => 'invoice_print_pdf',
'section' => 'invoicing',
- 'description' => 'Store postal invoices for download in PDF format rather than printing them directly.',
+ 'description' => 'For all invoice print operations, store postal invoices for download in PDF format rather than printing them directly.',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'invoice_print_pdf-spoolagent',
+ 'section' => 'invoicing',
+ 'description' => 'Store postal invoices PDF downloads in per-agent spools.',
'type' => 'checkbox',
},
Index: bill_batch.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/bill_batch.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- bill_batch.pm 20 Jan 2011 01:25:03 -0000 1.2
+++ bill_batch.pm 20 Jul 2011 18:34:19 -0000 1.3
@@ -2,9 +2,11 @@
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 @@
=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 @@
return $self->replace;
}
-=back
+sub check {
+ my $self = shift;
-=head1 CLASS METHODS
+ my $error =
+ $self->ut_numbern('batchnum')
+ || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
+ || $self->ut_enum('status', [ 'O', 'R' ] )
+ ;
+ return $error if $error;
-=item get_open_batch
+ $self->SUPER::check;
+}
-Returns the currently open batch. There should only be one at a time.
+=item agent
+
+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 @@
die $error if $error;
}
-
=back
=head1 BUGS
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -w -d -r1.62 -r1.63
--- AccessRight.pm 15 May 2011 01:43:40 -0000 1.62
+++ AccessRight.pm 20 Jul 2011 18:34:19 -0000 1.63
@@ -272,9 +272,11 @@
'Miscellaneous rights' => [
{ rightname=>'Job queue', global=>1 },
{ rightname=>'Time queue', global=>1 },
- { rightname=>'Process batches', global=>1 },
- { rightname=>'Reprocess batches', global=>1 },
- { rightname=>'Redownload resolved batches', global=>1 },
+ { rightname=>'Process batches', global=>1 }, #Process payment batches
+ { rightname=>'Reprocess batches', global=>1 }, #Reprocess payment batches
+ { rightname=>'Redownload resolved batches', global=>1 }, #Redownload resolved payment batches
+ { rightname=>'Process invoice batches', },
+ { rightname=>'Process global invoice batches', global=>1 },
{ rightname=>'Import', global=>1 }, #some of these are ag-virt'ed now? give em their own ACLs
{ rightname=>'Export', global=>1 },
{ rightname=> 'Edit rating data', desc=>'Delete CDRs', global=>1 },
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.349
retrieving revision 1.350
diff -u -w -d -r1.349 -r1.350
--- cust_bill.pm 14 Jul 2011 22:21:58 -0000 1.349
+++ cust_bill.pm 20 Jul 2011 18:34:19 -0000 1.350
@@ -1520,14 +1520,36 @@
sub batch_invoice {
my ($self, $opt) = @_;
- my $batch = FS::bill_batch->get_open_batch;
+ my $bill_batch = $self->get_open_bill_batch;
my $cust_bill_batch = FS::cust_bill_batch->new({
- batchnum => $batch->batchnum,
+ batchnum => $bill_batch->batchnum,
invnum => $self->invnum,
});
return $cust_bill_batch->insert($opt);
}
+=item get_open_batch
+
+Returns the currently open batch as an FS::bill_batch object, creating a new
+one if necessary. (A per-agent batch if invoice_print_pdf-spoolagent is
+enabled)
+
+=cut
+
+sub get_open_bill_batch {
+ my $self = shift;
+ my $hashref = { status => 'O' };
+ $hashref->{'agentnum'} = $conf->exists('invoice_print_pdf-spoolagent')
+ ? $self->cust_main->agentnum
+ : '';
+ my $batch = qsearchs('bill_batch', $hashref);
+ return $batch if $batch;
+ $batch = FS::bill_batch->new($hashref);
+ my $error = $batch->insert;
+ die $error if $error;
+ return $batch;
+}
+
=item ftp_invoice [ TEMPLATENAME ]
Sends this invoice data via FTP.
More information about the freeside-commits
mailing list