Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dunning): Add hasOverdueInvoices field to customer resolver #2520

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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