From a529004ed02a55510d53245bc642a2dd09c40705 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 20 Jun 2023 23:28:10 +0000 Subject: [PATCH] Add option to exclude member dues from transactions --- apiserver/apiserver/api/views.py | 4 ++++ webclient/src/AdminTransactions.js | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 15c04f9..1729c6c 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -509,6 +509,7 @@ class TransactionViewSet(Base, List, Create, Retrieve, Update): month = self.request.query_params.get('month', '') exclude_paypal = self.request.query_params.get('exclude_paypal', '') == 'true' exclude_snacks = self.request.query_params.get('exclude_snacks', '') == 'true' + exclude_dues = self.request.query_params.get('exclude_dues', '') == 'true' if self.action == 'list': if month: @@ -528,6 +529,9 @@ class TransactionViewSet(Base, List, Create, Retrieve, Update): if exclude_snacks: queryset = queryset.exclude(category='Snacks') + + if exclude_dues: + queryset = queryset.exclude(category='Membership') return queryset.order_by('-date', '-id') else: return queryset.all() diff --git a/webclient/src/AdminTransactions.js b/webclient/src/AdminTransactions.js index 8ae068e..65af646 100644 --- a/webclient/src/AdminTransactions.js +++ b/webclient/src/AdminTransactions.js @@ -51,6 +51,7 @@ export function AdminHistoricalTransactions(props) { const [summary, setSummary] = useState(summaryCache); const [excludePayPal, setExcludePayPal] = useState(false); const [excludeSnacks, setExcludeSnacks] = useState(true); + const [excludeDues, setExcludeDues] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(false); const isMobile = useIsMobile(); @@ -61,7 +62,7 @@ export function AdminHistoricalTransactions(props) { if (loading) return; setLoading(true); const month = input.month.format('YYYY-MM'); - requester('/transactions/?month=' + month + '&exclude_paypal=' + excludePayPal + '&exclude_snacks=' + excludeSnacks, 'GET', token) + requester('/transactions/?month=' + month + '&exclude_paypal=' + excludePayPal + '&exclude_snacks=' + excludeSnacks + '&exclude_dues=' + excludeDues, 'GET', token) .then(res => { setLoading(false); setError(false); @@ -100,9 +101,13 @@ export function AdminHistoricalTransactions(props) { setExcludeSnacks(v.checked); }; + const handleExcludeDues = (e, v) => { + setExcludeDues(v.checked); + }; + useEffect(() => { makeRequest(); - }, [excludePayPal, excludeSnacks]); + }, [excludePayPal, excludeSnacks, excludeDues]); return (
@@ -175,6 +180,13 @@ export function AdminHistoricalTransactions(props) { checked={excludeSnacks} /> + +
: