Skip to content

Commit

Permalink
add enum type for tax codes that are applicable on whole invoice when…
Browse files Browse the repository at this point in the history
… serializing to graphql
  • Loading branch information
annvelents committed Aug 28, 2024
1 parent a5db8cf commit ebb2b9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/graphql/types/invoices/applied_taxes/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ class Object < Types::BaseObject
implements Types::Taxes::AppliedTax

field :applied_on_whole_invoice, GraphQL::Types::Boolean, null: false, method: :applied_on_whole_invoice?
field :enumed_tax_code, Types::Invoices::AppliedTaxes::WholeInvoiceApplicableTaxCodeEnum, required: false
field :fees_amount_cents, GraphQL::Types::BigInt, null: false
field :invoice, Types::Invoices::Object, null: false

def enumed_tax_code
object.tax_code if object.applied_on_whole_invoice?
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Types
module Invoices
module AppliedTaxes
class WholeInvoiceApplicableTaxCodeEnum < Types::BaseEnum
graphql_name 'InvoiceAppliedTaxOnWholeInvoiceCodeEnum'

Invoice::AppliedTax::TAX_CODES_APPLICABLE_ON_WHOLE_INVOICE.each do |type|
value type
end
end
end
end
end

0 comments on commit ebb2b9c

Please sign in to comment.