X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=03cec75b84455e0489622b0df71aef0f90dcbde9;hp=70f23df9beb36ef5faf7be143696fbae97cbc9be;hb=2b8ffc98529637ffddfe7cbf6b4f9b8deb90f0fa;hpb=619b9c20b1c2c76d439284bd6d023e5d5d9dbc7d diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 70f23df9b..03cec75b8 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -13,6 +13,7 @@ use FS::cust_main_Mixin; use FS::cust_svc; use FS::part_pkg; use FS::cust_main; +use FS::cust_location; use FS::type_pkgs; use FS::pkg_svc; use FS::cust_bill_pkg; @@ -106,7 +107,7 @@ inherits from FS::Record. The following fields are currently supported: =item pkgnum -primary key (assigned automatically for new billing items) +Primary key (assigned automatically for new billing items) =item custnum @@ -116,6 +117,10 @@ Customer (see L) Billing item definition (see L) +=item locationnum + +Optional link to package location (see L) + =item setup date @@ -435,6 +440,7 @@ sub check { $self->ut_numbern('pkgnum') || $self->ut_foreign_key('custnum', 'cust_main', 'custnum') || $self->ut_numbern('pkgpart') + || $self->ut_foreign_keyn('locationnum', 'location', 'locationnum') || $self->ut_numbern('setup') || $self->ut_numbern('bill') || $self->ut_numbern('susp') @@ -1569,6 +1575,30 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } +=item cust_location + +Returns the location object, if any (see L). + +=cut + +sub cust_location { + my $self = shift; + return '' unless $self->locationnum; + qsearchs( 'cust_main', { 'locationnum' => $self->locationnum } ); +} + +=item cust_location_or_main + +If this package is associated with a location, returns the locaiton (see +L), otherwise returns the customer (see L). + +=cut + +sub cust_location_or_main { + my $self = shift; + $self->cust_location || $self->cust_main; +} + =item seconds_since TIMESTAMP Returns the number of seconds all accounts (see L) in this