1 package FS::realestate_property;
7 use FS::Record qw(qsearch qsearchs);
11 FS::realestate_property - Object representing a realestate_property record
15 use FS::realestate_property;
17 $record = new FS:realestate_property \%values;
18 $record = new FS::realestate_property {
20 address1 => '1500 Sugar Bowl Dr',
21 city => 'New Orleans',
28 $error = $record->insert;
29 $error = $new_rec->replace($record)
30 $error = $record->check;
32 $sub_record = $record->add_subproperty('Box Seat No. 42');
34 @subprops = $record->subproperties;
35 @subprops = $record->enabled_subproperties;
39 An FS::realestate_property object represents a real estate property. This
40 object may represent a single property, such as a rental house. It may also
41 represent a group of properties sharing a common address or identifier, such
42 as a shopping mall, apartment complex, or office building.
44 FS::realestate_property inherits from FS::Record.
46 The following fields are currently supported:
56 =item address1 *optional
58 =item address2 *optional
74 =item new HASHREF (see L<FS::Record>)
78 sub table {'realestate_property';}
80 =item insert (see L<FS::Record>)
84 FS::realestate_property records should never be deleted, only disabled
89 # Once this record has been associated with a customer in any way, it
90 # should not be deleted. todo perhaps, add a is_deletable function that
91 # checks if the record has ever actually been used, and allows deletion
92 # if it hasn't. (entered in error, etc).
93 croak "FS::realestate_property records should never be deleted";
97 =item replace OLD_RECORD (see L<FS::Record>)
99 =item check (see L<FS::Record>)
103 Returns the associated agent, if any, for this object
109 return undef unless $self->agentnum;
110 return qsearchs('agent', {agentnum => $self->agentnum} );
116 Returns all subproperties linked to this property
121 qsearch('realestate_subproperty', {propnum => shift->propnum} );
125 =item enabled_subproperties
127 Returns all subproperties linked to this property where disabled = 0
131 sub enabled_subproperties {
132 qsearch( 'realestate_subproperty', {
133 propnum => shift->propnum,
138 =item add_subproperty SUBPROPERTY_TITLE
140 Create a new subproperty record for this property
144 sub add_subproperty {
145 my ($self, $subtitle) = @_;
146 croak "add_subproperty() requires a \$subtitle parameter" unless $subtitle;
148 my $subp = new FS::realestate_subproperty {
149 propnum => $self->propnum,
150 subtitle => $subtitle,
153 my $err = $subp->insert;
154 die "Error inserting subproperty: $err" if $err;
172 L<FS::record>, L<FS::realestate_subproperty>, L<FS::svc_realestate>