Skip to content

Add tag filtering to invoiceTags list utility #709

Description

@Kingsman-99

Description

src/lib/invoiceTags.ts manages tags on invoices but provides no utility to filter a list of invoices by one or more tags. Callers implement this filter ad-hoc in multiple places, leading to inconsistent behaviour when an invoice has multiple tags.

Acceptance Criteria

  • filterByTags(invoices: Invoice[], tags: string[], opts?: { matchAll?: boolean }): Invoice[] exported from src/lib/invoiceTags.ts
  • Default (matchAll: false): returns invoices that have any of the given tags
  • matchAll: true: returns only invoices that have all of the given tags
  • Empty tags array returns all invoices unchanged
  • Exported from the existing barrel export if one exists
  • Unit tests: any-match, all-match, empty tags returns all, no matches returns empty array

Context

  • Target file: src/lib/invoiceTags.ts
  • Invoice type from src/lib/types — use existing import pattern in the file

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions