Refactor category type to use enum
This commit is contained in:
parent
6ca505d505
commit
bdc2ca22f6
6 changed files with 22 additions and 15 deletions
|
|
@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|||
import { View, Text, StyleSheet } from 'react-native';
|
||||
import { useTheme } from '../../app/contexts/ThemeContext';
|
||||
import useFetch from '../../hooks/useFetch';
|
||||
import { CategoryType } from '../../services/database';
|
||||
|
||||
const BudgetOverview = () => {
|
||||
const { colors } = useTheme();
|
||||
|
|
@ -9,12 +10,12 @@ const BudgetOverview = () => {
|
|||
const [budget, setBudget] = useState(0);
|
||||
|
||||
const spentQuery = {
|
||||
sql: "SELECT SUM(e.amount) as total FROM expense e LEFT JOIN category c ON e.category_guid = c.guid WHERE c.type = 'budget'",
|
||||
sql: `SELECT SUM(e.amount) as total FROM expense e LEFT JOIN category c ON e.category_guid = c.guid WHERE c.type = '${CategoryType.EXPENSE.toString()}'`,
|
||||
args: []
|
||||
};
|
||||
|
||||
const budgetQuery = {
|
||||
sql: "SELECT SUM(allocated_amount) as total FROM category WHERE type = 'budget'",
|
||||
sql: `SELECT SUM(allocated_amount) as total FROM category WHERE type = '${CategoryType.EXPENSE.toString()}'`,
|
||||
args: []
|
||||
};
|
||||
|
||||
|
|
|
|||
Reference in a new issue