Add option to exclude member dues from transactions
This commit is contained in:
parent
247d224a52
commit
a529004ed0
|
@ -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()
|
||||
|
|
|
@ -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 (
|
||||
<div>
|
||||
|
@ -175,6 +180,13 @@ export function AdminHistoricalTransactions(props) {
|
|||
checked={excludeSnacks}
|
||||
/>
|
||||
|
||||
<Checkbox
|
||||
className='filter-option'
|
||||
label='Exclude Dues'
|
||||
onChange={handleExcludeDues}
|
||||
checked={excludeDues}
|
||||
/>
|
||||
|
||||
<TransactionList transactions={transactions} />
|
||||
</div>
|
||||
:
|
||||
|
|
Loading…
Reference in New Issue
Block a user