User Tools

Site Tools


procedures:infobip_billing_whatsapp.zip

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
procedures:infobip_billing_whatsapp.zip [2025/05/28 09:42] – created luca.bottoliprocedures:infobip_billing_whatsapp.zip [2025/05/28 09:56] (current) luca.bottoli
Line 27: Line 27:
         file_path = os.path.join(folder_path, filename)         file_path = os.path.join(folder_path, filename)
         os.remove(file_path)         os.remove(file_path)
 +</code>
 +<code>
 +# ignoro warning di openpyxl
 +warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")
 +
 +df_list = []
 +
 +# scorro tutti i file .xlsx nella cartella
 +for filename in os.listdir(folder_path):
 +    if filename.endswith('.xlsx'):
 +        file_path = os.path.join(folder_path, filename)
 +        try:
 +            df = pd.read_excel(file_path, engine='openpyxl')
 +            df_list.append(df)
 +        except Exception as e:
 +            print(f"Errore nel file {filename}: {e}")
 +
 +# combino tutti i dataframe in uno solo
 +df = pd.concat(df_list, ignore_index=True)
 +df['From'] = df['From'].astype(str)
 +</code>
 +<code>
 +#creo il dataframe
 +df = df[['From', 'Purchase Price','Traffic Type']]
 +df['From'] = df['From'].astype(str)
 +df['Purchase Price'] = df['Purchase Price'] / 100
 +</code>
 +<code>
 +#associo ogni apikey al cliente
 +api_keys = {
 +    "390287238444": {
 +        "nome": "Alidays"
 +    },
 +    "390287238484": {
 +        "nome": "Alidays"
 +    },
 +    "390287238400": {
 +        "nome": "Alidays"
 +    },
 +    "390521832000": {
 +        "nome": "Arquati"
 +    },
 +    "393346275858": {
 +        "nome": "Estendo"
 +    },
 +    "390620190197": {
 +        "nome": "Farmacie"
 +    },
 +    "393316787339": {
 +        "nome": "F.IMM"
 +    },
 +    "3902300821": {
 +        "nome": "Grenke"
 +    }
 +}
 +</code>
 +<code>
 +#creo i dataframes per ogni apikey
 +numbers = df["From"].unique()
 +for number in numbers:
 +    df['From'] = df['From'].replace({number: api_keys[number]["nome"]})
 +dfs = [group for _, group in df.groupby('From')]
 +</code>
 +<code>
 +#faccio i conti e stampo
 +for d in dfs:
 +    print("\033[1m",d["From"].iloc[0],"\033[0m")
 +    print("\tWA: ", len(d[d["Traffic Type"] == "Service"]))
 +    print("\tTemplates Utility: ", len(d[d["Traffic Type"] == "Utility"]))
 +    print("\tTemplates Marketing: ", len(d[d["Traffic Type"] == "Marketing"]))
 +    print("\tCosto a noi WA: ", round(d[d["Traffic Type"] == "Service"]["Purchase Price"].sum(),2), "€")
 +    print("\tCosto a noi Utility: ", round(d[d["Traffic Type"] == "Utility"]["Purchase Price"].sum(),2), "€")
 +    print("\tCosto a noi Marketing: ", round(d[d["Traffic Type"] == "Marketing"]["Purchase Price"].sum(),2), "€")
 +    print("\tFatturare: ", round(len(d[d["Traffic Type"] == "Service"]) * 0.0619 + len(d[d["Traffic Type"] == "Utility"]) * 0.0647 + len(d[d["Traffic Type"] == "Marketing"]) * 0.0872 ,2), "€")
 </code> </code>
procedures/infobip_billing_whatsapp.zip.txt · Last modified: by luca.bottoli

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki