money.materialized_summary_billing_del() ADDS to balance_owed

Bug #1319998 reported by Blake GH on 2014-05-15
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Undecided
Unassigned
2.8
Undecided
Unassigned
2.9
Undecided
Unassigned

Bug Description

This function is called when rows are deleted from money.billing. This has the unfortunate side affect of INCREASING the balance_owed. The total_owed however is correct. The code:

IF NOT OLD.voided THEN
  UPDATE money.materialized_billable_xact_summary
    SET total_owed = total_owed - OLD.amount,
   balance_owed = balance_owed + OLD.amount
    WHERE id = OLD.xact;
 END IF;

I suggest this as a fix:

IF NOT OLD.voided THEN
  UPDATE money.materialized_billable_xact_summary
    SET total_owed = total_owed - OLD.amount,
   balance_owed = balance_owed - OLD.amount
    WHERE id = OLD.xact;
 END IF;

Dan Wells (dbw2) wrote :

Looks like a bug to me as well; confirming.

The proposed fix looks right, too.

Changed in evergreen:
status: New → Confirmed
Blake GH (bmagic) wrote :
Changed in evergreen:
assignee: nobody → Blake GH (blake-j)
Kathy Lussier (klussier) on 2015-12-14
tags: added: pullrequest
Changed in evergreen:
assignee: Blake GH (blake-j) → Kathy Lussier (klussier)
Kathy Lussier (klussier) wrote :

Thanks Blake! The fix works as advertised and has been pushed to master, 2.9 and 2.8!

Changed in evergreen:
assignee: Kathy Lussier (klussier) → nobody
milestone: none → 2.next
status: Confirmed → Fix Committed
Changed in evergreen:
milestone: 2.next → 2.10-beta
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers