这是indexloc提供的服务,不要输入任何密码
Skip to content

some "Sales" have entries with "Shares": "0" #1

@bmgit26

Description

@bmgit26

in transactions.where((element) => element['Action'] == 'Sale')) {

This leads to

Unhandled exception:
RangeError (start): Invalid value: Only valid value is 0: 1
#0      RangeError.checkValidRange (dart:core/errors.dart:387:7)
#1      _StringBase.substring (dart:core-patch/string_patch.dart:440:27)
#2      toPrice (package:gsu_cli/do_stuff.dart:72:58)
#3      computeCapitalGains (package:gsu_cli/do_stuff.dart:35:34)
#4      main (file:///Users/maxmichel/Downloads/gsu-main/gsu_cli/bin/gsu_cli.dart:25:28)

I think you can either add that to the for loop condition or end the handling of a transaction directly after the for loop beginning:

if transaction.element['Shares'] == '0' continue;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions