Modified to automatically calculate the crdr field, if not specified

git-svn-id: file:///svn-source/pmgr/branches/surplus_account_20090815@569 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-15 20:43:00 +00:00
parent 96a030e340
commit f30e536e47

View File

@@ -75,7 +75,6 @@ class Transaction extends AppModel {
// Go through the statement entries and flag as charges
foreach ($data['Entry'] AS &$entry)
$entry += array('type' => 'CHARGE',
'crdr' => 'CREDIT',
);
$ids = $this->addTransaction($data['control'], $data['Transaction'], $data['Entry']);
@@ -117,7 +116,6 @@ class Transaction extends AppModel {
// Go through the statement entries and flag as disbursements
foreach ($data['Entry'] AS &$entry)
$entry += array('type' => 'DISBURSEMENT', // not used
'crdr' => 'DEBIT',
'account_id' =>
(isset($entry['Tender']['tender_type_id'])
? ($this->LedgerEntry->Tender->TenderType->
@@ -237,7 +235,6 @@ class Transaction extends AppModel {
if (!isset($group[$entry['account_id']]))
$group[$entry['account_id']] =
array('account_id' => $entry['account_id'],
'crdr' => strtoupper($this->Account->fundamentalOpposite($data['Transaction']['crdr'])),
'amount' => 0);
$group[$entry['account_id']]['amount'] += $entry['amount'];
}
@@ -392,7 +389,6 @@ class Transaction extends AppModel {
// Go through the statement entries and flag as payments
foreach ($data['Entry'] AS &$entry)
$entry += array('type' => 'PAYMENT',
'crdr' => 'CREDIT',
);
$ids = $this->addTransaction($data['control'], $data['Transaction'], $data['Entry']);
@@ -517,22 +513,17 @@ class Transaction extends AppModel {
if ($result['error'])
$ret['error'] = true;
if ($control['assign_receipt'] &&
if (!empty($control['assign_receipt']) &&
!empty($result['receipt_balance'])) {
/* $result = $this->addTransactionEntries */
/* ($control, */
/* $transaction, */
/* array('' */
$result = $this->StatementEntry->addStatementEntry
(array('type' => 'SURPLUS',
'account_id' => $this->Account->accountPayableAccountID(),
'amount' => $result['receipt_balance'],
'effective_date' => $transaction['stamp'],
'transaction_id' => $transaction['id'],
'customer_id' => $transaction['customer_id'],
'lease_id' => $transaction['lease_id'],
$result = $this->addTransactionEntries
(array('include_ledger_entry' => true,
'include_statement_entry' => true),
array('crdr' => 'DEBIT') + $transaction,
array(array('type' => 'SURPLUS',
'account_id' => $this->Account->accountPayableAccountID(),
'amount' => $result['receipt_balance'],
),
));
}
@@ -676,6 +667,14 @@ class Transaction extends AppModel {
$entry['statement_entry_comment'] = null;
}
if (empty($transaction['crdr']) && !empty($transaction['account_id']))
$transaction['crdr'] = strtoupper($this->Account->fundamentalType
($transaction['account_id']));
if (empty($entry['crdr']) && !empty($transaction['crdr']))
$entry['crdr'] = strtoupper($this->Account->fundamentalOpposite
($transaction['crdr']));
// Priority goes to settings defined in $entry, but
// use the control information as defaults.
$entry += $control;
@@ -694,7 +693,7 @@ class Transaction extends AppModel {
array_intersect_key($entry,
array_flip(array('account_id', 'amount')));
$le2['ledger_id'] = $entry['new_ledger_id'];
$le2['crdr'] = strtoupper($this->Account->fundamentalOpposite($le1['crdr']));
$le2['crdr'] = strtoupper($this->Account->fundamentalType($le2['account_id']));
$le2['comment'] = "Ledger Balance Forward (b/f)";
}
else {
@@ -775,7 +774,6 @@ class Transaction extends AppModel {
'Entry' =>
array(array('tender_id' => null,
'account_id' => $this->Account->nsfAccountID(),
'crdr' => 'DEBIT',
'amount' => $tender['LedgerEntry']['amount'],
))),
$tender['Transaction']['account_id']);
@@ -856,7 +854,6 @@ class Transaction extends AppModel {
'include_statement_entry' => false,
'amount' => $rollback['Transaction']['amount'],
'account_id' => $this->Account->accountReceivableAccountID(),
'crdr' => 'DEBIT',
);
// Set the transaction amount to be negative
@@ -975,7 +972,6 @@ class Transaction extends AppModel {
'include_statement_entry' => true,
'type' => 'REVERSAL',
'crdr' => 'DEBIT',
'account_id' => $charge['StatementEntry']['account_id'],
'amount' => $rollback['Transaction']['amount'],