Skip to content

Commit

Permalink
feat(dunning): Add hasOverdueInvoices field to customer resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
rsempe committed Aug 30, 2024
1 parent 4ad1611 commit 1b85eaf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/graphql/types/customers/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Object < Types::BaseObject
description: 'Number of available credits from credit notes per customer'
field :has_active_wallet, Boolean, null: false, description: 'Define if a customer has an active wallet'
field :has_credit_notes, Boolean, null: false, description: 'Define if a customer has any credit note'
field :has_overdue_invoices, Boolean, null: false, description: 'Define if a customer has overdue invoices'

field :can_edit_attributes, Boolean, null: false, method: :editable? do
description 'Check if customer attributes are editable'
Expand All @@ -98,6 +99,10 @@ def has_credit_notes
object.credit_notes.finalized.any?
end

def has_overdue_invoices
object.invoices.payment_overdue.any?
end

def active_subscriptions_count
object.active_subscriptions.count
end
Expand Down
5 changes: 5 additions & 0 deletions schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/graphql/types/customers/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
it { is_expected.to have_field(:credit_notes_credits_available_count).of_type('Int!') }
it { is_expected.to have_field(:has_active_wallet).of_type('Boolean!') }
it { is_expected.to have_field(:has_credit_notes).of_type('Boolean!') }
it { is_expected.to have_field(:has_overdue_invoices).of_type('Boolean!') }

it { is_expected.to have_field(:can_edit_attributes).of_type('Boolean!') }
end

0 comments on commit 1b85eaf

Please sign in to comment.