File size: 16,342 Bytes
c73a3e0
 
 
 
 
fa1e2d7
c73a3e0
b9483ac
 
 
 
 
b7ebcf0
 
 
 
 
b9483ac
11ba886
 
ee6bd21
 
c73a3e0
 
 
670c918
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa1e2d7
c73a3e0
 
 
 
 
 
 
 
a8d1ee8
c73a3e0
 
 
 
 
 
 
 
 
 
 
6c915d6
c73a3e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5af475d
 
c73a3e0
 
 
6c915d6
352d214
 
 
 
 
 
6c915d6
 
 
 
 
 
 
352d214
 
 
7c11ab5
 
 
 
352d214
 
 
 
7c11ab5
 
fa1e2d7
 
2a78576
7c11ab5
6c915d6
 
 
 
fa1e2d7
 
 
 
 
6c915d6
 
 
 
 
 
fa1e2d7
 
 
 
6c915d6
 
 
 
 
 
fa1e2d7
 
 
 
 
 
6c915d6
352d214
7c11ab5
 
352d214
 
 
 
 
 
e93c756
 
352d214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19e516e
6c915d6
 
 
 
 
 
 
 
 
 
352d214
abd1bea
352d214
 
19e516e
352d214
 
 
7c11ab5
352d214
9c24e16
19e516e
e93c756
352d214
9c24e16
352d214
19e516e
352d214
 
eddefd4
 
 
 
 
 
 
9c24e16
 
 
 
 
 
fa1e2d7
6634da1
7c11ab5
03c98c9
67ec8b9
19e516e
67ec8b9
19e516e
6634da1
 
 
19e516e
9c24e16
19e516e
6634da1
 
 
 
 
 
 
7c11ab5
 
 
8e89fc7
9c24e16
670c918
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import streamlit as st
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import math
import numpy_financial as np_fin

st.set_page_config(
     page_title="Ex-stream-ly Cool App",
     page_icon="🧊",
     layout="wide",
     initial_sidebar_state="expanded",
     primaryColor="#F63366",
     backgroundColor="#FFFFFF",
     secondaryBackgroundColor="#F0F2F6",
     textColor="#262730",
     font="sans serif"
 )


st.title("Калькулятор Toyota📄")

genre = st.radio("Какой из вариантов", ("Покупка автоматизированного ричтрака", "Аренда автоматизированного ричтрака", "Покупка механизированного ричтрака"))

if genre == 'Покупка автоматизированного ричтрака':
    col1, col2, col3 = st.columns(3)

    with col1:
        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)

    with col2:
        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)     
#     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) 
    
elif genre == 'Аренда автоматизированного ричтрака':
    Rent_an_autopilot = st.number_input('Аренда автопилота, руб.', value = 20000)
    Rent_of_peripheral_equipment = st.number_input('Аренда перефирийного оборудования, руб.', value = 4000)
    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)
    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('Смена одного работника, часы', value = 8)
    Number_of_working_days_month = st.number_input('Количество рабочих дней в месяц, дн.', value = 20)
    Social_benefits_for_one_employee = st.number_input('Социальные выплаты одному сотруднику, руб.', value = 10000)
    Income_tax_rate = st.number_input('Ставка налога на прибыль', value = 0.2)
    Number_of_autopilots_serviced_by_one_employee = st.number_input('Количество автопилотов, обслуживаемых одним работником, шт.', value = 10)
    discounting = st.number_input('Ставка дисконтирования в месяц', value = 0.028)
    
else:
    Buying_a_richtruck = st.number_input('Покупка ричтрака, руб.', value=2000000)
    Maintenance = st.number_input('Обслуживание (месяц), руб.', value=10000)
    The_cost_of_repairing_one_car = st.number_input('Стоимость ремонта одной машины, руб.', value=1000)
    Monthly_salary_rate = st.number_input('Заработная ставка, руб. в месяц', value=40000)
    Number_of_months = st.number_input('Количество месяцев', value=12)
    Equipment_breakdown_rate = st.number_input('Коэфициент поломки оборудования', value=0.3)
    Price_for_processing_ont_pallet = st.number_input('Цена за обработку 1 паллета, руб.', value=300)
    Cargo_flow = st.number_input('Грузопоток, шт/месяц всего', value=10000)
    Efficiency = st.number_input('Производительность, шт в час', value=3)
    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)
    The_cost_of_demaged_goods = st.number_input('Стоимость поврежденного товара', value=1000)
    Product_damage_rate= st.number_input('Коэфициент повреждения товара', value=0.005)
    discounting = st.number_input('Ставка дисконтирования в месяц', value=0.028)


Rate_CPI = 1.05


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)
    
    if genre == 'Покупка автоматизированного ричтрака':
        Number_employees = math.ceil((Number_machines * Number_of_working_hours / Shift_of_one_employee) / Number_of_autopilots_serviced_by_one_employee)
    elif genre == 'Аренда автоматизированного ричтрака':
        Number_employees = math.ceil((Number_machines * Number_of_working_hours / Shift_of_one_employee) / Number_of_autopilots_serviced_by_one_employee)
    else:
        Number_employees = math.ceil((Number_machines * Number_of_working_hours / Shift_of_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)
    start_year = ((idx - 1) % 12 == 0)
    cost = 0
    wage_fund_with_indexation = (Social_benefits_for_one_employee + Monthly_salary_rate) * math.pow(Rate_CPI, indexation)
    
    if genre == 'Покупка автоматизированного ричтрака':
        Expected_repair_costs_per_month = Number_machines * Equipment_breakdown_rate * The_cost_of_repairing_one_car
        Wage_Fund = Number_employees * wage_fund_with_indexation
        
        if start_year:
            The_cost_of_insurance = Number_machines * Insurance_rate * (Buying_an_autopilot + Purchase_of_peripheral_equipment)
            cost += The_cost_of_insurance + Purchase_by
            
        cost += Number_machines * Maintenance + Expected_repair_costs_per_month + Wage_Fund
        
    elif genre == 'Аренда автоматизированного ричтрака':
        Expected_repair_costs_per_month = Number_machines * Equipment_breakdown_rate * The_cost_of_repairing_one_car
        Wage_Fund = Number_employees * wage_fund_with_indexation
        Autopilot_rental = Number_machines * Rent_an_autopilot
        
        if start_year:
            cost += Purchase_by
        
        cost += Autopilot_rental + Rent_of_peripheral_equipment + Purchase_by + Number_machines * Maintenance + Wage_Fund + Expected_repair_costs_per_month
        
    else:
        Expected_repair_costs_per_month = Number_machines * Equipment_breakdown_rate * The_cost_of_repairing_one_car
        Wage_Fund = Number_employees * wage_fund_with_indexation
        Expected_costs_for_the_purchase_of_damaged_goods = Efficiency * The_cost_of_demaged_goods * Product_damage_rate
        
        if start_year:
            The_cost_of_insurance = Number_machines * Insurance_rate * Buying_a_richtruck
            cost += The_cost_of_insurance
            
        cost += Number_machines * Maintenance + Expected_repair_costs_per_month + Wage_Fund + Expected_costs_for_the_purchase_of_damaged_goods
        
    return cost

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():
    if genre == 'Покупка автоматизированного ричтрака':
        I_0 = Buying_an_autopilot * Number_machines + Purchase_of_peripheral_equipment + Introduction_of_autopilot * Number_machines
        amortizat = Buying_an_autopilot * Number_machines + Introduction_of_autopilot * Number_machines
    elif genre == 'Аренда автоматизированного ричтрака':
        I_0 = Rent_of_peripheral_equipment
        amortizat = 0
    else:
        I_0 = Buying_a_richtruck * Number_machines
        amortizat = Buying_a_richtruck * Number_machines
        
    array_discounting = get_array_discounting()
    array_amortization = get_amortization(amortizat)
    
    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(round(profit))
        
        cur_PV = get_PV(profit, array_discounting[idx])
        
        array_PV.append(round(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
    
    
def get_id_first_positive_NPV(array_NPV):
    for idx, npv in enumerate(array_NPV):
        if npv > 0:
            return idx
    return len(array_NPV)
    
    
if st.button('Расчет эффективности'):
    Number_pallets, Number_machines, Number_employees = get_number_pallets_and_machines_employees()
    array_CF, array_PV = get_array_CF_PV()
    array_NPV = get_array_NPV()
    
    IRR = np_fin.irr(array_CF)
    
    st.write(f'Необходимое кол-во ричтраков {Number_machines}')
    st.write(f'Необходимое кол-во сотрудников {Number_employees}')
    
    st.write(f'NPV за {Number_of_months} месяцев:', array_NPV[-1])
    st.write(f'IRR на {Number_of_months} месяцев: {round(100 * IRR, 2)}%')
    
    if array_NPV[-1] < 0:
        st.write(f'{Number_of_months} месяцев не хватает для окупаемости проекта')
    else:
        id_first_positive_NPV = get_id_first_positive_NPV(array_NPV)
        st.write(f'Проект окупается на {id_first_positive_NPV} месяц')
        
    
    chart_data = pd.DataFrame(columns=['PV', 'NPV'])
    chart_data['PV'] = array_PV
    chart_data['NPV'] = array_NPV

    st.bar_chart(chart_data)