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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
from datetime import datetime
|
| 5 |
+
import emoji
|
| 6 |
+
|
| 7 |
+
current_day = datetime.now().day
|
| 8 |
+
|
| 9 |
+
dataframe=""
|
| 10 |
+
|
| 11 |
+
def day_without_sunday():
|
| 12 |
+
if current_day > 7:
|
| 13 |
+
return current_day-1
|
| 14 |
+
elif current_day > 14:
|
| 15 |
+
return current_day-2
|
| 16 |
+
elif current_day > 21:
|
| 17 |
+
return current_day - 3
|
| 18 |
+
else: return current_day-4
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
st.set_page_config(page_title="Rapport FDV",
|
| 22 |
+
page_icon=":bar_chart:",
|
| 23 |
+
layout="wide"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
df = pd.read_excel(
|
| 27 |
+
io="suivi.xlsx",
|
| 28 |
+
engine="openpyxl",
|
| 29 |
+
sheet_name=["AGADIR","QUALI NV"],
|
| 30 |
+
#skiprows=8,
|
| 31 |
+
usecols="A:AC",
|
| 32 |
+
#nrows=163,
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# st.dataframe(df)
|
| 36 |
+
# ------Sidebar-------
|
| 37 |
+
st.sidebar.header("Filter:")
|
| 38 |
+
uploaded_file = st.sidebar.file_uploader("Choose a file")
|
| 39 |
+
if uploaded_file is not None:
|
| 40 |
+
# To read file as bytes:
|
| 41 |
+
# bytes_data = uploaded_file.getvalue()
|
| 42 |
+
df = pd.read_excel(uploaded_file,
|
| 43 |
+
|
| 44 |
+
engine="openpyxl",
|
| 45 |
+
sheet_name=["AGADIR","QUALI NV"],
|
| 46 |
+
usecols="A:AC",
|
| 47 |
+
nrows=163,
|
| 48 |
+
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
quantitatif_df=df.get("AGADIR")
|
| 52 |
+
qualitatif_df=df.get("QUALI NV")
|
| 53 |
+
|
| 54 |
+
# st.write(bytes_data)
|
| 55 |
+
show_all_fdv = st.sidebar.checkbox('Tout les FDV')
|
| 56 |
+
vendeur = st.sidebar.multiselect(
|
| 57 |
+
"Vendeur:",
|
| 58 |
+
options=quantitatif_df["Vendeur"].unique(),
|
| 59 |
+
default=quantitatif_df["Vendeur"][0],
|
| 60 |
+
disabled=show_all_fdv
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
famille = st.sidebar.multiselect(
|
| 66 |
+
"Famille:",
|
| 67 |
+
options=quantitatif_df["Famille"].unique(),
|
| 68 |
+
default=quantitatif_df["Famille"][6]
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
jour_travail = st.sidebar.text_input(
|
| 73 |
+
label="Jour Travail", value=day_without_sunday())
|
| 74 |
+
jour_reste = st.sidebar.text_input(label="Jour Reste", value=24)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
df_selection_quantitatif = quantitatif_df.query(
|
| 80 |
+
"Vendeur== @vendeur & Famille==@famille"
|
| 81 |
+
)
|
| 82 |
+
df_select_qualitatif = qualitatif_df.query(
|
| 83 |
+
"Vendeur== @vendeur"
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
if show_all_fdv:
|
| 88 |
+
df_selection_quantitatif = quantitatif_df.query(
|
| 89 |
+
"Famille==@famille & Vendeur!='SOUATI NOUREDDINE' & Vendeur!='CDZ AGADIR GROS' &Vendeur!='CHAKIB ELFIL' & Vendeur!='CDZ AGADIR DET2'& Vendeur!='VIDE' ",
|
| 90 |
+
)
|
| 91 |
+
df_selection_quantitatif = df_selection_quantitatif.astype({
|
| 92 |
+
"REAL": "int",
|
| 93 |
+
"OBJ": "int",
|
| 94 |
+
"J-1": "int",
|
| 95 |
+
"REAL.1": "int",
|
| 96 |
+
'2021.1': "int",
|
| 97 |
+
|
| 98 |
+
})
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
st.dataframe(df_selection_quantitatif)
|
| 102 |
+
st.dataframe(df_select_qualitatif)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
total_ht = int(df_selection_quantitatif["REAL"].sum())
|
| 106 |
+
total_ttc = round(total_ht*1.2)
|
| 107 |
+
min_ca = int(df_selection_quantitatif["REAL"].min())
|
| 108 |
+
min_ca_index = int(df_selection_quantitatif["REAL"].idxmin())
|
| 109 |
+
|
| 110 |
+
max_ca = int(df_selection_quantitatif["REAL"].max())
|
| 111 |
+
max_ca_index = int(df_selection_quantitatif["REAL"].idxmax())
|
| 112 |
+
|
| 113 |
+
objectif_ht = ((round(df_selection_quantitatif["OBJ"].sum()))*24/int(jour_travail))
|
| 114 |
+
objectif_ttc = round(objectif_ht*1.2)
|
| 115 |
+
rest_jour_ttc = round((objectif_ttc-(total_ttc))/int(jour_reste))
|
| 116 |
+
average_ttc = round(total_ttc/int(jour_travail))
|
| 117 |
+
|
| 118 |
+
moyenne_client_facture=round(int(df_select_qualitatif["CLT FACTURE"].sum())/ int(jour_travail))
|
| 119 |
+
|
| 120 |
+
col1, col2, col3, col4, col5,col6,col7,col8 = st.columns(8)
|
| 121 |
+
with col1:
|
| 122 |
+
st.caption("Total HT",)
|
| 123 |
+
st.subheader(f'{total_ht:,}')
|
| 124 |
+
with col2:
|
| 125 |
+
st.caption("Total TTC")
|
| 126 |
+
st.subheader(f'{total_ttc:,}')
|
| 127 |
+
with col3:
|
| 128 |
+
st.caption("Objectif TTC")
|
| 129 |
+
st.subheader(f'{objectif_ttc:,}')
|
| 130 |
+
with col4:
|
| 131 |
+
st.caption("Rest jour TTC")
|
| 132 |
+
st.subheader(f'{rest_jour_ttc:,}')
|
| 133 |
+
with col5:
|
| 134 |
+
st.caption("ACM")
|
| 135 |
+
st.subheader(f'{round(df_select_qualitatif["% vs Obj"].sum()*100):,}%')
|
| 136 |
+
with col6:
|
| 137 |
+
st.caption("Moyenne TSM")
|
| 138 |
+
st.subheader(moyenne_client_facture)
|
| 139 |
+
with col7:
|
| 140 |
+
st.caption("Line /bl")
|
| 141 |
+
st.subheader(f'{round(df_select_qualitatif["%"].sum()*100):,}%')
|
| 142 |
+
with col8:
|
| 143 |
+
st.caption("TSM")
|
| 144 |
+
st.subheader(f'{round(df_select_qualitatif["%.1"].sum()*100):,}%')
|
| 145 |
+
st.text(f"Maximum Réaliser : {max_ca:} ({quantitatif_df['Vendeur'][max_ca_index]:} {emoji.emojize(':1st_place_medal:')})")
|
| 146 |
+
st.text(f"Minimum Réaliser : {min_ca:} ({quantitatif_df['Vendeur'][min_ca_index]:} {emoji.emojize(':thumbs_down:')})")
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
vendeur_ca = (
|
| 150 |
+
df_selection_quantitatif.groupby(by=["Vendeur"]).sum()[["REAL"]].sort_values(by="REAL")
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
fig_produit_sales = px.bar(
|
| 156 |
+
vendeur_ca,
|
| 157 |
+
x="REAL",
|
| 158 |
+
y=vendeur_ca.index,
|
| 159 |
+
orientation="h",
|
| 160 |
+
title='<b>CA par Vendeur</b>',
|
| 161 |
+
color_discrete_sequence=["#0083B8"] * len(vendeur_ca),
|
| 162 |
+
template="plotly_white",
|
| 163 |
+
color='REAL'
|
| 164 |
+
|
| 165 |
+
)
|
| 166 |
+
st.plotly_chart(fig_produit_sales)
|
| 167 |
+
|
| 168 |
+
hide_st_style = """
|
| 169 |
+
<style>
|
| 170 |
+
|
| 171 |
+
footer {visibility:hidden;}
|
| 172 |
+
header {visibility:hidden;}
|
| 173 |
+
</style>
|
| 174 |
+
"""
|
| 175 |
+
st.markdown(hide_st_style, unsafe_allow_html=True)
|
| 176 |
+
|
| 177 |
+
print(moyenne_client_facture)
|
requirements.txt
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
altair==4.2.0
|
| 2 |
+
attrs==22.1.0
|
| 3 |
+
blinker==1.5
|
| 4 |
+
cachetools==5.2.0
|
| 5 |
+
certifi==2022.9.24
|
| 6 |
+
charset-normalizer==2.1.1
|
| 7 |
+
click==8.1.3
|
| 8 |
+
commonmark==0.9.1
|
| 9 |
+
decorator==5.1.1
|
| 10 |
+
docopt==0.6.2
|
| 11 |
+
emoji==2.2.0
|
| 12 |
+
entrypoints==0.4
|
| 13 |
+
et-xmlfile==1.1.0
|
| 14 |
+
gitdb==4.0.9
|
| 15 |
+
GitPython==3.1.29
|
| 16 |
+
idna==3.4
|
| 17 |
+
importlib-metadata==5.0.0
|
| 18 |
+
Jinja2==3.1.2
|
| 19 |
+
jsonschema==4.17.0
|
| 20 |
+
MarkupSafe==2.1.1
|
| 21 |
+
numpy==1.23.4
|
| 22 |
+
openpyxl==3.0.10
|
| 23 |
+
packaging==21.3
|
| 24 |
+
pandas==1.5.1
|
| 25 |
+
Pillow==9.3.0
|
| 26 |
+
pipreqs==0.4.11
|
| 27 |
+
plotly==5.11.0
|
| 28 |
+
protobuf==3.20.3
|
| 29 |
+
pyarrow==10.0.0
|
| 30 |
+
pydeck==0.8.0
|
| 31 |
+
Pygments==2.13.0
|
| 32 |
+
Pympler==1.0.1
|
| 33 |
+
pyparsing==3.0.9
|
| 34 |
+
pyrsistent==0.19.2
|
| 35 |
+
python-dateutil==2.8.2
|
| 36 |
+
pytz==2022.6
|
| 37 |
+
pytz-deprecation-shim==0.1.0.post0
|
| 38 |
+
requests==2.28.1
|
| 39 |
+
rich==12.6.0
|
| 40 |
+
semver==2.13.0
|
| 41 |
+
six==1.16.0
|
| 42 |
+
smmap==5.0.0
|
| 43 |
+
streamlit==1.14.0
|
| 44 |
+
tenacity==8.1.0
|
| 45 |
+
toml==0.10.2
|
| 46 |
+
toolz==0.12.0
|
| 47 |
+
tornado==6.2
|
| 48 |
+
typing_extensions==4.4.0
|
| 49 |
+
tzdata==2022.6
|
| 50 |
+
tzlocal==4.2
|
| 51 |
+
urllib3==1.26.12
|
| 52 |
+
validators==0.20.0
|
| 53 |
+
yarg==0.1.9
|
| 54 |
+
zipp==3.10.0
|