File size: 4,140 Bytes
ec6dd69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd6a24d
ec6dd69
 
 
 
 
 
 
dd6a24d
 
 
 
 
 
 
 
 
ec6dd69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd6a24d
 
 
ec6dd69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd6a24d
ec6dd69
 
 
 
 
 
 
 
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
import streamlit as st
from utils import set_algorithm_name, get_pdf_iframe
from menu import display_pages_menu
from country_by_country.utils.constants import (
    JURIDICTIONS,
    CURRENCIES,
    SECTORS,
    COMPANIES,
)
from Levenshtein import distance
import sys
import logging
import pandas as pd
import numpy as np
import re

logging.basicConfig(stream=sys.stdout, level=logging.INFO, format="%(message)s")


st.set_page_config(layout="wide", page_title="Report metadata")
st.title("Country by Country Tax Reporting analysis : Metadata")
st.subheader(
    "This page will allow you to fill in metadata about the report : company name, headquarter, currency, unit, ...",
)
display_pages_menu()


if "pdf_after_page_validation" in st.session_state:
    col1, col2 = st.columns(2)
    with col1:
        st.markdown(
            get_pdf_iframe(st.session_state["pdf_after_page_validation"]),
            unsafe_allow_html=True,
        )
    with col2:
        with st.form("metadata_form"):
            if "metadata" in st.session_state:
                company_name = st.session_state["metadata"]["company_name"]
                sector = st.session_state["metadata"]["sector"]
                year = st.session_state["metadata"]["year"]
                currency = st.session_state["metadata"]["currency"]
                unit = st.session_state["metadata"]["unit"]
                headquarter = st.session_state["metadata"]["headquarter"]
                decimal_separator = st.session_state["metadata"]["separator"]
            else:
                company_name = None
                sector = None
                year = ""
                currency = None
                unit = None
                headquarter = ""
                decimal_separator = ","

            separator_list = [",", "."]
            decimal_separator = st.selectbox(
                "Decimal separator",
                separator_list,
                index=separator_list.index(decimal_separator),
            )

            companies = list(COMPANIES.keys())
            company_name = st.selectbox(
                "Company name",
                companies,
                index=companies.index(company_name) if company_name else 0,
            )

            sector = st.selectbox(
                "Sector", SECTORS, index=SECTORS.index(sector) if sector else 0
            )

            year = st.text_input("Year", value=year)

            currencies = {
                (
                    CURRENCIES[currency]["AlphabeticCode"],
                    CURRENCIES[currency]["Currency"],
                )
                for currency in CURRENCIES
            }
            currencies = sorted(currencies, key=lambda x: x[0])
            currencies = [f"{currency[0]} - {currency[1]}" for currency in currencies]
            currency = st.selectbox(
                "Currency",
                currencies,
                index=currencies.index(currency)
                if currency
                else currencies.index("EUR - Euro"),
            )

            units = [
                "units",
                "thousands",
                "millions",
                "10 millions",
                "100 millions",
                "billions",
            ]
            unit = st.selectbox("Unit", units, index=units.index(unit) if unit else 0)

            headquarters = list(JURIDICTIONS.keys())
            headquarter = st.selectbox(
                "Headquarter location",
                headquarters,
                index=headquarters.index(headquarter) if headquarter else 0,
            )

            submitted = st.form_submit_button(
                label="Submit",
            )
            if submitted:
                st.session_state["metadata"] = {
                    "separator": decimal_separator,
                    "company_name": company_name,
                    "sector": sector,
                    "year": year,
                    "currency": currency,
                    "unit": unit,
                    "headquarter": headquarter,
                }
                st.switch_page("pages/3_Merge_Tables.py")