Adjusted formatting only

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@357 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-21 02:55:43 +00:00
parent c002f3f3ba
commit ae5d4763f9

View File

@@ -302,33 +302,33 @@ executeSchema();
################################################################# #################################################################
## Test Contact ## Test Contact
addRow('contacts', addRow('contacts', {
{ 'first_name' => 'Abijah', 'first_name' => 'Abijah',
# 'middle_name' => 'M', # 'middle_name' => 'M',
'last_name' => 'Perkins' }); 'last_name' => 'Perkins' });
addRow('contact_addresses', addRow('contact_addresses', {
{ 'address' => '1324 N Liberty Lake Rd\nPMB 263', 'address' => '1324 N Liberty Lake Rd\nPMB 263',
'city' => 'Liberty Lake', 'city' => 'Liberty Lake',
'state' => 'WA', 'state' => 'WA',
'postcode' => '99019', 'postcode' => '99019',
'country' => 'USA' }); 'country' => 'USA' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'},
'method' => 'ADDRESS', 'method' => 'ADDRESS',
'type' => 'MAIN', 'type' => 'MAIN',
'preference' => 'PRIMARY' }, 'preference' => 'PRIMARY' },
1); 1);
addRow('contact_addresses', addRow('contact_addresses', {
{ 'address' => '5221 W Myrtlewood Ct', 'address' => '5221 W Myrtlewood Ct',
'city' => 'Spokane', 'city' => 'Spokane',
'state' => 'WA', 'state' => 'WA',
'postcode' => '99208', 'postcode' => '99208',
'country' => 'USA' }); 'country' => 'USA' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'},
'method' => 'ADDRESS', 'method' => 'ADDRESS',
'type' => 'HOME', 'type' => 'HOME',
@@ -349,33 +349,33 @@ addRow('contacts_methods',
# 'preference' => 'ALTERNATE' }, # 'preference' => 'ALTERNATE' },
# 1); # 1);
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => 'MOBILE', 'type' => 'MOBILE',
'phone' => '5098445573' }); 'phone' => '5098445573' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'MAIN', 'type' => 'MAIN',
'preference' => 'PRIMARY' }, 'preference' => 'PRIMARY' },
1); 1);
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => 'MOBILE', 'type' => 'MOBILE',
'phone' => '5098445973' }); 'phone' => '5098445973' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'MAIN', 'type' => 'MAIN',
'preference' => 'ALTERNATE' }, 'preference' => 'ALTERNATE' },
1); 1);
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => 'VIRTUAL', 'type' => 'VIRTUAL',
'phone' => '5095901112' }); 'phone' => '5095901112' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'BUSINESS', 'type' => 'BUSINESS',
@@ -393,52 +393,52 @@ addRow('contacts_methods',
# 'preference' => 'ALTERNATE' }, # 'preference' => 'ALTERNATE' },
# 1); # 1);
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => 'VIRTUAL', 'type' => 'VIRTUAL',
'phone' => '8774488664' }); 'phone' => '8774488664' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'BUSINESS', 'type' => 'BUSINESS',
'preference' => 'WORK' }, 'preference' => 'WORK' },
1); 1);
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => 'FAX', 'type' => 'FAX',
'phone' => '8662960131' }); 'phone' => '8662960131' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'BUSINESS', 'type' => 'BUSINESS',
'preference' => 'WORK' }, 'preference' => 'WORK' },
1); 1);
addRow('contact_emails', addRow('contact_emails', {
{ 'email' => 'abijah\@PerkinsHouse.com' }); 'email' => 'abijah\@PerkinsHouse.com' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'},
'method' => 'EMAIL', 'method' => 'EMAIL',
'type' => 'HOME', 'type' => 'HOME',
'preference' => 'PRIMARY' }, 'preference' => 'PRIMARY' },
1); 1);
addRow('contact_emails', addRow('contact_emails', {
{ 'email' => 'abijah\@PerkinsREI.com' }); 'email' => 'abijah\@PerkinsREI.com' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'},
'method' => 'EMAIL', 'method' => 'EMAIL',
'type' => 'HOME', 'type' => 'HOME',
'preference' => 'WORK' }, 'preference' => 'WORK' },
1); 1);
addRow('contact_emails', addRow('contact_emails', {
{ 'email' => 'abijah\@ValleyStorage.info' }); 'email' => 'abijah\@ValleyStorage.info' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'},
'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'},
'method' => 'EMAIL', 'method' => 'EMAIL',
'type' => 'BUSINESS', 'type' => 'BUSINESS',
@@ -449,11 +449,11 @@ addRow('contacts_methods',
################################################################# #################################################################
## GROUPS ## GROUPS
addRow('groups', addRow('groups', {
{ 'code' => 'Owner', 'code' => 'Owner',
'name' => 'Owner Group' }); 'name' => 'Owner Group' });
addRow('group_permissions', addRow('group_permissions', {
{ 'group_id' => $newdb{'tables'}{'groups'}{'autoid'}, 'group_id' => $newdb{'tables'}{'groups'}{'autoid'},
'name' => 'EVERYTHING', 'name' => 'EVERYTHING',
'access' => 'FORCED' }, 'access' => 'FORCED' },
1); 1);
@@ -462,8 +462,8 @@ addRow('group_permissions',
################################################################# #################################################################
## USERS ## USERS
addRow('users', addRow('users', {
{ 'code' => 'AP', 'code' => 'AP',
'login' => 'abijah', 'login' => 'abijah',
'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'} }); 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'} });
@@ -471,18 +471,18 @@ addRow('users',
################################################################# #################################################################
## SITES ## SITES
addRow('sites', addRow('sites', {
{ 'code' => 'VSS', 'code' => 'VSS',
'name' => 'Valley Storage' }); 'name' => 'Valley Storage' });
addRow('site_memberships', addRow('site_memberships', {
{ 'site_id' => $newdb{'tables'}{'sites'}{'autoid'}, 'site_id' => $newdb{'tables'}{'sites'}{'autoid'},
'user_id' => $newdb{'tables'}{'users'}{'autoid'}, 'user_id' => $newdb{'tables'}{'users'}{'autoid'},
'group_id' => $newdb{'tables'}{'groups'}{'autoid'} }, 'group_id' => $newdb{'tables'}{'groups'}{'autoid'} },
1); 1);
addRow('site_areas', addRow('site_areas', {
{ 'site_id' => $newdb{'tables'}{'sites'}{'autoid'}, 'site_id' => $newdb{'tables'}{'sites'}{'autoid'},
'code' => 'Main', 'code' => 'Main',
'name' => 'Main Facility Area' }); 'name' => 'Main Facility Area' });
@@ -490,8 +490,8 @@ addRow('site_areas',
################################################################# #################################################################
## LEASES ## LEASES
addRow('lease_types', addRow('lease_types', {
{ 'code' => 'SL', 'code' => 'SL',
'name' => 'Storage Lease' }); 'name' => 'Storage Lease' });
@@ -503,8 +503,8 @@ $newdb{'lookup'}{'account'} = {};
$query = "SELECT * FROM pmgr_accounts"; $query = "SELECT * FROM pmgr_accounts";
$result = query($db_handle, $query); $result = query($db_handle, $query);
foreach $row (@$result) { foreach $row (@$result) {
addRow('ledgers', addRow('ledgers', {
{ 'account_id' => $row->{'id'}, 'account_id' => $row->{'id'},
'comment' => undef }); 'comment' => undef });
$newdb{'lookup'}{'account'}{$row->{'name'}} $newdb{'lookup'}{'account'}{$row->{'name'}}
@@ -606,8 +606,8 @@ $newdb{'lookup'}{'unit_type'} = {};
$query = "SELECT * FROM UnitType ORDER BY TypeID"; $query = "SELECT * FROM UnitType ORDER BY TypeID";
foreach $row (@{query($sdbh, $query)}) { foreach $row (@{query($sdbh, $query)}) {
addRow('unit_types', addRow('unit_types', {
{ 'code' => 'xxx', 'code' => 'xxx',
'name' => $row->{'UnitType'} }); 'name' => $row->{'UnitType'} });
$newdb{'lookup'}{'unit_type'}{$row->{'TypeID'}} = $newdb{'lookup'}{'unit_type'}{$row->{'TypeID'}} =
$newdb{'tables'}{'unit_types'}{'autoid'}; $newdb{'tables'}{'unit_types'}{'autoid'};
@@ -623,8 +623,8 @@ foreach $row (@{query($sdbh, $query)}) {
my $sz = sizeCode($row->{'Width'}, $row->{'Depth'}); my $sz = sizeCode($row->{'Width'}, $row->{'Depth'});
next if defined $newdb{'lookup'}{'unit_size'}{$sz}; next if defined $newdb{'lookup'}{'unit_size'}{$sz};
addRow('unit_sizes', addRow('unit_sizes', {
{ 'unit_type_id' => $row->{'Type'}, 'unit_type_id' => $row->{'Type'},
'code' => $sz, 'code' => $sz,
'name' => $sz, 'name' => $sz,
'width' => $internal_adjustment_factor * $row->{'Width'}, 'width' => $internal_adjustment_factor * $row->{'Width'},
@@ -647,8 +647,8 @@ foreach $row (@{query($sdbh, $query)}) {
my $sz = sizeCode($row->{'Width'}, $row->{'Depth'}); my $sz = sizeCode($row->{'Width'}, $row->{'Depth'});
my $szid = $newdb{'lookup'}{'unit_size'}{$sz}{'id'}; my $szid = $newdb{'lookup'}{'unit_size'}{$sz}{'id'};
addRow('units', addRow('units', {
{ 'unit_size_id' => $szid, 'unit_size_id' => $szid,
'code' => $row->{'UnitID'}, 'code' => $row->{'UnitID'},
'name' => $row->{'UnitID'}, 'name' => $row->{'UnitID'},
'status' => $row->{'Rented'} ?'OCCUPIED' :($row->{'Rentable'} ?'VACANT' :'UNAVAILABLE'), 'status' => $row->{'Rented'} ?'OCCUPIED' :($row->{'Rentable'} ?'VACANT' :'UNAVAILABLE'),
@@ -686,8 +686,8 @@ $info{'extents'}{'left'} = 0;
$info{'extents'}{'bottom'} = $internal_adjustment_factor * ($top_adjustment + $row->{'bot'} + 0); $info{'extents'}{'bottom'} = $internal_adjustment_factor * ($top_adjustment + $row->{'bot'} + 0);
$info{'extents'}{'right'} = $internal_adjustment_factor * ($left_adjustment + $row->{'rgt'} + 0); $info{'extents'}{'right'} = $internal_adjustment_factor * ($left_adjustment + $row->{'rgt'} + 0);
addRow('maps', addRow('maps', {
{ 'name' => 'Main Facility Map', 'name' => 'Main Facility Map',
'site_area_id' => $newdb{'tables'}{'site_areas'}{'autoid'}, 'site_area_id' => $newdb{'tables'}{'site_areas'}{'autoid'},
'width' => $info{'extents'}{'right'} - $info{'extents'}{'left'}, 'width' => $info{'extents'}{'right'} - $info{'extents'}{'left'},
'depth' => $info{'extents'}{'bottom'} - $info{'extents'}{'top'} }); 'depth' => $info{'extents'}{'bottom'} - $info{'extents'}{'top'} });
@@ -703,8 +703,8 @@ $query .= " FROM UnitInfo U INNER JOIN mapUnitsV2 M ON M.unitID = U.UnitID";
# Go through each one, calculating the map location # Go through each one, calculating the map location
foreach $row (@{query($sdbh, $query)}) { foreach $row (@{query($sdbh, $query)}) {
addRow('maps_units', addRow('maps_units', {
{ 'map_id' => $newdb{'tables'}{'maps'}{'autoid'}, 'map_id' => $newdb{'tables'}{'maps'}{'autoid'},
'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'}, 'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'},
'pt_top' => $internal_adjustment_factor * ($row->{'pt_t'}), 'pt_top' => $internal_adjustment_factor * ($row->{'pt_t'}),
'pt_left' => $internal_adjustment_factor * ($row->{'pt_l'}), 'pt_left' => $internal_adjustment_factor * ($row->{'pt_l'}),
@@ -734,8 +734,8 @@ foreach $row (@{query($sdbh, $query)}) {
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}} $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}
= { 'name' => "$row->{'LastName'}, $row->{'FirstName'}" }; = { 'name' => "$row->{'LastName'}, $row->{'FirstName'}" };
addRow('contacts', addRow('contacts', {
{ 'first_name' => $row->{'FirstName'}, 'first_name' => $row->{'FirstName'},
'middle_name' => $row->{'MiddleName'}, 'middle_name' => $row->{'MiddleName'},
'last_name' => $row->{'LastName'}, 'last_name' => $row->{'LastName'},
'id_local' => $row->{'IDNum'} || undef, 'id_local' => $row->{'IDNum'} || undef,
@@ -744,29 +744,29 @@ foreach $row (@{query($sdbh, $query)}) {
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'} = $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'} =
$newdb{'tables'}{'contacts'}{'autoid'}; $newdb{'tables'}{'contacts'}{'autoid'};
addRow('customers', addRow('customers', {
{ 'name' => "$row->{'LastName'}, $row->{'FirstName'}", 'name' => "$row->{'LastName'}, $row->{'FirstName'}",
'primary_contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, 'primary_contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
}); });
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'} = $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'} =
$newdb{'tables'}{'customers'}{'autoid'}; $newdb{'tables'}{'customers'}{'autoid'};
addRow('contacts_customers', addRow('contacts_customers', {
{ 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'}, 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'},
'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
'type' => 'TENANT' }, 'type' => 'TENANT' },
1); 1);
if ($row->{'City'}) { if ($row->{'City'}) {
addRow('contact_addresses', addRow('contact_addresses', {
{ 'address' => $row->{'HomeAddress'} . ($row->{'HomeAddr2'} ? "\n".$row->{'HomeAddr2'} : "") || undef, 'address' => $row->{'HomeAddress'} . ($row->{'HomeAddr2'} ? "\n".$row->{'HomeAddr2'} : "") || undef,
'city' => $row->{'City'}, 'city' => $row->{'City'},
'state' => $newdb{'lookup'}{'state'}{$row->{'StateID'}}, 'state' => $newdb{'lookup'}{'state'}{$row->{'StateID'}},
'postcode' => $row->{'Zip'} || undef, 'postcode' => $row->{'Zip'} || undef,
'country' => 'USA' }); 'country' => 'USA' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'},
'method' => 'ADDRESS', 'method' => 'ADDRESS',
'type' => 'HOME', 'type' => 'HOME',
@@ -782,12 +782,12 @@ foreach $row (@{query($sdbh, $query)}) {
{'type' => 'MOBILE', 'preference' => 'ALTERNATE', 'phone' => $row->{'CellPhone'}}) {'type' => 'MOBILE', 'preference' => 'ALTERNATE', 'phone' => $row->{'CellPhone'}})
{ {
if ($_->{'phone'}) { if ($_->{'phone'}) {
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => $_->{'type'}, 'type' => $_->{'type'},
'phone' => $_->{'phone'}, 'phone' => $_->{'phone'},
'ext' => $_->{'ext'} }); 'ext' => $_->{'ext'} });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'MAIN', 'type' => 'MAIN',
@@ -797,10 +797,10 @@ foreach $row (@{query($sdbh, $query)}) {
} }
if ($row->{'Email'}) { if ($row->{'Email'}) {
addRow('contact_emails', addRow('contact_emails', {
{ 'email' => $row->{'Email'} }); 'email' => $row->{'Email'} });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'},
'method' => 'EMAIL', 'method' => 'EMAIL',
'type' => 'MAIN', 'type' => 'MAIN',
@@ -810,29 +810,29 @@ foreach $row (@{query($sdbh, $query)}) {
next unless $row->{'AltFirstName'} || $row->{'AltLastName'} || $row->{'AltAddress'} || $row->{'AltPhone'}; next unless $row->{'AltFirstName'} || $row->{'AltLastName'} || $row->{'AltAddress'} || $row->{'AltPhone'};
addRow('contacts', addRow('contacts', {
{ 'first_name' => $row->{'AltFirstName'} || undef, 'first_name' => $row->{'AltFirstName'} || undef,
'middle_name' => $row->{'AltMI'} || undef, 'middle_name' => $row->{'AltMI'} || undef,
'last_name' => $row->{'AltLastName'} || undef }); 'last_name' => $row->{'AltLastName'} || undef });
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'} = $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'} =
$newdb{'tables'}{'contacts'}{'autoid'}; $newdb{'tables'}{'contacts'}{'autoid'};
addRow('contacts_customers', addRow('contacts_customers', {
{ 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'}, 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'},
'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'},
'type' => 'ALTERNATE' }, 'type' => 'ALTERNATE' },
1); 1);
if ($row->{'AltCity'}) { if ($row->{'AltCity'}) {
addRow('contact_addresses', addRow('contact_addresses', {
{ 'address' => $row->{'AltAddress'} . ($row->{'AltAddr2'} ? "\n".$row->{'AltAddr2'} : ""), 'address' => $row->{'AltAddress'} . ($row->{'AltAddr2'} ? "\n".$row->{'AltAddr2'} : ""),
'city' => $row->{'AltCity'}, 'city' => $row->{'AltCity'},
'state' => $newdb{'lookup'}{'state'}{$row->{'AltStateID'}}, 'state' => $newdb{'lookup'}{'state'}{$row->{'AltStateID'}},
'postcode' => $row->{'AltZip'}, 'postcode' => $row->{'AltZip'},
'country' => 'USA' }); 'country' => 'USA' });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'},
'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'},
'method' => 'ADDRESS', 'method' => 'ADDRESS',
'type' => 'MAIN', 'type' => 'MAIN',
@@ -841,12 +841,12 @@ foreach $row (@{query($sdbh, $query)}) {
} }
if ($row->{'AltPhone'}) { if ($row->{'AltPhone'}) {
addRow('contact_phones', addRow('contact_phones', {
{ 'type' => 'LANDLINE', 'type' => 'LANDLINE',
'phone' => $row->{'AltPhone'}, 'phone' => $row->{'AltPhone'},
'ext' => undef }); 'ext' => undef });
addRow('contacts_methods', addRow('contacts_methods', {
{ 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'}, 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'},
'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'},
'method' => 'PHONE', 'method' => 'PHONE',
'type' => 'MAIN', 'type' => 'MAIN',
@@ -869,8 +869,8 @@ foreach $row (@{query($sdbh, $query)}) {
'lease_date' => $row->{'DateIn'}, 'lease_date' => $row->{'DateIn'},
}; };
addRow('leases', addRow('leases', {
{ 'number' => $newdb{'tables'}{'leases'}{'autoid'}+1, 'number' => $newdb{'tables'}{'leases'}{'autoid'}+1,
#'number' => $row->{'LedgerID'}, #'number' => $row->{'LedgerID'},
'lease_type_id' => $newdb{'tables'}{'lease_types'}{'autoid'}, 'lease_type_id' => $newdb{'tables'}{'lease_types'}{'autoid'},
'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'}, 'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'},
@@ -911,8 +911,8 @@ foreach $row (@{query($sdbh, $query)}) {
dates('invoice', $row->{'ChargeDate'}, $row->{'EndDate'}, dates('invoice', $row->{'ChargeDate'}, $row->{'EndDate'},
$row->{'ChargeDescription'}, $row->{'LedgerID'}); $row->{'ChargeDescription'}, $row->{'LedgerID'});
addRow('transactions', addRow('transactions', {
{ 'type' => 'INVOICE', 'type' => 'INVOICE',
'stamp' => $stamp, 'stamp' => $stamp,
#'amount' => $row->{'InvoiceAmount'}, #'amount' => $row->{'InvoiceAmount'},
#'comment' => "Invoice Transaction", #'comment' => "Invoice Transaction",
@@ -965,8 +965,8 @@ foreach $row (@{query($sdbh, $query)}) {
= $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'}; = $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'};
# debit: A/R credit: Rent/LateCharge/Etc # debit: A/R credit: Rent/LateCharge/Etc
addRow('double_entries', addRow('double_entries', {
{ 'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'id'}, 'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'id'},
'effective_date' => $effective_date, 'effective_date' => $effective_date,
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'}, 'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'}, 'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
@@ -975,12 +975,13 @@ foreach $row (@{query($sdbh, $query)}) {
'amount' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'}, 'amount' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'},
'comment' => "Double Entry: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}", 'comment' => "Double Entry: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}",
}); });
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'} $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'}
= $newdb{'tables'}{'double_entries'}{'autoid'}; = $newdb{'tables'}{'double_entries'}{'autoid'};
# Add the Charge Entry # Add the Charge Entry
addRow('entries', addRow('entries', {
{ 'type' => 'CHARGE', 'type' => 'CHARGE',
'through_date' => $through_date, 'through_date' => $through_date,
'double_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'}, 'double_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'},
'account_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_account_id'}, 'account_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_account_id'},
@@ -993,8 +994,8 @@ foreach $row (@{query($sdbh, $query)}) {
= $newdb{'tables'}{'entries'}{'autoid'}; = $newdb{'tables'}{'entries'}{'autoid'};
# Add the A/R entry # Add the A/R entry
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'double_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'}, 'double_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'},
'account_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_account_id'}, 'account_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_account_id'},
'ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_ledger_id'},
@@ -1181,8 +1182,8 @@ foreach $row (@{query($sdbh, $query)}) {
if ($newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'type'} if ($newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'type'}
== 'Concession'); == 'Concession');
addRow('transactions', addRow('transactions', {
{ 'type' => 'RECEIPT', 'type' => 'RECEIPT',
'stamp' => $stamp, 'stamp' => $stamp,
}); });
@@ -1206,8 +1207,8 @@ foreach $row (@{query($sdbh, $query)}) {
= $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'}; = $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'};
# debit: Cash/Check/Etc credit: A/R # debit: Cash/Check/Etc credit: A/R
addRow('double_entries', addRow('double_entries', {
{ 'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'}, 'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'},
'effective_date' => $effective_date, 'effective_date' => $effective_date,
'customer_id' => undef, # This is set later... 'customer_id' => undef, # This is set later...
'debit_ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'}, 'debit_ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'},
@@ -1220,8 +1221,8 @@ foreach $row (@{query($sdbh, $query)}) {
= $newdb{'tables'}{'double_entries'}{'autoid'}; = $newdb{'tables'}{'double_entries'}{'autoid'};
# Add the Payment Entry # Add the Payment Entry
addRow('entries', addRow('entries', {
{ 'type' => 'PAYMENT', 'type' => 'PAYMENT',
'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'}, 'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'},
'ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'},
'crdr' => 'DEBIT', 'crdr' => 'DEBIT',
@@ -1236,8 +1237,8 @@ foreach $row (@{query($sdbh, $query)}) {
= $newdb{'tables'}{'entries'}{'autoid'}; = $newdb{'tables'}{'entries'}{'autoid'};
# Add the A/R Entry # Add the A/R Entry
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_account_id'}, 'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_account_id'},
'ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_ledger_id'},
'crdr' => 'CREDIT', 'crdr' => 'CREDIT',
@@ -1281,15 +1282,15 @@ foreach $row (@{query($sdbh, $query)})
my $reconcile_amount = ($charge_amount < $payment_amount) ? $charge_amount : $payment_amount; my $reconcile_amount = ($charge_amount < $payment_amount) ? $charge_amount : $payment_amount;
# Reconcile the A/R Account # Reconcile the A/R Account
addRow('reconciliations', addRow('reconciliations', {
{ 'debit_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ar_entry_id'}, 'debit_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ar_entry_id'},
'credit_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ar_entry_id'}, 'credit_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ar_entry_id'},
'amount' => $reconcile_amount, 'amount' => $reconcile_amount,
}); });
# Reconcile the payment to the charge # Reconcile the payment to the charge
addRow('charges_payments', addRow('charges_payments', {
{ 'charge_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'entry_id'}, 'charge_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'entry_id'},
'payment_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'entry_id'}, 'payment_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'entry_id'},
'amount' => $reconcile_amount, 'amount' => $reconcile_amount,
}); });
@@ -1324,28 +1325,28 @@ print("Set up Petty Cash...\n");
# Add the first loan # Add the first loan
# debit: Equity credit: Loan # debit: Equity credit: Loan
addRow('transactions', addRow('transactions', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'stamp' => datefmt('03/25/2009 16:00'), 'stamp' => datefmt('03/25/2009 16:00'),
}); });
addRow('double_entries', addRow('double_entries', {
{ 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'},
'effective_date' => $effective_date, 'effective_date' => $effective_date,
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'},
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'},
'amount' => 5000, 'amount' => 5000,
'comment' => "HTP Loan #1", 'comment' => "HTP Loan #1",
}); });
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'},
'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'},
'crdr' => 'DEBIT', 'crdr' => 'DEBIT',
'double_entry_id' => $newdb{'tables'}{'double_entries'}{'autoid'}, 'double_entry_id' => $newdb{'tables'}{'double_entries'}{'autoid'},
'comment' => "Equity: HTP Loan #1", 'comment' => "Equity: HTP Loan #1",
}); });
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'account'}{'Loan'}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{'Loan'}{'account_id'},
'ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'},
'crdr' => 'CREDIT', 'crdr' => 'CREDIT',
@@ -1355,28 +1356,28 @@ addRow('entries',
# Add the second loan # Add the second loan
# debit: Equity credit: Loan # debit: Equity credit: Loan
addRow('transactions', addRow('transactions', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'stamp' => datefmt('04/01/2009 16:00'), 'stamp' => datefmt('04/01/2009 16:00'),
}); });
addRow('double_entries', addRow('double_entries', {
{ 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'},
'effective_date' => $effective_date, 'effective_date' => $effective_date,
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'},
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'},
'amount' => 1000, 'amount' => 1000,
'comment' => "HTP Loan #2", 'comment' => "HTP Loan #2",
}); });
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'},
'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'},
'crdr' => 'DEBIT', 'crdr' => 'DEBIT',
'double_entry_id' => $newdb{'tables'}{'double_entries'}{'autoid'}, 'double_entry_id' => $newdb{'tables'}{'double_entries'}{'autoid'},
'comment' => "Equity: HTP Loan #2", 'comment' => "Equity: HTP Loan #2",
}); });
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'account'}{'Loan'}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{'Loan'}{'account_id'},
'ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'},
'crdr' => 'CREDIT', 'crdr' => 'CREDIT',
@@ -1386,28 +1387,28 @@ addRow('entries',
# Cheat for now, using equity for Petty Cash # Cheat for now, using equity for Petty Cash
# debit: Petty Cash credit: Equity # debit: Petty Cash credit: Equity
addRow('transactions', addRow('transactions', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'stamp' => datefmt('03/25/2009 16:00'), 'stamp' => datefmt('03/25/2009 16:00'),
}); });
addRow('double_entries', addRow('double_entries', {
{ 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'},
'effective_date' => $effective_date, 'effective_date' => $effective_date,
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'}, 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'},
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'},
'amount' => 750, 'amount' => 750,
'comment' => "Petty Cash Funding", 'comment' => "Petty Cash Funding",
}); });
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'account_id'},
'ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'},
'crdr' => 'DEBIT', 'crdr' => 'DEBIT',
'double_entry_id' => $newdb{'tables'}{'double_entries'}{'autoid'}, 'double_entry_id' => $newdb{'tables'}{'double_entries'}{'autoid'},
'comment' => "Petty Cash: Petty Cash Funding", 'comment' => "Petty Cash: Petty Cash Funding",
}); });
addRow('entries', addRow('entries', {
{ 'type' => 'TRANSFER', 'type' => 'TRANSFER',
'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'},
'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'},
'crdr' => 'CREDIT', 'crdr' => 'CREDIT',