 /**
   * Returns periods that have not been AP locked for the given subsidiary*
   */
  export function getSubsidiaryOpenPeriods (subsidiary: number) {
    const s = search.create({
      type: 'taskitemstatus',
      filters: [
        ['itemtype', 'anyof', 'PCP_LOCK_AP'],
        'AND',
        ['subsidiary', 'anyof', subsidiary],
        'AND',
        ['complete', search.Operator.IS, false]
      ],
      columns: ['period', 'subsidiary', 'book', 'itemtype', 'complete', 'inprogress']
    })
    return Seq(LazySearch.from(s))
      .map(nsSearchResult2obj<{ period, subsidiary, itemtype, complete, inprogress }>())
      .toArray()
  }