__PACKAGE__->columns(Primary => 'id');
__PACKAGE__->columns(Essential => qw/xact_start usr xact_finish total_paid
last_payment_ts total_owed last_billing_ts
- balance_owed xact_type/);
+ balance_owed xact_type last_billing_note/);
#-------------------------------------------------------------------------------
package money::billing;
MAX(credit.payment_ts) AS last_payment_ts,
SUM(COALESCE(debit.amount,0)) AS total_owed,
MAX(debit.billing_ts) AS last_billing_ts,
+ COALESCE(debit.note,'') AS last_billing_note,
SUM(COALESCE(debit.amount,0) - COALESCE(credit.amount,0)) AS balance_owed,
p.relname AS xact_type
FROM money.billable_xact xact
LEFT JOIN money.billing debit ON (xact.id = debit.xact AND debit.voided IS FALSE)
LEFT JOIN money.payment credit ON (xact.id = credit.xact AND credit.voided IS FALSE)
WHERE xact.xact_finish IS NULL
- GROUP BY 1,2,3,4,10;
+ GROUP BY 1,2,3,4,9,11;
CREATE OR REPLACE VIEW money.usr_summary AS
SELECT usr,