Payment by Type, Previous Month

For users or potential users.
Post Reply
KevinRossen
Posts: 293
Joined: Mon Apr 22, 2013 8:49 am
Location: Dallas, TX
Contact:

Payment by Type, Previous Month

Post by KevinRossen » Tue Mar 17, 2015 1:23 pm

I wrote this query today and thought others might find it useful. It returns all payments from the previous month by date and payment type. Let me know if you have any questions:

EDIT: 3/19-Changed the query to work nicely with replication

Code: Select all

SET @SetDate=DATE_FORMAT(CURDATE()-INTERVAL 1 MONTH, '%y-%m');
-- Default month in prior month. Change above line to change date range
-- Example for current month: SET @SetDate=DATE_FORMAT(CURDATE(), '%y-%m');
-- Example for specific month: SET @SetDate=DATE_FORMAT('2014-12-01', '%y-%m');
SELECT 
	p.PayDate,
	d.ItemName AS PayType,
	ROUND(SUM(p.PayAmt),2) AS $Total
FROM payment p
LEFT JOIN definition d ON p.PayType=d.DefNum
WHERE DATE_FORMAT(p.PayDate, '%y-%m')=@SetDate AND p.PayType<>0
GROUP BY p.PayDate,d.ItemName
UNION
SELECT 
	DATE(cp.DateCP) AS PayDate,
	'InsPay' AS PayType,
	ROUND(SUM(cp.InsPayAmt),2) AS $InsTotal
FROM claimproc cp
INNER JOIN claimpayment cpay ON cpay.ClaimPaymentNum=cp.ClaimPaymentNum
WHERE DATE_FORMAT(cp.DateCP, '%y-%m')=@SetDate
GROUP BY PayDate
ORDER BY PayDate, PayType;
Last edited by KevinRossen on Thu Mar 19, 2015 7:46 am, edited 1 time in total.
Kevin Rossen
Office Manager, Rossen Dental
Founder, DivergentDental.com
Image

allends
Posts: 240
Joined: Fri Aug 23, 2013 11:29 am

Re: Payment by Type, Previous Month

Post by allends » Tue Mar 17, 2015 3:16 pm

For any customers on 15.1, the Payments report will now give you the payments grouped by payment type and ordered by date.
Allen
Open Dental Software
http://www.opendental.com

KevinRossen
Posts: 293
Joined: Mon Apr 22, 2013 8:49 am
Location: Dallas, TX
Contact:

Re: Payment by Type, Previous Month

Post by KevinRossen » Tue Mar 17, 2015 3:40 pm

Nice! I just built 15.1 last night from source on my test system, so I haven't had time to play with it yet. That's a nice update!
Kevin Rossen
Office Manager, Rossen Dental
Founder, DivergentDental.com
Image

Post Reply