コード例 #1
0
def create_deposit(deposit_data):
    try:
        deposit_df = turn_deposit_data_into_df(deposit_data)
        add_new_deposit(format_deposit_df(deposit_df))
        return success_response()
    except:
        return failure_response('Unknown deposit error')
コード例 #2
0
ファイル: file_manager.py プロジェクト: dolitham/arlo
def set_field_to_value_on_ids_deposit_input(ids, field_name, field_value):
    if field_name == 'id':
        return failure_response('Impossible to change id')
    deposit_input = read_deposit_input()
    change_field_on_several_ids_to_value(deposit_input, ids, field_name,
                                         field_value)
    save_deposit_input(deposit_input)
    return success_response()
コード例 #3
0
def is_valid_transaction_df(df):
    print('#is_valid_transaction')
    print(df)
    if missing_valid_amount(df):
        return failure_response('no valid amount')

    if missing_mandatory_field(df):
        return failure_response('missing mandatory field')

    return success_response()
コード例 #4
0
def remove_data_on_id_if_possible(id_to_remove):
    transaction_to_delete = get_transaction_with_id(id_to_remove)
    if transaction_to_delete.shape[0] == 0:
        return failure_response('ID not found, nothing to delete')

    if set(transaction_to_delete['account'].tolist()) & set(auto_accounts):
        return failure_response('Impossible to remove automatic transaction')

    remove_data_on_id(id_to_remove)
    return success_response()
コード例 #5
0
ファイル: set_fields.py プロジェクト: dolitham/arlo
def edit_transaction(fields):
    if 'id' not in fields:
        return failure_response('invalid id')
    transaction_id = fields['id']
    response = success_response()
    for field in set(fields) - {'id'}:
        if field == 'cycle':
            response = change_cycle_on_id(transaction_id, fields[field])
        else:
            response = set_field_to_value_on_ids([transaction_id], field,
                                                 fields[field])
    return response
コード例 #6
0
def split_transaction_if_possible(the_input):
    data = read_data()
    transaction = filter_df_on_id(data, the_input['id'])

    if transaction.shape[0] != 1:
        return failure_response('Invalid id')

    if not amounts_valid_split(transaction, the_input['amount1'], the_input['amount2']):
        return failure_response('Invalid amounts')

    if not all_split_fields_present(the_input):
        return failure_response('Missing fields')

    _split_transaction(the_input, transaction)
    return success_response()
コード例 #7
0
ファイル: set_fields.py プロジェクト: dolitham/arlo
def link_ids_if_possible(ids):
    error_message, ids = parse_ids(ids)

    if error_message:
        return error_message

    if len(ids) < 2:
        return failure_response('not enough transactions')

    data = read_data()
    data_ids = filter_df_several_values(data, 'id', ids)

    if how_many_rows(data_ids) != len(ids):
        return failure_response('at least one transaction missing')

    if round(result_function_applied_to_field(data_ids, amount_euro_col, sum),
             2) != 0:
        return failure_response('transactions do not cancel each other out')

    if present_links_is_not_empty(data_ids):
        return failure_response('one or more transaction already linked')

    _link_ids(ids)
    return success_response()
コード例 #8
0
 def post():
     id_one_way = request.args.get('id')
     account = request.args.get('account')
     create_transfer_if_possible(id_one_way, account)
     return success_response()
コード例 #9
0
 def post():
     the_id = request.args.get('id')
     delete_deposit_debit(the_id)
     return success_response()
コード例 #10
0
 def post():
     the_id = request.args.get('id')
     the_deposit_name = request.args.get('deposit')
     create_deposit_debit(the_id, the_deposit_name)
     return success_response()
コード例 #11
0
def create_several_recurring(how_many_recurring):
    response = success_response()
    for name in how_many_recurring:
        if how_many_recurring[name] > 0:
            response = create_single_recurring(name, how_many_recurring[name])
    return response
コード例 #12
0
def remove_deposit_input_on_id_if_possible(id_to_remove):
    remove_deposit_input_on_id(id_to_remove)
    return success_response()
コード例 #13
0
def status_field_not_empty(field_name, field_value):
    if field_value is None:
        return failure_response('No ' + field_name + ' Entered')
    return success_response()