Moving back to the Invoice/Receipt mechanism. Seems to work fairly well, even if it's non-standard.
git-svn-id: file:///svn-source/pmgr/branches/charge_credit_20090629@189 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -633,15 +633,6 @@ CREATE TABLE `pmgr_customers` (
|
|||||||
-- If NULL, rely on the contact info exclusively
|
-- If NULL, rely on the contact info exclusively
|
||||||
`name` VARCHAR(80) DEFAULT NULL,
|
`name` VARCHAR(80) DEFAULT NULL,
|
||||||
|
|
||||||
-- A customer gets their own account, although any
|
|
||||||
-- lease specific charge (rent, late fees, etc) will
|
|
||||||
-- be debited against the lease account. This one
|
|
||||||
-- will be used for non-lease related charges, as
|
|
||||||
-- well as charges that intentionally span more than
|
|
||||||
-- one lease (such as one security deposit to cover
|
|
||||||
-- two or more units).
|
|
||||||
`account_id` INT(10) UNSIGNED NOT NULL,
|
|
||||||
|
|
||||||
-- Primary Contact... every customer must have one
|
-- Primary Contact... every customer must have one
|
||||||
-- (and presumably, most customers will _be_ one).
|
-- (and presumably, most customers will _be_ one).
|
||||||
-- REVISIT <AP> 20090612:
|
-- REVISIT <AP> 20090612:
|
||||||
@@ -708,7 +699,6 @@ CREATE TABLE `pmgr_leases` (
|
|||||||
`lease_type_id` INT(10) UNSIGNED NOT NULL,
|
`lease_type_id` INT(10) UNSIGNED NOT NULL,
|
||||||
`unit_id` INT(10) UNSIGNED NOT NULL,
|
`unit_id` INT(10) UNSIGNED NOT NULL,
|
||||||
`customer_id` INT(10) UNSIGNED NOT NULL,
|
`customer_id` INT(10) UNSIGNED NOT NULL,
|
||||||
`account_id` INT(10) UNSIGNED NOT NULL,
|
|
||||||
`late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
|
`late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
|
||||||
|
|
||||||
`lease_date` DATE NOT NULL,
|
`lease_date` DATE NOT NULL,
|
||||||
@@ -848,7 +838,7 @@ CREATE TABLE `pmgr_accounts` (
|
|||||||
-- For LIABILITY, EQUITY, and INCOME, the opposite
|
-- For LIABILITY, EQUITY, and INCOME, the opposite
|
||||||
-- is true, with reconciliations posted, under
|
-- is true, with reconciliations posted, under
|
||||||
-- normal circumstances, when a debit occurs.
|
-- normal circumstances, when a debit occurs.
|
||||||
`trackable` INT UNSIGNED DEFAULT 0,
|
`trackable` INT UNSIGNED DEFAULT 1,
|
||||||
|
|
||||||
-- Security Level
|
-- Security Level
|
||||||
`level` INT UNSIGNED DEFAULT 1,
|
`level` INT UNSIGNED DEFAULT 1,
|
||||||
@@ -869,15 +859,17 @@ INSERT INTO `pmgr_accounts` (`type`, `name`, `trackable`)
|
|||||||
('ASSET', 'Invoice', 1),
|
('ASSET', 'Invoice', 1),
|
||||||
('ASSET', 'Receipt', 1),
|
('ASSET', 'Receipt', 1),
|
||||||
('LIABILITY', 'A/P', 1),
|
('LIABILITY', 'A/P', 1),
|
||||||
('LIABILITY', 'Tax', 0),
|
('LIABILITY', 'Tax', 1),
|
||||||
('LIABILITY', 'Customer Credit', 1),
|
('LIABILITY', 'Customer Credit', 1),
|
||||||
('ASSET', 'Bank', 0),
|
('ASSET', 'Bank', 1),
|
||||||
('ASSET', 'Till', 0),
|
('ASSET', 'Cash', 1),
|
||||||
|
('ASSET', 'Check', 1),
|
||||||
|
('ASSET', 'Money Order', 1),
|
||||||
('LIABILITY', 'Security Deposit', 1),
|
('LIABILITY', 'Security Deposit', 1),
|
||||||
('INCOME', 'Rent', 0),
|
('INCOME', 'Rent', 1),
|
||||||
('INCOME', 'Late Charge', 0),
|
('INCOME', 'Late Charge', 1),
|
||||||
('EXPENSE', 'Concession', 0),
|
('EXPENSE', 'Concession', 1),
|
||||||
('EXPENSE', 'Bad Debt', 0);
|
('EXPENSE', 'Bad Debt', 1);
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
|
||||||
@@ -942,6 +934,10 @@ DROP TABLE IF EXISTS `pmgr_transactions`;
|
|||||||
CREATE TABLE `pmgr_transactions` (
|
CREATE TABLE `pmgr_transactions` (
|
||||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
|
||||||
|
-- `type` ENUM('INVOICE',
|
||||||
|
-- 'RECEIPT')
|
||||||
|
-- NOT NULL,
|
||||||
|
|
||||||
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`through_date` DATE DEFAULT NULL,
|
`through_date` DATE DEFAULT NULL,
|
||||||
`due_date` DATE DEFAULT NULL,
|
`due_date` DATE DEFAULT NULL,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use DBI;
|
|||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
|
|
||||||
my $use_ir = 0;
|
my $use_ir = 1;
|
||||||
|
|
||||||
# Internally adjust all numbers coming from the database to
|
# Internally adjust all numbers coming from the database to
|
||||||
# be in inches. Not necessary to go to this detail, but the
|
# be in inches. Not necessary to go to this detail, but the
|
||||||
@@ -482,8 +482,10 @@ foreach $row (@$result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# For compatibility, while deciding on account names
|
# For compatibility, while deciding on account names
|
||||||
$newdb{'lookup'}{'account'}{'Cash'}
|
if (!defined $newdb{'lookup'}{'account'}{'Cash'}) {
|
||||||
= $newdb{'lookup'}{'account'}{'Till'};
|
$newdb{'lookup'}{'account'}{'Cash'}
|
||||||
|
= $newdb{'lookup'}{'account'}{'Till'};
|
||||||
|
}
|
||||||
|
|
||||||
$newdb{'lookup'}{'charge_type'} = {};
|
$newdb{'lookup'}{'charge_type'} = {};
|
||||||
$newdb{'lookup'}{'charge_type'}{'Rent'} =
|
$newdb{'lookup'}{'charge_type'}{'Rent'} =
|
||||||
@@ -510,9 +512,9 @@ $newdb{'lookup'}{'payment_type'} = {};
|
|||||||
$newdb{'lookup'}{'payment_type'}{1}
|
$newdb{'lookup'}{'payment_type'}{1}
|
||||||
= { 'name' => 'Cash', 'account_name' => 'Cash', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Cash'} };
|
= { 'name' => 'Cash', 'account_name' => 'Cash', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Cash'} };
|
||||||
$newdb{'lookup'}{'payment_type'}{2}
|
$newdb{'lookup'}{'payment_type'}{2}
|
||||||
= { 'name' => 'Check', 'account_name' => 'Cash', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Check'} };
|
= { 'name' => 'Check', 'account_name' => 'Check', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Check'} };
|
||||||
$newdb{'lookup'}{'payment_type'}{3}
|
$newdb{'lookup'}{'payment_type'}{3}
|
||||||
= { 'name' => 'Money Order', 'account_name' => 'Cash', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Money Order'} };
|
= { 'name' => 'Money Order', 'account_name' => 'Money Order', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Money Order'} };
|
||||||
$newdb{'lookup'}{'payment_type'}{4}
|
$newdb{'lookup'}{'payment_type'}{4}
|
||||||
= { 'name' => 'ACH', 'account_name' => 'Bank', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'ACH'} };
|
= { 'name' => 'ACH', 'account_name' => 'Bank', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'ACH'} };
|
||||||
$newdb{'lookup'}{'payment_type'}{12}
|
$newdb{'lookup'}{'payment_type'}{12}
|
||||||
@@ -702,7 +704,7 @@ foreach $row (@{query($sdbh, $query)}) {
|
|||||||
addRow('customers',
|
addRow('customers',
|
||||||
{ 'name' => "$row->{'LastName'}, $row->{'FirstName'}",
|
{ 'name' => "$row->{'LastName'}, $row->{'FirstName'}",
|
||||||
'primary_contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
|
'primary_contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'},
|
||||||
'account_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'account_id'} });
|
});
|
||||||
|
|
||||||
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'} =
|
$newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'} =
|
||||||
$newdb{'tables'}{'customers'}{'autoid'};
|
$newdb{'tables'}{'customers'}{'autoid'};
|
||||||
@@ -832,7 +834,6 @@ foreach $row (@{query($sdbh, $query)}) {
|
|||||||
'lease_type_id' => $newdb{'tables'}{'lease_types'}{'autoid'},
|
'lease_type_id' => $newdb{'tables'}{'lease_types'}{'autoid'},
|
||||||
'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'},
|
'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'},
|
||||||
'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'},
|
'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'},
|
||||||
'account_id' => $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'account_id'},
|
|
||||||
'lease_date' => datefmt($row->{'DateIn'}),
|
'lease_date' => datefmt($row->{'DateIn'}),
|
||||||
'movein_date' => datefmt($row->{'DateIn'}),
|
'movein_date' => datefmt($row->{'DateIn'}),
|
||||||
'moveout_date' => datefmt($row->{'DateOut'}),
|
'moveout_date' => datefmt($row->{'DateOut'}),
|
||||||
@@ -1047,53 +1048,67 @@ foreach $row (@{query($sdbh, $query)})
|
|||||||
= $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'monetary_source_id'};
|
= $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'monetary_source_id'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'credit_ledger_id'}
|
||||||
|
= $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_id'};
|
||||||
|
|
||||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'}
|
||||||
= $newdb{'lookup'}{'account'}{$newdb{'lookup'}{'payment'}{
|
= $newdb{'lookup'}{'account'}{
|
||||||
$row->{'PaymentID'}}{'account_name'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'account_name'}
|
||||||
}{'ledger_id'};
|
}{'ledger_id'};
|
||||||
|
|
||||||
if ($use_ir) {
|
if ($use_ir) {
|
||||||
addRow('ledger_entries',
|
addRow('ledger_entries',
|
||||||
{ 'monetary_source_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'monetary_source_id'},
|
{ #'monetary_source_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'monetary_source_id'},
|
||||||
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
|
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
|
||||||
'debit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'},
|
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'},
|
||||||
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'},
|
'credit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'credit_ledger_id'},
|
||||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
||||||
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
||||||
'amount' => $row->{'PaymentAmount'},
|
'amount' => $row->{'PaymentAmount'},
|
||||||
'comment' => "Receipt: $row->{'ReceiptNum'}; Charge: $row->{'ChargeID'}; Payment: $row->{'PaymentID'}" });
|
'comment' => "Receipt: $row->{'ReceiptNum'}; " });
|
||||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'}
|
||||||
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'credit_ledger_id'}
|
||||||
= $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'};
|
= $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Sitelink splits one physical payment into multiple "payments" to match each charge
|
# Sitelink splits one physical payment into multiple "payments" to match each charge
|
||||||
# This is kludgy, but for our cases at least, brings those pseudo-payments back into
|
# This is kludgy, but for our cases at least, brings those pseudo-payments back into
|
||||||
# a single one. It presumes that there is only one PaymentType per receipt.
|
# a single one. It presumes that there is only one PaymentType per receipt.
|
||||||
if (!$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'}) {
|
if (!$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}) {
|
||||||
addRow('ledger_entries',
|
addRow('ledger_entries',
|
||||||
{ 'monetary_source_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'monetary_source_id'},
|
{ 'monetary_source_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'monetary_source_id'},
|
||||||
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
|
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
|
||||||
'debit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'},
|
'debit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'},
|
||||||
'credit_ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_id'},
|
'credit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'credit_ledger_id'},
|
||||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
||||||
#'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
#'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
||||||
'amount' => 0,
|
'amount' => 0,
|
||||||
'comment' => "Receipt: $row->{'ReceiptNum'}; " });
|
'comment' => "Receipt: $row->{'ReceiptNum'}; Charge: $row->{'ChargeID'}; Payment: $row->{'PaymentID'}" });
|
||||||
|
|
||||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
||||||
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||||
}
|
}
|
||||||
|
|
||||||
$newdb{'tables'}{'ledger_entries'}{'rows'}[
|
$newdb{'tables'}{'ledger_entries'}{'rows'}[
|
||||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
||||||
]{'amount'} += $row->{'PaymentAmount'};
|
]{'amount'} += $row->{'PaymentAmount'};
|
||||||
|
|
||||||
$newdb{'tables'}{'ledger_entries'}{'rows'}[
|
$newdb{'tables'}{'ledger_entries'}{'rows'}[
|
||||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
||||||
]{'comment'} .= 'P:'.$row->{'PaymentID'} . '->C:' . $row->{'ChargeID'} . '; ';
|
]{'comment'} .= 'P:'.$row->{'PaymentID'} . '->C:' . $row->{'ChargeID'} . '; ';
|
||||||
|
|
||||||
|
if ($use_ir) {
|
||||||
|
# Reconcile the invoice account. Since this is from the perspective
|
||||||
|
# of the invoice, the entry crediting the charge is the debit, and
|
||||||
|
# the entry debiting A/R is the credit.
|
||||||
|
addRow('reconciliations',
|
||||||
|
{ 'debit_ledger_entry_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'},
|
||||||
|
'credit_ledger_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'},
|
||||||
|
'amount' => $row->{'PaymentAmount'},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
# OK, now that the receipt is reconciled, update
|
# OK, now that the receipt is reconciled, update
|
||||||
# payment to reference the true ledger_entry_id
|
# payment to reference the true ledger_entry_id
|
||||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
||||||
@@ -1127,83 +1142,83 @@ my %fake =
|
|||||||
('customer_id' => 4,
|
('customer_id' => 4,
|
||||||
'ledger_id' => 4,
|
'ledger_id' => 4,
|
||||||
'invoice' => [ { 'id' => 1000,
|
'invoice' => [ { 'id' => 1000,
|
||||||
'date' => '2009-05-05',
|
'date' => '2009-05-05',
|
||||||
'entry' => [ { 'id' => 2100,
|
'entry' => [ { 'id' => 2100,
|
||||||
'account_name' => 'Security Deposit',
|
'account_name' => 'Security Deposit',
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
'tax' => 0 },
|
'tax' => 0 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ 'id' => 1001,
|
{ 'id' => 1001,
|
||||||
'date' => '2009-05-01',
|
'date' => '2009-05-01',
|
||||||
'thru' => '2009-05-31',
|
'thru' => '2009-05-31',
|
||||||
'entry' => [ { 'id' => 2110,
|
'entry' => [ { 'id' => 2110,
|
||||||
'account_name' => 'Rent',
|
'account_name' => 'Rent',
|
||||||
'amount' => 100,
|
'amount' => 100,
|
||||||
'tax' => 5 },
|
'tax' => 5 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ 'id' => 1002,
|
{ 'id' => 1002,
|
||||||
'date' => '2009-05-11',
|
'date' => '2009-05-11',
|
||||||
'entry' => [ { 'id' => 2120,
|
'entry' => [ { 'id' => 2120,
|
||||||
'account_name' => 'Late Charge',
|
'account_name' => 'Late Charge',
|
||||||
'amount' => 25,
|
'amount' => 25,
|
||||||
'tax' => 0 },
|
'tax' => 0 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'receipt' => [ { 'id' => 2000,
|
'receipt' => [ { 'id' => 2000,
|
||||||
'date' => '2009-05-15',
|
'date' => '2009-05-15',
|
||||||
'entry' => [ { 'id' => 2200,
|
'entry' => [ { 'id' => 2200,
|
||||||
'track' => [ { 'debit'=>2100, 'amount'=>10 },
|
'track' => [ { 'debit'=>2100, 'amount'=>10 },
|
||||||
{ 'debit'=>2110, 'amount'=>5 } ],
|
{ 'debit'=>2110, 'amount'=>5 } ],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'amount' => 15 },
|
'amount' => 15 },
|
||||||
{ 'id' => 2201,
|
{ 'id' => 2201,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>10 } ],
|
'track' => [ { 'debit'=>2110, 'amount'=>10 } ],
|
||||||
'type' => 2,
|
'type' => 2,
|
||||||
'amount' => 10 },
|
'amount' => 10 },
|
||||||
{ 'id' => 2202,
|
{ 'id' => 2202,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>5 } ],
|
'track' => [ { 'debit'=>2110, 'amount'=>5 } ],
|
||||||
'type' => 3,
|
'type' => 3,
|
||||||
'amount' => 5 },
|
'amount' => 5 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ 'id' => 2001,
|
{ 'id' => 2001,
|
||||||
'date' => '2009-05-18',
|
'date' => '2009-05-18',
|
||||||
'entry' => [ { 'id' => 2210,
|
'entry' => [ { 'id' => 2210,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>30 } ],
|
'track' => [ { 'debit'=>2110, 'amount'=>30 } ],
|
||||||
'type' => 5,
|
'type' => 5,
|
||||||
'amount' => 30 },
|
'amount' => 30 },
|
||||||
{ 'id' => 2211,
|
{ 'id' => 2211,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>20 } ],
|
'track' => [ { 'debit'=>2110, 'amount'=>20 } ],
|
||||||
'type' => 6,
|
'type' => 6,
|
||||||
'amount' => 20 },
|
'amount' => 20 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ 'id' => 2002,
|
{ 'id' => 2002,
|
||||||
'date' => '2009-05-22',
|
'date' => '2009-05-22',
|
||||||
'entry' => [ { 'id' => 2220,
|
'entry' => [ { 'id' => 2220,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>10 } ],
|
'track' => [ { 'debit'=>2110, 'amount'=>10 } ],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'amount' => 10 },
|
'amount' => 10 },
|
||||||
{ 'id' => 2221,
|
{ 'id' => 2221,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>5 } ],
|
'track' => [ { 'debit'=>2110, 'amount'=>5 } ],
|
||||||
'type' => 2,
|
'type' => 2,
|
||||||
'amount' => 5 },
|
'amount' => 5 },
|
||||||
{ 'id' => 2222,
|
{ 'id' => 2222,
|
||||||
'track' => [ { 'debit'=>2110, 'amount'=>15 },
|
'track' => [ { 'debit'=>2110, 'amount'=>15 },
|
||||||
{ 'debit'=>2111, 'amount'=>5 },
|
{ 'debit'=>2111, 'amount'=>5 },
|
||||||
{ 'debit'=>2120, 'amount'=>5 } ],
|
{ 'debit'=>2120, 'amount'=>5 } ],
|
||||||
'type' => 7,
|
'type' => 7,
|
||||||
'amount' => 25 },
|
'amount' => 25 },
|
||||||
{ 'id' => 2223,
|
{ 'id' => 2223,
|
||||||
'track' => [ { 'debit'=>2120, 'amount'=>20 } ],
|
'track' => [ { 'debit'=>2120, 'amount'=>20 } ],
|
||||||
'type' => 8,
|
'type' => 8,
|
||||||
'amount' => 30 },
|
'amount' => 30 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1230,7 +1245,7 @@ sub fakeTesting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addRow('transactions',
|
addRow('transactions',
|
||||||
{ 'stamp' => '2009-05-10' });
|
{ 'stamp' => '2009-04-30' });
|
||||||
|
|
||||||
addRow('ledger_entries',
|
addRow('ledger_entries',
|
||||||
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
||||||
@@ -1257,10 +1272,10 @@ sub fakeTesting {
|
|||||||
1);
|
1);
|
||||||
|
|
||||||
foreach my $e (@{$tx->{'entry'}}) {
|
foreach my $e (@{$tx->{'entry'}}) {
|
||||||
my $crdr = ($ir eq 'invoice') ? 'Invoice' : 'Receipt';
|
my $ircrdr = ($ir eq 'invoice') ? 'Invoice' : 'Receipt';
|
||||||
my $dr = ($ir eq 'invoice') ? 'A/R' : 'Cash';
|
my $dr = ($ir eq 'invoice') ? 'A/R' : 'Cash';
|
||||||
$crdr = $dr;
|
|
||||||
my $cr = ($ir eq 'invoice') ? $e->{'account_name'} : 'A/R';
|
my $cr = ($ir eq 'invoice') ? $e->{'account_name'} : 'A/R';
|
||||||
|
my $crdr;
|
||||||
my $monetary_source_id;
|
my $monetary_source_id;
|
||||||
|
|
||||||
if (defined $e->{'type'}) {
|
if (defined $e->{'type'}) {
|
||||||
@@ -1274,29 +1289,41 @@ sub fakeTesting {
|
|||||||
$monetary_source_id = $newdb{'ids'}{'monetary_source'}{'internal'};
|
$monetary_source_id = $newdb{'ids'}{'monetary_source'}{'internal'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$crdr = $dr;
|
||||||
|
if ($use_ir) {
|
||||||
|
$crdr = $ircrdr;
|
||||||
|
addRow('ledger_entries',
|
||||||
|
{ 'id' => $e->{'id'}+10000,
|
||||||
|
'monetary_source_id' => ($ir eq 'invoice' ? undef : $monetary_source_id),
|
||||||
|
'transaction_id' => $tx->{'id'},
|
||||||
|
'debit_ledger_id' => $newdb{'lookup'}{'account'}{$dr}{'ledger_id'},
|
||||||
|
'credit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
||||||
|
'customer_id' => $fake{'customer_id'},
|
||||||
|
#'lease_id' => $fake{'lease_id'},
|
||||||
|
'amount' => $e->{'amount'},
|
||||||
|
'comment' => "Fake $ir entry" },
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
|
||||||
addRow('ledger_entries',
|
addRow('ledger_entries',
|
||||||
{ 'id' => $e->{'id'},
|
{ 'id' => $e->{'id'},
|
||||||
'monetary_source_id' => $monetary_source_id,
|
'monetary_source_id' => ($ir eq 'invoice' ? $monetary_source_id : undef),
|
||||||
'transaction_id' => $tx->{'id'},
|
'transaction_id' => $tx->{'id'},
|
||||||
'debit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
'debit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
||||||
'credit_ledger_id' => $newdb{'lookup'}{'account'}{$cr}{'ledger_id'},
|
'credit_ledger_id' => $newdb{'lookup'}{'account'}{$cr}{'ledger_id'},
|
||||||
'customer_id' => $fake{'customer_id'},
|
'customer_id' => $fake{'customer_id'},
|
||||||
'lease_id' => $fake{'lease_id'},
|
'lease_id' => $fake{'lease_id'},
|
||||||
'amount' => $e->{'amount'},
|
'amount' => $e->{'amount'},
|
||||||
'comment' => "Fake $ir entry" },
|
'comment' => "Fake Entry" },
|
||||||
1);
|
1);
|
||||||
|
|
||||||
# addRow('ledger_entries',
|
if ($use_ir) {
|
||||||
# { 'id' => $e->{'id'},
|
addRow('reconciliations',
|
||||||
# 'monetary_source_id' => $monetary_source_id,
|
{ 'debit_ledger_entry_id' => $e->{'id'} + ($ir eq 'invoice' ? 10000 : 0),
|
||||||
# 'transaction_id' => $tx->{'id'},
|
'credit_ledger_entry_id' => $e->{'id'} + ($ir eq 'invoice' ? 0 : 10000),
|
||||||
# 'debit_ledger_id' => $newdb{'lookup'}{'account'}{$dr}{'ledger_id'},
|
'amount' => $e->{'amount'},
|
||||||
# 'credit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
});
|
||||||
# 'customer_id' => $fake{'customer_id'},
|
}
|
||||||
# 'lease_id' => $fake{'lease_id'},
|
|
||||||
# 'amount' => $e->{'amount'},
|
|
||||||
# 'comment' => "Fake $ir entry" },
|
|
||||||
# 1);
|
|
||||||
|
|
||||||
foreach my $t (@{$e->{'track'}}) {
|
foreach my $t (@{$e->{'track'}}) {
|
||||||
addRow('reconciliations',
|
addRow('reconciliations',
|
||||||
@@ -1308,29 +1335,41 @@ sub fakeTesting {
|
|||||||
|
|
||||||
next unless $e->{'tax'};
|
next unless $e->{'tax'};
|
||||||
|
|
||||||
|
$crdr = $dr;
|
||||||
|
if ($use_ir) {
|
||||||
|
$crdr = $ircrdr;
|
||||||
|
addRow('ledger_entries',
|
||||||
|
{ 'id' => $e->{'id'}+10001,
|
||||||
|
'monetary_source_id' => ($ir eq 'invoice' ? undef : $monetary_source_id),
|
||||||
|
'transaction_id' => $tx->{'id'},
|
||||||
|
'debit_ledger_id' => $newdb{'lookup'}{'account'}{$dr}{'ledger_id'},
|
||||||
|
'credit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
||||||
|
'customer_id' => $fake{'customer_id'},
|
||||||
|
#'lease_id' => $fake{'lease_id'},
|
||||||
|
'amount' => $e->{'tax'},
|
||||||
|
'comment' => "Fake Tax Invoice Entry" },
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
|
||||||
addRow('ledger_entries',
|
addRow('ledger_entries',
|
||||||
{ 'id' => $e->{'id'}+1,
|
{ 'id' => $e->{'id'}+1,
|
||||||
'monetary_source_id' => $monetary_source_id,
|
'monetary_source_id' => ($ir eq 'invoice' ? $monetary_source_id : undef),
|
||||||
'transaction_id' => $tx->{'id'},
|
'transaction_id' => $tx->{'id'},
|
||||||
'debit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
'debit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
||||||
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Tax'}{'ledger_id'},
|
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Tax'}{'ledger_id'},
|
||||||
'customer_id' => $fake{'customer_id'},
|
'customer_id' => $fake{'customer_id'},
|
||||||
'lease_id' => $fake{'lease_id'},
|
'lease_id' => $fake{'lease_id'},
|
||||||
'amount' => $e->{'amount'},
|
'amount' => $e->{'tax'},
|
||||||
'comment' => "Fake Tax" },
|
'comment' => "Fake Tax Entry" },
|
||||||
1);
|
1);
|
||||||
|
|
||||||
# addRow('ledger_entries',
|
if ($use_ir) {
|
||||||
# { 'id' => $e->{'id'}+1,
|
addRow('reconciliations',
|
||||||
# 'monetary_source_id' => $monetary_source_id,
|
{ 'debit_ledger_entry_id' => $e->{'id'} + ($ir eq 'invoice' ? 10001 : 1),
|
||||||
# 'transaction_id' => $tx->{'id'},
|
'credit_ledger_entry_id' => $e->{'id'} + ($ir eq 'invoice' ? 1 : 10001),
|
||||||
# 'debit_ledger_id' => $newdb{'lookup'}{'account'}{$dr}{'ledger_id'},
|
'amount' => $e->{'tax'},
|
||||||
# 'credit_ledger_id' => $newdb{'lookup'}{'account'}{$crdr}{'ledger_id'},
|
});
|
||||||
# 'customer_id' => $fake{'customer_id'},
|
}
|
||||||
# 'lease_id' => $fake{'lease_id'},
|
|
||||||
# 'amount' => $e->{'tax'},
|
|
||||||
# 'comment' => "Fake Tax" },
|
|
||||||
# 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class LedgerEntriesController extends AppController {
|
|||||||
|
|
||||||
'conditions' => array('LedgerEntry.id' => $id),
|
'conditions' => array('LedgerEntry.id' => $id),
|
||||||
));
|
));
|
||||||
pr($entry);
|
//pr($entry);
|
||||||
|
|
||||||
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
|
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
|
||||||
// CakePHP will not include them in the LedgerEntry->find (or so it
|
// CakePHP will not include them in the LedgerEntry->find (or so it
|
||||||
|
|||||||
@@ -81,12 +81,16 @@ echo $this->element('table',
|
|||||||
echo '<div class="infobox">' . "\n";
|
echo '<div class="infobox">' . "\n";
|
||||||
$rows = array();
|
$rows = array();
|
||||||
if ($debit_ledger['Account']['trackable']) {
|
if ($debit_ledger['Account']['trackable']) {
|
||||||
$rows[] = array('Debit Amount Reconciled:', FormatHelper::currency($stats['debit_amount_reconciled']));
|
$rows[] = array("Applied from {$debit_ledger['Account']['name']}:",
|
||||||
$rows[] = array('Debit Amount Remaining:', FormatHelper::currency($stats['debit_amount_remaining']));
|
FormatHelper::currency($stats['debit_amount_reconciled']));
|
||||||
|
$rows[] = array("{$debit_ledger['Account']['name']} Amount Remaining:",
|
||||||
|
FormatHelper::currency($stats['debit_amount_remaining']));
|
||||||
}
|
}
|
||||||
if ($credit_ledger['Account']['trackable']) {
|
if ($credit_ledger['Account']['trackable']) {
|
||||||
$rows[] = array('Credit Amount Reconciled:', FormatHelper::currency($stats['credit_amount_reconciled']));
|
$rows[] = array("Applied to {$credit_ledger['Account']['name']}:",
|
||||||
$rows[] = array('Credit Amount Remaining:', FormatHelper::currency($stats['credit_amount_remaining']));
|
FormatHelper::currency($stats['credit_amount_reconciled']));
|
||||||
|
$rows[] = array("{$credit_ledger['Account']['name']} Amount Remaining:",
|
||||||
|
FormatHelper::currency($stats['credit_amount_remaining']));
|
||||||
}
|
}
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'summary',
|
array('class' => 'summary',
|
||||||
@@ -113,7 +117,7 @@ echo '<div CLASS="detail supporting">' . "\n";
|
|||||||
|
|
||||||
if ($debit_ledger['Account']['trackable']) {
|
if ($debit_ledger['Account']['trackable']) {
|
||||||
echo $this->element('ledger_entries',
|
echo $this->element('ledger_entries',
|
||||||
array('caption' => "Payments Received",
|
array('caption' => "Applied to " . $debit_ledger['Account']['name'],
|
||||||
'grid_div_id' => 'debit_reconciliation_ledger_entries',
|
'grid_div_id' => 'debit_reconciliation_ledger_entries',
|
||||||
'account_ftype' => 'debit',
|
'account_ftype' => 'debit',
|
||||||
'reconcile_id' => $entry['id'],
|
'reconcile_id' => $entry['id'],
|
||||||
@@ -123,7 +127,7 @@ if ($debit_ledger['Account']['trackable']) {
|
|||||||
|
|
||||||
if ($credit_ledger['Account']['trackable']) {
|
if ($credit_ledger['Account']['trackable']) {
|
||||||
echo $this->element('ledger_entries',
|
echo $this->element('ledger_entries',
|
||||||
array('caption' => "Charges Paid",
|
array('caption' => "Applied to " . $credit_ledger['Account']['name'],
|
||||||
'grid_div_id' => 'credit_reconciliation_ledger_entries',
|
'grid_div_id' => 'credit_reconciliation_ledger_entries',
|
||||||
'account_ftype' => 'credit',
|
'account_ftype' => 'credit',
|
||||||
'reconcile_id' => $entry['id'],
|
'reconcile_id' => $entry['id'],
|
||||||
|
|||||||
Reference in New Issue
Block a user