def analyze(): # z = int(input('Show remaining money? Yes = 1 OR No = Any_key : ')) # if z == 1: p = dir.file('/db.txt') z = open(p, 'r') cal = 0 rem = 0 for i in z: # reading values of amount in db to sum up to cal y = ast.literal_eval(i) if y['Type'] == 'CREDIT': x = int(y['amount']) cal += x elif y['Type'] == 'DEBIT': m = int(y['amount']) rem += m statement_cre = 'Your total credit amount : N{}'.format(cal) statement_deb = 'Your total debit amount : N{}'.format(rem) final = cal - rem if final < 0: final_fix = abs(final) statement_err = 'Your balance is: N{}, means you have spend N{} over-budget'.format( final, final_fix) # gets absolute of remaining money statement_tol = 0 else: statement_err = 0 statement_tol = 'Your balance is: N{}'.format(final) x = [statement_cre, statement_deb, statement_tol, statement_err] z.close() return x
def __init__(self, **kwargs): super(MenuPage, self).__init__(**kwargs) box = FloatLayout box.padding = 20 box.spacing = 10 Window.size = (500, 300) with self.canvas.before: box.rect = Rectangle(source=dir.file('/res/wall.jpg'), size=Window.size, pos=self.pos) wel = Image(source=dir.file('/res/welcome.jpg'), size_hint=(1, .3), pos_hint={'top': .96}) box.add_widget(self, wel) btn1 = Button(text='CREDIT', bold=True, size_hint=(.3, .2), pos_hint={ 'center_x': .3, 'center_y': .5 }, background_color=(0, 1, 0, .8)) btn1.bind(on_press=self.changeScreen) box.add_widget(self, btn1) btn2 = Button(text='DEBIT', bold=True, size_hint=(.3, .2), pos_hint={ 'center_x': .7, 'center_y': .5 }, background_color=(1, 0, 0, .8)) btn2.bind(on_press=self.changeScreen) box.add_widget(self, btn2) btn3 = Button(text='VAULT', bold=True, size_hint=(.3, .2), pos_hint={ 'center_x': .5, 'center_y': .25 }, background_color=(.5, .5, .8, .8)) btn3.bind(on_press=self.validate) box.add_widget(self, btn3)
def __init__(self, **kwargs): super(VaultPage, self).__init__(**kwargs) self.padding = 20 self.spacing = 10 Window.size = (500, 300) with self.canvas.before: self.rect = Rectangle(source=dir.file('/res/wall.jpg'), size=Window.size, pos=self.pos) self.home = ImageButton(source=dir.file('/res/home_btn.jpg'), size_hint=(.15, .15), pos_hint={ 'center_y': .9, 'center_x': .9 }) self.home.bind(on_release=self.changeScreen) self.add_widget(self.home) self.btn1 = Button(text='SUMMARY', bold=True, size_hint=(.3, .15), pos_hint={ 'center_x': .3, 'center_y': .1 }, background_color=(0, 1, 0, .8)) self.btn1.bind(on_press=self.summary_gen) self.add_widget(self.btn1) self.btn2 = Button(text='ACCT BALANCE', bold=True, size_hint=(.3, .15), pos_hint={ 'center_x': .7, 'center_y': .1 }, background_color=(0, 1, 0, .8)) self.btn2.bind(on_press=self.adapt) self.add_widget(self.btn2)
def __init__(self, **kwargs): super(DbPage, self).__init__(**kwargs) self.padding = 20 self.spacing = 10 Window.size = (500, 300) with self.canvas.before: self.rect = Rectangle(source=dir.file('/res/wall.jpg'), size=Window.size, pos=self.pos) self.btn1 = Button(text='CREDIT', bold=True, size_hint=(.3, .2), pos_hint={ 'center_x': .3, 'center_y': .5 }, background_color=(0, 1, 0, .8)) self.btn1.bind(on_press=self.changeScreen) self.add_widget(self.btn1)
def call_part(): # returns data from db.txt o = dir.file('/db.txt') z = open(o, 'r') for i in z: f = ast.literal_eval(i) if f['Type'] == 'CREDIT': table['CREDIT'] = table.get('CREDIT', []) + [f['amount']] table['RECP'] = table.get('RECP', []) + [f['sender']] table['METHOD'] = table.get('METHOD', []) + [f['method']] table['DEBIT'] = table.get('DEBIT', []) + ['-'] table['DATE/TIME'] = table.get('DATE/TIME', []) + [f['date/time']] elif f['Type'] == 'DEBIT': table['DEBIT'] = table.get('DEBIT', []) + [f['amount']] table['CREDIT'] = table.get('CREDIT', []) + ['-'] table['RECP'] = table.get('RECP', []) + [f['sender']] table['METHOD'] = table.get('METHOD', []) + [f['method']] table['DATE/TIME'] = table.get('DATE/TIME', []) + [f['date/time']] report = pd.DataFrame(table) table.clear() return str(report)
def __init__(self, **kwargs): super(EntryPage, self).__init__(**kwargs) self.padding = 20 self.spacing = 10 Window.size = (500, 300) with self.canvas.before: self.rect = Rectangle(source=dir.file('/res/wall.jpg'), size=Window.size, pos=self.pos) self.amount = TextInput(id='credit_amount', multiline=False, write_tab=False, size_hint=(.7, .1), pos_hint={ 'center_x': .5, 'center_y': .8 }, hint_text=self.hint[0]) self.add_widget(self.amount) self.recp = TextInput(id='credit_recp', multiline=False, write_tab=False, size_hint=(.7, .1), pos_hint={ 'center_x': .5, 'center_y': .6 }, hint_text=self.hint[1]) self.add_widget(self.recp) self.purpose = TextInput(id='credit_purpose', multiline=False, write_tab=False, size_hint=(.7, .1), pos_hint={ 'center_x': .5, 'center_y': .4 }, hint_text=self.hint[2]) self.add_widget(self.purpose) self.cash = CheckBox(id='Cash', size_hint=(.2, .1), pos_hint={ 'center_x': .15, 'center_y': .2 }) self.bank = CheckBox(id='Bank', size_hint=(.2, .1), pos_hint={ 'center_x': .8, 'center_y': .2 }) self.cash.bind(on_press=self.toggle) self.bank.bind(on_press=self.toggle) self.add_widget(self.cash) self.add_widget(self.bank) self.cash_L = Label(text='Cash', bold=True, size_hint=(.2, .1), pos_hint={ 'center_x': .23, 'center_y': .2 }) self.bank_L = Label(text='Bank', bold=True, size_hint=(.2, .1), pos_hint={ 'center_x': .88, 'center_y': .2 }) self.add_widget(self.cash_L) self.add_widget(self.bank_L) self.btn1 = Button(text='SUBMIT', bold=True, size_hint=(.3, .2), pos_hint={ 'center_x': .5, 'center_y': .1 }, background_color=(0, 1, 0, .8)) self.btn1.bind(on_press=self.store) self.add_widget(self.btn1)