Making progress. Much still to do, but there are hints of functionality finally returning so I'm snapshotting.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@360 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -2,16 +2,13 @@
|
||||
class Payment extends AppModel {
|
||||
|
||||
var $belongsTo = array(
|
||||
'Customer',
|
||||
'Lease',
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'DoubleEntry',
|
||||
);
|
||||
|
||||
var $hasAndBelongsToMany = array(
|
||||
'DoubleEntry',
|
||||
'LedgerEntry',
|
||||
'DepositTransaction' => array(
|
||||
'className' => 'Transaction',
|
||||
),
|
||||
'NsfTransaction' => array(
|
||||
'className' => 'Transaction',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -36,7 +33,7 @@ class Payment extends AppModel {
|
||||
|
||||
// Create the payment entry, and reconcile the credit side
|
||||
// of the double-entry (which should be A/R) as a payment.
|
||||
$ids = $this->DoubleEntry->Ledger->Account->postDoubleEntry
|
||||
$ids = $this->LedgerEntry->Ledger->Account->postLedgerEntry
|
||||
($payment,
|
||||
array('debit_ledger_id' => $A->currentLedgerID($entry['account_id']),
|
||||
'credit_ledger_id' => $A->currentLedgerID($A->paymentAccountID())
|
||||
@@ -97,7 +94,7 @@ class Payment extends AppModel {
|
||||
('first',
|
||||
array('contain' =>
|
||||
array(/* e3 */
|
||||
'DoubleEntry' =>
|
||||
'LedgerEntry' =>
|
||||
array('Transaction.id',
|
||||
'Payment.id',
|
||||
'Customer.id',
|
||||
@@ -126,7 +123,7 @@ class Payment extends AppModel {
|
||||
),
|
||||
|
||||
/* e2 */
|
||||
'DebitReconciliationDoubleEntry' =>
|
||||
'DebitReconciliationLedgerEntry' =>
|
||||
array(/* e2 credit */
|
||||
'CreditLedger' => /* i.e. A/R Ledger */
|
||||
array('fields' => array(),
|
||||
@@ -141,11 +138,11 @@ class Payment extends AppModel {
|
||||
/* e1 */
|
||||
// STUPID CakePHP bug screws up CLASS contains CLASS.
|
||||
// Use the same class, but with different name.
|
||||
'DebitReconciliationDoubleEntry2',
|
||||
'DebitReconciliationLedgerEntry2',
|
||||
),
|
||||
|
||||
/* e4 */
|
||||
'CreditReconciliationDoubleEntry' =>
|
||||
'CreditReconciliationLedgerEntry' =>
|
||||
array(/* e4 debit */
|
||||
'DebitLedger' => /* e.g. BANK Ledger */
|
||||
array('fields' => array('id'),
|
||||
@@ -170,9 +167,9 @@ class Payment extends AppModel {
|
||||
|
||||
$t4_id = null;
|
||||
$t5_id = null;
|
||||
foreach ($source['DoubleEntry'] AS $e3) {
|
||||
foreach ($source['LedgerEntry'] AS $e3) {
|
||||
// We expect only a single e4 entry
|
||||
$e4 = $e3['CreditReconciliationDoubleEntry'];
|
||||
$e4 = $e3['CreditReconciliationLedgerEntry'];
|
||||
if (count($e4) < 1)
|
||||
continue;
|
||||
if (count($e4) > 1)
|
||||
@@ -188,7 +185,7 @@ class Payment extends AppModel {
|
||||
$bank_account_id = $e4['DebitLedger']['account_id'];
|
||||
|
||||
// post new e5
|
||||
$e5_ids = $A->postDoubleEntry
|
||||
$e5_ids = $A->postLedgerEntry
|
||||
(array('transaction_id' => $t4_id),
|
||||
null,
|
||||
array('debit_ledger_id' => $A->currentLedgerID($bank_account_id),
|
||||
@@ -211,7 +208,7 @@ class Payment extends AppModel {
|
||||
// post new e6... this will be our crossover point
|
||||
// from typical positive entries to negative entries.
|
||||
// Therefore, no reconciliation on this account.
|
||||
$e6_ids = $A->postDoubleEntry
|
||||
$e6_ids = $A->postLedgerEntry
|
||||
(array('transaction_id' => $t5_id),
|
||||
array('monetary_source_id' => $e3['monetary_source_id']),
|
||||
array('debit_ledger_id' => $A->currentLedgerID($nsf_account_id),
|
||||
@@ -223,7 +220,7 @@ class Payment extends AppModel {
|
||||
'comment' => "NSF tracker; Monetary Source #{$id}",
|
||||
),
|
||||
array('debit' => array
|
||||
(array('DoubleEntry' =>
|
||||
(array('LedgerEntry' =>
|
||||
array('id' => $e5_ids['id'],
|
||||
'amount' => $amount))),
|
||||
)
|
||||
@@ -237,12 +234,12 @@ class Payment extends AppModel {
|
||||
compact('e6_ids', 'amount')));
|
||||
|
||||
$t6_id = null;
|
||||
foreach ($e3['DebitReconciliationDoubleEntry'] AS $e2) {
|
||||
foreach ($e2['DebitReconciliationDoubleEntry2'] AS $e1) {
|
||||
foreach ($e3['DebitReconciliationLedgerEntry'] AS $e2) {
|
||||
foreach ($e2['DebitReconciliationLedgerEntry2'] AS $e1) {
|
||||
$amount = -1*$e1['Reconciliation']['amount'];
|
||||
|
||||
// post new e7
|
||||
$e7_ids = $A->postDoubleEntry
|
||||
$e7_ids = $A->postLedgerEntry
|
||||
(array('transaction_id' => $t6_id),
|
||||
null,
|
||||
array('debit_ledger_id' => $A->currentLedgerID($receipt_account_id),
|
||||
@@ -254,12 +251,12 @@ class Payment extends AppModel {
|
||||
'comment' => "NSF Receipt; Monetary Source #{$id}",
|
||||
),
|
||||
array('debit' => array
|
||||
(array('DoubleEntry' =>
|
||||
(array('LedgerEntry' =>
|
||||
array('id' => $e6_ids['id'],
|
||||
'amount' => $amount))),
|
||||
|
||||
'credit' => array
|
||||
(array('DoubleEntry' =>
|
||||
(array('LedgerEntry' =>
|
||||
array('id' => $e1['id'],
|
||||
'amount' => $amount))),
|
||||
)
|
||||
@@ -276,11 +273,11 @@ class Payment extends AppModel {
|
||||
}
|
||||
|
||||
// Cheat for now
|
||||
$customer_id = $source['DoubleEntry'][0]['customer_id'];
|
||||
$customer_id = $source['LedgerEntry'][0]['customer_id'];
|
||||
$lease_id = null;
|
||||
|
||||
// post new e8
|
||||
$e8_ids = $A->postDoubleEntry
|
||||
$e8_ids = $A->postLedgerEntry
|
||||
(array('transaction_id' => $t6_id),
|
||||
null,
|
||||
array('debit_ledger_id' => $A->currentLedgerID($ar_account_id),
|
||||
|
||||
Reference in New Issue
Block a user