diff --git a/db/schema.sql b/db/schema.sql index 0b51ef9..a6b8200 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -1062,7 +1062,7 @@ CREATE TABLE `pmgr_statement_entries` ( `type` ENUM('CHARGE', 'PAYMENT', - 'CREDIT') + 'SURPLUS') NOT NULL, `transaction_id` INT(10) UNSIGNED NOT NULL, diff --git a/site/models/statement_entry.php b/site/models/statement_entry.php index 8e72a7d..3da2455 100644 --- a/site/models/statement_entry.php +++ b/site/models/statement_entry.php @@ -39,7 +39,7 @@ class StatementEntry extends AppModel { ($sum ? ')' : '') . ' AS charge' . ($sum ? 's' : ''), ($sum ? 'SUM(' : '') . - "IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'CREDIT'," . + "IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'SURPLUS'," . " {$entry_name}.amount, NULL)" . ($sum ? ')' : '') . ' AS payment' . ($sum ? 's' : ''), @@ -346,7 +346,7 @@ OPTION 2 // First, find all known credits $lquery = $query; - $lquery['conditions'][] = array('StatementEntry.type' => 'CREDIT'); + $lquery['conditions'][] = array('StatementEntry.type' => 'SURPLUS'); $lquery['order'][] = 'StatementEntry.effective_date ASC'; $credits = $this->find('all', $lquery); /* pr(array('StatementEntry::assignCredits' => */ @@ -435,7 +435,7 @@ OPTION 2 $payment_account_id = $credit['LedgerEntry']['account_id']; } else { - die("HOW DID WE GET HERE WITH NO CREDITS?"); + die("HOW DID WE GET HERE WITH NO SURPLUS?"); } // Set the payment amount to the maximum amount @@ -454,7 +454,7 @@ OPTION 2 /* + compact('credit'))); */ if ($credit['balance'] < 0) - die("HOW DID WE END UP WITH NEGATIVE CREDIT BALANCE?"); + die("HOW DID WE END UP WITH NEGATIVE SURPLUS BALANCE?"); // If we've exhaused the credit, get it out of the // available credit pool (but keep track of it for later). @@ -534,7 +534,7 @@ OPTION 2 /* + compact('credit'))); */ $result = $this->addStatementEntry - (array('type' => 'CREDIT', + (array('type' => 'SURPLUS', 'account_id' => $credit['LedgerEntry']['account_id'], 'amount' => $credit['balance'], 'effective_date' => $credit['Transaction']['stamp'],