Beispiel #1
0
    def get_add_ledger_manually_input(self):
        ret = {}
        ret['description'] = self.request_string("Description:")
        ret['transaction_category'] = self.request_enum(TransactionTypes)
        from_account_name = self.request_from_dict(dsvca.accounts_as_dict(),
                                                   "From Account:")
        ret['from_account'] = dsvca.account_by_name(from_account_name)

        from_bucket_name = self.request_from_dict(
            dsvca.buckets_as_dict_by_account(ret['from_account']),
            "From Bucket:")
        ret['from_bucket'] = dsvca.bucket_by_account_and_name(
            ret['from_account'], from_bucket_name)

        ret['debit'] = self.request_float("Debit:")
        ret['credit'] = self.request_float("Credit:")

        to_account_name = self.request_from_dict(dsvca.accounts_as_dict(),
                                                 "To Account:")
        ret['to_account'] = dsvca.account_by_name(to_account_name)

        to_bucket_name = self.request_from_dict(
            dsvca.buckets_as_dict_by_account(ret['to_account']), "To Bucket:")
        ret['to_bucket'] = dsvca.bucket_by_account_and_name(
            ret['to_account'], to_bucket_name)
        ret['payment_type'] = self.request_enum(PaymentType)
        ret['date_stamp'] = self.request_date()
        ret['notes'] = self.request_string("Notes:")

        return ret
Beispiel #2
0
    def get_enter_ledger_from_income_transaction_input(self):
        ret = {}
        to_account_name = self.request_from_dict(dsvca.accounts_as_dict(),
                                                 prompt="To Account:")
        ret['to_account'] = dsvca.account_by_name(to_account_name)

        to_bucket_name = self.request_from_dict(
            dsvca.buckets_as_dict_by_account(
                dsvca.account_by_name(ret['to_account'])), "To Bucket:")
        ret['to_bucket'] = dsvca.bucket_by_account_and_name(
            ret['to_account'], to_bucket_name)
        ret['notes'] = self.request_string("Notes:")
        return ret
Beispiel #3
0
def load_new_transactions():
    print('******************** Load New Transactions *************')

    # Ask User for source
    source = userInteraction.request_from_dict({
        1: TransactionSource.PNC.name,
        2: TransactionSource.BARCLAYCARDUS.name,
        3: TransactionSource.ARCHIVE.name
    }
    )

    if source is None:
        return

    # Get Filepath
    in_path = userInteraction.request_open_filepath()

    # React to user input
    if source == TransactionSource.BARCLAYCARDUS.name:
        transactions = dft.read_in_barclay_transactions(in_path)
    elif source == TransactionSource.PNC.name:
        transactions = dft.read_in_pnc_transactions(in_path)
    elif source == TransactionSource.ARCHIVE.name:
        account = userInteraction.request_from_dict(dsvca.accounts_as_dict())
        transactions = dft.read_in_old_ledgers(filepath=in_path, account=dsvca.account_by_name(account))
        userInteraction.notify_user("Ledger Items created directly")
    else:
        print(NOTIMPLEMENTED)
        return

    userInteraction.notify_user(f"{len(transactions)} new Transactions from {source}")
Beispiel #4
0
    def get_record_expense_input(self, accountManager):
        ret = {}
        ret['description'] = self.request_string("Description:")
        ret['debit'] = self.request_float("Debit:")
        ret['payment_type'] = self.request_enum(PaymentType)
        ret['date_stamp'] = self.request_date()

        from_account_name = self.request_from_dict(dsvca.accounts_as_dict(),
                                                   prompt="From Account:")
        ret['from_account'] = dsvca.account_by_name(from_account_name)
        accountManager.print_positive_remaining(account=ret['from_account'],
                                                amount_threshold=ret['debit'])
        eligible_buckets = accountManager.positive_remaining_buckets(
            account=ret['from_account'], amount_threshold=ret['debit'])
        if eligible_buckets is None or len(eligible_buckets) == 0:
            self.notify_user(f"No eligible Buckets to cover {ret['debit']}")
            return None

        eligible_bucket_names_as_dict = {
            index: row["name"]
            for index, row in eligible_buckets.iterrows()
        }
        from_bucket_name = self.request_from_dict(
            eligible_bucket_names_as_dict, "From Bucket:")
        ret['from_bucket'] = dsvca.bucket_by_account_and_name(
            ret['from_account'], from_bucket_name)

        return ret
Beispiel #5
0
    def add_equity(self):
        name = self.uns.request_string("Name: ")
        description = self.uns.request_string("Description: ")
        accountName = self.uns.request_from_dict(dsvca.accounts_as_dict())
        equityClass = self.uns.request_enum(EquityClass)
        if equityClass == EquityClass.ASSET:
            equityType = self.uns.request_enum(AssetType)
        elif equityClass == EquityClass.LIABILITY:
            equityType = self.uns.request_enum(LiabiltyType)
        else:
            raise Exception(f"Unknown equity class: {equityClass.name}")

        interestRate = self.uns.request_float("Interest Rate: ")
        equityTimeHorizon = self.uns.request_enum(EquityTimeHorizon)
        equityStatus = self.uns.request_enum(EquityStatus)
        equityContingency = self.uns.request_enum(EquityContingency)

        equity = dsvce.enter_if_not_exists(
            name=name,
            description=description,
            accountId=str(dsvca.account_by_name(accountName).id),
            equityClass=equityClass,
            equityType=equityType,
            equityTimeHorizon=equityTimeHorizon,
            equityStatus=equityStatus,
            equityContingency=equityContingency,
            interestRate=interestRate)

        if equity is not None:
            self.uns.notify_user("Equity entered successfully!")
Beispiel #6
0
    def plot_balance_over_time(self):
        relevant_mos = self.uns.request_int("Number of past months: ")
        accountName = self.uns.request_from_dict(dsvca.accounts_as_dict())
        account = dsvca.account_by_name(accountName)

        ax = plot.plot_assets_liabilities_worth_over_time(
            relevant_mos, accountIds=[str(account.id)])
        if ax is None:
            self.uns.notify_user("No Data to show...")
Beispiel #7
0
    def print_balance_sheet(self):
        accountName = self.uns.request_from_dict(dsvca.accounts_as_dict())
        relevant_mos = self.uns.request_int("Number of past months: ")
        account = dsvca.account_by_name(accountName)

        data = dsvce.balance_sheet_over_time(relevant_months=relevant_mos,
                                             accountIds=[str(account.id)])

        self.uns.notify_user(f"\n---------Balance Sheet---------")
        self.uns.pretty_print_items(data)
Beispiel #8
0
    def test_enter_account(self):
        name = "test name"
        description = "test description"
        type = AccountType.PERSONAL
        ads.enter_account(name, description, type)

        account = ads.account_by_name(name)

        assert account.account_name == name
        assert account.description == description
        assert account.type == type.name
Beispiel #9
0
    def get_enter_ledger_from_expense_transaction_input(self):
        ret = {}
        from_account_name = self.request_from_dict(dsvca.accounts_as_dict(),
                                                   prompt="From Account:")
        ret['from_account'] = dsvca.account_by_name(from_account_name)
        from_bucket_name = self.request_from_dict(
            dsvca.buckets_as_dict_by_account(ret['from_account']),
            "From Bucket:")
        ret['from_bucket'] = dsvca.bucket_by_account_and_name(
            ret['from_account'], from_bucket_name)

        return ret
Beispiel #10
0
    def print_value_snapshots(self, accountName=None):
        if accountName is None:
            accountName = self.uns.request_from_dict(dsvca.accounts_as_dict())

        account = dsvca.account_by_name(accountName)

        equities = dsvce.equities_by_account(account.id)

        if equities is None or len(equities) == 0:
            self.uns.notify_user(f"No Equities in account [{accountName}]")
            return

        self.uns.pretty_print_items(sorted(equities,
                                           key=lambda x: x.equityType),
                                    title="Equities Snapshots")
Beispiel #11
0
    def record_value(self):
        accountName = self.uns.request_from_dict(dsvca.accounts_as_dict())
        equityName = self.uns.request_from_dict(dsvce.equities_as_dict())
        year = self.uns.request_int("Year: ")
        month = self.uns.request_int("Month: ")
        value = self.uns.request_float("Value: ")

        account = dsvca.account_by_name(accountName)
        equity = dsvce.equity_by_account_and_name(str(account.id), equityName)
        if equity is None:
            raise Exception(
                f"Equity: {accountName} [{account.id}], {equityName} not found."
            )
        value = dsvce.record_value_on_equity(equity, year, month, value)

        if value is not None:
            self.uns.notify_user("Value Recorded successfully!")
Beispiel #12
0
 def select_account(self, statusList=None):
     accountName = self.request_from_dict(
         dsvca.accounts_as_dict(statusList=statusList))
     if accountName is None:
         return None
     return dsvca.account_by_name(accountName)
Beispiel #13
0
    def delete_equity(self):
        accountName = self.uns.request_from_dict(dsvca.accounts_as_dict())
        equityName = self.uns.request_from_dict(dsvce.equities_as_dict())

        dsvce.delete_equity(dsvca.account_by_name(accountName).id, equityName)