def set_expenses(input_file, output_file): df = pd.read_csv(input_file, encoding="utf-8") expenses = ["Налог", "Цена с налогом"] df = df.drop(expenses, axis=1, errors="ignore") for i, row in df.iterrows(): brutto_price = df.loc[i, "Цена брутто"] netto_price = df.loc[i, "Цена нетто"] sell_price = brutto_price if not np.isnan(netto_price): sell_price = netto_price t = Tax( sell_price, df.loc[i, "Топливо"], df.loc[i, "Первая регистрация"], df.loc[i, "Объем двигателя"] ) df.loc[i, "Налог"] = round(t.get_tax(), 2) df["Цена с налогом"] = round(df["Цена нетто"].combine_first(df["Цена брутто"]) + df["Налог"], 2) expenses_fields_position = df.columns.get_loc("Цена нетто") + 1 df = move_columns_to_position(df, expenses, expenses_fields_position) df.to_csv(output_file, index=False, encoding="utf-8")
def __init__(self, name, age, retireAge, deadAge, incomePA, expensesPM, proportionSaved): self.name = name self.age = age self.retireAge = retireAge self.deadAge = deadAge # Education # Currently does not take user input and is hard coded in the Education Class initialisation... # Loans self.hasLoan = False self.loanDict = {} self.noLoans = 0 self.loanPaymentSum = 0 # Earnings # Income self.hasIncome = False self.incomePA = incomePA self.income = self.incomePA / 12 self.hasIncome = True # Expenses self.expenses = expensesPM # Expenses per month # Savings self.proportionSaved = proportionSaved # Inherit Loan init.. by inheriting this class, we can access it's attributes and methods... Income.__init__(self, self.income) # pass attribute to class # Init Expenses Expenses.__init__(self, self.expenses) # Init Savings Savings.__init__(self, self.proportionSaved) # Init Tax Tax.__init__(self) # Init super Superannuation.__init__(self, 0.095) # Init asset value AssetValue.__init__(self, 0.06) # Init Education Education.__init__(self) # Init Earnings Earnings.__init__(self, self.eduLevel, self.age, self.retireAge)
async def on_ready(): print('Logged in as') print('------') print(bot.user.name) print(bot.user.id) print('------') tax = Tax(bot) tax_task = asyncio.ensure_future(tax.wealth_tax()) coins = Coin(bot) await coins.give_coin() await tax_task
def main(argv): # Configure the application, including taxes and categories sales_tax_exceptions = [] if len(argv) > 1: with open(argv[1]) as f: for line in f: sales_tax_exceptions.append(line.strip()) sales_tax = Tax('0.10') import_duty = Tax('0.05') # Using the same name for both taxes ensures they're aggregated and # printed out on the same line categories = [ ExceptionCategory( u'Sales Taxes', sales_tax_exceptions, lambda i: sales_tax.calculate(i.value * i.quantity) ), Category( u'Sales Taxes', [u'imported'], last_minute_hack(import_duty) ), # Category( # 'Student Discount', # ['book'], # lambda i: (-1) * sales_tax.calculate(i.value * i.quantity) # ) ] # Create a basket basket = Basket(categories) # Add line items with open(argv[0]) as f: for line in f: line_item = parse_lineitem(line.strip()) if line_item: basket.add_line(line_item) # "Checkout" print basket.receipt()
def test_default_tax(self): t = Tax() self.assertEqual(t.tax(0), 0) self.assertEqual(t.tax(10000), 0) self.assertEqual(t.tax(10009), 0) self.assertEqual(t.tax(10010), 1) self.assertEqual(t.tax(12000), 200) self.assertEqual(t.tax(56789), 8697) self.assertEqual(t.tax(1234567), 473326)
def test_default_overall_rate(self): t = Tax() self.assertGreaterEqual(t.overall_rate(0), 0) self.assertLessEqual(t.overall_rate(0), 10009) self.assertEqual(t.overall_rate(0.06), 25000) self.assertEqual(t.overall_rate(0.09), 34376) self.assertEqual(t.overall_rate(0.32), 256250) self.assertEqual(t.overall_rate(0.40), None)
def test_net_rate_15_net_is_500001(self): self.assertEqual(37500.15, Tax(500001))
def menu_options(p_counter): selection = player_turn(p_counter) if selection == 1: #LISTO action = Entry(players, p_counter) action.a_entry() var = change_player(p_counter) if var == 1: return 0 elif selection == 2: #LISTO block = Counter_attack(p_counter, players, 2) block = block.attack() if block == 0: #Nadie quiso contraatacar, entonces se ejecuta la acción. action = Abroad_help(players, p_counter) action.a_abroad_help() else: #En este caso se puede hacer un desafío attacking = block #El jugador "block" quiso contraatacar action = Challenge(attacking - 1, players, 2, 2) a, b, c = action.challenge_player() if a == 0 and b == 0: #Nadie quiso desafiar el contra-ataque, entonces no se ejecuta la acción y le toca al siguiente jugador var = change_player(p_counter) if var == 1: return 0 elif a == 0 and b == 1: #El que contra-atacó mintió, la acción si se ejecuta action = Abroad_help(players, p_counter) action.a_abroad_help() elif b == 3: if a == 1: players[attacking - 1]._Players__influence1 = return_card( players[attacking - 1]._Players__influence1) elif a == 2: players[attacking - 1]._Players__influence2 = return_card( players[attacking - 1]._Players__influence2) var = change_player(p_counter) if var == 1: return 0 elif selection == 3: #LISTO action = Hit(players, p_counter) result = action.hit() if result == 0: menu_options(p_counter) var = change_player(p_counter) if var == 1: return 0 elif selection == 4: #LISTO action = Challenge( p_counter, players, 1, 4) #El 1 significa que se verifican las influencias de acciones a, b, c = action.challenge_player() if a == 0 and b == 0: #Nadie quiso desafiar, entonces se ejecuta la acción action = Tax(players, p_counter) action.a_tax() elif b == 3: if a == 1: players[p_counter]._Players__influence1 = return_card( players[p_counter]._Players__influence1) elif a == 2: action = Tax(players, p_counter) action.a_tax() players[p_counter]._Players__influence2 = return_card( players[p_counter]._Players__influence2) action = Tax(players, p_counter) action.a_tax() var = change_player(p_counter) if var == 1: return 0 elif selection == 5: #ASESINATO--------------- verif = Murder(players, p_counter) verif = verif.verif() if verif == 0: menu_options(p_counter) action = Challenge(p_counter, players, 1, 5) a, b, c = action.challenge_player() if a == 0 and b == 0: #Nadie quiso desafiar, luego van los contra-ataques action = Counter_attack(p_counter, players, 5) player_attack = action.attack() if player_attack == 0: #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción action = Murder(players, p_counter) action.murder() else: #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa) action = Challenge(player_attack - 1, players, 2, 5) a, b, c = action.challenge_player( ) #c es el jugador que desafió if a == 0 and b == 0: #Nadie desafía el contra-ataque, la acción no se cumple, pierde las monedas players[p_counter]._Players__coins = -3 var = change_player(p_counter) if var == 1: return 0 elif a == 0 and b == 1: #Pierde el desafío el que contra-atacó, se ejecuta la acción action = Murder(players, p_counter) action.murder() elif b == 3: #El que contraatacó ganó el desafío. if a == 1: players[c]._Players__influence1 = return_card( players[c]._Players__influence1) else: players[c]._Players__influence2 = return_card( players[c]._Players__influence2) elif a == 0 and b == 1: #Alguien quiso contra-atacar, el jugador pierde el desafío entonces no realiza la acción y cambia de turno var = change_player(p_counter) if var == 1: return 0 elif b == 3: #Si poseía la carta influencia, entonces pasa a contra-ataques if a == 1: players[p_counter]._Players__influence1 = return_card( players[p_counter]._Players__influence1) elif a == 2: players[p_counter]._Players__influence2 = return_card( players[p_counter]._Players__influence2) action = Counter_attack(p_counter, players, 5) player_attack = action.attack() if player_attack == 0: #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción action = Murder(players, p_counter) action.murder() else: #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa) action = Challenge(player_attack - 1, players, 2, 5) a, b, c = action.challenge_player( ) #c es el jugador que desafió if a == 0 and b == 0: #Nadie desafía el contra-ataque, la acción no se cumple var = change_player(p_counter) if var == 1: return 0 elif a == 0 and b == 1: #Pierde el desafío el que contra-atacó, se ejecuta la acción action = Murder(players, p_counter) action.murder() elif b == 3: #El que contraatacó ganó el desafío. if a == 1: players[c]._Players__influence1 = return_card( players[c]._Players__influence1) else: players[c]._Players__influence2 = return_card( players[c]._Players__influence2) var = change_player(p_counter) if var == 1: return 0 elif selection == 6: #EXTORSIÓN------------- action = Challenge(p_counter, players, 1, 6) a, b, c = action.challenge_player() if a == 0 and b == 0: #Nadie quiso contra-atacar, luego van los contra-ataques action = Counter_attack(p_counter, players, 6) player_attack = action.attack() if player_attack == 0: #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción action = Extortion(players, p_counter) action.extortion() else: #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa) action = Challenge(player_attack - 1, players, 2, 6) a, b, c = action.challenge_player( ) #c es el jugador que desafió if a == 0 and b == 0: #Nadie desafía el contra-ataque, la acción no se cumple var = change_player(p_counter) if var == 1: return 0 elif a == 0 and b == 1: #Pierde el desafío el que contra-atacó, se ejecuta la acción action = Extortion(players, p_counter) action.extortion() elif b == 3: #El que contraatacó ganó el desafío. if a == 1: players[c]._Players__influence1 = return_card( players[c]._Players__influence1) else: players[c]._Players__influence2 = return_card( players[c]._Players__influence2) elif a == 0 and b == 1: #el jugador pierde el desafío entonces no realiza la acción y cambia de turno var = change_player(p_counter) if var == 1: return 0 elif b == 3: #Si poseía la carta influencia, pasa a contra-ataque if a == 1: players[p_counter]._Players__influence1 = return_card( players[p_counter]._Players__influence1) elif a == 2: players[p_counter]._Players__influence2 = return_card( players[p_counter]._Players__influence2) action = Counter_attack(p_counter, players, 5) player_attack = action.attack() if player_attack == 0: #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción action = Extortion(players, p_counter) action.extortion() else: #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa) action = Challenge(player_attack - 1, players, 2, 5) a, b, c = action.challenge_player( ) #c es el jugador que desafió if a == 0 and b == 0: #Nadie desafía el contra-ataque, la acción no se cumple var = change_player(p_counter) if var == 1: return 0 elif a == 0 and b == 1: #Pierde el desafío el que contra-atacó, se ejecuta la acción action = Extortion(players, p_counter) action.extortion() elif b == 3: #El que contraatacó ganó el desafío. if a == 1: players[c]._Players__influence1 = return_card( players[c]._Players__influence1) else: players[c]._Players__influence2 = return_card( players[c]._Players__influence2) elif selection == 7: #LISTA------------- action = Challenge(p_counter, players, 1, 7) a, b, c = action.challenge_player() if a == 0 and b == 0: #Nadie quiso desafiar, entonces se hace la acción action = Change(players, p_counter, influences) action.change_cards() elif a == 0 and b == 1: #el jugador pierde el desafío entonces no realiza la acción y cambia de turno var = change_player(p_counter) if var == 1: return 0 elif b == 3: #Si poseía la carta influencia, realiza la acción if a == 1: players[p_counter]._Players__influence1 = return_card( players[p_counter]._Players__influence1) elif a == 2: players[p_counter]._Players__influence2 = return_card( players[p_counter]._Players__influence2) action = Change(players, p_counter, influences) action.change_cards() var = change_player(p_counter) if var == 1: return 0
def test_net_rate_35_net_is_10000000000_00(self): self.assertEqual(2862500.0, Tax(10000000000.00))
def test_net_rate_35_net_is_5000001(self): self.assertEqual(1112500.35, Tax(5000001))
def test_not_number(self): self.assertEqual("Input Error!", Tax("str"))
def test_net_rate_25_net_is_2000000(self): self.assertEqual(512500.0, Tax(2000000))
def test_net_rate_20_net_is_1000000(self): self.assertEqual(262500.0, Tax(1000000))
def _initialize_squares(): PROP_MEDITERRANEAN = ColorProperty(name=MEDITERRANEAN_AVENUE, price=60, rents=[4, 10, 30, 90, 160, 250], property_group=PURPLE, size_of_property_group=2, house_price=50) PROP_BALTIC = ColorProperty(name=BALTIC_AVENUE, price=60, rents=[4, 20, 60, 180, 320, 450], property_group=PURPLE, size_of_property_group=2, house_price=50) PROP_ORIENTAL = ColorProperty(name=ORIENTAL_AVENUE, price=100, rents=[6, 30, 90, 270, 400, 550], property_group=LIGHT_BLUE, size_of_property_group=3, house_price=50) PROP_VERMONT = ColorProperty(name=VERMONT_AVENUE, price=100, rents=[6, 30, 90, 270, 400, 550], property_group=LIGHT_BLUE, size_of_property_group=3, house_price=50) PROP_CONNECTICUT = ColorProperty(name=CONNECTICUT_AVENUE, price=120, rents=[8, 40, 100, 300, 450, 600], property_group=LIGHT_BLUE, size_of_property_group=3, house_price=50) PROP_ST_CHARLES = ColorProperty(name=ST_CHARLES_PLACE, price=140, rents=[10, 50, 150, 450, 625, 750], property_group=PINK, size_of_property_group=3, house_price=100) PROP_STATES = ColorProperty(name=STATES_AVENUE, price=140, rents=[10, 50, 150, 450, 625, 750], property_group=PINK, size_of_property_group=3, house_price=100) PROP_VIRGINIA = ColorProperty(name=VIRGINIA_AVENUE, price=160, rents=[12, 60, 180, 500, 700, 900], property_group=PINK, size_of_property_group=3, house_price=100) PROP_ST_JAMES = ColorProperty(name=ST_JAMES_PLACE, price=180, rents=[14, 70, 200, 550, 750, 950], property_group=ORANGE, size_of_property_group=3, house_price=100) PROP_TENNESSEE = ColorProperty(name=TENNESSEE_AVENUE, price=180, rents=[14, 70, 200, 550, 750, 950], property_group=ORANGE, size_of_property_group=3, house_price=100) PROP_NEW_YORK = ColorProperty(name=NEW_YORK_AVENUE, price=200, rents=[16, 80, 220, 600, 800, 1000], property_group=ORANGE, size_of_property_group=3, house_price=100) PROP_KENTUCKY = ColorProperty(name=KENTUCKY_AVENUE, price=220, rents=[18, 90, 250, 700, 875, 1050], property_group=RED, size_of_property_group=3, house_price=150) PROP_INDIANA = ColorProperty(name=INDIANA_AVENUE, price=220, rents=[18, 90, 250, 700, 875, 1050], property_group=RED, size_of_property_group=3, house_price=150) PROP_ILLINOIS = ColorProperty(name=ILLINOIS_AVENUE, price=240, rents=[20, 100, 300, 750, 925, 1100], property_group=RED, size_of_property_group=3, house_price=150) PROP_ATLANTIC = ColorProperty(name=ATLANTIC_AVENUE, price=260, rents=[22, 110, 330, 800, 975, 1150], property_group=YELLOW, size_of_property_group=3, house_price=150) PROP_VENTNOR = ColorProperty(name=VENTNOR_AVENUE, price=260, rents=[22, 110, 330, 800, 975, 1150], property_group=YELLOW, size_of_property_group=3, house_price=150) PROP_MARVIN = ColorProperty(name=MARVIN_GARDENS, price=280, rents=[24, 120, 360, 850, 1025, 1200], property_group=YELLOW, size_of_property_group=3, house_price=150) PROP_PACIFIC = ColorProperty(name=PACIFIC_AVENUE, price=300, rents=[26, 130, 390, 900, 1100, 1275], property_group=GREEN, size_of_property_group=3, house_price=200) PROP_NORTH_CAROLINA = ColorProperty( name=NORTH_CAROLINA_AVENUE, price=300, rents=[26, 130, 390, 900, 1100, 1275], property_group=GREEN, size_of_property_group=3, house_price=200) PROP_PENNSYLVANIA = ColorProperty( name=PENNSYLVANIA_AVENUE, price=320, rents=[28, 150, 450, 1000, 1200, 1400], property_group=GREEN, size_of_property_group=3, house_price=200) PROP_PARK = ColorProperty(name=PARK_PLACE, price=350, rents=[35, 175, 500, 1100, 1300, 1500], property_group=DARK_BLUE, size_of_property_group=2, house_price=200) PROP_BOARDWALK = ColorProperty(name=BOARDWALK, price=400, rents=[50, 200, 600, 1400, 1700, 2000], property_group=DARK_BLUE, size_of_property_group=2, house_price=200) PROP_READING_RAILROAD = NonColorProperty(name=READING_RAILROAD, price=200, rents=[25, 50, 100, 200], property_group=RAILROAD, size_of_property_group=4) PROP_PENNSYLVANIA_RAILROAD = NonColorProperty( name=PENNSYLVANIA_RAILROAD, price=200, rents=[25, 50, 100, 200], property_group=RAILROAD, size_of_property_group=4) PROP_B_AND_O_RAILROAD = NonColorProperty(name=B_AND_O_RAILROAD, price=200, rents=[25, 50, 100, 200], property_group=RAILROAD, size_of_property_group=4) PROP_SHORT_LINE = NonColorProperty(name=SHORT_LINE_RAILROAD, price=200, rents=[25, 50, 100, 200], property_group=RAILROAD, size_of_property_group=4) PROP_ELECTRIC_COMPANY = NonColorProperty(name=ELECTRIC_COMPANY, price=150, rents=[-1, -1], property_group=UTILITY, size_of_property_group=2) PROP_WATER_WORKS = NonColorProperty(name=WATER_WORKS, price=150, rents=[-1, -1], property_group=UTILITY, size_of_property_group=2) PROP_GO = FreeSpace(name=GO) PROP_JAIL = FreeSpace(name=JAIL) PROP_FREE_PARKING = FreeSpace(name=FREE_PARKING) PROP_GO_TO_JAIL = GoToJail(name=GO_TO_JAIL) PROP_COMMUNITY_CHEST_1 = Card(name=COMMUNITY_CHEST_1, card_type=COMMUNITY_CHEST_CARD) PROP_COMMUNITY_CHEST_2 = Card(name=COMMUNITY_CHEST_2, card_type=COMMUNITY_CHEST_CARD) PROP_COMMUNITY_CHEST_3 = Card(name=COMMUNITY_CHEST_3, card_type=COMMUNITY_CHEST_CARD) PROP_CHANCE_1 = Card(name=CHANCE_1, card_type=CHANCE_CARD) PROP_CHANCE_2 = Card(name=CHANCE_2, card_type=CHANCE_CARD) PROP_CHANCE_3 = Card(name=CHANCE_3, card_type=CHANCE_CARD) PROP_INCOME_TAX = Tax(name=INCOME_TAX, tax=200) PROP_LUXURY_TAX = Tax(name=LUXURY_TAX, tax=100) return [ PROP_GO, PROP_MEDITERRANEAN, PROP_COMMUNITY_CHEST_1, PROP_BALTIC, PROP_INCOME_TAX, PROP_READING_RAILROAD, PROP_ORIENTAL, PROP_CHANCE_1, PROP_VERMONT, PROP_CONNECTICUT, PROP_JAIL, PROP_ST_CHARLES, PROP_ELECTRIC_COMPANY, PROP_STATES, PROP_VIRGINIA, PROP_PENNSYLVANIA_RAILROAD, PROP_ST_JAMES, PROP_COMMUNITY_CHEST_2, PROP_TENNESSEE, PROP_NEW_YORK, PROP_FREE_PARKING, PROP_KENTUCKY, PROP_CHANCE_2, PROP_INDIANA, PROP_ILLINOIS, PROP_B_AND_O_RAILROAD, PROP_ATLANTIC, PROP_VENTNOR, PROP_WATER_WORKS, PROP_MARVIN, PROP_GO_TO_JAIL, PROP_PACIFIC, PROP_NORTH_CAROLINA, PROP_COMMUNITY_CHEST_3, PROP_PENNSYLVANIA, PROP_SHORT_LINE, PROP_CHANCE_3, PROP_PARK, PROP_LUXURY_TAX, PROP_BOARDWALK ]
def test_net_rate_15_net_is_750000(self): self.assertEqual(112500.0, Tax(750000))
def test_net_rate_20_net_is_750001(self): self.assertEqual(112500.20, Tax(750001))
def test_net_rate_0_net_is_0(self): self.assertEqual(0.0, Tax(0.0))
def test_net_rate_25_net_is_1000001(self): self.assertEqual(262500.25, Tax(1000001))
def test_net_rate_0_net_is_150000(self): self.assertEqual(0.0, Tax(150000))
def test_net_rate_30_net_is_2000001(self): self.assertEqual(512500.30, Tax(2000001))
def test_net_rate_5_net_is_150001(self): self.assertEqual(0.05, Tax(150001))
def test_net_rate_30_net_is_5000000(self): self.assertEqual(1112500.0, Tax(5000000))
def test_net_rate_5_net_is_300000(self): self.assertEqual(7500, Tax(300000))
def test_net_rate_35_net_is_9999999999_99(self): self.assertEqual(2862500.0, Tax(9999999999.99))
def test_net_rate_10_net_is_300001(self): self.assertEqual(7500.1, Tax(300001))
def test_min_0(self): self.assertEqual("Input Error!", Tax(-1))
def test_net_rate_10_net_is_500000(self): self.assertEqual(37500.0, Tax(500000))