Spaces:
Sleeping
Sleeping
Commit ·
531709d
1
Parent(s): 0f536b1
bilan
Browse files- src/streamlit_app.py +84 -31
- src/tcrg-rgat.csv +0 -0
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,93 @@
|
|
| 1 |
-
import altair as alt
|
| 2 |
-
import numpy as np
|
| 3 |
-
import pandas as pd
|
| 4 |
import streamlit as st
|
|
|
|
| 5 |
|
| 6 |
-
""
|
| 7 |
-
# Welcome to Streamlit!
|
| 8 |
|
| 9 |
-
|
| 10 |
-
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
|
| 11 |
-
forums](https://discuss.streamlit.io).
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
radius = indices
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
st.altair_chart(alt.Chart(df, height=700, width=700)
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
+
st.title("📘 Grand Livre Comptable")
|
|
|
|
| 5 |
|
| 6 |
+
df = pd.read_csv("src/tcrg-rgat.csv")
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Renommer les colonnes utiles
|
| 9 |
+
df = df.rename(columns={
|
| 10 |
+
"General-Ledger-Account-Code-Code-du-compte-du-grand-livre-général": "Compte_GL",
|
| 11 |
+
"Subleger-Account-Identifier-Compte_du_GL_auxiliaire": "Compte_auxiliaire",
|
| 12 |
+
"Journal-Voucher-Item-Amount-Montant-de-l'item-de-la-pièce-de-journal": "Montant",
|
| 13 |
+
"Credit/Debit-Code-Code-Crédit/Débit": "Type",
|
| 14 |
+
"Accounting-Effective-Date-Date-d'entrée-en-vigueur-comptable": "Date",
|
| 15 |
+
"Journal-Voucher-Item-Identifier-Identificateur-de-l'item-de-la-pièce-de-journal": "N°_pièce"
|
| 16 |
+
})
|
| 17 |
|
| 18 |
+
df = df[df["Compte_GL"].notna()]
|
| 19 |
+
df["Débit"] = df.apply(lambda row: row["Montant"] if row["Type"] == "D" else 0, axis=1)
|
| 20 |
+
df["Crédit"] = df.apply(lambda row: row["Montant"] if row["Type"] == "C" else 0, axis=1)
|
| 21 |
+
df["Date"] = pd.to_datetime(df["Date"])
|
| 22 |
+
df = df.sort_values("Date")
|
| 23 |
|
| 24 |
+
st.subheader("🧾 Écritures comptables")
|
| 25 |
+
st.dataframe(df[["Date", "Compte_GL", "Débit", "Crédit", "Montant", "Type", "N°_pièce"]])
|
|
|
|
| 26 |
|
| 27 |
+
st.subheader("📊 Résumé du Grand Livre")
|
| 28 |
+
resume = df.groupby("Compte_GL").agg({
|
| 29 |
+
"Débit": "sum",
|
| 30 |
+
"Crédit": "sum",
|
| 31 |
+
"Montant": "count"
|
| 32 |
+
}).rename(columns={"Montant": "Nombre_lignes"}).reset_index()
|
| 33 |
+
st.dataframe(resume)
|
| 34 |
|
| 35 |
+
# Export bouton
|
| 36 |
+
@st.cache_data
|
| 37 |
+
def convert_to_excel(df1, df2):
|
| 38 |
+
from io import BytesIO
|
| 39 |
+
output = BytesIO()
|
| 40 |
+
with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
|
| 41 |
+
df1.to_excel(writer, index=False, sheet_name='Ecritures')
|
| 42 |
+
df2.to_excel(writer, index=False, sheet_name='Résumé_GL')
|
| 43 |
+
return output.getvalue()
|
| 44 |
+
|
| 45 |
+
excel_bytes = convert_to_excel(df, resume)
|
| 46 |
+
st.download_button(
|
| 47 |
+
label="📥 Télécharger le fichier Excel",
|
| 48 |
+
data=excel_bytes,
|
| 49 |
+
file_name="grand_livre.xlsx",
|
| 50 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
# import altair as alt
|
| 55 |
+
# import numpy as np
|
| 56 |
+
# import pandas as pd
|
| 57 |
+
# import streamlit as st
|
| 58 |
+
|
| 59 |
+
# """
|
| 60 |
+
# # Welcome to Streamlit!
|
| 61 |
+
|
| 62 |
+
# Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
|
| 63 |
+
# If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
|
| 64 |
+
# forums](https://discuss.streamlit.io).
|
| 65 |
+
|
| 66 |
+
# In the meantime, below is an example of what you can do with just a few lines of code:
|
| 67 |
+
# """
|
| 68 |
+
|
| 69 |
+
# num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
|
| 70 |
+
# num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
|
| 71 |
+
|
| 72 |
+
# indices = np.linspace(0, 1, num_points)
|
| 73 |
+
# theta = 2 * np.pi * num_turns * indices
|
| 74 |
+
# radius = indices
|
| 75 |
+
|
| 76 |
+
# x = radius * np.cos(theta)
|
| 77 |
+
# y = radius * np.sin(theta)
|
| 78 |
+
|
| 79 |
+
# df = pd.DataFrame({
|
| 80 |
+
# "x": x,
|
| 81 |
+
# "y": y,
|
| 82 |
+
# "idx": indices,
|
| 83 |
+
# "rand": np.random.randn(num_points),
|
| 84 |
+
# })
|
| 85 |
|
| 86 |
+
# st.altair_chart(alt.Chart(df, height=700, width=700)
|
| 87 |
+
# .mark_point(filled=True)
|
| 88 |
+
# .encode(
|
| 89 |
+
# x=alt.X("x", axis=None),
|
| 90 |
+
# y=alt.Y("y", axis=None),
|
| 91 |
+
# color=alt.Color("idx", legend=None, scale=alt.Scale()),
|
| 92 |
+
# size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
|
| 93 |
+
# ))
|
src/tcrg-rgat.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|