#!/usr/bin/env python
import argparse
from pymongo import MongoClient
from getpass import getpass
from Market import Market
from Business import Business
from Profile import myBusiness

parser = argparse.ArgumentParser(description='Utility used to make a trasaction between you and another business.')
parser.add_argument('name', metavar='name', type=str, nargs=1, help="The name of a business you want to transact with.")
parser.add_argument('quantity', metavar='quantity', type=int, nargs=1, help="The number of units you want to buy/sell.")

args=parser.parse_args()

print("You are the Business: %s"%myBusiness['name'])
me=Business.load(myBusiness['name'])
them=Business.load(args.name[0])
if me is None or them is None:
    print("There is a problem with this transaction.")
else:
    print(me,them)
    Business.transact(me,them,args.quantity[0])
    me.save()
    them.save()
