Just updated the comments, and added e2a and e1 into the query. No functional change yet.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@330 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -26,16 +26,16 @@ class MonetarySource extends AppModel {
|
||||
*
|
||||
* FEE RENT A/R RECEIPT CHECK NSF BANK
|
||||
* ------- ------- ------- ------- ------- ------- -------
|
||||
* | |50 50| | | | | t1
|
||||
* | |50 50| | | | | e1
|
||||
* | | | | | | |
|
||||
* | | |50 50| | | | t2a
|
||||
* | | | |50 50| | | t2b
|
||||
* | | |50 50| | | | e2a
|
||||
* | | | |50 50| | | e2b
|
||||
* | | | | | | |
|
||||
* | | | | |50 | 50| t3
|
||||
* | | | | |50 | 50| e3
|
||||
* | | | | | | |
|
||||
* | | | | | 50| |50 t4a
|
||||
* | | 50| | | |50 | t4b
|
||||
* |35 | 35| | | | | t4b
|
||||
* | | | | | 50| |50 e4
|
||||
* | | 50| | | |50 | e5a
|
||||
* |35 | 35| | | | | e5b
|
||||
|
||||
* - NOTE
|
||||
* The above example is great, except it leave no way to resolve
|
||||
@@ -43,17 +43,17 @@ class MonetarySource extends AppModel {
|
||||
* perhaps we need to run a negative credit to A/R, which we can
|
||||
* use to reconcile against the Rent<->A/R double entry:
|
||||
*
|
||||
* | | | | | 50| |50 t4a
|
||||
* | | |-50 | | -50| | t4b
|
||||
* |35 | 35| | | | | t4b
|
||||
* | | | | | 50| |50 e4
|
||||
* | | |-50 | | -50| | e5a
|
||||
* |35 | 35| | | | | e5b
|
||||
|
||||
* OR perhaps even a negative entry all the way through to the
|
||||
* bank, making the NSF appear not as a withdrawal, but as a
|
||||
* negative deposit (i.e, and adjustment, just like it really is):
|
||||
*
|
||||
* | | | | | |-50 -50| t4a
|
||||
* | | |-50 | | -50| | t4b
|
||||
* |35 | 35| | | | | t4b
|
||||
* | | | | | |-50 -50| e4
|
||||
* | | |-50 | | -50| | e5a
|
||||
* |35 | 35| | | | | e5b
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -67,17 +67,18 @@ class MonetarySource extends AppModel {
|
||||
$source = $this->find
|
||||
('first',
|
||||
array('contain' =>
|
||||
array(/* t2b */
|
||||
array(/* e2b */
|
||||
'LedgerEntry' =>
|
||||
array('Transaction.id',
|
||||
'MonetarySource.id',
|
||||
'Customer.id',
|
||||
'Lease.id',
|
||||
|
||||
/* e.g. CHECK */
|
||||
'DebitLedger' =>
|
||||
|
||||
/* e2b debit */
|
||||
'DebitLedger' => /* e.g. CHECK Ledger */
|
||||
array('fields' => array(),
|
||||
'Account' =>
|
||||
|
||||
'Account' => /* e.g. CHECK Account */
|
||||
array('fields' => array('id', 'name'),
|
||||
'conditions' =>
|
||||
/* array(array('Account.payable' => 1), */
|
||||
@@ -87,22 +88,50 @@ class MonetarySource extends AppModel {
|
||||
),
|
||||
),
|
||||
|
||||
/* e.g. RECEIPT */
|
||||
'CreditLedger' =>
|
||||
/* e2b credit */
|
||||
'CreditLedger' => /* i.e. RECEIPT Ledger */
|
||||
array('fields' => array('id'),
|
||||
'Account' =>
|
||||
'Account' => /* i.e. RECEIPT Account */
|
||||
array('fields' => array('id', 'name'),
|
||||
'conditions' =>
|
||||
array('Account.id' => $A->receiptAccountID()),
|
||||
),
|
||||
),
|
||||
|
||||
/* t3 */
|
||||
/* e2a */
|
||||
'DebitReconciliationLedgerEntry' =>
|
||||
array(/* e2a credit */
|
||||
'CreditLedger' => /* i.e. A/R Ledger */
|
||||
array('fields' => array(),
|
||||
|
||||
'Account' => /* i.e. A/R Account */
|
||||
array('fields' => array(),
|
||||
'conditions' =>
|
||||
array('Account.id' => $A->accountReceivableAccountID()),
|
||||
),
|
||||
),
|
||||
|
||||
/* e1 */
|
||||
'DebitReconciliationLedgerEntry' =>
|
||||
array(/* e1 credit */
|
||||
'CreditLedger' => /* e.g. Rent Ledger */
|
||||
array('fields' => array(),
|
||||
|
||||
'Account' => /* e.g. Rent Account */
|
||||
array('fields' => array(),
|
||||
'conditions' =>
|
||||
array('Account.id' => $A->accountReceivableAccountID()),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
/* e3 */
|
||||
'CreditReconciliationLedgerEntry' =>
|
||||
array(/* e.g. BANK */
|
||||
'DebitLedger' =>
|
||||
array(/* e3 debit */
|
||||
'DebitLedger' => /* e.g. BANK Ledger */
|
||||
array('fields' => array('id'),
|
||||
'Account' =>
|
||||
'Account' => /* e.g. BANK Account */
|
||||
array('fields' => array('id', 'name'),
|
||||
'conditions' =>
|
||||
array('Account.depositable' => 1),
|
||||
@@ -127,19 +156,24 @@ class MonetarySource extends AppModel {
|
||||
$nsf_rec_ids = array();
|
||||
|
||||
$transaction_id = null;
|
||||
// FOR EACH e2b
|
||||
foreach ($source['LedgerEntry'] AS $entry) {
|
||||
// Count number of e3 entries
|
||||
if (count($entry['CreditReconciliationLedgerEntry']) < 1)
|
||||
continue;
|
||||
if (count($entry['CreditReconciliationLedgerEntry']) > 1)
|
||||
die('Too many CRLEs');
|
||||
|
||||
// e2b amount
|
||||
$amount = $entry['amount'];
|
||||
|
||||
// e3 account
|
||||
$bank_account_id = $entry['CreditReconciliationLedgerEntry'][0]['DebitLedger']['account_id'];
|
||||
|
||||
pr(array('checkpoint' => 'outerloop',
|
||||
compact('id', $amount, 'bank_account_id', $entry)));
|
||||
|
||||
// post new e4
|
||||
$ids = $A->postLedgerEntry
|
||||
(array('transaction_id' => $transaction_id),
|
||||
null,
|
||||
@@ -173,6 +207,7 @@ class MonetarySource extends AppModel {
|
||||
$lease_id = $source['LedgerEntry'][0]['lease_id'];
|
||||
$customer_id = $source['LedgerEntry'][0]['customer_id'];
|
||||
|
||||
// post new e5a
|
||||
$ids = $A->postLedgerEntry
|
||||
(null,
|
||||
null,
|
||||
@@ -195,6 +230,7 @@ class MonetarySource extends AppModel {
|
||||
|
||||
$tid = $ids['transaction_id'];
|
||||
|
||||
// post new e5b
|
||||
$ids = $A->postLedgerEntry
|
||||
(array('transaction_id' => $tid),
|
||||
null,
|
||||
|
||||
Reference in New Issue
Block a user