Added a closes table to the schema, so that we can keep track of daily closes, deposits, etc. Moved into the model an operation to close a set of ledgers and make a deposit.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@200 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-02 09:19:33 +00:00
parent dfe61cbc2a
commit ed673de22f
6 changed files with 99 additions and 41 deletions

View File

@@ -9,6 +9,8 @@ class Ledger extends AppModel {
var $belongsTo = array(
'Account',
'PriorLedger' => array('className' => 'Ledger'),
'Close',
);
var $hasMany = array(
@@ -50,23 +52,21 @@ class Ledger extends AppModel {
* function: closeLedger
* - Closes the current ledger, and returns a fresh one
*/
function closeLedger($id) {
function closeLedger($id, $close_id) {
$this->recursive = -1;
$stamp = date('Y-m-d G:i:s');
$this->id = $id;
$this->read();
$this->data['Ledger']['close_stamp'] = $stamp;
$this->data['Ledger']['closed'] = 1;
$this->data['Ledger']['close_id'] = $close_id;
$this->save($this->data, false);
$stats = $this->stats($id);
$this->read();
$this->data['Ledger']['id'] = null;
$this->data['Ledger']['closed'] = 0;
$this->data['Ledger']['open_stamp'] = $stamp;
$this->data['Ledger']['close_stamp'] = null;
$this->data['Ledger']['close_id'] = null;
$this->data['Ledger']['prior_ledger_id'] = $id;
$this->data['Ledger']['comment'] = null;
++$this->data['Ledger']['sequence'];
$this->id = null;
@@ -83,9 +83,7 @@ class Ledger extends AppModel {
// Create a transaction for balance transfer
$transaction = new Transaction();
$transaction->create();
if (!$transaction->save(array(),
array('validate' => false,
))) {
if (!$transaction->save(array(), false)) {
return null;
}
@@ -100,9 +98,7 @@ class Ledger extends AppModel {
$carry_entry = new LedgerEntry();
$carry_entry->create();
if (!$carry_entry->save($carry_entry_data,
array('validate' => false,
))) {
if (!$carry_entry->save($carry_entry_data, false)) {
return null;
}