60 lines
No EOL
1.7 KiB
Python
60 lines
No EOL
1.7 KiB
Python
import streamlit as st
|
|
from trial_balance_parser import parse_trial_balance_to_excel
|
|
|
|
|
|
st.set_page_config(
|
|
page_title="MEDITECH Detail Trial Balance Parser",
|
|
page_icon="📄",
|
|
layout="wide",
|
|
)
|
|
|
|
|
|
st.title("MEDITECH Detail Trial Balance Parser")
|
|
|
|
st.write(
|
|
"Upload a MEDITECH Detail Trial Balance PDF and export the parsed transactions "
|
|
"and account summary to Excel."
|
|
)
|
|
|
|
uploaded_file = st.file_uploader(
|
|
"Upload Trial Balance PDF",
|
|
type=["pdf"],
|
|
)
|
|
|
|
if uploaded_file is not None:
|
|
st.info(f"Uploaded file: {uploaded_file.name}")
|
|
|
|
if st.button("Parse PDF"):
|
|
try:
|
|
with st.spinner("Parsing PDF..."):
|
|
excel_bytes, df_txn, df_acct, title = parse_trial_balance_to_excel(uploaded_file)
|
|
|
|
st.success("Parsed successfully.")
|
|
|
|
col1, col2 = st.columns(2)
|
|
|
|
with col1:
|
|
st.metric("Transactions", len(df_txn))
|
|
|
|
with col2:
|
|
st.metric("Account Summary Rows", len(df_acct))
|
|
|
|
if title:
|
|
st.write(f"**Report Title:** {title}")
|
|
|
|
st.subheader("Transactions Preview")
|
|
st.dataframe(df_txn, use_container_width=True)
|
|
|
|
st.subheader("Account Summary Preview")
|
|
st.dataframe(df_acct, use_container_width=True)
|
|
|
|
st.download_button(
|
|
label="Download Excel File",
|
|
data=excel_bytes,
|
|
file_name="meditech_trial_balance_parsed.xlsx",
|
|
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
)
|
|
|
|
except Exception as e:
|
|
st.error("Something went wrong while parsing the PDF.")
|
|
st.exception(e) |