getNextIndicesForFunds method

  1. @override
Indices? getNextIndicesForFunds(
  1. String fellowship,
  2. String contract
)

Get the next available indices for the given fellowship and template

fellowship A String label of the fellowship to get the next indices for template A String label of the template to get the next indices for Returns the next indices for the given fellowship and template if possible. Else null

Implementation

@override
Indices? getNextIndicesForFunds(String fellowship, String contract) {
  final fellowshipResult = fellowshipsStore.findFirstSync(_instance,
      finder: Finder(filter: Filter.equals("name", fellowship)));

  final contractResult = contractsStore.findFirstSync(_instance,
      finder: Finder(filter: Filter.equals("contract", contract)));

  if (fellowshipResult != null && contractResult != null) {
    final cartesianResult = cartesiansStore.findFirstSync(_instance,
        finder: Finder(
            filter: Filter.and([
              Filter.equals("xFellowship", fellowshipResult["xFellowship"]),
              Filter.equals("yContract", contractResult.key),
            ]),
            sortOrders: [SortOrder("zState", false)]));

    if (cartesianResult != null) {
      return Indices(
        x: cartesianResult["xFellowship"]! as int,
        y: cartesianResult["yContract"]! as int,
        z: (cartesianResult["zState"]! as int) + 1,
      );
    }
  }

  return null;
}