示例#1
0
 def create_agents_list(count: int):
     """
     Creates and returns a list of a dictionary
     -"agent":Holds the agent's dictionary (info)
     -'time':Holds the agent's (date)time that he's still busy. 
             If the time is in the past, he's not busy
     -'deals':Holds total deals earned  (10k per closed deal)
     -'revenue': revenue from each car sold
     """
     agents_list = []
     _today = datetime.today()
     for agent in agents(count):
         agents_list.append({
             'agent':
             agent,
             'time':
             datetime(_today.year, _today.month, _today.day, 8),
             'commission':
             0,
             'revenue':
             0,
             'bonus':
             False,
             'deals':
             0,
             'deals_attempted':
             0,
         })
     return agents_list
示例#2
0
文件: agent.py 项目: eyang8828/Cars
 def setUp(self):
     self.agents = agents.agents(5)
     self.customers = customers.customers(100)
     self.agents_list = []
     for aget in self.agents:
         new_agent = agent.Agent(**aget)
         self.agents_list.append(new_agent)
示例#3
0
文件: agent.py 项目: eyang8828/Cars
 def test_bonus(self):
     """
     check whether bonus applied correctly.
     """
     the_agent_stuff = agents.agents(1)
     test_list = []
     for stuff in the_agent_stuff:
         the_agent = agent.Agent(**stuff)
         test_list.append(the_agent)
     agent.Agent.init(*test_list)
     for customer in self.customers:
         best_agent, wait_time = agent.Agent.get(**customer)
     self.assertTrue(agent.Agent.bonus(best_agent.agent_id))
示例#4
0
    def showTable():
        """
        Show all the performaces results and display them in a QTableWidget
        """
        random.seed(0)

        # Check if user enter 0
        if Sales.agents == 0 or Sales.customers == 0:
            Sales.table.setRowCount(0)
            Sales.mean.setText("0.0")
            Sales.median.setText("0.0")
            Sales.sd.setText("0.0")
            return
        # Else do regular logic and display result to the table
        else:
            Agent.init(agents(Sales.agents),
                       datetime.today().replace(hour=HOURS[0]))
            waits = []
            for customer in customers(Sales.customers):
                agent, wait = Agent.get(customer)
                waits.append(wait)
            locale.setlocale(locale.LC_ALL, locale.getlocale())
            Sales.mean.setText(str(statistics.mean(waits)))
            Sales.median.setText(str(statistics.median(waits)))
            if len(waits) == 1:
                Sales.sd.setText("0.0")
            else:
                Sales.sd.setText("{:.2f}".format(statistics.stdev(waits)))
            Sales.table.setRowCount(Sales.agents)
            for index, agent in enumerate(Agent.list):
                Sales.table.setItem(index, 0,
                                    QTableWidgetItem(str(agent.agent_id)))
                Sales.table.setItem(index, 1,
                                    QTableWidgetItem(str(agent.closes)))
                Sales.table.setItem(
                    index, 2,
                    QTableWidgetItem(str(locale.currency(agent.revenue))))
                Sales.table.setItem(
                    index, 3,
                    QTableWidgetItem(str(locale.currency(agent.closes *
                                                         10000))))
                Sales.table.setItem(
                    index, 4,
                    QTableWidgetItem(
                        str(locale.currency(agent.bonuses * 100000))))
示例#5
0
    def sales(self):
        """
        Simulate sales using test data and print out customer and agent reports showing
            (1) Summary statistics, with the mean, median, and SD of customer wait times.
            (2) Agent data showing agent ID, deals closed, total revenue generated,
                commission earned, and bonus awarded, in a tabular form.
        """
        all_customers = customers(100)
        all_agents = agents(5)
        list_of_agent = []
        for aget in all_agents:
            new_agent = agent.Agent(**aget)
            list_of_agent.append(new_agent)
        agent.Agent.init(*list_of_agent)
        date = 0
        wait_times = []
        for customer in all_customers:
            """
            check if it's a new day. If true, reset the appointment 
            """
            if customer.get("arrival_time").day > date:
                agent.Agent.new_day()
                date = customer.get("arrival_time").day
            """
            pass the customer the method "get", and return with the selected agent and waittime
            """
            best_agent, wait_time = agent.Agent.get(**customer)
            wait_times.append(wait_time)
        """
        get the wait_time status
        """
        best_agent.get_stats(*wait_times)

        for aagent in list_of_agent:
            agent.Agent.bonus(aagent.agent_id)
            print()
            print("Agent_id : ", aagent.agent_id)
            agent.Agent.get_sales(aagent.agent_id)
示例#6
0
文件: run.py 项目: vutran25/display
    def report(self):
        """
        Simulate sales using test data and print out customer and agent reports.
        """
        random.seed(0)
        Agent.init(agents(5), datetime.today().replace(hour=HOURS[0]))
        waits = []
        for customer in customers(100):
            agent, wait = Agent.get(customer)
            waits.append(wait)

        locale.setlocale(locale.LC_ALL, locale.getlocale())
        print("{:<9.4}{:<9.4}{:<9.4}".format("MEAN", "MED", "SD"))
        print("{:<9.4}{:<9.4}{:<9.4}".format(statistics.mean(waits),
                                             statistics.median(waits),
                                             statistics.stdev(waits)))
        print("\n{:<9}{:>6}{:>18}{:>18}{:>18}".format("ID", "DEALS", "REVENUE",
                                                      "COMMISSION", "BONUS"))
        for agent in Agent.list:
            print("{:<9}{:>6}{:>18}{:>18}{:>18}".format(
                agent.agent_id, agent.closes, locale.currency(agent.revenue),
                locale.currency(agent.closes * 10000),
                locale.currency(agent.bonuses * 100000)))
示例#7
0
 def test_get(cls, customer):
     for agent in Agent.init(agents(1)):
         assert agent.deals_closed == 10
         assert agent._bonus > customer["arrival_time"]
         if agent.bonus == 100000:
             print("this test works")
示例#8
0

class Run(object):
    """
    Run the sales.
    """
    def sales(self):
        """
        Simulate sales using test data and print out customer and agent reports showing
            (1) Summary statistics, with the mean, median, and SD of customer wait times.
            (2) Agent data showing agent ID, deals closed, total revenue generated,
                commission earned, and bonus awarded, in a tabular form.
        """


Agent.init(agents(5))

agents = Agent._agents
agent_stats = []
agents = []
wait_times = []

for customer in customers(100):
    stats = Agent.get(customer)
    wait_times.append(stats[0])
    agent_stats.append(stats[1:])

#Calculating Mean, Median, SD
wait_time_mean = ((sum(wait_times)) / float(len(wait_times)))
wait_time_median = median(wait_times)
SD = stdev(wait_times)
示例#9
0
"""
ALL 5 agents
"""
import random
from data.agents import agents
random.seed(0)
AGENTS = list(agents(5))