Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Fix Reports transactions breakdown (#309)

soky srm45e2f04d9e78
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index 495b13dfd9..2688d0b1e5 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -304,11 +304,13 @@ class ReportsController < ApplicationController
def build_transactions_breakdown
# Base query: all transactions in the period
+ # Exclude transfers, one-time, and CC payments (matching income_statement logic)
transactions = Transaction
.joins(:entry)
.joins(entry: :account)
.where(accounts: { family_id: Current.family.id, status: [ "draft", "active" ] })
.where(entries: { entryable_type: "Transaction", excluded: false, date: @period.date_range })
+ .where.not(kind: [ "funds_movement", "one_time", "cc_payment" ])
.includes(entry: :account, category: [])
# Apply filters
@@ -397,11 +399,13 @@ class ReportsController < ApplicationController
def build_transactions_breakdown_for_export
# Get flat transactions list (not grouped) for export
+ # Exclude transfers, one-time, and CC payments (matching income_statement logic)
transactions = Transaction
.joins(:entry)
.joins(entry: :account)
.where(accounts: { family_id: Current.family.id, status: [ "draft", "active" ] })
.where(entries: { entryable_type: "Transaction", excluded: false, date: @period.date_range })
+ .where.not(kind: [ "funds_movement", "one_time", "cc_payment" ])
.includes(entry: :account, category: [])
transactions = apply_transaction_filters(transactions)
@@ -432,11 +436,13 @@ class ReportsController < ApplicationController
end
# Get all transactions in the period
+ # Exclude transfers, one-time, and CC payments (matching income_statement logic)
transactions = Transaction
.joins(:entry)
.joins(entry: :account)
.where(accounts: { family_id: Current.family.id, status: [ "draft", "active" ] })
.where(entries: { entryable_type: "Transaction", excluded: false, date: @period.date_range })
+ .where.not(kind: [ "funds_movement", "one_time", "cc_payment" ])
.includes(entry: :account, category: [])
transactions = apply_transaction_filters(transactions)