#!/usr/bin/env python3
import datetime as dt

class Bill:
    '''
    This is the class to represent each bill, having the info about:
        - $$
        - Author
        - Description
    '''
    def __init__(self, bill_amount, bill_payer, bill_name):
        ''' Default constructor, takes ($, Author, Description) '''
        self.amount = bill_amount
        self.description = bill_name
        self.payer = bill_payer

    def __repr__(self):
        ''' Representation when called direcly '''
        return 'R$ {:7.2f} - {} ({})'.format(
            self.amount, self.description, self.payer)

    def get_amount(self):
        ''' get method for $$ '''
        return self.amount

    def get_payer(self):
        ''' get method for payer '''
        return self.payer

    def get_description(self):
        ''' get method for description '''
        return self.description

class Bank:
    def __init__(self, b_name):
        ''' default constructor for creating a new bank (i.e.: Bank("Name")) '''
        self.bank_name = str()
        self.wallet_list = {}
        self.bills_list = list()
        self.bank_name = b_name

    def add(self, bill, payer, description):
        '''
        Add a specific bill to the bank, like:
        bank.add(1.99, "Me", "Something")
        '''
        b = Bill(bill, payer, description)
        self.bills_list.append(b)
   
    def insert(self, value, description):
        '''
        Add a specific amount of money to the bank account, like:
        bank.add(1200.0, 'salary')
        '''
        if description not in self.wallet_list:
            self.wallet_list[description] = value
        else:
            self.wallet_list[description] += value
        
    def get_wallet(self):
        return self.wallet_list
        
   
    def report(self):
        ''' see all bills in a pretty print '''
        # first, sort the list
        self.bills_list = sorted(self.bills_list, key = lambda k: k.get_amount(), reverse = True)
        print("@ {}".format(self.bank_name))
        for bill in self.bills_list:
            print('\t', end='')
            print(bill)

    def sum(self):
        ''' get total bank sum '''
        sum = float()
        for bill in self.bills_list:
            sum += bill.get_amount()
        return sum

    def sum_payer(self, payer):
        ''' get specific payer bank sum '''
        sum = float()
        for bill in self.bills_list:
            if(bill.get_payer() == payer):
                sum += bill.get_amount()
        return sum

    def payers(self):
        ''' returns a set of payers of a given bank '''
        set_payers = list()
        for bill in self.bills_list:
            set_payers.append(bill.get_payer())
        set_payers = set(set_payers)
        return set_payers

def gen_bill(bank):
    ''' general function to give a bill report '''
    bank.report()
    print('\t' + "-" * 38)
    print('\t' + "R$ {:7.2f} - TOTAL".format(bank.sum()))
    print("\n\t~ DIVIDED TO:")
    for payer in bank.payers():
        print('\t' + "R$ {:7.2f} - {}".format(bank.sum_payer(payer), payer))
    print()
    
def gen_wallet(bank):
    '''general function to give a wallet report '''
    print("\t~ AMOUNT IN MY ACCOUNT:")
    for description, value in bank.get_wallet().items():
        print('\t' + "R$ {:7.2f} - {}".format(value, description))
    print()
    

def timestamp():
    print("Generated on:", dt.datetime.now())


#!/usr/bin/env python3
import datetime as dt

class Bill:
    '''
    This is the class to represent each bill, having the info about:
        - $$
        - Author
        - Description
    '''
    def __init__(self, bill_amount, bill_payer, bill_name):
        ''' Default constructor, takes ($, Author, Description) '''
        self.amount = bill_amount
        self.description = bill_name
        self.payer = bill_payer

    def __repr__(self):
        ''' Representation when called direcly '''
        return 'R$ {:7.2f} - {} ({})'.format(
            self.amount, self.description, self.payer)

    def get_amount(self):
        ''' get method for $$ '''
        return self.amount

    def get_payer(self):
        ''' get method for payer '''
        return self.payer

    def get_description(self):
        ''' get method for description '''
        return self.description

class Bank:
    def __init__(self, b_name):
        ''' default constructor for creating a new bank (i.e.: Bank("Name")) '''
        self.bank_name = str()
        self.wallet_list = {}
        self.bills_list = list()
        self.bank_name = b_name

    def add(self, bill, payer, description):
        '''
        Add a specific bill to the bank, like:
        bank.add(1.99, "Me", "Something")
        '''
        b = Bill(bill, payer, description)
        self.bills_list.append(b)
   
    def insert(self, value, description):
        '''
        Add a specific amount of money to the bank account, like:
        bank.add(1200.0, 'salary')
        '''
        if description not in self.wallet_list:
            self.wallet_list[description] = value
        else:
            self.wallet_list[description] += value
        
    def get_wallet(self):
        return self.wallet_list
        
   
    def report(self):
        ''' see all bills in a pretty print '''
        # first, sort the list
        self.bills_list = sorted(self.bills_list, key = lambda k: k.get_amount(), reverse = True)
        print("@ {}".format(self.bank_name))
        for bill in self.bills_list:
            print('\t', end='')
            print(bill)

    def sum(self):
        ''' get total bank sum '''
        sum = float()
        for bill in self.bills_list:
            sum += bill.get_amount()
        return sum

    def sum_payer(self, payer):
        ''' get specific payer bank sum '''
        sum = float()
        for bill in self.bills_list:
            if(bill.get_payer() == payer):
                sum += bill.get_amount()
        return sum

    def payers(self):
        ''' returns a set of payers of a given bank '''
        set_payers = list()
        for bill in self.bills_list:
            set_payers.append(bill.get_payer())
        set_payers = set(set_payers)
        return set_payers

def gen_bill(bank):
    ''' general function to give a bill report '''
    bank.report()
    print('\t' + "-" * 38)
    print('\t' + "R$ {:7.2f} - TOTAL".format(bank.sum()))
    print("\n\t~ DIVIDED TO:")
    for payer in bank.payers():
        print('\t' + "R$ {:7.2f} - {}".format(bank.sum_payer(payer), payer))
    print()
    
def gen_wallet(bank):
    '''general function to give a wallet report '''
    print("\t~ AMOUNT IN MY ACCOUNT:")
    for description, value in bank.get_wallet().items():
        print('\t' + "R$ {:7.2f} - {}".format(value, description))
    print()
    

def timestamp():
    print("Generated on:", dt.datetime.now())


#!/usr/bin/env python3 This is the class to represent each bill, having the info about:         - $$         - Author         - Description Default constructor, takes ($, Author, Description) Representation when called direcly get method for $$ get method for payer get method for description default constructor for creating a new bank (i.e.: Bank("Name")) Add a specific bill to the bank, like:         bank.add(1.99, "Me", "Something") Add a specific amount of money to the bank account, like:         bank.add(1200.0, 'salary') see all bills in a pretty print # first, sort the list get total bank sum get specific payer bank sum returns a set of payers of a given bank general function to give a bill report general function to give a wallet report