Still trying to figure out what issuing a refund should look like. I switched the entry to be negative, which may (should) make reporting easier.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@350 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -152,9 +152,7 @@ class AccountsController extends AppController {
|
|||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$payment_accounts = $this->Account->paymentAccounts();
|
$payment_accounts = $this->Account->collectableAccounts();
|
||||||
$payment_accounts[$this->Account->nsfAccountID()] =
|
|
||||||
$this->Account->name($this->Account->nsfAccountID());
|
|
||||||
//$payment_accounts[$this->Account->nameToID('Bank')] = 'Bank';
|
//$payment_accounts[$this->Account->nameToID('Bank')] = 'Bank';
|
||||||
$default_accounts = array_diff_key($payment_accounts,
|
$default_accounts = array_diff_key($payment_accounts,
|
||||||
array($this->Account->concessionAccountID() => 1));
|
array($this->Account->concessionAccountID() => 1));
|
||||||
|
|||||||
@@ -432,11 +432,14 @@ class CustomersController extends AppController {
|
|||||||
$entries = $this->Customer->LedgerEntry->find
|
$entries = $this->Customer->LedgerEntry->find
|
||||||
('all', array
|
('all', array
|
||||||
('contain' => false,
|
('contain' => false,
|
||||||
'conditions' => array('LedgerEntry.id' => array(199,200,201)),
|
'conditions' => array('LedgerEntry.id' =>
|
||||||
|
//array(199,200,201)
|
||||||
|
61
|
||||||
|
),
|
||||||
));
|
));
|
||||||
pr(compact('entries'));
|
pr(compact('entries'));
|
||||||
|
|
||||||
$this->Customer->LedgerEntry->refund($entries);
|
$this->Customer->LedgerEntry->reverse($entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -475,11 +475,18 @@ class LeasesController extends AppController {
|
|||||||
'action' => 'receipt',
|
'action' => 'receipt',
|
||||||
$lease['Customer']['id']));
|
$lease['Customer']['id']));
|
||||||
|
|
||||||
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit > 0)
|
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit > 0 && $outstanding_balance > 0)
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Apply Deposit', 'url' => array('action' => 'apply_deposit',
|
array('name' => 'Apply Deposit', 'url' => array('action' => 'apply_deposit',
|
||||||
$id));
|
$id));
|
||||||
|
|
||||||
|
if (isset($lease['Lease']['moveout_date']) &&
|
||||||
|
$outstanding_balance <= 0 &&
|
||||||
|
($outstanding_deposit - $outstanding_balance) > 0)
|
||||||
|
$this->sidemenu_links[] =
|
||||||
|
array('name' => 'Issue Refund', 'url' => array('action' => 'refund',
|
||||||
|
$id));
|
||||||
|
|
||||||
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit == 0 && $outstanding_balance > 0)
|
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit == 0 && $outstanding_balance > 0)
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Write-Off', 'url' => array('action' => 'bad_debt',
|
array('name' => 'Write-Off', 'url' => array('action' => 'bad_debt',
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ class LedgerEntriesController extends AppController {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function reverse($id) {
|
function reverse($id) {
|
||||||
$id = $this->LedgerEntry->reverse($id);
|
$this->LedgerEntry->reverse($id);
|
||||||
$this->redirect(array('action'=>'view', $id));
|
$this->redirect(array('action'=>'view', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,13 +433,27 @@ class LedgerEntriesController extends AppController {
|
|||||||
(!$entry['CreditLedger']['Account']['trackable'] ||
|
(!$entry['CreditLedger']['Account']['trackable'] ||
|
||||||
$stats['credit']['amount_reconciled'] == 0)
|
$stats['credit']['amount_reconciled'] == 0)
|
||||||
|
|
||||||
|| 1 // REVISIT <AP>: 20090711 : Testing
|
&& 0
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Set up dynamic menu items
|
// Set up dynamic menu items
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Operations', 'header' => true);
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
|
$this->sidemenu_links[] =
|
||||||
|
array('name' => 'Undo',
|
||||||
|
'url' => array('action' => 'reverse',
|
||||||
|
$id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->LedgerEntry->Ledger->Account->type
|
||||||
|
($entry['CreditLedger']['Account']['id']) == 'INCOME')
|
||||||
|
{
|
||||||
|
// Set up dynamic menu items
|
||||||
|
$this->sidemenu_links[] =
|
||||||
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Reverse',
|
array('name' => 'Reverse',
|
||||||
'url' => array('action' => 'reverse',
|
'url' => array('action' => 'reverse',
|
||||||
|
|||||||
@@ -211,6 +211,25 @@ class Account extends AppModel {
|
|||||||
return $payment_accounts;
|
return $payment_accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: collectableAccounts
|
||||||
|
* - Returns an array of accounts suitable to show income collection
|
||||||
|
*/
|
||||||
|
|
||||||
|
function collectableAccounts() {
|
||||||
|
$accounts = $this->paymentAccounts();
|
||||||
|
|
||||||
|
foreach(array($this->nsfAccountID(),
|
||||||
|
$this->securityDepositAccountID())
|
||||||
|
AS $account_id) {
|
||||||
|
$accounts[$account_id] = $this->name($account_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ class LedgerEntry extends AppModel {
|
|||||||
* - Reverses the ledger entry
|
* - Reverses the ledger entry
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function reverse($id, $amount = null, $transaction_id = null, $rec_id = null) {
|
function reverse1($id, $amount = null, $transaction_id = null, $rec_id = null) {
|
||||||
/* pr(array('LedgerEntry::reverse', */
|
/* pr(array('LedgerEntry::reverse', */
|
||||||
/* compact('id', 'amount', 'transaction_id', 'rec_id'))); */
|
/* compact('id', 'amount', 'transaction_id', 'rec_id'))); */
|
||||||
|
|
||||||
@@ -378,8 +378,8 @@ class LedgerEntry extends AppModel {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: refund
|
* function: reverse
|
||||||
* - Flags the given items as refunded
|
* - Reverses the charges
|
||||||
*
|
*
|
||||||
* SAMPLE MOVE IN w/ PRE PAYMENT
|
* SAMPLE MOVE IN w/ PRE PAYMENT
|
||||||
* DEPOSIT RENT A/R RECEIPT CHECK PETTY BANK
|
* DEPOSIT RENT A/R RECEIPT CHECK PETTY BANK
|
||||||
@@ -427,20 +427,26 @@ OPTION 2
|
|||||||
* | | | | | | |
|
* | | | | | | |
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function refund($ledger_entries, $stamp = null) {
|
function reverse($ledger_entries, $stamp = null) {
|
||||||
pr(array('LedgerEntry::refund',
|
pr(array('LedgerEntry::reverse',
|
||||||
compact('ledger_entries', 'stamp')));
|
compact('ledger_entries', 'stamp')));
|
||||||
|
|
||||||
|
// If the user only wants to reverse one ID, we'll allow it
|
||||||
|
if (!is_array($ledger_entries))
|
||||||
|
$ledger_entries = $this->find
|
||||||
|
('all', array
|
||||||
|
('contain' => false,
|
||||||
|
'conditions' => array('LedgerEntry.id' => $ledger_entries)));
|
||||||
|
|
||||||
$A = new Account();
|
$A = new Account();
|
||||||
|
|
||||||
$cp_account_id = $A->creditPayableAccountID();
|
$ar_account_id = $A->accountReceivableAccountID();
|
||||||
$cp_account_id = $A->accountReceivableAccountID();
|
|
||||||
$receipt_account_id = $A->receiptAccountID();
|
$receipt_account_id = $A->receiptAccountID();
|
||||||
|
|
||||||
$transaction_id = null;
|
$transaction_id = null;
|
||||||
foreach ($ledger_entries AS $entry) {
|
foreach ($ledger_entries AS $entry) {
|
||||||
$entry = $entry['LedgerEntry'];
|
$entry = $entry['LedgerEntry'];
|
||||||
$amount = $entry['amount'];
|
$amount = -1*$entry['amount'];
|
||||||
|
|
||||||
if (isset($entry['credit_account_id']))
|
if (isset($entry['credit_account_id']))
|
||||||
$refund_account_id = $entry['credit_account_id'];
|
$refund_account_id = $entry['credit_account_id'];
|
||||||
@@ -455,8 +461,8 @@ OPTION 2
|
|||||||
$ids = $A->postLedgerEntry
|
$ids = $A->postLedgerEntry
|
||||||
(array('transaction_id' => $transaction_id),
|
(array('transaction_id' => $transaction_id),
|
||||||
null,
|
null,
|
||||||
array('debit_ledger_id' => $A->currentLedgerID($refund_account_id),
|
array('debit_ledger_id' => $A->currentLedgerID($ar_account_id),
|
||||||
'credit_ledger_id' => $A->currentLedgerID($cp_account_id),
|
'credit_ledger_id' => $A->currentLedgerID($refund_account_id),
|
||||||
'effective_date' => $entry['effective_date'],
|
'effective_date' => $entry['effective_date'],
|
||||||
'through_date' => $entry['through_date'],
|
'through_date' => $entry['through_date'],
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
@@ -476,7 +482,7 @@ OPTION 2
|
|||||||
$transaction_id = $ids['transaction_id'];
|
$transaction_id = $ids['transaction_id'];
|
||||||
|
|
||||||
pr(array('checkpoint' => 'Posted Refund Ledger Entry',
|
pr(array('checkpoint' => 'Posted Refund Ledger Entry',
|
||||||
compact('ids', 'amount', 'refund_account_id', 'cp_account_id')));
|
compact('ids', 'amount', 'refund_account_id', 'ar_account_id')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user