[freeside-commits] freeside/FS/FS pkg_category.pm, NONE, 1.1 Schema.pm, 1.88, 1.89 cust_bill.pm, 1.211, 1.212 part_pkg.pm, 1.71, 1.72 pkg_class.pm, 1.2, 1.3
Jeff Finucane,420,,
jeff at wavetail.420.am
Wed Jun 18 20:18:19 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv10248/FS/FS
Modified Files:
Schema.pm cust_bill.pm part_pkg.pm pkg_class.pm
Added Files:
pkg_category.pm
Log Message:
package categories (meta package classes) and grouping invoices by them
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- Schema.pm 5 Jun 2008 19:29:01 -0000 1.88
+++ Schema.pm 19 Jun 2008 03:18:16 -0000 1.89
@@ -1778,11 +1778,23 @@
'index' => [],
},
+ 'pkg_category' => {
+ 'columns' => [
+ 'categorynum', 'serial', '', '', '', '',
+ 'categoryname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'categorynum',
+ 'unique' => [],
+ 'index' => [ ['disabled'] ],
+ },
+
'pkg_class' => {
'columns' => [
- 'classnum', 'serial', '', '', '', '',
- 'classname', 'varchar', '', $char_d, '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
+ 'classnum', 'serial', '', '', '', '',
+ 'classname', 'varchar', '', $char_d, '', '',
+ 'categorynum', 'int', 'NULL', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'classnum',
'unique' => [],
Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- part_pkg.pm 14 May 2008 18:07:22 -0000 1.71
+++ part_pkg.pm 19 Jun 2008 03:18:17 -0000 1.72
@@ -475,6 +475,21 @@
}
}
+=item categoryname
+
+Returns the package category name, or the empty string if there is no package
+category.
+
+=cut
+
+sub categoryname {
+ my $self = shift;
+ my $pkg_class = $self->pkg_class;
+ $pkg_class
+ ? $pkg_class->categoryname
+ : '';
+}
+
=item classname
Returns the package class name, or the empty string if there is no package
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -d -r1.211 -r1.212
--- cust_bill.pm 4 Jun 2008 22:44:04 -0000 1.211
+++ cust_bill.pm 19 Jun 2008 03:18:17 -0000 1.212
@@ -2506,7 +2506,7 @@
if ( $cust_bill_pkg->pkgnum > 0 ) {
- my $desc = $cust_bill_pkg->part_pkg->classname;
+ my $desc = $cust_bill_pkg->part_pkg->categoryname;
$s{$desc} += $cust_bill_pkg->setup
if ( $cust_bill_pkg->setup != 0 );
@@ -2576,7 +2576,7 @@
my @cust_bill_pkg =
grep { $_->pkgnum &&
( defined($section)
- ? $_->part_pkg->classname eq $section->{'description'}
+ ? $_->part_pkg->categoryname eq $section->{'description'}
: 1
)
} $self->cust_bill_pkg;
Index: pkg_class.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/pkg_class.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pkg_class.pm 20 Dec 2006 09:49:08 -0000 1.2
+++ pkg_class.pm 19 Jun 2008 03:18:17 -0000 1.3
@@ -2,8 +2,9 @@
use strict;
use vars qw( @ISA );
-use FS::Record qw( qsearch );
+use FS::Record qw( qsearchs qsearch );
use FS::part_pkg;
+use FS::pkg_category;
@ISA = qw( FS::Record );
@@ -38,6 +39,8 @@
=item classname - Text name of this package class
+=item categorynum - Number of associated pkg_category (see L<FS::pkg_category>)
+
=item disabled - Disabled flag, empty or 'Y'
=back
@@ -95,10 +98,35 @@
$self->ut_numbern('classnum')
or $self->ut_text('classname')
+ or $self->ut_foreign_keyn('categorynum', 'pkg_category', 'categorynum')
or $self->SUPER::check;
}
+=item pkg_category
+
+Returns the pkg_category record associated with this class, or false if there
+is none.
+
+=cut
+
+sub pkg_category {
+ my $self = shift;
+ qsearchs('pkg_category', { 'categorynum' => $self->categorynum } );
+}
+
+=item categoryname
+
+Returns the category name associated with this class, or false if there
+is none.
+
+=cut
+
+sub categoryname {
+ my $pkg_category = shift->pkg_category;
+ $pkg_category->categoryname if $pkg_category;
+}
+
=back
=head1 BUGS
--- NEW FILE: pkg_category.pm ---
package FS::pkg_category;
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearch );
use FS::part_pkg;
@ISA = qw( FS::Record );
=head1 NAME
FS::pkg_category - Object methods for pkg_category records
=head1 SYNOPSIS
use FS::pkg_category;
$record = new FS::pkg_category \%hash;
$record = new FS::pkg_category { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::pkg_category object represents an package category. Every package class
(see L<FS::pkg_class>) has, optionally, a package category. FS::pkg_category
inherits from FS::Record. The following fields are currently supported:
=over 4
=item categorynum - primary key (assigned automatically for new package categoryes)
=item categoryname - Text name of this package category
=item disabled - Disabled flag, empty or 'Y'
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new package category. To add the package category to the database, see
L<"insert">.
=cut
sub table { 'pkg_category'; }
=item insert
Adds this package category to the database. If there is an error, returns the
error, otherwise returns false.
=item delete
Deletes this package category from the database. Only package categoryes with no
associated package definitions can be deleted. If there is an error, returns
the error, otherwise returns false.
=cut
sub delete {
my $self = shift;
return "Can't delete an pkg_category with pkg_class records!"
if qsearch( 'pkg_class', { 'categorynum' => $self->categorynum } );
$self->SUPER::delete;
}
=item replace OLD_RECORD
Replaces OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=item check
Checks all fields to make sure this is a valid package category. If there is an
error, returns the error, otherwise returns false. Called by the insert and
replace methods.
=cut
sub check {
my $self = shift;
$self->ut_numbern('categorynum')
or $self->ut_text('categoryname')
or $self->SUPER::check;
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>, L<FS::part_pkg>, schema.html from the base documentation.
=cut
1;
More information about the freeside-commits
mailing list