Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -114,7 +114,21 @@ def generate_plan_id(user_data):
|
|
| 114 |
|
| 115 |
# Function to display saved records as a table and save to CSV
|
| 116 |
def display_saved_records():
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
df = pd.DataFrame(st.session_state.data)
|
| 119 |
|
| 120 |
if not df.empty:
|
|
@@ -132,13 +146,48 @@ def display_saved_records():
|
|
| 132 |
# Save DataFrame to CSV without index
|
| 133 |
df.to_csv(file_path, index=False)
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
# Function to load theme configuration
|
| 144 |
def load_theme_config():
|
|
@@ -348,7 +397,14 @@ if bundle_by == "Feature specific":
|
|
| 348 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
| 349 |
# Convert values to int if not None
|
| 350 |
max_value = int(max_value.strip()) if max_value else None
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
Usage = int(Usage.strip()) if Usage else None
|
| 353 |
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
|
| 354 |
|
|
@@ -404,13 +460,18 @@ if bundle_by == "Feature specific":
|
|
| 404 |
main()
|
| 405 |
|
| 406 |
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 411 |
-
user_input_1 = st.
|
| 412 |
-
|
| 413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
|
| 415 |
# 6th layer: Expected Billing
|
| 416 |
fee_reversal_options = ["RTO", "DTO", "Cancel"]
|
|
|
|
| 114 |
|
| 115 |
# Function to display saved records as a table and save to CSV
|
| 116 |
def display_saved_records():
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
html_content_5 = """
|
| 120 |
+
<h1 style='
|
| 121 |
+
color: #a689f6;
|
| 122 |
+
font-size: 25px;
|
| 123 |
+
background-image: -webkit-linear-gradient(0deg, #a689f6 3%, #272191 33%, #413bb9 61%);
|
| 124 |
+
background-clip: text;
|
| 125 |
+
-webkit-background-clip: text;
|
| 126 |
+
text-fill-color: transparent;
|
| 127 |
+
-webkit-text-fill-color: transparent;
|
| 128 |
+
'>Saved records</h1>
|
| 129 |
+
"""
|
| 130 |
+
|
| 131 |
+
st.markdown(html_content_5, unsafe_allow_html=True)
|
| 132 |
df = pd.DataFrame(st.session_state.data)
|
| 133 |
|
| 134 |
if not df.empty:
|
|
|
|
| 146 |
# Save DataFrame to CSV without index
|
| 147 |
df.to_csv(file_path, index=False)
|
| 148 |
|
| 149 |
+
button_styles = """
|
| 150 |
+
<style>
|
| 151 |
+
.stButton button {
|
| 152 |
+
color: #ffffff; /* Text color */
|
| 153 |
+
font-size: 20px;
|
| 154 |
+
background-image: linear-gradient(0deg, #a689f6 3%, #413bb9 61%);
|
| 155 |
+
border: none;
|
| 156 |
+
padding: 10px 20px;
|
| 157 |
+
cursor: pointer;
|
| 158 |
+
border-radius: 15px;
|
| 159 |
+
display: inline-block;
|
| 160 |
+
text-decoration: none;
|
| 161 |
+
text-align: center;
|
| 162 |
+
transition: background-color 0.3s ease;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.stButton button:hover {
|
| 166 |
+
background-color: #00ff00; /* Hover background color */
|
| 167 |
+
color: #ff0000; /* Hover text color */
|
| 168 |
+
}
|
| 169 |
+
</style>
|
| 170 |
+
"""
|
| 171 |
|
| 172 |
+
# Render custom CSS styles
|
| 173 |
+
st.markdown(button_styles, unsafe_allow_html=True)
|
| 174 |
+
|
| 175 |
+
# Define file path (replace with your actual file path)
|
| 176 |
+
file_path = os.path.join(folder_path, "records.csv")
|
| 177 |
+
|
| 178 |
+
# Function to read file data
|
| 179 |
+
def read_file(file_path):
|
| 180 |
+
with open(file_path, 'rb') as f:
|
| 181 |
+
file_data = f.read()
|
| 182 |
+
return file_data
|
| 183 |
+
|
| 184 |
+
# Download button with custom styling
|
| 185 |
+
st.download_button(
|
| 186 |
+
label="Download CSV",
|
| 187 |
+
data=read_file(file_path),
|
| 188 |
+
file_name="records.csv",
|
| 189 |
+
mime="text/csv",
|
| 190 |
+
)
|
| 191 |
|
| 192 |
# Function to load theme configuration
|
| 193 |
def load_theme_config():
|
|
|
|
| 397 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
| 398 |
# Convert values to int if not None
|
| 399 |
max_value = int(max_value.strip()) if max_value else None
|
| 400 |
+
user_input_11 = int(user_input.strip()) if user_input else None
|
| 401 |
+
try:
|
| 402 |
+
user_input_22 = float(user_input_11)
|
| 403 |
+
user_input = "{:.2f}".format(user_input_22)
|
| 404 |
+
except (TypeError, ValueError):
|
| 405 |
+
user_input = 0
|
| 406 |
+
|
| 407 |
+
|
| 408 |
Usage = int(Usage.strip()) if Usage else None
|
| 409 |
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
|
| 410 |
|
|
|
|
| 460 |
main()
|
| 461 |
|
| 462 |
|
| 463 |
+
user_input_3 = 0
|
| 464 |
+
|
|
|
|
| 465 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 466 |
+
user_input_1 = st.number_input("Enter Commercial value:",min_value=0.0, help = "Enter the Commercial value")
|
| 467 |
+
|
| 468 |
+
|
| 469 |
+
try:
|
| 470 |
+
user_input_2 = float(user_input_1)
|
| 471 |
+
user_input_3 = "{:.2f}".format(user_input_2)
|
| 472 |
+
except (TypeError, ValueError):
|
| 473 |
+
user_input_3 = 0
|
| 474 |
+
|
| 475 |
|
| 476 |
# 6th layer: Expected Billing
|
| 477 |
fee_reversal_options = ["RTO", "DTO", "Cancel"]
|