Added a primary contact for each customer, as there must be someone (or some entity) to contact for every customer. This simply makes it explicit, and has the added benefit of being easier to work with when querying.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@104 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-13 04:19:19 +00:00
parent 2f91dd456a
commit 55dd94681a
3 changed files with 23 additions and 2 deletions

View File

@@ -629,11 +629,28 @@ CREATE TABLE `pmgr_actions_late_schedules` (
DROP TABLE IF EXISTS `pmgr_customers`;
CREATE TABLE `pmgr_customers` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) NOT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
-- If NULL, rely on the contact info exclusively
`name` VARCHAR(80) DEFAULT NULL,
-- A customer gets their own account, although any
-- lease specific charge (rent, late fees, etc) will
-- be debited against the lease account. This one
-- will be used for non-lease related charges, as
-- well as charges that intentionally span more than
-- one lease (such as one security deposit to cover
-- two or more units).
`account_id` INT(10) UNSIGNED NOT NULL,
-- Primary Contact... every customer must have one
-- (and presumably, most customers will _be_ one).
-- REVISIT <AP> 20090612:
-- Does this contact also get added to the
-- contacts_customers table?
`primary_contact_id` INT(10) UNSIGNED NOT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@@ -678,6 +678,7 @@ foreach $row (@{query($sdbh, $query)}) {
addRow('customers',
{ 'name' => "$row->{'LastName'}, $row->{'FirstName'}",
'primary_contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
'account_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'account'} });
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'cust'} =

View File

@@ -9,6 +9,9 @@ class Customer extends AppModel {
var $belongsTo = array(
'Account',
'PrimaryContact' => array(
'className' => 'Contact',
),
);
var $hasMany = array(