Commit 899c4cf3 by Icíar Lloréns Jover

### Notebook explaining and using the profit/commission calculator

parent ee4a7f3f
Pipeline #75982 passed with stage
in 24 seconds
 { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# CBD Profit calculator\n", "\n", "In order to run this program, first be sure to modify the entries as desired. Once it is modified, go on the \"Run\" menu at the top of the window and press \"Run all cells\". Scroll down to see the result of the predictions!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Entries\n", "\n", "This is the part where the user inputs the sales predictions. Follow instructions so as to get meaningful profit and commission results: \n", "\n", "1. First, enter the needed number (for example 2) of time steps as such: *nb_timesteps = 2*\n", "2. Second, enter all of the new information that is occurring at each time step. Each variable (nb_new_stores_timestep, total_nb_10_bottles_timestep, ...) is an ordered list of values. Each value refers to (**IN ORDER**) each time step. For example, if in time steps 1, 2 and 3, a variable has values X, Y, and Z, this should be entered as: \n", " variable = [X, Y, Z]\n", "\n", " A) The variable **nb_new_stores_timestep** describes the number of **new** stores that the sales advisor has gained at the time step of interest. For example, if at time step 1, the salesperson gets one new store, but at time step 2 they get 3 new stores (amounting to a total of 4 stores in the portfolio), the variable should be set as: \n", " \n", " *nb_new_stores_timestep = [1, 3]*\n", " \n", " B) The variable **total_nb_10_bottles_timestep** describes the TOTAL amount of 10% bottles that the portfolio stores have ordered at each time step.\n", " \n", " C) The variable **total_nb_20_bottles_timestep** describes the TOTAL amount of 20% bottles that the portfolio stores have ordered at each time step.\n", " \n", " D) The variable **total_nb_30_bottles_timestep** describes the TOTAL amount of 40% bottles that the portfolio stores have ordered at each time step.\n", " " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "nb_timesteps = 3\n", "\n", "nb_new_stores_timestep = [1, 3, 5]\n", "total_nb_10_bottles_timestep = [0, 10, 50]\n", "total_nb_20_bottles_timestep = [0, 7, 30]\n", "total_nb_40_bottles_timestep = [0, 3, 15]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Constants and functions\n", "\n", "In general, do not touch this part of code unless it is to modify the cost, retail prices or commission on the products. If this part is ever to be modified, be sure to only modify the portion headed with \"CONSTANTS\"" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "# CONSTANTS\n", "bottle_10_cost = 30\n", "bottle_20_cost = 40\n", "bottle_40_cost = 80\n", "\n", "bottle_10_price = 75\n", "bottle_20_price = 135\n", "bottle_40_price = 240\n", "\n", "pack_cost = 220\n", "pack_price = 300\n", "pack_commission = 60\n", "pack_prof = pack_price - pack_cost - pack_commission\n", "\n", "# FUNCTIONS\n", "def compute_sales():\n", " sales = []\n", " for i in range(nb_timesteps):\n", " sale_timestep = bottle_10_price * total_nb_10_bottles_timestep[i] \\\n", " + bottle_20_price * total_nb_20_bottles_timestep[i] \\\n", " + bottle_40_price * total_nb_40_bottles_timestep[i]\n", " sales.append(sale_timestep)\n", "\n", " return sales\n", "\n", "\n", "def compute_costs():\n", " costs = []\n", " for i in range(nb_timesteps):\n", " cost_timestep = bottle_10_cost * total_nb_10_bottles_timestep[i] \\\n", " + bottle_20_cost * total_nb_20_bottles_timestep[i] \\\n", " + bottle_40_cost * total_nb_40_bottles_timestep[i]\n", " costs.append(cost_timestep)\n", "\n", " return costs\n", "\n", "def compute_sales_commission_rate():\n", " commission_rates = []\n", " for i in range(nb_timesteps):\n", " commission_rates.append(max(10, sum(nb_new_stores_timestep[:i]) + 4)/ 100)\n", " return commission_rates\n", "\n", "def compute():\n", "\n", " sales = compute_sales()\n", " sales_comm_rate = compute_sales_commission_rate()\n", " costs = compute_costs()\n", "\n", " # Compute salesperson total commission\n", " sales_comm = [sales[i] * sales_comm_rate[i] for i in range(nb_timesteps)]\n", " pack_comm = [nb_new_stores_timestep[i] * pack_commission for i in range(nb_timesteps)]\n", " total_commission = [sales_comm[i] + pack_comm[i] for i in range(nb_timesteps)]\n", "\n", " # Compute profit\n", " pack_profit = [nb_new_stores_timestep[i] * pack_prof for i in range(nb_timesteps)]\n", " sales_profit = [sales[i] - costs[i] - sales_comm[i] for i in range(nb_timesteps)]\n", " total_profit = [sales_profit[i] + pack_profit[i] for i in range(nb_timesteps)]\n", "\n", " return total_commission, total_profit\n", "\n", "\n", "def display(nb_timesteps, total_commission, total_profit):\n", " sum_commission = sum(total_commission)* 1.00\n", " sum_profit = sum(total_profit)*1.00\n", "\n", " for i in range(nb_timesteps):\n", " print(\"Time step {: > 3} -- Sales advisor's commission: {: > 10.2f} € -- Profit: {: > 10.2f} €\".format(i+1,total_commission[i],total_profit[i]))\n", "\n", " print(\"\\n\")\n", " print(\"{:>32} {:>7} €\".format('Total sales advisor commission:', sum_commission))\n", " print(\"{:>32} {:>7} €\".format('Total profit:', sum_profit))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Display\n", "\n", "This portion of the code displays the result of the profit and commission computation at each time step and and the end of all time steps." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Time step 1 -- Sales advisor's commission: 60.00 € -- Profit: 20.00 €\n", "Time step 2 -- Sales advisor's commission: 421.50 € -- Profit: 1413.50 €\n", "Time step 3 -- Sales advisor's commission: 1440.00 € -- Profit: 6460.00 €\n", "\n", "\n", " Total sales advisor commission: 1921.5 €\n", " Total profit: 7893.5 €\n" ] } ], "source": [ "total_commission, total_profit = compute()\n", "display(nb_timesteps, total_commission, total_profit)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment