def edit_balance(edit_click, submit_click, cname, cfunds, cgoal, cgoal_date, name, funds, goal, goal_date, user): funcs = dc.Data(user['name'], user['password']) button_id = {'type': ''} ctx = dash.callback_context if ctx.triggered: button_id = json.loads(ctx.triggered[0]['prop_id'].split('.')[0]) if button_id['type'] == 'balance-edit-icon': return {'display':''},{'display':''},{'display':''},{'display':''}\ ,{'display':'none'},{'display':'none'},{'display':'none'},{'display':'none'}\ ,{'display':'none'},{'display':''} elif button_id['type'] == 'balance-submit-change-icon': if str(cname) != str(name) or str(cfunds) != str(funds) or str( cgoal) != str(goal) or str(cgoal_date) != str(goal_date): input_dict = {'cname':cname, 'cfunds':cfunds, 'cgoal':cgoal, 'cgoal_date':cgoal_date, 'name':name\ , 'funds':funds, 'goal':goal, 'goal_date':goal_date, 'user':user['name']} funcs.edit_balance(input_dict) return {'display':'none'},{'display':'none'},{'display':'none'},{'display':'none'}\ ,{'display':''},{'display':''},{'display':''},{'display':''}\ ,{'display':''},{'display':'none'} else: raise PreventUpdate
def get_data(user): data = dc.Data(user=user) expense_proj = data.projection_summary() return_dict = { 'proj_summary':expense_proj } return return_dict
def get_data(user, password): data = dc.Data(user, password) balances = data.display_balances().round(2) balance_names = [{ 'label': i, 'value': i } for i in balances.loc[:, 'name'].sort_values().unique()] return_dict = {'balances': balances, 'balance_names': balance_names} return return_dict
def new_balance(n_clicks, name, funds, goal, goal_date, user_store): if n_clicks: input_dict = { 'name': name, 'funds': funds, 'goal': goal, 'goal_date': goal_date, 'user': user_store['name'] } funcs = dc.Data(user_store['name'], user_store['password']) funcs.new_balance(input_dict)
def get_data(user, password): data = dc.Data(user=user, password=password) today = date.today() invoice_df = data.display_invoices() invoice_df.loc[:, 'date'] = pd.to_datetime( invoice_df.loc[:, 'date']).dt.strftime('%m/%d/%Y') categories = [{ 'label': i, 'value': i } for i in invoice_df.loc[:, 'category'].sort_values().unique()] expense_df = data.display_invoices(invoice_type='Expense') expense_summary = data.annual_summary() income_summary = data.annual_summary(invoice_type='Income') net_income = data.net_income() balances = data.display_balances().round(2) balance_names = [{ 'label': i, 'value': i } for i in balances.loc[:, 'name'].sort_values().unique()] expense_graph_df = expense_df.loc[:, ['date', 'value']] expense_graph_df.loc[:,'Year-Month'] = pd.DatetimeIndex(expense_graph_df.loc[:, ('date')]).year.astype(str) \ +'_'+ pd.DatetimeIndex(expense_graph_df.loc[:, ('date')]).month.astype(str) expense_graph_df = expense_graph_df.loc[:, ['Year-Month', 'value']].groupby( by=['Year-Month']).sum( ).sort_values(by='Year-Month') expense_fig = px.line(expense_graph_df.loc[:].rename(columns={ 'value': 'Expenses' }).reset_index(), x='Year-Month', y='Expenses') expense_proj = data.projection_summary() return_dict = { 'data': data, 'today': today, 'invoice_df': invoice_df, 'categories': categories, 'expense_df': expense_df.loc, 'expense_summary': expense_summary, 'income_summary': income_summary, 'net_income': net_income, 'balances': balances, 'balance_names': balance_names, 'expense_fig': expense_fig, 'proj_summary': expense_proj } return return_dict
def new_invoice(n_clicks, value, name, category, invoice_type, balance, date, user_store): if n_clicks: input_dict = { 'value': value, 'name': name, 'category': category, 'invoice_type': invoice_type, 'balance': balance, 'date': date, 'user': user_store['name'] } funcs = dc.Data(user_store['name'], user_store['password']) funcs.new_invoice(input_dict)
def transfer_balance(n_clicks, t_from, t_to, funds, user_store): if n_clicks: input_dict = { 'value': funds, 'name': f'From: {t_from}, To: {t_to}', 'category': 'Transfers', 'invoice_type': 'Transfer', 'balance': t_from, 'date': str(data['today']), 'user': user_store['name'], 'to_balance': t_to } funcs = dc.Data(user_store['name'], user_store['password']) funcs.new_invoice(input_dict, is_transfer=True)
def get_data(user): data = dc.Data(user=user) today = date.today() invoice_df = data.display_invoices() invoice_df.loc[:,'date'] = pd.to_datetime(invoice_df.loc[:, 'date']).dt.strftime('%m/%d/%Y') categories = [{'label':i,'value':i} for i in invoice_df.loc[:,'category'].sort_values().unique()] balances = data.display_balances().round(2) balance_names = [{'label':i,'value':i} for i in balances.loc[:,'name'].sort_values().unique()] return_dict = { 'today':today, 'invoice_df':invoice_df, 'categories':categories, 'balance_names':balance_names, } return return_dict
def get_data(user, password): data = dc.Data(user, password) balances = data.display_balances().round(2) balance_names = [{ 'label': i, 'value': i } for i in balances.loc[:, 'name'].sort_values().unique()] return_dict = {'balances': balances, 'balance_names': balance_names} return return_dict data = get_data('.', None) data_funcs = dc.Data('.', None) def create_balance_div(index, name, funds, goal, goal_date): layout = html.Div([ html.P(name, className='balance-p-name', id={ 'type': 'balance-p-name', 'index': index }), dcc.Input(className='change-bname-input', value=name, id={ 'type': 'change-bname-input', 'index': index