From 66ad8ec5d006e9ea120213f39493ea5dc4a45019 Mon Sep 17 00:00:00 2001
From: Jesse Luehrs <doy@tozt.net>
Date: Sat, 1 Feb 2020 01:33:57 -0500
Subject: add another view

---
 data/denorm.sql | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(limited to 'data/denorm.sql')

diff --git a/data/denorm.sql b/data/denorm.sql
index 915df09..fd0e273 100644
--- a/data/denorm.sql
+++ b/data/denorm.sql
@@ -1,3 +1,4 @@
+DROP VIEW IF EXISTS spending;
 DROP VIEW IF EXISTS future_transactions;
 DROP VIEW IF EXISTS denorm_scheduled_transactions;
 DROP VIEW IF EXISTS denorm_transactions;
@@ -316,3 +317,36 @@ CREATE VIEW future_transactions AS (
     WHERE
         date <= CURRENT_DATE + interval '2 years'
 );
+
+CREATE VIEW spending AS (
+    SELECT
+        id,
+        subtransaction_id,
+        date,
+        amount,
+        memo,
+        cleared,
+        approved,
+        flag_color,
+        account_id,
+        account,
+        payee_id,
+        payee,
+        category_group_id,
+        category_group,
+        category_id,
+        category
+    FROM
+        denorm_transactions LEFT JOIN categories ON (
+            denorm_transactions.category_id = categories.id
+        )
+    WHERE
+        amount < 0 AND
+        NOT categories.hidden AND
+        transfer_account_id IS NULL AND
+        category != 'Retirement' and
+        category != 'Income Tax' and
+        category != 'Donations' and
+        category != 'Family' and
+        category != 'Reimbursables'
+);
-- 
cgit v1.2.3-54-g00ecf

