-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliner.py
279 lines (234 loc) · 9.79 KB
/
liner.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
from liner_toolkit import *
# Lining System class
class LiningSystem:
def __init__(self):
self.liner = Liner("empty", 0, 0)
# In case of a discount
self.liner_cost = 0
# In case of a discount
self.discount_percentage = 0
self.total_liners = 1
self.weight = 0
self.cost = 0
# Sets price of lifting hem
def set_lifting_hem(self):
self.liner.set_lifting_hem()
self.set_weight()
self.set_cost()
# Discount liner
def discount_liner(self, discount_percentage):
# Record for documentation
self.discount_percentage = discount_percentage
# Gets real discount number
discount_number = discount_percentage / 100
# Records new single liner cost
self.liner_cost = self.liner.total_cost - (discount_number * self.liner.total_cost)
self.set_weight()
self.set_cost()
# Add liners
def add_liners(self, added_liners):
self.total_liners += added_liners
self.set_weight()
self.set_cost()
# Calculates cost of liner (depending on discount)
def get_liner_cost(self):
if self.discount_percentage == 0:
return self.liner.total_cost
else:
return self.liner_cost
# Sets lining system weight
def set_weight(self):
self.weight = self.liner.total_weight * self.total_liners
# Sets lining system cost
def set_cost(self):
self.cost = self.get_liner_cost() * self.total_liners
# Liner class for that encapsulates all shapes of liners
class Liner:
def __init__(self, tank, price, weight):
self.sq_price = price
self.sq_weight = weight
self.info = self.__create_liner(tank.lower())
self.lifting_hem_area = 0
self.tank_square_footage = 0
self.five_percent = 0
self.liner_square_footage = 0
self.weight = 0
self.cost = 0
self.quote_square_footage = 0
# Including lifting hem
self.total_five_percent = 0
# Including lifting hem
self.total_liner_square_footage = 0
# Including lifting hem
self.total_cost = 0
# Including lifting hem
self.total_weight = 0
# Updates liner configurations
def configure(self):
self.tank_square_footage = self.info.tank_square_footage
self.five_percent = self.info.calculate_five_percent()
self.liner_square_footage = self.info.liner_square_footage
self.weight = self.__calculate_liner_weight()
self.cost = self.__calculate_liner_cost()
self.quote_square_footage = self.liner_square_footage + self.five_percent
# Lifting hem
self.total_five_percent = self.five_percent
# Lifting hem
self.total_liner_square_footage = self.liner_square_footage
# Lifting hem
self.total_cost = round(self.quote_square_footage * self.sq_price, 2)
# Lifting hem
self.total_weight = self.weight
# Sets lifting hem for liner
def set_lifting_hem(self):
self.lifting_hem_area = self.__get_lifting_hem_area()
self.total_liner_square_footage += self.lifting_hem_area
self.total_five_percent = self.total_liner_square_footage * 0.05
self.total_cost = self.__calculate_liner_cost()
self.total_weight = self.__calculate_liner_weight()
self.quote_square_footage = self.total_liner_square_footage + self.total_five_percent
# Calculates weight of liner
def __calculate_liner_weight(self):
return round(self.sq_weight * (self.liner_square_footage + self.lifting_hem_area))
# Calculates cost of liner
def __calculate_liner_cost(self):
return round(self.sq_price * (self.liner_square_footage + self.lifting_hem_area), 2)
@staticmethod
# Creates specific liner
def __create_liner(tank):
if tank[0] == 'c':
return CLiner()
elif tank[0] == 'f':
return FLiner()
elif tank[0] == 'r':
return RLiner()
else:
return 0
# Calculates lifting hem area depending on liner type
def __get_lifting_hem_area(self):
if isinstance(self.info, CLiner):
return self.info.circumference_liner
elif isinstance(self.info, RLiner):
return self.info.perimeter_liner
else:
return 0
# Grabs bottom square footage
def bottom_liner_square_footage(self):
return self.info.liner_bottom_square_footage()
# Grabs wall square footage
def wall_liner_square_footage(self):
return self.info.liner_wall_square_footage()
# Circular liner class
class CLiner:
def __init__(self):
self.diameter_tank = 0
self.diameter_liner = 0
self.depth_tank = 0
self.depth_liner = 0
self.circumference_tank = 0
self.circumference_liner = 0
self.tank_square_footage = 0
self.liner_square_footage = 0
# Update liner configurations
def configure(self, diameter_ft, diameter_inch, depth_ft, depth_inch, depth_extensions):
self.diameter_tank = converter(diameter_ft, diameter_inch)
self.diameter_liner = diameter_modifier(self.diameter_tank)
self.depth_tank = converter(depth_ft, depth_inch)
self.depth_liner = self.depth_tank + converter(0, depth_extensions)
self.circumference_tank = self.diameter_tank * math.pi
self.circumference_liner = self.diameter_liner * math.pi
self.__set_tank_square_footage()
self.__set_liner_square_footage()
# Calculates square footage of tank bottom
def __tank_bottom_square_footage(self):
return self.diameter_tank ** 2
# Calculates square footage of tank wall
def __tank_wall_square_footage(self):
return self.circumference_tank * self.depth_tank
# Calculates square footage of tank
def __set_tank_square_footage(self):
self.tank_square_footage = round(self.__tank_bottom_square_footage() + self.__tank_wall_square_footage())
# Calculates five percent of liner order
def calculate_five_percent(self):
scrap_cost = 0.05
return round(self.liner_square_footage * scrap_cost, 2)
# Calculates square footage of liner bottom
def liner_bottom_square_footage(self):
return self.diameter_liner ** 2
# Calculates square footage of liner wall
def liner_wall_square_footage(self):
return self.circumference_liner * self.depth_liner
# Calculates square footage of liner
def __set_liner_square_footage(self):
self.liner_square_footage = round(self.liner_bottom_square_footage() + self.liner_wall_square_footage())
# Rectangular liner class
class RLiner:
def __init__(self):
self.length_tank = 0
self.length_liner = 0
self.width_tank = 0
self.width_liner = 0
self.depth_tank = 0
self.depth_liner = 0
self.perimeter_tank = 0
self.perimeter_liner = 0
self.tank_square_footage = 0
self.liner_square_footage = 0
# Update liner configuration
def configure(self, length_ft, length_inch, width_ft, width_inch, depth_ft, depth_inch, depth_extensions):
self.length_tank = converter(length_ft, length_inch)
self.length_liner = length_modifier(self.length_tank)
self.width_tank = converter(width_ft, width_inch)
self.width_liner = self.width_tank
self.depth_tank = converter(depth_ft, depth_inch)
self.depth_liner = self.depth_tank + converter(0, depth_extensions)
self.perimeter_tank = (self.length_tank + self.width_tank) * 2
self.perimeter_liner = (self.length_liner + self.width_liner) * 2
self.__set_tank_square_footage()
self.__set_liner_square_footage()
# Calculates square footage of tank bottom
def __tank_bottom_square_footage(self):
return self.length_tank * self.width_tank
# Calculates square footage of tank wall
def __tank_wall_square_footage(self):
return (self.length_tank + self.width_tank) * 2 * self.depth_tank
# Calculates square footage of tank
def __set_tank_square_footage(self):
self.tank_square_footage = round(self.__tank_bottom_square_footage() + self.__tank_wall_square_footage())
# Calculates five percent of liner order
def calculate_five_percent(self):
scrap_cost = 0.05
return round(self.liner_square_footage * scrap_cost, 2)
# Calculates square footage of liner bottom
def liner_bottom_square_footage(self):
return self.length_liner * self.width_liner
# Calculates square footage of liner wall
def liner_wall_square_footage(self):
return (self.length_liner + self.width_liner) * 2 * self.depth_liner
# Calculates square footage of liner
def __set_liner_square_footage(self):
self.liner_square_footage = round(self.liner_bottom_square_footage() + self.liner_wall_square_footage())
# Flat sheet liner class
class FLiner:
def __init__(self):
self.length_liner = 0
self.width_liner = 0
self.tank_square_footage = 0
self.liner_square_footage = 0
# Update liner configuration
def configure(self, length_ft, length_inch, width_ft, width_inch):
self.length_liner = converter(length_ft, length_inch)
self.width_liner = converter(width_ft, width_inch)
self.tank_square_footage = round(self.length_liner * self.width_liner)
self.liner_square_footage = self.tank_square_footage
# Calculates five percent of liner order
def calculate_five_percent(self):
scrap_cost = 0
return self.liner_square_footage * scrap_cost
# Calculates square footage of liner bottom
def liner_bottom_square_footage(self):
return self.length_liner * self.width_liner
@staticmethod
# Returns 0 since it's a flat sheet
def liner_wall_square_footage(self):
return 0