-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalgos.py
316 lines (233 loc) · 9.86 KB
/
algos.py
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
from datetime import date
#_____________________________________________________________________________________________________________#
def project_name(date, clientName, category):
"""establish the name of the project, should be used as primary key"""
# date converted to string
date_object = str(date)
# date string abstracted to the 2 digits of the year,month and day
record_date = date_object[2:4] + date_object[5:7] + date_object[8:10]
prjt_name = record_date + "_" + str(clientName) + "_" + str(category)
return prjt_name
def client_name()-> str:
"""record the client name for the project
Returns:
str: client name
"""
global name
print("\n client name/ project name")
print("***************************************************")
while True:
name = str.lower(input("insert name:"))
if " " in name:
name = name.replace(" ","_")
break
elif name is None:
print("a project must have a client, how do you pay bills, without him/her?")
else:
break
print("***************************************************")
return name
# Date algorithim
def datetime_enforcer(description: str, lower_limit:int,upper_limit:int)-> int:
"""_summary_
Args:
description (str): enforces the input provided by the user; can be date, month or year
lower_limit (int): it should not surpass this point
upper_limit (int): it should not go above this point
Returns:
int: the correct value for date, month or year
"""
while True:
custom_date = input(f"{description}:")
if custom_date.isdigit():
custom_date = int(custom_date)
if custom_date >= lower_limit and custom_date <= upper_limit :
break
print("Try again")
return custom_date
def date_setup(date_purpose:str)-> str:
"""Set up the string format for a date
Args:
date_purpose (str): The description of the use of the date i.e commencment date, completion date
Returns:
str: date in str format
"""
while True:
print()
print(f"{date_purpose}")
print("***************************************************")
print( "1) Today's date\n"
"2) Custom date")
print("___________________________________________________")
user_option = input("insert: ")
print("***************************************************")
if user_option.isdigit():
user_option = int(user_option)
if user_option == 1:
current_date = date.today()
break
elif user_option == 2:
custom_date = datetime_enforcer("date", 1,31)
custom_month = datetime_enforcer("month",1,12)
custom_year = datetime_enforcer("year",2022,2023)
print("***************************************************")
current_date = date(custom_year, custom_month, custom_date)
break
else:
print("Wrong input, try again.")
else:
print("Wrong input, try again.")
# format date to string format
current_date =current_date.strftime('%Y-%m-%d %H:%M:%S')
return current_date
## project fund algos
#_____________________________________________________________________________________________________________#
def money_setup(money_purpose):
"""Records all transactions done in kenya shillings"""
print()
print(f"{money_purpose} (ksh)")
print("***************************************************")
amount = float(input("Amount:"))
print("***************************************************")
return amount
def dollars_to_ksh():
# establish amount of dollars withdrawn
print("***************************************************")
dollars_withdrawn = float(input("insert amount withdrawn (dollars):"))
amount_recieved = float(input("insert amount recieved (ksh):"))
print("***************************************************")
# establish an exchange rate fee a constant used for the project
#anything above this becomes company's profit
rate = 110
# establish project amount ()
project_amount = dollars_withdrawn * rate
er_income = amount_recieved - project_amount
return project_amount, er_income
def project_fund(money_purpose,project_source_id,usd = True):
"""All project funds are recorded in usd
Args:
money_purpose (_type_): description of money type
project_source_id(int): select physical projects only then convert to usd
usd (bool, optional): if not true amount is converted from ksh to usd. Defaults to True.
Returns:
_type_: amount to be recorderd in usd
"""
if project_source_id == 2:
print()
print(f"{money_purpose} (ksh)")
print("***************************************************")
amount = float(input("Amount:"))
print("***************************************************")
if usd :
exchange_rate = 110
amount = round(amount/exchange_rate)
else:
print()
print(f"{money_purpose} (usd)")
print("***************************************************")
amount = float(input("Amount:"))
print("***************************************************")
return amount
#bees algos
#_____________________________________________________________________________________________________________#
def gender_type():
gender_dict= {1:"MALE",2:"FEMALE"}
print("Choose one of the gender options")
for key, value in gender_dict.items():
print(f"{key}: {value}")
user_input = int(input("choose:"))
return gender_dict[user_input]
#project fund distribution
#_____________________________________________________________________________________________________________#
def salaries_matrix(salary, bees_no_dict: dict):
"""Picks up the salaries fund and sub divides among the bees"""
# loop to control greed/inappropiate allocation
salary_app = {}
for key, value in bees_no_dict.items():
amount_earned = float(input(f"{key}:{value} SHARE : "))
amount_remaining = (float(salary)) - amount_earned
print(f"AMOUNT REMAINING {amount_remaining}")
salary_app=[key]=amount_earned
salary = amount_remaining
return salary_app
def display_fee_distribution(project_source_id,project_fund,timeline = True):
project_bounty,tax,formode_fee,salaries = project_funds_distribution_V3(project_source_id,project_fund,optical_illusion=True)
company_fund, salaries_repeat, tax = project_funds_distribution_V3(project_source_id,project_fund,optical_illusion=False)
print()
print(f"Detail fee distribution(usd)")
print("***************************************************")
print(f"project fund : {project_fund}")
print(f"company fund : {company_fund}")
print(f"salaries fund : {salaries_repeat}")
print(f"tax : {tax}")
print("***************************************************")
print()
print(f"Bee Fee distribution (usd)")
print("***************************************************")
print(f"project bounty : {project_bounty}")
print(f"Marketplace fee : {tax}")
print(f"formode fee : {formode_fee}")
print(f"Your fee : {salaries}")
if timeline is True:
# Optical deadlines to ensure projects are completed on time always
expected_timeline = int(input("Real Timeline (days):"))
optical_timeline = round(2/3 * (expected_timeline))
print(f"Timeline: {optical_timeline} days")
else:
pass
print("___________________________________________________")
def project_funds_distribution_V3(project_source_id, project_fund,optical_illusion= False):
client_fee = float(project_fund)
distribution_factor = (2/3) # distribution to reality
real_fee = distribution_factor * client_fee
# real_fee should always be a whole number rounded to 0 or 5 to make it convincing
base = 5
real_fee = base * round(real_fee /5)
# optical illusion achieved
optical_fee = client_fee - real_fee
if project_source_id == 1: #fiverr
# illusion
illusion_tax = 0.2 * optical_fee
illusion_formode_fee = optical_fee - illusion_tax
# reality
reality_tax = 0.2 * real_fee
bee_fees =round(0.7 * real_fee)
reality_formode_fee = ( real_fee - ( reality_tax + bee_fees))
elif project_source_id == 2: #physical
# illusion
illusion_tax = 0
illusion_formode_fee = optical_fee - illusion_tax
# reality
reality_tax = 0
bee_fees =round(0.9 * real_fee)
reality_formode_fee = ( real_fee - ( reality_tax + bee_fees))
elif project_source_id == 3: #gopillar
# illusion
illusion_tax = 0
illusion_formode_fee = optical_fee - illusion_tax
# reality
reality_tax = 0
bee_fees =round(0.9 * real_fee)
reality_formode_fee = ( real_fee - ( reality_tax + bee_fees))
elif project_source_id == 5: #paypal
# illusion
illusion_tax = 0.05 * optical_fee
illusion_formode_fee = optical_fee - illusion_tax
# reality
reality_tax = 0.05 * real_fee
bee_fees =round(0.85 * real_fee)
reality_formode_fee = ( real_fee - ( reality_tax + bee_fees))
else:
print("projects fund yet to be included")
company_fund = reality_formode_fee + illusion_formode_fee
tax = reality_tax + illusion_tax
salaries = bee_fees
project_bounty = real_fee
if optical_illusion is True:
package = (project_bounty,reality_tax,reality_formode_fee,salaries)
else:
package = (company_fund,salaries,tax)
return package
if __name__ == "__main__":
name = client_name()
print(name)