File size: 4,726 Bytes
246762d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d95b5b6
246762d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d95b5b6
246762d
 
 
 
 
d95b5b6
246762d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d95b5b6
246762d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import streamlit as st
import pandas as pd
import plotly.express as px
from datetime import datetime
import emoji

current_day = datetime.now().day

dataframe=""

def day_without_sunday():
    if current_day > 7:
        return current_day-1
    elif current_day > 14:
        return current_day-2
    elif current_day > 21:
        return current_day - 3
    else: return current_day-4


st.set_page_config(page_title="Rapport FDV",
                    page_icon=":bar_chart:",
                    layout="wide"
)

df = pd.read_excel(
    io="suivi.xlsx",
    engine="openpyxl",
    sheet_name=["TANGER","QUALI NV"],
    #skiprows=8,
    usecols="A:AC",
    #nrows=163,
)

# st.dataframe(df)
# ------Sidebar-------
st.sidebar.header("Filter:")
uploaded_file = st.sidebar.file_uploader("Choose a file")
if uploaded_file is not None:
    # To read file as bytes:
    # bytes_data = uploaded_file.getvalue()
    df = pd.read_excel(uploaded_file,
                                
                                engine="openpyxl",
                                sheet_name=["TANGER","QUALI NV"],     
                                usecols="A:AC",
                                nrows=163,

    )
    
quantitatif_df=df.get("TANGER")
qualitatif_df=df.get("QUALI NV")

    # st.write(bytes_data)
show_all_fdv = st.sidebar.checkbox('Tout les FDV')
vendeur = st.sidebar.multiselect(
    "Vendeur:",
    options=quantitatif_df["Vendeur"].unique(),
    default=quantitatif_df["Vendeur"][0],
    disabled=show_all_fdv
)



famille = st.sidebar.multiselect(
    "Famille:",
    options=quantitatif_df["Famille"].unique(),
    default=quantitatif_df["Famille"][6]
)


jour_travail = st.sidebar.text_input(
    label="Jour Travail", value=day_without_sunday())
jour_reste = st.sidebar.text_input(label="Jour Reste", value=24)




df_selection_quantitatif = quantitatif_df.query(
    "Vendeur== @vendeur & Famille==@famille"
)
df_select_qualitatif = qualitatif_df.query(
    "Vendeur== @vendeur" 
)


if show_all_fdv:
    df_selection_quantitatif = quantitatif_df.query(
        "Famille==@famille & Vendeur!='KHALIL HMER LEGHROUNE'  & Vendeur!='CDZ TANGER GROS' &Vendeur!='BAALAKI YOUSSEF' & Vendeur!='CDZ AGADIR DET2'& Vendeur!='VIDE' ", 
    )
df_selection_quantitatif = df_selection_quantitatif.astype({
    "REAL": "int",
    "OBJ": "int",
    "J-1": "int",
    "REAL.1": "int",
    '2021.1': "int",

})


st.dataframe(df_selection_quantitatif)
st.dataframe(df_select_qualitatif)


total_ht = int(df_selection_quantitatif["REAL"].sum())
total_ttc = round(total_ht*1.2)
min_ca = int(df_selection_quantitatif["REAL"].min())
min_ca_index = int(df_selection_quantitatif["REAL"].idxmin())

max_ca = int(df_selection_quantitatif["REAL"].max())
max_ca_index = int(df_selection_quantitatif["REAL"].idxmax())

objectif_ht = ((round(df_selection_quantitatif["OBJ"].sum()))*24/int(jour_travail))
objectif_ttc = round(objectif_ht*1.2)
rest_jour_ttc = round((objectif_ttc-(total_ttc))/int(jour_reste))
average_ttc = round(total_ttc/int(jour_travail))

moyenne_client_facture=round(int(df_select_qualitatif["CLT FACTURE"].sum())/ int(jour_travail))

col1, col2, col3, col4, col5,col6,col7,col8 = st.columns(8)
with col1:
    st.caption("Total HT",)
    st.subheader(f'{total_ht:,}')
with col2:
    st.caption("Total TTC")
    st.subheader(f'{total_ttc:,}')
with col3:
    st.caption("Objectif TTC")
    st.subheader(f'{objectif_ttc:,}')
with col4:
    st.caption("Rest jour TTC")
    st.subheader(f'{rest_jour_ttc:,}')
with col5:
    st.caption("ACM")
    st.subheader(f'{round(df_select_qualitatif["% vs Obj"].sum()*100):,}%')
with col6:
    st.caption("Moyenne TSM")
    st.subheader(moyenne_client_facture)
with col7:
    st.caption("Line /bl")
    st.subheader(f'{round(df_select_qualitatif["%"].sum()*100):,}%')
with col8:
    st.caption("TSM")
    st.subheader(f'{round(df_select_qualitatif["%.1"].sum()*100):,}%')
st.text(f"Maximum Réaliser : {max_ca:} ({quantitatif_df['Vendeur'][max_ca_index]:} {emoji.emojize(':1st_place_medal:')})")
st.text(f"Minimum Réaliser : {min_ca:} ({quantitatif_df['Vendeur'][min_ca_index]:} {emoji.emojize(':thumbs_down:')})")


vendeur_ca = (
    df_selection_quantitatif.groupby(by=["Vendeur"]).sum()[["REAL"]].sort_values(by="REAL")
)



fig_produit_sales = px.bar(
    vendeur_ca,
    x="REAL",
    y=vendeur_ca.index,
    orientation="h",
    title='<b>CA par Vendeur</b>',
    color_discrete_sequence=["#0083B8"] * len(vendeur_ca),
    template="plotly_white",
    color='REAL'
    
)
st.plotly_chart(fig_produit_sales)

hide_st_style = """
<style>

footer {visibility:hidden;}
header {visibility:hidden;}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)

print(moyenne_client_facture)