import streamlit as st import pandas as pd from utils import * from data import * from io import BytesIO def screenFull(): if "screen_full_entries" not in st.session_state: st.session_state.screen_full_entries = [] col1, col2 = st.columns(2) with col1: brand_name = st.text_input("Brand Name", key="brand_name") with col2: cur_date = st.date_input("Date", value="today", key="quote_date") # Select Companies sp_company = st.selectbox("Select Screen Print Company", list(screen_data.keys()), key="combo_screen_full_sp_company") fc_company = st.selectbox("Select Full Colour Company", list(full_data.keys()), key="combo_screen_full_fc_company") sp_data = screen_data[sp_company] df_fc = pd.DataFrame(full_data[fc_company]) col1, col2, col3 = st.columns(3) with col1: selected_type = st.selectbox("Print Type", list(sp_data.keys()), key="combo_screen_full_print_type") with col2: selected_size = st.selectbox("Print Size", list(sp_data[selected_type].columns[1:4]), key="combo_screen_full_print_size") with col3: selected_options = st.multiselect("Options", ["Darks", "Fleece", "90% Poly+", "Sleeves & Legs"], key="combo_screen_full_options") col4, col5, col6 = st.columns(3) with col4: print_area = st.selectbox("Full Colour Print", list(df_fc.columns[1:]), key="combo_screen_full_print_area") with col5: quantity = st.number_input("Enter Quantity", min_value=1, step=1, key="combo_screen_full_quantity") with col6: item_price = st.number_input("Item Cost (Fixed)", min_value=0.0, step=0.01, key="combo_screen_full_item_price") # Calculate Prices # --- Screen Print --- sp_df = sp_data[selected_type] sp_range = next((row["Qty"] for _, row in sp_df.iterrows() if quantity <= int(row["Qty"].split()[-1])), sp_df.iloc[-1]["Qty"]) sp_row = sp_df[sp_df["Qty"] == sp_range] sp_base_price = sp_row[selected_size].values[0] if not sp_row.empty else 0.0 sp_option_cost = sum(sp_row[opt].values[0] for opt in selected_options if opt in sp_row) if not sp_row.empty else 0.0 sp_total_price = sp_base_price + sp_option_cost # --- Full Color --- quantity_labels_fc = df_fc["Quantity"].tolist() fc_range = find_quantity_range(quantity, quantity_labels_fc) fc_print_price = float(df_fc[df_fc["Quantity"] == fc_range][print_area].values[0]) total_deco_price = sp_total_price + fc_print_price net_value = quantity * (item_price + total_deco_price) unit_net_cost = item_price + total_deco_price net_value = unit_net_cost * quantity margin_percentage = st.number_input("Enter Margin (%)", min_value=1.0, max_value=99.0, step=0.1, value=40.0, key="combo_screen_full_margin_val") margin = margin_percentage / 100 margin_display = f"{margin_percentage:.2f}%" total_selling_price = net_value / (1 - margin) unit_selling_price = total_selling_price / quantity # Add Entry if st.button("➕ Add Entry", key="add_screen_full_entry"): entry = { "Brand Name": brand_name, "Selected Date": cur_date, "Quantity": quantity, "Print Type": selected_type, "Print Size": selected_size, "SP Base Price": f"${sp_base_price:.2f}", "SP Options": ", ".join(selected_options) if selected_options else "None", "SP Option Price": f"${sp_option_cost:.2f}", "SP Total Price": f"${sp_total_price:.2f}", "Full Colour Area": print_area, "FC Price": f"${fc_print_price:.2f}", "Total Decoration Cost": f"${total_deco_price:.2f}", "Item Cost": f"${item_price:.2f}", "Net Cost (per unit)": f"${unit_net_cost:.2f}", "Total Net Cost": f"${net_value:,.2f}", "Margin": margin_display, "Unit Selling Price": f"${unit_selling_price:.2f}", "Total Selling Price": f"${total_selling_price:.2f}" } st.session_state.screen_full_entries.append(entry) # Display Breakdown if st.session_state.screen_full_entries: #st.subheader("Pricing Breakdown") st.markdown(f"