diff --git a/app/graphql/types/customers/object.rb b/app/graphql/types/customers/object.rb index 0f9438c4cc4..14b273d31d9 100644 --- a/app/graphql/types/customers/object.rb +++ b/app/graphql/types/customers/object.rb @@ -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' @@ -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 diff --git a/schema.graphql b/schema.graphql index 47bde471733..91a4f6521b8 100644 --- a/schema.graphql +++ b/schema.graphql @@ -3083,6 +3083,11 @@ type Customer { Define if a customer has any credit note """ hasCreditNotes: Boolean! + + """ + Define if a customer has overdue invoices + """ + hasOverdueInvoices: Boolean! id: ID! invoiceGracePeriod: Int invoices: [Invoice!] diff --git a/schema.json b/schema.json index 343008d9f5b..2e216f79f40 100644 --- a/schema.json +++ b/schema.json @@ -12222,6 +12222,24 @@ ] }, + { + "name": "hasOverdueInvoices", + "description": "Define if a customer has overdue invoices", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, { "name": "id", "description": null, diff --git a/spec/graphql/types/customers/object_spec.rb b/spec/graphql/types/customers/object_spec.rb index d933ff5d8f1..66076548956 100644 --- a/spec/graphql/types/customers/object_spec.rb +++ b/spec/graphql/types/customers/object_spec.rb @@ -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