Re-implemented the deposit functionality. This is mostly working, although I'd like to get customer added to the tenders table, and probably change to a single deposit ledger entry for each tender type. A single entry would require that all tender types have been recorded to the same account, something that isn't mandated at the present, but is likely to be true most of the time. Perhaps they could just be grouped by account id, which should work in all cases and yet align with tender type 99% of the time. I'll have to think about it.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@412 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-29 08:55:09 +00:00
parent cdba179d79
commit 2ffe04e3e4
10 changed files with 318 additions and 174 deletions

View File

@@ -290,16 +290,20 @@ class Account extends AppModel {
* with the old balance carried forward.
*/
function closeCurrentLedger($id = null, $close_id = null) {
$contain = array('CurrentLedger' => array('fields' => array('CurrentLedger.id')));
$ret = array();
if (!$close_id) {
$close = new Close();
$close->create();
if (!$close->save(array('stamp' => null), false)) {
return false;
}
$close_id = $close->id;
if (!$close->save(array('stamp' => null), false))
return array('error' => true) + $ret;
$ret['close_id'] = $close->id;
}
else {
$ret['close_id'] = $close_id;
}
$contain = array('CurrentLedger' => array('fields' => array('CurrentLedger.id')));
$this->cacheQueries = true;
$account = $this->find('all', array
@@ -312,10 +316,12 @@ class Account extends AppModel {
//pr(compact('id', 'account'));
foreach ($account AS $acct) {
if (!$this->Ledger->closeLedger($acct['CurrentLedger']['id'], $close_id))
return false;
if (!$this->Ledger->closeLedger($acct['CurrentLedger']['id'], $ret['close_id']))
return array('error' => true) + $ret;
$ret['ledgers'][] = $acct['CurrentLedger']['id'];
}
return true;
return $ret + array('error' => false);
}