X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_statement.pm;h=45fae1ccfde5d3a2df84459c73852b1fb6bab847;hb=98aa4355cb0a31f97cdbeabb6c190c908ba355a0;hp=83dd5c1be663528b4a4dc437b42447ba5dc096ec;hpb=40a7b3dc653e099f7bd0bd762b649b04c4432db2;p=freeside.git diff --git a/FS/FS/cust_statement.pm b/FS/FS/cust_statement.pm index 83dd5c1be..45fae1ccf 100644 --- a/FS/FS/cust_statement.pm +++ b/FS/FS/cust_statement.pm @@ -60,6 +60,10 @@ Creates a new record. To add the record to the database, see L<"insert">. Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the I method. +Pass "statementnum => 'ALL'" to create a temporary statement that includes +all of the customer's invoices. This statement can't be inserted and won't +set the statementnum field on any invoices. + =cut sub new { FS::Record::new(@_); } @@ -165,7 +169,16 @@ Returns the associated invoices (cust_bill records) for this statement. sub cust_bill { my $self = shift; - qsearch('cust_bill', { 'statementnum' => $self->statementnum } ); + # we use it about a thousand times, let's cache it + $self->{Hash}->{cust_bill} ||= [ + qsearch('cust_bill', { + $self->statementnum eq 'ALL' ? + ('custnum' => $self->custnum) : + ('statementnum' => $self->statementnum) + } ) + ]; + + @{ $self->{Hash}->{cust_bill} } } sub _aggregate {