diff --git a/db/schema.sql b/db/schema.sql index f7ffa70..9d40241 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -849,7 +849,7 @@ CREATE TABLE `pmgr_accounts` ( `payable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for payments? -- Security Level - `level` INT UNSIGNED DEFAULT 1, + `level` INT UNSIGNED DEFAULT 10, `name` VARCHAR(80) NOT NULL, `external_account` INT(10) UNSIGNED DEFAULT NULL, @@ -861,6 +861,10 @@ CREATE TABLE `pmgr_accounts` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; LOCK TABLES `pmgr_accounts` WRITE; +INSERT INTO `pmgr_accounts` (`type`, `name`, `level`) + VALUES + ('EQUITY', 'Equity', 1), + ('LIABILITY', 'Loan', 1); INSERT INTO `pmgr_accounts` (`type`, `name`, `tillable`, `depositable`, `chargeable`, `payable`) VALUES ('ASSET', 'A/R', 0, 0, 0, 0), @@ -868,7 +872,7 @@ INSERT INTO `pmgr_accounts` (`type`, `name`, `tillable`, `depositable`, `chargea ('ASSET', 'Receipt', 0, 0, 0, 0), ('LIABILITY', 'A/P', 0, 0, 0, 0), ('LIABILITY', 'Tax', 0, 0, 1, 0), - ('LIABILITY', 'Customer Credit', 0, 0, 1, 1), +-- ('LIABILITY', 'Customer Credit', 0, 0, 1, 1), ('ASSET', 'Petty Cash', 0, 0, 0, 0), ('ASSET', 'Bank', 0, 1, 0, 0), ('ASSET', 'ACH', 0, 0, 0, 1), @@ -878,9 +882,9 @@ INSERT INTO `pmgr_accounts` (`type`, `name`, `tillable`, `depositable`, `chargea ('LIABILITY', 'Security Deposit', 0, 0, 1, 1), ('INCOME', 'Rent', 0, 0, 1, 0), ('INCOME', 'Late Charge', 0, 0, 1, 0), + ('INCOME', 'Damage', 0, 0, 1, 0), ('EXPENSE', 'Concession', 0, 0, 0, 1), ('EXPENSE', 'Bad Debt', 0, 0, 0, 1), - ('EXPENSE', 'Cleaning', 0, 0, 0, 0), ('EXPENSE', 'Maintenance', 0, 0, 0, 0); UNLOCK TABLES; diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl index 98b7908..54bd007 100644 --- a/scripts/sitelink2pmgr.pl +++ b/scripts/sitelink2pmgr.pl @@ -1346,6 +1346,70 @@ foreach $row (@{query($sdbh, $query)}) } +###################################################################### +## Special case - Equities / Loans / Petty Cash + +my ($stamp, $effective_date, $through_date); + +print("Set up Petty Cash...\n"); + +# Add the first loan +# debit: Equity credit: Loan +addRow('transactions', + { 'stamp' => datefmt('03/25/2009 16:00'), + }); +addRow('ledger_entries', + { 'effective_date' => $effective_date, + 'through_date' => $through_date, + 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'}, + 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, + 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, + 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, + 'customer_id' => undef, + 'lease_id' => undef, + 'amount' => 5000, + 'comment' => "HTP Loan #1", + }); + +# Add the second loan +# debit: Equity credit: Loan +addRow('transactions', + { 'stamp' => datefmt('04/01/2009 16:00'), + }); +addRow('ledger_entries', + { 'effective_date' => $effective_date, + 'through_date' => $through_date, + 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'}, + 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, + 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, + 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, + 'customer_id' => undef, + 'lease_id' => undef, + 'amount' => 1000, + 'comment' => "HTP Loan #2", + }); + +# Cheat for now, using equity for Petty Cash +# debit: Petty Cash credit: Equity +addRow('transactions', + { 'stamp' => datefmt('03/25/2009 16:00'), + }); +addRow('ledger_entries', + { 'effective_date' => $effective_date, + 'through_date' => $through_date, + 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'}, + 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, + 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'}, + 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, + 'customer_id' => undef, + 'lease_id' => undef, + 'amount' => 750, + 'comment' => "Petty Cash Funding", + }); + + + + ###################################################################### ## Fake Data for Testing