Spaces:
Sleeping
Sleeping
Upload 8 files
Browse files- embroidery.py +181 -8
- embroideryFullcolor.py +0 -1
- fullColor.py +0 -1
- screenPrint.py +0 -1
- screenprintFullcolor.py +0 -1
embroidery.py
CHANGED
|
@@ -9,6 +9,18 @@ def embroidery():
|
|
| 9 |
if "embroidery_entries" not in st.session_state:
|
| 10 |
st.session_state.embroidery_entries = []
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
col1, col2 = st.columns(2)
|
| 13 |
with col1:
|
| 14 |
brand_name = st.text_input("Brand Name", key="brand_name")
|
|
@@ -47,8 +59,8 @@ def embroidery():
|
|
| 47 |
net_value = unit_net_cost * quantity
|
| 48 |
|
| 49 |
|
| 50 |
-
if st.
|
| 51 |
-
if
|
| 52 |
total_selling_price = net_value / (1 - margin)
|
| 53 |
unit_selling_price = total_selling_price / quantity
|
| 54 |
entry = {
|
|
@@ -63,7 +75,27 @@ def embroidery():
|
|
| 63 |
"Unit Selling Price": f"${unit_selling_price:.2f}",
|
| 64 |
"Total Selling Price": f"${total_selling_price:.2f}"
|
| 65 |
}
|
| 66 |
-
st.session_state.embroidery_entries.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
if st.session_state.embroidery_entries:
|
|
@@ -81,17 +113,25 @@ def embroidery():
|
|
| 81 |
st.markdown(f"<div style='font-size: 16px;'>π Margin: <br><b>{entry['Margin']}</b></div><br>", unsafe_allow_html=True)
|
| 82 |
st.markdown(f"<div style='font-size: 16px;'>π Unit Price: <br><b>{entry['Unit Selling Price']}</b></div><br>", unsafe_allow_html=True)
|
| 83 |
st.markdown(f"<div style='font-size: 16px;'>π° Selling Price: <br><b>{entry['Total Selling Price']}</b></div><br>", unsafe_allow_html=True)
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
if st.button("π Reset Entries"):
|
| 89 |
-
st.session_state.
|
| 90 |
st.rerun()
|
| 91 |
|
| 92 |
entries = st.session_state.get("embroidery_entries", [])
|
| 93 |
if entries:
|
| 94 |
-
st.subheader("")
|
| 95 |
st.markdown("""
|
| 96 |
<style>
|
| 97 |
.excel-button {
|
|
@@ -135,6 +175,138 @@ def embroidery():
|
|
| 135 |
key="excel-download",
|
| 136 |
help="Download embroidery pricing breakdown as an Excel file"
|
| 137 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# html = """
|
| 139 |
# <html>
|
| 140 |
# <head>
|
|
@@ -202,3 +374,4 @@ def embroidery():
|
|
| 202 |
# </html>
|
| 203 |
# """
|
| 204 |
# st.components.v1.html(html, height=100)
|
|
|
|
|
|
| 9 |
if "embroidery_entries" not in st.session_state:
|
| 10 |
st.session_state.embroidery_entries = []
|
| 11 |
|
| 12 |
+
if "editing_index" not in st.session_state:
|
| 13 |
+
st.session_state.editing_index = None
|
| 14 |
+
|
| 15 |
+
if "temp_edit_data" in st.session_state:
|
| 16 |
+
temp = st.session_state.temp_edit_data
|
| 17 |
+
st.session_state.brand_name = temp["Brand Name"]
|
| 18 |
+
st.session_state.quote_date = pd.to_datetime(temp["Selected Date"])
|
| 19 |
+
st.session_state.quantity = temp["Quantity"]
|
| 20 |
+
st.session_state.stitch_count = temp["Stitch Count"]
|
| 21 |
+
st.session_state.item_price = float(temp["Net Cost (per unit)"].replace("$", "")) - float(temp["Stitch Price"].replace("$", ""))
|
| 22 |
+
del st.session_state.temp_edit_data
|
| 23 |
+
|
| 24 |
col1, col2 = st.columns(2)
|
| 25 |
with col1:
|
| 26 |
brand_name = st.text_input("Brand Name", key="brand_name")
|
|
|
|
| 59 |
net_value = unit_net_cost * quantity
|
| 60 |
|
| 61 |
|
| 62 |
+
if st.session_state.editing_index is not None:
|
| 63 |
+
if st.button("β
Update Entry"):
|
| 64 |
total_selling_price = net_value / (1 - margin)
|
| 65 |
unit_selling_price = total_selling_price / quantity
|
| 66 |
entry = {
|
|
|
|
| 75 |
"Unit Selling Price": f"${unit_selling_price:.2f}",
|
| 76 |
"Total Selling Price": f"${total_selling_price:.2f}"
|
| 77 |
}
|
| 78 |
+
st.session_state.embroidery_entries[st.session_state.editing_index] = entry
|
| 79 |
+
st.session_state.editing_index = None
|
| 80 |
+
st.rerun()
|
| 81 |
+
else:
|
| 82 |
+
if st.button("β Add Entry"):
|
| 83 |
+
if quantity and stitch_count and item_price:
|
| 84 |
+
total_selling_price = net_value / (1 - margin)
|
| 85 |
+
unit_selling_price = total_selling_price / quantity
|
| 86 |
+
entry = {
|
| 87 |
+
"Brand Name": brand_name,
|
| 88 |
+
"Selected Date": cur_date,
|
| 89 |
+
"Quantity": quantity,
|
| 90 |
+
"Stitch Count": stitch_count,
|
| 91 |
+
"Stitch Price": f"${stitch_price:.2f}",
|
| 92 |
+
"Net Cost (per unit)": f"${unit_net_cost:.2f}",
|
| 93 |
+
"Total Net Cost": f"${net_value:.2f}",
|
| 94 |
+
"Margin": margin_display,
|
| 95 |
+
"Unit Selling Price": f"${unit_selling_price:.2f}",
|
| 96 |
+
"Total Selling Price": f"${total_selling_price:.2f}"
|
| 97 |
+
}
|
| 98 |
+
st.session_state.embroidery_entries.append(entry)
|
| 99 |
|
| 100 |
|
| 101 |
if st.session_state.embroidery_entries:
|
|
|
|
| 113 |
st.markdown(f"<div style='font-size: 16px;'>π Margin: <br><b>{entry['Margin']}</b></div><br>", unsafe_allow_html=True)
|
| 114 |
st.markdown(f"<div style='font-size: 16px;'>π Unit Price: <br><b>{entry['Unit Selling Price']}</b></div><br>", unsafe_allow_html=True)
|
| 115 |
st.markdown(f"<div style='font-size: 16px;'>π° Selling Price: <br><b>{entry['Total Selling Price']}</b></div><br>", unsafe_allow_html=True)
|
| 116 |
+
edit_col, delete_col,_ = st.columns([2, 2, 2])
|
| 117 |
+
|
| 118 |
+
with edit_col:
|
| 119 |
+
if st.button(f"βοΈ", key=f"edit_{i}"):
|
| 120 |
+
st.session_state.editing_index = i
|
| 121 |
+
st.session_state.temp_edit_data = entry
|
| 122 |
+
st.rerun()
|
| 123 |
+
|
| 124 |
+
with delete_col:
|
| 125 |
+
if st.button(f"ποΈ", key=f"delete_{i}"):
|
| 126 |
+
del st.session_state.embroidery_entries[i]
|
| 127 |
+
st.rerun()
|
| 128 |
|
| 129 |
if st.button("π Reset Entries"):
|
| 130 |
+
st.session_state.embroidery_entries = []
|
| 131 |
st.rerun()
|
| 132 |
|
| 133 |
entries = st.session_state.get("embroidery_entries", [])
|
| 134 |
if entries:
|
|
|
|
| 135 |
st.markdown("""
|
| 136 |
<style>
|
| 137 |
.excel-button {
|
|
|
|
| 175 |
key="excel-download",
|
| 176 |
help="Download embroidery pricing breakdown as an Excel file"
|
| 177 |
)
|
| 178 |
+
|
| 179 |
+
# def embroidery():
|
| 180 |
+
# df = pd.DataFrame(emb_data)
|
| 181 |
+
# if "embroidery_entries" not in st.session_state:
|
| 182 |
+
# st.session_state.embroidery_entries = []
|
| 183 |
+
|
| 184 |
+
# col1, col2 = st.columns(2)
|
| 185 |
+
# with col1:
|
| 186 |
+
# brand_name = st.text_input("Brand Name", key="brand_name")
|
| 187 |
+
# with col2:
|
| 188 |
+
# cur_date = st.date_input("Date", value="today", key="quote_date")
|
| 189 |
+
|
| 190 |
+
# company_choice = st.selectbox("Select Company", list(emb_data.keys()), key="emb_company")
|
| 191 |
+
# if company_choice:
|
| 192 |
+
# df = pd.DataFrame(emb_data[company_choice])
|
| 193 |
+
# col1, col2, col3 = st.columns(3)
|
| 194 |
+
# with col1:
|
| 195 |
+
# quantity = st.number_input("Enter Quantity", min_value=1, step=1, key="quantity")
|
| 196 |
+
# with col2:
|
| 197 |
+
# stitch_count = st.multiselect(
|
| 198 |
+
# "Select Stitch Count",
|
| 199 |
+
# options=list(df.columns[1:]),
|
| 200 |
+
# key="stitch_count"
|
| 201 |
+
# )
|
| 202 |
+
# with col3:
|
| 203 |
+
# item_price = st.number_input('Item Cost (Fixed)', min_value=0.0, step=0.01, key="item_price")
|
| 204 |
+
# margin_percentage = st.number_input("Enter Margin (%)", min_value=1.0, max_value=99.0, step=0.1, value=40.0)
|
| 205 |
+
# margin = margin_percentage / 100 # Manual margin stored as decimal
|
| 206 |
+
# margin_display = f"{margin_percentage:.2f}%" # Display the exact selected percentage
|
| 207 |
+
|
| 208 |
+
# quantity_labels = df["Quantity"].tolist()
|
| 209 |
+
# selected_range = find_quantity_range(quantity, quantity_labels)
|
| 210 |
+
|
| 211 |
+
# if stitch_count:
|
| 212 |
+
# stitch_prices = df[df["Quantity"] == selected_range][stitch_count].values[0]
|
| 213 |
+
# stitch_price = float(sum(stitch_prices))
|
| 214 |
+
# else:
|
| 215 |
+
# stitch_price = 0.0
|
| 216 |
+
|
| 217 |
+
# net_value = quantity * (item_price + stitch_price)
|
| 218 |
+
# unit_net_cost = item_price + stitch_price
|
| 219 |
+
# net_value = unit_net_cost * quantity
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
# if st.button("β Add Entry"):
|
| 223 |
+
# if quantity and stitch_count and item_price:
|
| 224 |
+
# total_selling_price = net_value / (1 - margin)
|
| 225 |
+
# unit_selling_price = total_selling_price / quantity
|
| 226 |
+
# entry = {
|
| 227 |
+
# "Brand Name": brand_name,
|
| 228 |
+
# "Selected Date": cur_date,
|
| 229 |
+
# "Quantity": quantity,
|
| 230 |
+
# "Stitch Count": stitch_count,
|
| 231 |
+
# "Stitch Price": f"${stitch_price:.2f}",
|
| 232 |
+
# "Net Cost (per unit)": f"${unit_net_cost:.2f}",
|
| 233 |
+
# "Total Net Cost": f"${net_value:.2f}",
|
| 234 |
+
# "Margin": margin_display,
|
| 235 |
+
# "Unit Selling Price": f"${unit_selling_price:.2f}",
|
| 236 |
+
# "Total Selling Price": f"${total_selling_price:.2f}"
|
| 237 |
+
# }
|
| 238 |
+
# st.session_state.embroidery_entries.append(entry)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
# if st.session_state.embroidery_entries:
|
| 242 |
+
# #st.subheader(brand_name)
|
| 243 |
+
# st.markdown(f"<h4 style='color: #f1c40f';>{brand_name}</h4>", unsafe_allow_html=True)
|
| 244 |
+
# cols = st.columns(len(st.session_state.embroidery_entries))
|
| 245 |
+
# for i, (col, entry) in enumerate(zip(cols, st.session_state.embroidery_entries)):
|
| 246 |
+
# with col:
|
| 247 |
+
# #st.write(f"### Entry {i+1}")
|
| 248 |
+
# st.markdown(f"<h4 style='color: #d31145';>Entry {i+1}</h4><br>", unsafe_allow_html=True)
|
| 249 |
+
# st.markdown(f"<div style='font-size: 16px;'>π Quantity: <br><b>{entry['Quantity']}</b></div><br>", unsafe_allow_html=True)
|
| 250 |
+
# st.markdown(f"<div style='font-size: 16px;'>πͺ‘ Stitch Price: <br><b>{entry['Stitch Price']}</b></div><br>", unsafe_allow_html=True)
|
| 251 |
+
# st.markdown(f"<div style='font-size: 16px;'>πͺ Net Cost (per unit): <br><b>{entry['Net Cost (per unit)']}</b></div><br>", unsafe_allow_html=True)
|
| 252 |
+
# st.markdown(f"<div style='font-size: 16px;'>π° Total Net Cost: <br><b>{entry['Total Net Cost']}</b></div><br>", unsafe_allow_html=True)
|
| 253 |
+
# st.markdown(f"<div style='font-size: 16px;'>π Margin: <br><b>{entry['Margin']}</b></div><br>", unsafe_allow_html=True)
|
| 254 |
+
# st.markdown(f"<div style='font-size: 16px;'>π Unit Price: <br><b>{entry['Unit Selling Price']}</b></div><br>", unsafe_allow_html=True)
|
| 255 |
+
# st.markdown(f"<div style='font-size: 16px;'>π° Selling Price: <br><b>{entry['Total Selling Price']}</b></div><br>", unsafe_allow_html=True)
|
| 256 |
+
# if st.button(f"β Delete {i+1}", key=f"delete_{i}"):
|
| 257 |
+
# del st.session_state.embroidery_entries[i]
|
| 258 |
+
# st.rerun()
|
| 259 |
+
|
| 260 |
+
# if st.button("π Reset Entries"):
|
| 261 |
+
# st.session_state.entries = []
|
| 262 |
+
# st.rerun()
|
| 263 |
+
|
| 264 |
+
# entries = st.session_state.get("embroidery_entries", [])
|
| 265 |
+
# if entries:
|
| 266 |
+
# st.subheader("")
|
| 267 |
+
# st.markdown("""
|
| 268 |
+
# <style>
|
| 269 |
+
# .excel-button {
|
| 270 |
+
# background-color: #d31145;
|
| 271 |
+
# color: white;
|
| 272 |
+
# padding: 12px 24px;
|
| 273 |
+
# border: none;
|
| 274 |
+
# border-radius: 8px;
|
| 275 |
+
# font-size: 14px;
|
| 276 |
+
# font-weight: bold;
|
| 277 |
+
# cursor: pointer;
|
| 278 |
+
# transition: background-color 0.3s ease;
|
| 279 |
+
# box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
| 280 |
+
# }
|
| 281 |
+
# .excel-button:hover {
|
| 282 |
+
# background-color: #b80e3a;
|
| 283 |
+
# }
|
| 284 |
+
# </style>
|
| 285 |
+
# """, unsafe_allow_html=True)
|
| 286 |
+
# df = pd.DataFrame(entries)
|
| 287 |
+
# df = df[[
|
| 288 |
+
# 'Quantity', 'Stitch Price', 'Net Cost (per unit)', 'Total Net Cost',
|
| 289 |
+
# 'Margin', 'Unit Selling Price', 'Total Selling Price', 'Selected Date'
|
| 290 |
+
# ]]
|
| 291 |
+
# output = BytesIO()
|
| 292 |
+
# with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
|
| 293 |
+
# df.to_excel(writer, index=False, startrow=3, sheet_name='Embroidery Breakdown')
|
| 294 |
+
# workbook = writer.book
|
| 295 |
+
# worksheet = writer.sheets['Embroidery Breakdown']
|
| 296 |
+
# header_format = workbook.add_format({'bold': True, 'font_color': '#d31145', 'font_size': 14})
|
| 297 |
+
# worksheet.write('A1', brand_name, header_format)
|
| 298 |
+
# #worksheet.write('A2', cur_date)
|
| 299 |
+
# processed_data = output.getvalue()
|
| 300 |
+
# output.seek(0)
|
| 301 |
+
|
| 302 |
+
# st.download_button(
|
| 303 |
+
# label="π₯ Download Results as Excel",
|
| 304 |
+
# data=output,
|
| 305 |
+
# file_name='embroidery.xlsx',
|
| 306 |
+
# mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
| 307 |
+
# key="excel-download",
|
| 308 |
+
# help="Download embroidery pricing breakdown as an Excel file"
|
| 309 |
+
# )
|
| 310 |
# html = """
|
| 311 |
# <html>
|
| 312 |
# <head>
|
|
|
|
| 374 |
# </html>
|
| 375 |
# """
|
| 376 |
# st.components.v1.html(html, height=100)
|
| 377 |
+
|
embroideryFullcolor.py
CHANGED
|
@@ -90,7 +90,6 @@ def embFull():
|
|
| 90 |
|
| 91 |
entries = st.session_state.get("combined_entries", [])
|
| 92 |
if entries:
|
| 93 |
-
st.subheader("")
|
| 94 |
st.markdown("""
|
| 95 |
<style>
|
| 96 |
.excel-button {
|
|
|
|
| 90 |
|
| 91 |
entries = st.session_state.get("combined_entries", [])
|
| 92 |
if entries:
|
|
|
|
| 93 |
st.markdown("""
|
| 94 |
<style>
|
| 95 |
.excel-button {
|
fullColor.py
CHANGED
|
@@ -83,7 +83,6 @@ def fullColor():
|
|
| 83 |
|
| 84 |
entries = st.session_state.get("entries", [])
|
| 85 |
if entries:
|
| 86 |
-
st.subheader("")
|
| 87 |
st.markdown("""
|
| 88 |
<style>
|
| 89 |
.excel-button {
|
|
|
|
| 83 |
|
| 84 |
entries = st.session_state.get("entries", [])
|
| 85 |
if entries:
|
|
|
|
| 86 |
st.markdown("""
|
| 87 |
<style>
|
| 88 |
.excel-button {
|
screenPrint.py
CHANGED
|
@@ -104,7 +104,6 @@ def screenPrint():
|
|
| 104 |
|
| 105 |
entries = st.session_state.get("entries_screenprint", [])
|
| 106 |
if entries:
|
| 107 |
-
st.subheader("")
|
| 108 |
st.markdown("""
|
| 109 |
<style>
|
| 110 |
.excel-button {
|
|
|
|
| 104 |
|
| 105 |
entries = st.session_state.get("entries_screenprint", [])
|
| 106 |
if entries:
|
|
|
|
| 107 |
st.markdown("""
|
| 108 |
<style>
|
| 109 |
.excel-button {
|
screenprintFullcolor.py
CHANGED
|
@@ -116,7 +116,6 @@ def screenFull():
|
|
| 116 |
|
| 117 |
entries = st.session_state.get("screen_full_entries", [])
|
| 118 |
if entries:
|
| 119 |
-
st.subheader("")
|
| 120 |
st.markdown("""
|
| 121 |
<style>
|
| 122 |
.excel-button {
|
|
|
|
| 116 |
|
| 117 |
entries = st.session_state.get("screen_full_entries", [])
|
| 118 |
if entries:
|
|
|
|
| 119 |
st.markdown("""
|
| 120 |
<style>
|
| 121 |
.excel-button {
|