[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting AR reports from the past



Just replying to myself already:

This is where I'm at now:

koumbit-ls=# SELECT cu.name, a.invnumber, SUM(a.amount), SUM(c.amount)
FROM ar a JOIN customer cu ON (a.customer_id = cu.id) JOIN acc_trans c
ON c.trans_id = a.id  WHERE c.chart_id=10004 AND c.amount > 0 AND
c.transdate <= '2007-08-31' AND a.transdate <= '2007-08-31' GROUP BY
a.invnumber,cu.name  HAVING SUM(c.amount) <> SUM(a.amount) ORDER BY
cu.name;

(which basically "works")

The funniest thing happened then: I tried to verify those results
against the "Outstanding" AR report, and it came to my attention that
the Outstanding report did exactly what I needed (with some error margin
probably due to our dark Gnucash history).

I'm still curious to know what people think of my SQL or that problem in
general.

Thanks,

-- 
Marijuana grows naturally on the planet.
Mushrooms grows naturally on the planet.
Don't you think making nature against the law is a bit... unnatural?
                        - Bill Hicks

Attachment: signature.asc
Description: Digital signature