diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b21384f2..dcbe0293 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,10 @@ updates: schedule: interval: "monthly" open-pull-requests-limit: 100 + groups: + python-dependencies: + patterns: + - "*" ignore: - dependency-name: "sphinx-jsonschema" # Newer versions of sphinx-jsonschema have compatibility issues diff --git a/.github/workflows/CodeQL.yml b/.github/workflows/CodeQL.yml index a9c95c79..db216882 100644 --- a/.github/workflows/CodeQL.yml +++ b/.github/workflows/CodeQL.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/DocumentationBuild.yml b/.github/workflows/DocumentationBuild.yml index 76023af9..60c03f44 100644 --- a/.github/workflows/DocumentationBuild.yml +++ b/.github/workflows/DocumentationBuild.yml @@ -24,7 +24,7 @@ jobs: run: /usr/local/bin/entrypoint.sh - name: Checkout project source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Poetry uses: snok/install-poetry@v1 diff --git a/.github/workflows/PackagePublish.yml b/.github/workflows/PackagePublish.yml index 4acfee74..2582c3f7 100644 --- a/.github/workflows/PackagePublish.yml +++ b/.github/workflows/PackagePublish.yml @@ -44,7 +44,7 @@ jobs: steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/PackageTest.yml b/.github/workflows/PackageTest.yml index 8d317822..8b2221bc 100644 --- a/.github/workflows/PackageTest.yml +++ b/.github/workflows/PackageTest.yml @@ -35,7 +35,7 @@ jobs: run: /usr/local/bin/entrypoint.sh - name: Checkout source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Poetry uses: snok/install-poetry@v1 diff --git a/README.md b/README.md index 7ac9fcd3..dfc7c246 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,5 @@ [![](https://app.codacy.com/project/badge/Grade/e964afceb32c4f6ea10425e8cabd0d44)](https://www.codacy.com/gh/pitt-crc/bank/dashboard?utm_source=github.com&utm_medium=referral&utm_content=pitt-crc/bank&utm_campaign=Badge_Grade) [![](https://app.codacy.com/project/badge/Coverage/e964afceb32c4f6ea10425e8cabd0d44)](https://www.codacy.com/gh/pitt-crc/bank/dashboard?utm_source=github.com&utm_medium=referral&utm_content=pitt-crc/bank&utm_campaign=Badge_Coverage) -[![](https://github.com/pitt-crc/bank/actions/workflows/CodeQL.yml/badge.svg)](https://github.com/pitt-crc/bank/actions/workflows/CodeQL.yml) See the online docs: [https://pitt-crc.github.io/bank](https://pitt-crc.github.io/bank) diff --git a/bank/account_logic.py b/bank/account_logic.py index 855fa02e..72800dab 100644 --- a/bank/account_logic.py +++ b/bank/account_logic.py @@ -722,6 +722,7 @@ def _build_usage_table(self) -> PrettyTable: f' {recent_proposal_alloc_status}') # Proposal End Date as first row + output_table.title = f"{self._account_name} Proposal Information" output_table.add_row(['Proposal End Date:', proposal.end_date.strftime(settings.date_format), ""], divider=True) @@ -805,13 +806,14 @@ def _build_usage_table(self) -> PrettyTable: output_table.add_row(['Aggregate Usage', usage_percentage, ""], divider=True) else: investment_total = sum(inv.service_units for inv in investments) - investment_percentage = self._calculate_percentage(aggregate_usage_total, - allocation_total + investment_total) + investment_remaining = sum(inv.current_sus for inv in investments) + investment_used = investment_total - investment_remaining + investment_percentage = self._calculate_percentage(investment_used, investment_total) output_table.add_row(['Investment SUs', "SUs Remaining", "% Used"], divider=True) output_table.add_row([f'**Investment SUs', "",""]) output_table.add_row([f'are applied on', "", ""]) - output_table.add_row([f'any cluster to', str(investment_total)+"**", investment_percentage]) + output_table.add_row([f'any cluster to', str(investment_remaining)+"**", investment_percentage]) output_table.add_row([f'cover usage above',"",""]) output_table.add_row([f'Total SUs', "", ""], divider=True) output_table.add_row(['Aggregate Usage', usage_percentage, ""]) @@ -830,23 +832,16 @@ def _build_investment_table(self) -> PrettyTable: if not investments: raise MissingInvestmentError('Account has no investments') - table = PrettyTable(header=False, padding_width=5) - table.add_row(['Investment ID', - 'Total Investment SUs', - 'Start Date', - 'Current SUs', - 'Withdrawn SUs', - 'Rollover SUs']) - - for inv in investments: - table.add_row([ - inv.id, - inv.service_units, - inv.start_date.strftime(settings.date_format), - inv.current_sus, - inv.withdrawn_sus, - inv.withdrawn_sus]) + table = PrettyTable(header=False, padding_width=5, max_width=80) + table.title =f"{self._account_name} Investment Information" + for inv in investments: + table.add_row(['Investment ID','Start Date','End Date'], divider=True) + table.add_row([inv.id, inv.start_date.strftime(settings.date_format), inv.end_date.strftime(settings.date_format)], divider=True) + + table.add_row(['Total Service Units', 'Current SUs', 'Withdrawn SUs'], divider=True) + table.add_row([inv.service_units, inv.current_sus, inv.withdrawn_sus], divider=True) + table.add_row(['','',''], divider=True) return table def info(self) -> None: @@ -854,6 +849,7 @@ def info(self) -> None: try: print(self._build_usage_table()) + print("\n") except MissingProposalError as e: print(f'Account {self._account_name} has no active proposal: {str(e)}') @@ -1024,26 +1020,13 @@ def update_status(self) -> None: continue investment_sus_remaining = source.current_sus - total_usage_exceeding_limits - # Investment can not cover, attempt to withdraw remaining SUs in the investment + # Investment can not cover if investment_sus_remaining < 0: total_usage_exceeding_limits -= source.current_sus + source.current_sus = 0 + continue - # TODO: This is the full amount, should it be less? - # Could use total divided by 5 to represent 5 year investment, - # while disbursement available and total_usage_exceeding_limits > 0, - # determine if usage covered like below. - source.current_sus = source.service_units - source.withdrawn_sus - source.withdrawn_sus = source.service_units - - investment_sus_remaining = source.current_sus - total_usage_exceeding_limits - - # Still can not cover after withdrawal - if investment_sus_remaining < 0: - total_usage_exceeding_limits -= source.current_sus - source.current_sus = 0 - continue - - if investment_sus_remaining >= 0: + else: source.current_sus -= total_usage_exceeding_limits lock_clusters = [] total_usage_exceeding_limits = 0 diff --git a/pyproject.toml b/pyproject.toml index 8a242c18..85aee2e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ crc-bank = "bank.cli.app:CommandLineApplication.execute" [tool.poetry.dependencies] beautifulsoup4 = "4.12.2" pandas = "2.0.3" -prettytable = "3.8.0" +prettytable = "3.9.0" python = ">=3.8, <4.0" python-environ = "0.4.54" SQLAlchemy = "2.0.19"