Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,9 @@ celerybeat-schedule
dmypy.json

# Pyre type checker
.pyre/
.pyre/

db.sqlite3
accounts/test/test_view.py
userincome/test/test_view.py

8 changes: 3 additions & 5 deletions ExpenseTracker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'main',
'accounts',
'userincome',
'expenses',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -90,11 +91,8 @@
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME'),
'USER': os.environ.get('DB_USER'),
'PASSWORD': os.environ.get('DB_USER_PASSWORD'),
'HOST': os.environ.get('DB_HOST'),
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

Expand Down
49 changes: 49 additions & 0 deletions ExpenseTracker/static/js/searchExp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const searchField = document.querySelector("#searchField");

const tableOutput = document.querySelector(".table-output");
const appTable = document.querySelector(".app-table");
const paginationContainer = document.querySelector(".pagination-container");
tableOutput.style.display = "none";
const noResults = document.querySelector(".no-results");
const tbody = document.querySelector(".table-body");

searchField.addEventListener("keyup", (e) => {
const searchValue = e.target.value;

if (searchValue.trim().length > 0) {
paginationContainer.style.display = "none";
tbody.innerHTML = "";
fetch("search-expenses", {
body: JSON.stringify({ searchText: searchValue }),
method: "POST",
})
.then((res) => res.json())
.then((data) => {
console.log("data", data);
appTable.style.display = "none";
tableOutput.style.display = "block";

console.log("data.length", data.length);

if (data.length === 0) {
noResults.style.display = "block";
tableOutput.style.display = "none";
} else {
noResults.style.display = "none";
data.forEach((item) => {
tbody.innerHTML += `
<tr>
<td>${item.amount}</td>
<td>${item.category}</td>
<td>${item.description}</td>
<td>${item.date}</td>
</tr>`;
});
}
});
} else {
tableOutput.style.display = "none";
appTable.style.display = "block";
paginationContainer.style.display = "block";
}
});
161 changes: 161 additions & 0 deletions ExpenseTracker/static/js/stat_exp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// // const renderChart = (data, labels) => {
// // var ctx = document.getElementById("myChart").getContext("2d");
// // var myChart = new Chart(ctx, {
// // type: "doughnut",
// // data: {
// // labels: labels,
// // datasets: [
// // {
// // label: "Last 6 months expenses",
// // data: data,
// // backgroundColor: [
// // "rgba(255, 99, 132, 0.2)",
// // "rgba(54, 162, 235, 0.2)",
// // "rgba(255, 206, 86, 0.2)",
// // "rgba(75, 192, 192, 0.2)",
// // "rgba(153, 102, 255, 0.2)",
// // "rgba(255, 159, 64, 0.2)",
// // ],
// // borderColor: [
// // "rgba(255, 99, 132, 1)",
// // "rgba(54, 162, 235, 1)",
// // "rgba(255, 206, 86, 1)",
// // "rgba(75, 192, 192, 1)",
// // "rgba(153, 102, 255, 1)",
// // "rgba(255, 159, 64, 1)",
// // ],
// // borderWidth: 1,
// // },
// // ],
// // },
// // options: {
// // title: {
// // display: true,
// // text: "Expenses per category",
// // },
// // },
// // });
// // };

// // const getChartData = () => {
// // console.log("fetching");
// // fetch("/expense_category_summary")
// // .then((res) => res.json())
// // .then((results) => {
// // console.log("results", results);
// // const category_data = results.expense_category_data;
// // const [labels, data] = [
// // Object.keys(category_data),
// // Object.values(category_data),
// // ];

// // renderChart(data, labels);
// // });
// // };

// // document.onload = getChartData();







// var ctx = document.getElementById('myChart').getContext('2d');
// var myChart = new Chart(ctx, {
// type: 'bar',
// data: {
// labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
// datasets: [{
// label: '# of Votes',
// data: [12, 19, 3, 5, 2, 3],
// backgroundColor: [
// 'rgba(255, 99, 132, 0.2)',
// 'rgba(54, 162, 235, 0.2)',
// 'rgba(255, 206, 86, 0.2)',
// 'rgba(75, 192, 192, 0.2)',
// 'rgba(153, 102, 255, 0.2)',
// 'rgba(255, 159, 64, 0.2)'
// ],
// borderColor: [
// 'rgba(255, 99, 132, 1)',
// 'rgba(54, 162, 235, 1)',
// 'rgba(255, 206, 86, 1)',
// 'rgba(75, 192, 192, 1)',
// 'rgba(153, 102, 255, 1)',
// 'rgba(255, 159, 64, 1)'
// ],
// borderWidth: 1
// }]
// },
// options: {
// scales: {
// y: {
// beginAtZero: true
// }
// }
// }
// });



const renderChart = (data, labels) => {
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, {
type: "pie",
data: {
labels: labels,
datasets: [
{
label: "Last 6 months expenses",
data: data,
backgroundColor: [
"rgba(255, 99, 132, 0.2)",
"rgba(54, 162, 235, 0.2)",
"rgba(255, 206, 86, 0.2)",
"rgba(75, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(255, 159, 64, 0.2)",
],
borderColor: [
"rgba(255, 99, 132, 1)",
"rgba(54, 162, 235, 1)",
"rgba(255, 206, 86, 1)",
"rgba(75, 192, 192, 1)",
"rgba(153, 102, 255, 1)",
"rgba(255, 159, 64, 1)",
],
borderWidth: 1,
},
],

},
options: {
title: {
display: true,
text: "Expenses per category",
},
},
});
};

const getChartData = () => {
// console.log("fetching");
fetch("expense_category_summary")
.then((res) => res.json())
.then((results) => {
console.log("results", results);
const category_data = results.expense_category_data;
const [labels, data] = [
Object.keys(category_data),
Object.values(category_data),
];

renderChart(data, labels);
});
};

document.onload = getChartData();



64 changes: 64 additions & 0 deletions ExpenseTracker/static/js/static.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@


const renderChart = (data, labels) => {
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, {

type: "pie",
data: {
labels: labels,
datasets: [
{
label: "Last 6 months expenses",
data: data,
backgroundColor: [
"rgba(255, 99, 132, 0.2)",
"rgba(54, 162, 235, 0.2)",
"rgba(255, 206, 86, 0.2)",
"rgba(75, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(255, 159, 64, 0.2)",
],
borderColor: [
"rgba(255, 99, 132, 1)",
"rgba(54, 162, 235, 1)",
"rgba(255, 206, 86, 1)",
"rgba(75, 192, 192, 1)",
"rgba(153, 102, 255, 1)",
"rgba(255, 159, 64, 1)",
],
borderWidth: 1,
},
],

},
options: {
title: {
display: true,
text: "Incomes per Sources",
},
},
});
};

const getChartData = () => {
// console.log("fetching");
fetch("income_source_summary")
.then((res) => res.json())
.then((results) => {
console.log("results", results);
const category_data = results.income_source_data;
const [labels, data] = [
Object.keys(category_data),
Object.values(category_data),
];

renderChart(data, labels);
});
};

document.onload = getChartData();




45 changes: 45 additions & 0 deletions ExpenseTracker/static/js/statics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@




var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});






1 change: 1 addition & 0 deletions ExpenseTracker/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
path('', include('main.urls')),
path('auth/', include('accounts.urls')),
path('income/', include('userincome.urls')),
path('expenses/', include('expenses.urls')),
]
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pycodestyle = "*"
gunicorn = "*"
django-heroku = "*"
whitenoise = "*"
coverage = "*"

[requires]
python_version = "3.7"
Loading