Added some changes to try and resolve some accounting problems. However, I may be about to redo the accounting stuff altogether.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@67 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-04 01:56:09 +00:00
parent e1671a9fca
commit 46e3316ce1
2 changed files with 282 additions and 10 deletions

View File

@@ -132,10 +132,10 @@ CREATE TABLE `pmgr_contacts` (
-- FEDERAL ID, e.g. SSN or EIN
`id_federal` VARCHAR(16) DEFAULT NULL,
-- STATE ID, e.g. drivers license
`id_num` VARCHAR(16) DEFAULT NULL,
`id_state` CHAR(2) DEFAULT NULL,
`id_exp` DATE DEFAULT NULL,
-- LOCAL ID, e.g. drivers license
`id_local` VARCHAR(16) DEFAULT NULL,
`id_local_state` CHAR(2) DEFAULT NULL,
`id_local_exp` DATE DEFAULT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
@@ -511,6 +511,8 @@ CREATE TABLE `pmgr_units` (
'LIENED')
NOT NULL DEFAULT 'VACANT',
`current_lease_id` INT(10) UNSIGNED DEFAULT NULL,
`sort_order` MEDIUMINT UNSIGNED NOT NULL,
`walk_order` MEDIUMINT UNSIGNED NOT NULL,
@@ -650,6 +652,7 @@ CREATE TABLE `pmgr_leases` (
`lease_type_id` INT(10) UNSIGNED NOT NULL,
`unit_id` INT(10) UNSIGNED NOT NULL,
`primary_contact_id` INT(10) UNSIGNED DEFAULT NULL, -- NOT NULL,
`late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
`lease_date` DATE NOT NULL,
@@ -683,12 +686,11 @@ CREATE TABLE `pmgr_contacts_leases` (
`contact_id` INT(10) UNSIGNED NOT NULL,
-- What type of contact is this for the lease?
`type` ENUM('TENANT', -- PRIMARY TENANT
'COTENANT', -- ADDITIONAL TENANT
`type` ENUM('TENANT', -- TENANT
'ALTERNATE') -- ALTERNATE CONTACT ONLY
NOT NULL DEFAULT 'TENANT',
-- If the tenant is removed as part of the lease
-- If the tenant is active as part of the lease
`active` TINYINT DEFAULT 1,
`comment` VARCHAR(255) DEFAULT NULL,
@@ -698,6 +700,68 @@ CREATE TABLE `pmgr_contacts_leases` (
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ######################################################################
-- ##
-- ## RESERVATIONS
-- ##
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
-- TABLE pmgr_reservations
DROP TABLE IF EXISTS `pmgr_reservations`;
CREATE TABLE `pmgr_reservations` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-- Allow user to specify their own reservation numbers
-- If NULL, `id` will be used
`number` VARCHAR(20) DEFAULT NULL,
`contact_id` INT(10) UNSIGNED NOT NULL,
`deposit` FLOAT(12,2) DEFAULT NULL,
`reservation_date` DATE NOT NULL,
`expiration_date` DATE DEFAULT NULL,
`fulfilled_date` DATE DEFAULT NULL,
`lease_id` INT(10) UNSIGNED NOT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
-- TABLE pmgr_reservations_units
DROP TABLE IF EXISTS `pmgr_reservations_units`;
CREATE TABLE `pmgr_reservations_units` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`reservation_id` INT(10) UNSIGNED NOT NULL,
`requested_id` INT(10) UNSIGNED DEFAULT NULL,
`type` ENUM('UNIT',
'UNIT_SIZE',
'UNIT_TYPE')
NOT NULL DEFAULT 'UNIT',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ######################################################################
-- ######################################################################
-- ######################################################################
@@ -721,7 +785,8 @@ CREATE TABLE `pmgr_accounts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) NOT NULL,
`external_name` VARCHAR(80) NOT NULL,
`external_account` INT(10) UNSIGNED DEFAULT NULL,
`external_name` VARCHAR(80) DEFAULT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`id`)
@@ -789,6 +854,34 @@ CREATE TABLE `pmgr_charges` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- -- ----------------------------------------------------------------------
-- -- ----------------------------------------------------------------------
-- -- TABLE pmgr_invoices
-- DROP TABLE IF EXISTS `pmgr_invoices`;
-- CREATE TABLE `pmgr_invoices` (
-- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-- `stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-- `comment` VARCHAR(255) DEFAULT NULL,
-- PRIMARY KEY (`id`)
-- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- -- ----------------------------------------------------------------------
-- -- ----------------------------------------------------------------------
-- -- TABLE pmgr_charges_invoices
-- DROP TABLE IF EXISTS `pmgr_charges_invoices`;
-- CREATE TABLE `pmgr_charges_invoices` (
-- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-- `charge_id` INT(10) UNSIGNED NOT NULL,
-- `invoice_id` INT(10) UNSIGNED NOT NULL,
-- `amount` FLOAT(12,2) NOT NULL,
-- PRIMARY KEY (`id`)
-- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ######################################################################
-- ######################################################################
@@ -910,7 +1003,6 @@ CREATE TABLE `pmgr_payments` (
DROP TABLE IF EXISTS `pmgr_receipts`;
CREATE TABLE `pmgr_receipts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`comment` VARCHAR(255) DEFAULT NULL,

View File

@@ -435,7 +435,7 @@ foreach $row (@$result) {
my $cid = $tenant_map{$row->{'TenantID'}}{'id'};
$query = "INSERT INTO pmgr_contacts
(`id`, `first_name`, `middle_name`, `last_name`, `display_name`, `id_num`, `id_state`)
(`id`, `first_name`, `middle_name`, `last_name`, `display_name`, `id_local`, `id_local_state`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
($cid, $row->{'FirstName'}, $row->{'MiddleName'}, $row->{'LastName'},
@@ -739,6 +739,186 @@ foreach $row (@$result) {
}
}
$query = "INSERT INTO pmgr_charges
(`id`, `charge_type_id`, `lease_id`,
`charge_date`, `charge_to_date`,
`amount`, `tax`, `total`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1000, $charge_type_map{'Security Deposit'}, 17,
'2009-05-05', undef,
10, 0, 10,
'Fake security deposit for testing purposes')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges
(`id`, `charge_type_id`, `lease_id`,
`charge_date`, `charge_to_date`,
`amount`, `tax`, `total`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1001, $charge_type_map{'Rent'}, 17,
'2009-05-01', '2009-05-31',
100, 5, 105,
'Fake charge for testing purposes')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges
(`id`, `charge_type_id`, `lease_id`,
`charge_date`, `charge_to_date`,
`amount`, `tax`, `total`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1002, $charge_type_map{'Late Fee'}, 17,
'2009-05-11', undef,
25, 0, 25,
'Fake late charge for testing purposes')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_receipts
(`id`, `stamp`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(2000, '2009-05-15', 'Fake receipt #1')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3000, 2000, 1, 15, 'Fake receipt #1 payment #1')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3001, 2000, 2, 10, 'Fake receipt #1 payment #2')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3002, 2000, 3, 5, 'Fake receipt #1 payment #3')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1000, 2000, 10)
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1001, 2000, 20)
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_receipts
(`id`, `stamp`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(2100, '2009-05-18', 'Fake receipt #2')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3100, 2100, 5, 30, 'Fake receipt #2 payment #1')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3101, 2100, 6, 20, 'Fake receipt #2 payment #2')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1001, 2100, 50)
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_receipts
(`id`, `stamp`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(2200, '2009-05-22', 'Fake receipt #3')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3200, 2200, 1, 10, 'Fake receipt #3 payment #1')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3201, 2200, 2, 5, 'Fake receipt #3 payment #2')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3202, 2200, 7, 20, 'Fake receipt #3 payment #3')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(3203, 2200, 8, 15, 'Fake receipt #3 payment #4')
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1001, 2200, 35)
)) . ")";
query($db_handle, $query) || die("Unable to insert");
$query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(1002, 2200, 15)
)) . ")";
query($db_handle, $query) || die("Unable to insert");
__END__
######################################################################