Project Report 09 43
Project Report 09 43
Degree Engineering in
Report Writing
Personal Finance
Submitted by
Sahil Patel(92100133009)
Heet Chothani(92100133043)
Information and Communication Technology
2023-24
CERTIFICATE
This is to certify that the project entitled Personal Finance has been carried
out by Sahil Patel(92100133009)and Heet Chothani(92100133043) under
my guidance in partial fulfillment of the degree of Bachelor Engineering in
Information and Communication Technology (6th Semester) of Marwadi
University, Rajkot during the academic year 2023-24.
Date : 03-05-2024
1 Project Description
2 Overview
3 Diagram
4 Output
5 Future Enhancement
Project Description:
➢ Debt Management
Understanding different types of debt.
Strategies for paying off high-interest debt.
Responsible use of credit cards.
transactions.forEach((transaction) => {
const monthYear = moment(transaction.date).format("MMM YYYY");
const tag = transaction.tag;
if (spendingData[tag]) {
spendingData[tag] += transaction.amount;
} else {
spendingData[tag] = transaction.amount;
}
}
});
useEffect(() => {
fetchTransactions();
}, []);
setTransactions([...transactions, newTransaction]);
setIsExpenseModalVisible(false);
setIsIncomeModalVisible(false);
addTransaction(newTransaction);
calculateBalance();
};
transactions.forEach((transaction) => {
if (transaction.type === "income") {
incomeTotal += transaction.amount;
} else {
expensesTotal += transaction.amount;
}
});
setIncome(incomeTotal);
setExpenses(expensesTotal);
setCurrentBalance(incomeTotal - expensesTotal);
};
useEffect(() => {
calculateBalance();
}, [transactions]);
const balanceConfig = {
data: balanceData,
xField: "month",
yField: "balance",
};
const spendingConfig = {
data: spendingDataArray,
angleField: "value",
colorField: "category",
};
function reset() {
console.log("resetting");
}
const cardStyle = {
boxShadow: "0px 0px 30px 8px rgba(3, 127, 127, 0.75)",
margin: "2rem",
borderRadius: "0.5rem",
minWidth: "400px",
flex: 1,
};
function exportToCsv() {
const csv = unparse(transactions, {
fields: ["name", "type", "date", "amount", "tag"],
});
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "transactions.csv";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
<AddExpenseModal
isExpenseModalVisible={isExpenseModalVisible}
handleExpenseCancel={handleExpenseCancel}
onFinish={onFinish}
/>
<AddIncomeModal
isIncomeModalVisible={isIncomeModalVisible}
handleIncomeCancel={handleIncomeCancel}
onFinish={onFinish}
/>
{transactions.length === 0 ? (
<NoTransactions />
):(
<>
<Row gutter={16}>
<Card bordered={true} style={cardStyle}>
<h2>Financial Statistics</h2>
<Line {...{ ...balanceConfig, data: balanceData }} />
</Card>
<Card bordered={true} style={{ ...cardStyle, flex: 0.45 }}>
<h2>Total Spending</h2>
{spendingDataArray.length == 0 ? (
<p>Seems like you haven't spent anything till now...</p>
):(
<Pie {...{ ...spendingConfig, data: spendingDataArray }} />
)}
</Card>
</Row>
</>
)}
<TransactionSearch
transactions={transactions}
exportToCsv={exportToCsv}
fetchTransactions={fetchTransactions}
addTransaction={addTransaction}
/>
{/* PDF Viewer */}
{isPDFVisible && (
<PDFViewer style={{ width: "100%", height: "100vh" }}>
<Document>
<Page size="A4" style={styles.page}>
<Text>Transaction History PDF</Text>
<TransactionTable />
</Page>
</Document>
</PDFViewer>
)}
Expenses Page:
import React, { useEffect, useRef, useState } from "react";
import styled from "styled-components";
import OverViewComponent from "./OverViewComponent";
import TransactionsComponent from "./TransactionsComponent";
import Chart from "chart.js/auto";
import { motion } from "framer-motion";
useEffect(() => {
const calculateBalance = () => {
let totalExpense = 0;
let totalIncome = 0;
transactions.forEach((transaction) => {
if (transaction.type === "EXPENSE") {
totalExpense += transaction.amount;
} else {
totalIncome += transaction.amount;
}
});
setExpense(totalExpense);
setIncome(totalIncome);
useEffect(() => {
if (chartRef.current) {
chartRef.current.destroy();
}
const ctx = document.getElementById("myChart");
chartRef.current = new Chart(ctx, {
type: "bar", // Change the chart type to bar
data: {
labels: ["Income", "Expense"],
datasets: [
{
label: "Amount",
data: [income, expense],
backgroundColor: [
"rgba(75, 192, 192, 0.2)",
"rgba(255, 99, 132, 0.2)",
],
borderColor: ["rgba(75, 192, 192, 1)", "rgba(255, 99, 132, 1)"],
borderWidth: 1,
},
],
},
options: {
scales: {
y: {
beginAtZero: true,
},
},
},
});
}, [income, expense]);
return (
<Container>
<OverViewComponent
expense={expense}
income={income}
addTransaction={addTransaction}
/>
{transactions.length > 0 && (
<TransactionsComponent transactions={transactions} />
)}
<ChartContainer id="myChart" />
<AlertContainer>
{showAlert && (
<motion.div
initial={{ opacity: 0, y: -50 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -50 }}
transition={{ duration: 0.5 }}
style={{
backgroundColor: "red",
color: "white",
padding: "10px 20px",
borderRadius: "8px",
boxShadow: "0px 4px 6px rgba(0, 0, 0, 0.1)",
}}
>
Expense exceeds income! Redirecting to dashboard...
</motion.div>
)}
</AlertContainer>
</Container>
);
};