Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,21 +2,6 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
import io
|
| 5 |
-
import pdfkit
|
| 6 |
-
|
| 7 |
-
def generate_pdf_report(expenses, income, remaining_balance):
|
| 8 |
-
html = f"""
|
| 9 |
-
<h1>Laporan Keuangan</h1>
|
| 10 |
-
<p><strong>Total Pemasukan:</strong> Rp {income:,}</p>
|
| 11 |
-
<p><strong>Total Pengeluaran:</strong> Rp {sum(expenses.values()):,}</p>
|
| 12 |
-
<p><strong>Sisa Saldo:</strong> Rp {remaining_balance:,}</p>
|
| 13 |
-
<h2>Detail Pengeluaran</h2>
|
| 14 |
-
<ul>
|
| 15 |
-
{''.join(f'<li>{category}: Rp {amount:,}</li>' for category, amount in expenses.items())}
|
| 16 |
-
</ul>
|
| 17 |
-
"""
|
| 18 |
-
pdfkit.from_string(html, "report.pdf")
|
| 19 |
-
return "report.pdf"
|
| 20 |
|
| 21 |
def main():
|
| 22 |
st.title("Financial Budget Planner 💰")
|
|
@@ -66,16 +51,8 @@ def main():
|
|
| 66 |
csv = df.to_csv(index=False).encode("utf-8")
|
| 67 |
st.download_button("Download CSV", csv, "laporan_keuangan.csv", "text/csv")
|
| 68 |
|
| 69 |
-
# Unduh laporan sebagai PDF
|
| 70 |
-
if st.button("Unduh Laporan PDF"):
|
| 71 |
-
pdf_path = generate_pdf_report(expenses, income, remaining_balance)
|
| 72 |
-
with open(pdf_path, "rb") as pdf_file:
|
| 73 |
-
pdf_bytes = pdf_file.read()
|
| 74 |
-
st.download_button("Download PDF", pdf_bytes, "laporan_keuangan.pdf", "application/pdf")
|
| 75 |
-
|
| 76 |
if __name__ == "__main__":
|
| 77 |
main()
|
| 78 |
|
| 79 |
|
| 80 |
-
#Saya telah menambahkan fitur untuk mengunduh laporan keuangan dalam format CSV dan PDF. Laporan akan mencakup pemasukan, total pengeluaran, sisa saldo, serta detail pengeluaran berdasarkan kategori.
|
| 81 |
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
import io
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def main():
|
| 7 |
st.title("Financial Budget Planner 💰")
|
|
|
|
| 51 |
csv = df.to_csv(index=False).encode("utf-8")
|
| 52 |
st.download_button("Download CSV", csv, "laporan_keuangan.csv", "text/csv")
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
if __name__ == "__main__":
|
| 55 |
main()
|
| 56 |
|
| 57 |
|
|
|
|
| 58 |
|