TovaHasi's picture
Update app.py
19e516e
raw
history blame
5.71 kB
import streamlit as st
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import math
st.title("Калькулятор Toyota📄")
st.markdown("Тут данные ввести")
Buying_an_autopilot = st.number_input('Покупка автопилота, руб.', value=2000000)
Purchase_of_peripheral_equipment = st.number_input('Покупка перефирийного оборудования, руб.', value=40000)
Purchase_by = st.number_input('Покупка ПО, руб.', value=10000)
Introduction_of_autopilot = st.number_input('Внедрение автопилота, руб.', value=20000)
Maintenance = st.number_input('Обслуживание (месяц), руб.', value=100000)
The_cost_of_repairing_one_car = st.number_input('Стоимость ремонта одной машины, руб.', value=10000)
Inflation_rate = st.number_input('Уровень инфляции', value=0.04)
Monthly_salary_rate = st.number_input('Заработная ставка, руб. в месяц', value=40000)
Number_of_months = st.number_input('Количество месяцев', value=12)
Equipment_breakdown_rate = st.number_input('Коэффициент поломки оборудования', value=0.1)
Price_for_processing_ont_pallet = st.number_input('Цена за обработку 1 паллета, руб.', value=300)
Cargo_flow = st.number_input('Грузопоток, шт/месяц', value=10000)
Efficiency = st.number_input('Производительность, шт в час', value=5)
Number_of_working_hours = st.number_input('Количество рабочих часов', value=8)
Shift_of_one_employee = st.number_input('Смена 1 работника, ч.', value=8)
Number_of_working_days_month = st.number_input('Количество рабочих дней в месяц, дн.', value=20)
Social_benefits_for_one_employee = st.number_input('Социальные выплаты 1 сотруднику, руб.', value=10000)
Insurance_rate = st.number_input('Ставка страхования', value=0.005)
Income_tax_rate = st.number_input('Ставка налога на прибыль', value=0.2)
Number_of_autopilots_serviced_by_one_employee = st.number_input('Количество автопилотов, обслуживаемых 1 работником', value=10)
discounting = st.number_input('Ставка дисконтирования в месяц', value=0.028)
Rate_CPI = 1.1
def get_number_pallets_and_machines_employees():
Number_pallets = Efficiency * Number_of_working_hours * Number_of_working_days_month
Number_machines = math.ceil(Cargo_flow / Number_pallets)
Number_employees = math.ceil((Number_machines * Number_of_working_hours / Shift_of_one_employee) / Number_of_autopilots_serviced_by_one_employee)
return Number_pallets, Number_machines, Number_employees
def get_revenue(idx):
indexation = math.floor(idx / 12)
Price = Price_for_processing_ont_pallet * math.pow(Rate_CPI, indexation)
revenue = Number_machines * Number_pallets * Price
return revenue
def get_costs(idx):
indexation = math.floor(idx / 12)
wage_fund_with_indexation = math.pow((Social_benefits_for_one_employee + Monthly_salary_rate), indexation)
Expected_repair_costs_per_month = Number_machines * Equipment_breakdown_rate * The_cost_of_repairing_one_car
Wage_Fund = Number_employees * wage_fund_with_indexation
The_cost_of_insurance = Number_machines * Insurance_rate * (Buying_an_autopilot + Purchase_of_peripheral_equipment)
return Purchase_by + Number_machines * Maintenance + Expected_repair_costs_per_month + Wage_Fund + The_cost_of_insurance
def get_profit(amortization, idx):
profit = get_revenue(idx) - get_costs(idx) - amortization
if profit > 0:
return profit
else:
return profit * 0.8
def get_PV(profit, discounting):
return profit * discounting
def get_array_discounting():
array_discounting = [1]
for idx in range(Number_of_months):
array_discounting.append(array_discounting[-1] / (1 + discounting))
return array_discounting
def get_amortization(value):
array_amortization = [0]
value = value / 60
for idx in range(Number_of_months):
array_amortization.append(value)
return array_amortization
def get_array_CF_PV():
I_0 = Buying_an_autopilot * Number_machines + Purchase_of_peripheral_equipment + Introduction_of_autopilot
array_discounting = get_array_discounting()
array_amortization = get_amortization(I_0)
array_PV = [-I_0]
array_CF = [-I_0]
for idx in range(1, Number_of_months + 1, 1):
profit = get_profit(array_amortization[idx], idx)
array_CF.append(profit)
cur_PV = get_PV(profit, array_discounting[idx])
array_PV.append(cur_PV)
return array_CF, array_PV
def get_array_NPV():
array_NPV = [array_PV[0]]
for idx in range(1, Number_of_months + 1, 1):
array_NPV.append(array_NPV[-1] + array_PV[idx])
return array_NPV
if st.button('Сюда кликнуть чтобы посчитать'):
Number_pallets, Number_machines, Number_employees = get_number_pallets_and_machines_employees()
array_CF, array_PV = get_array_PV()
array_NPV = get_array_NPV()
IRR = np.irr(array_CF)
st.write(f'NPV за {Number_of_months} месяцев:', array_NPV[-1])
st.write(f'IRR на {Number_of_months} месяцев:', IRR)
chart_data = pd.DataFrame(columns=['PV', 'NPV'])
chart_data['PV'] = array_PV
chart_data['NPV'] = array_NPV
st.area_chart(chart_data)