Extra notes and scratch SQL statements added during the 0.2.0 work, but added only now.

git-svn-id: file:///svn-source/pmgr/branches/v0.3.0_work@942 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2010-03-02 03:37:13 +00:00
parent 9952673655
commit f01e62fc6e
2 changed files with 114 additions and 3 deletions

View File

@@ -135,9 +135,7 @@ FROM pmgr_transactions T
-- E.account_id != T.account_id -- E.account_id != T.account_id
GROUP BY T.id GROUP BY T.id
HAVING HAVING
(T.type = 'INVOICE' AND Tamt <> T.amount) (T.amount <> IF(T.type IN ('INVOICE','TRANSFER','DEPOSIT','PAYMENT'), Tamt, Oamt))
OR
(T.type <> 'INVOICE' AND Oamt <> T.amount)
OR OR
(Tamt * -1 <> Oamt) (Tamt * -1 <> Oamt)
@@ -576,3 +574,105 @@ ORDER BY IF(U.id IS NOT NULL, 1,
IF (S.id IS NOT NULL, 3, 4))) ASC, IF (S.id IS NOT NULL, 3, 4))) ASC,
IF (G.id IS NOT NULL, G.rank, 0) ASC IF (G.id IS NOT NULL, G.rank, 0) ASC
; ;
-- ----------------------------------------------------
-- Income by Month
SELECT MONTH(SE.effective_date) AS mon, YEAR(SE.effective_date) AS yr,
SE.account_id AS acct, ROUND(SUM(SE.amount)) AS amt
FROM pmgr_statement_entries SE
WHERE SE.type = 'CHARGE'
AND SE.effective_date >= '2009-04-01' AND SE.effective_date <= NOW()
GROUP BY yr, mon, acct WITH ROLLUP
-- ----------------------------------------------------
-- Rent Income by Month
SELECT MONTH(SE.effective_date) AS mon, YEAR(SE.effective_date) AS yr,
ROUND(SUM(SE.amount)) AS amt
FROM pmgr_statement_entries SE
WHERE SE.type = 'CHARGE'
AND SE.effective_date >= '2009-04-01' AND SE.effective_date <= NOW()
AND SE.account_id = 13
GROUP BY yr, mon WITH ROLLUP
-- ----------------------------------------------------
-- Occupancy during given month
SELECT COUNT(L.id) FROM pmgr_leases L
WHERE L.movein_date < '2009-10-01'
AND (L.moveout_date IS NULL OR L.moveout_date > '2009-09-01')
-- ----------------------------------------------------
-- Move-ins by month
SELECT MONTH(L.movein_date) AS mon, YEAR(L.movein_date) AS yr, COUNT(L.id)
FROM pmgr_leases L
WHERE L.movein_date >= '2009-04-01'
GROUP BY yr, mon
-- ----------------------------------------------------
-- Move-outs by month
SELECT MONTH(L.moveout_date) AS mon, YEAR(L.moveout_date) AS yr, COUNT(L.id)
FROM pmgr_leases L
WHERE L.moveout_date >= '2009-04-01'
GROUP BY yr, mon
-- ----------------------------------------------------
-- Move-ins/Move-outs by month
SELECT
MONTH(L.movein_date) AS mon, YEAR(L.movein_date) AS yr,
IF(L.movein_date AS mon, YEAR(L.movein_date) AS yr,
FROM pmgr_leases L
WHERE L.movein_date >= '2009-04-01'
GROUP BY yr, mon
-- ----------------------------------------------------
-- Rent charged
SELECT SUM(SE.amount)
FROM pmgr_statement_entries SE
LEFT JOIN pmgr_accounts A ON A.id = SE.account_id
WHERE A.name = 'Rent'
-- AND SE.effective_date >= '2009-04-01'
-- AND SE.effective_date < '2009-12-01'
-- --------------------------------------------------------------
-- Merge two customers
SELECT * FROM pmgr_statement_entries WHERE customer_id = 65
;
UPDATE pmgr_leases SET customer_id=21 WHERE customer_id=65;
UPDATE pmgr_reservations SET customer_id=21 WHERE customer_id=65;
UPDATE pmgr_statement_entries SET customer_id=21 WHERE customer_id=65;
UPDATE pmgr_tenders SET customer_id=21 WHERE customer_id=65;
UPDATE pmgr_transactions SET customer_id=21 WHERE customer_id=65;
-- Make sure to update customer info afterwards
-- --------------------------------------------------------------
-- Determine income from a customer
SELECT NT.name AS 'type', SUM(LE.amount) AS 'total'
FROM pmgr_tenders N
LEFT JOIN pmgr_tender_types NT ON NT.id = N.tender_type_id
LEFT JOIN pmgr_ledger_entries LE ON LE.id = N.ledger_entry_id
LEFT JOIN pmgr_customers C ON C.id = N.customer_id
WHERE
N.customer_id = 49
AND N.nsf_ledger_entry_id IS NULL
AND (NT.tillable OR NT.auto_deposit)
GROUP BY NT.name WITH ROLLUP
-- --------------------------------------------------------------
-- Determine rent charges by month
SELECT MONTH(SE.effective_date) AS 'mon',
YEAR(SE.effective_date) AS 'yr',
DATE_FORMAT(SE.effective_date, "%m/1/%Y") AS 'date',
SUM(SE.amount) AS 'total'
FROM pmgr_accounts A
LEFT JOIN pmgr_statement_entries SE ON SE.account_id = A.id
WHERE
A.name = 'Rent'
AND SE.effective_date < NOW()
GROUP BY yr, mon -- WITH ROLLUP

View File

@@ -1,3 +1,14 @@
Change the summary text "Balance Owed" to "Customer Credit"
or something similar when there is a negative balance owed.
Shrink the width of the detail view box so that the detail
and summary both fit on the same page on the Acer Netbook.
Remove Date from Ledger Entries on the Transaction page
(presuming that the Date is taken directly from the
Transaction and that all Ledger dates are all the same)
Add Deposit Slip # to the title bar when viewing deposit
Reversing a rent charge is not considered as part of the Reversing a rent charge is not considered as part of the
"charged-through" date on the lease. Consequently, the "charged-through" date on the lease. Consequently, the