Пример #1
0
def sample_command(args):
  plane = PLANES[args.plane]
  part91_hours = args.part91_hours
  part135_hours = args.part135_hours
  years = args.years
  acquisition = parse_acquisition(args)
  usage_model = parse_usage_model(args)
  constants = parse_constants(args)
  plane = update_plane(plane, args)

  balance = simple(
      plane,
      acquisition,
      part91_hours,
      part135_hours,
      years,
      usage=usage_model,
      constants=constants,
      sell=args.sell)

  part91_percentage = 1. * part91_hours / (part91_hours + part135_hours)

  for year in range(years + 1):
    print('year %d: %s' % (year, ' '.join(map(str, balance.select(year=year)))))
    income = balance.sum(year=year, item_klazz=Income)
    profit = tax_adjusted_profit(balance, year=year, part91_percentage=part91_percentage)
    print('  -> income: %.2f, profit: %.2f' % (income, profit))
    print('')

  print('aggregate:')
  income = balance.sum(item_klazz=Income)
  profit = tax_adjusted_profit(balance, part91_percentage=part91_percentage)
  print('  -> income: %.2f, profit: %.2f' % (income, profit))
Пример #2
0
  def model(plane, acquisition, hours, years):
    balance_sheet = simple(
        plane,
        acquisition,
        part91_hours,
        hours,
        years,
        usage=usage_model,
        constants=constants,
        sell=args.sell)

    part91_percentage = 1. * part91_hours / (part91_hours + hours)
    value = tax_adjusted_profit(balance_sheet, part91_percentage=part91_percentage)

    if args.output == 'outlay':
      return value
    elif args.output == 'hourly':
      return value / (part91_hours * 12 * years) if (part91_hours * years) > 0 else 0
    elif args.output == 'yearly':
      return value / years if years > 0 else 0
    else:
      raise ValueError('Unknown outlay type %s' % args.output)