Skip to content

Commit

Permalink
fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
codereverser committed Aug 11, 2021
1 parent c81fb46 commit 9b238d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions casparser/analysis/gains.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,13 @@ def sell(self, sell_date: date, quantity: Decimal, nav: Decimal, tax: Decimal):
fin_year = get_fin_year(sell_date)
original_quantity = abs(quantity)
pending_units = original_quantity
while pending_units >= 1e-3:
while pending_units >= 1e-2:
try:
purchase_date, units, purchase_nav, purchase_tax = self.transactions.popleft()
except IndexError:
raise GainsError(
f"Error computing gains for {self._fund.name}. Please contact support."
f"FIFOUnits mismatch for {self._fund.name}. Please contact support."
)

if units <= pending_units:
gain_units = units
else:
Expand Down
8 changes: 3 additions & 5 deletions casparser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ def print_summary(data, output_filename=None, include_zero_folios=False):


def print_gains(data, output_file_path=None):
try:
cg = CapitalGainsReport(data)
except GainsError as exc:
console.print(exc)
return
cg = CapitalGainsReport(data)
summary = cg.get_summary()
table = Table(title="Capital Gains statement (Realised)", show_lines=True)
table.add_column("FY", no_wrap=True)
Expand Down Expand Up @@ -287,6 +283,8 @@ def cli(output, summary, password, include_all, gains, force_pdfminer, filename)
except IncompleteCASError:
console.print("[bold red]Error![/] - Cannot compute gains. CAS is incomplete!")
sys.exit(2)
except GainsError as exc:
console.print(exc)


if __name__ == "__main__":
Expand Down

0 comments on commit 9b238d6

Please sign in to comment.