money.materialized_summary_billing_del() ADDS to balance_owed

Bug #1319998 reported by Blake GH
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Undecided
Unassigned
2.8
Fix Released
Undecided
Unassigned
2.9
Fix Released
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;

Tags: pullrequest
Revision history for this message
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
Revision history for this message
Blake GH (bmagic) wrote :
Changed in evergreen:
assignee: nobody → Blake GH (blake-j)
Revision history for this message
Blake GH (bmagic) wrote :
Kathy Lussier (klussier)
tags: added: pullrequest
Changed in evergreen:
assignee: Blake GH (blake-j) → Kathy Lussier (klussier)
Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.