Class: ModernTreasury::Resources::Invoices

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/resources/invoices.rb,
lib/modern_treasury/resources/invoices/line_items.rb

Defined Under Namespace

Classes: LineItems

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Invoices

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Invoices.

Parameters:



257
258
259
260
# File 'lib/modern_treasury/resources/invoices.rb', line 257

def initialize(client:)
  @client = client
  @line_items = ModernTreasury::Resources::Invoices::LineItems.new(client: client)
end

Instance Attribute Details

#line_itemsModernTreasury::Resources::Invoices::LineItems (readonly)



7
8
9
# File 'lib/modern_treasury/resources/invoices.rb', line 7

def line_items
  @line_items
end

Instance Method Details

#add_payment_order(payment_order_id, id: , request_options: {}) ⇒ nil

Add a payment order to an invoice.

Parameters:

Returns:

  • (nil)

See Also:



240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/modern_treasury/resources/invoices.rb', line 240

def add_payment_order(payment_order_id, params)
  parsed, options = ModernTreasury::InvoiceAddPaymentOrderParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["api/invoices/%1$s/payment_orders/%2$s", id, payment_order_id],
    model: NilClass,
    options: options
  )
end

#create(counterparty_id: , due_date: , originating_account_id: , auto_advance: nil, contact_details: nil, counterparty_billing_address: nil, counterparty_shipping_address: nil, currency: nil, description: nil, fallback_payment_method: nil, ingest_ledger_entries: nil, invoice_line_items: nil, invoicer_address: nil, ledger_account_settlement_id: nil, metadata: nil, notification_email_addresses: nil, notifications_enabled: nil, payment_effective_date: nil, payment_method: nil, payment_type: nil, receiving_account_id: nil, recipient_email: nil, recipient_name: nil, remind_after_overdue_days: nil, virtual_account_id: nil, request_options: {}) ⇒ ModernTreasury::Models::Invoice

Some parameter documentations has been truncated, see Models::InvoiceCreateParams for more details.

create invoice

Parameters:

  • counterparty_id (String)

    The ID of the counterparty receiving the invoice.

  • due_date (Time)

    A future date by when the invoice needs to be paid.

  • originating_account_id (String)

    The ID of the internal account the invoice should be paid to.

  • auto_advance (Boolean, nil)

    When true, the invoice will progress to unpaid automatically and cannot be edite

  • contact_details (Array<ModernTreasury::Models::ContactDetail>)

    The invoicer’s contact details displayed at the top of the invoice.

  • counterparty_billing_address (ModernTreasury::Models::InvoiceCreateParams::CounterpartyBillingAddress, nil)

    The counterparty’s billing address.

  • counterparty_shipping_address (ModernTreasury::Models::InvoiceCreateParams::CounterpartyShippingAddress, nil)

    The counterparty’s shipping address where physical goods should be delivered.

  • currency (Symbol, ModernTreasury::Models::Currency)

    Currency that the invoice is denominated in. Defaults to ‘USD` if not provided.

  • description (String)

    A free-form description of the invoice.

  • fallback_payment_method (String, nil)

    When payment_method is automatic, the fallback payment method to use when an aut

  • ingest_ledger_entries (Boolean, nil)

    Whether to ingest the ledger_entries to populate the invoice line items. If this

  • invoice_line_items (Array<ModernTreasury::Models::InvoiceCreateParams::InvoiceLineItem>, nil)

    An array of invoice line items. The API supports a maximum of 50 invoice line it

  • invoicer_address (ModernTreasury::Models::InvoiceCreateParams::InvoicerAddress, nil)

    The invoice issuer’s business address.

  • ledger_account_settlement_id (String, nil)

    The ID of the virtual account the invoice should be paid to.

  • metadata (Hash{Symbol=>String}, nil)

    Additional data represented as key-value pairs. Both the key and value must be s

  • notification_email_addresses (Array<String>, nil)

    Emails in addition to the counterparty email to send invoice status notification

  • notifications_enabled (Boolean)

    If true, the invoice will send email notifications to the invoice recipients abo

  • payment_effective_date (Date)

    Date transactions are to be posted to the participants’ account. Defaults to the

  • payment_method (Symbol, ModernTreasury::Models::InvoiceCreateParams::PaymentMethod)

    The method by which the invoice can be paid. ‘ui` will show the embedded payment

  • payment_type (Symbol, ModernTreasury::Models::PaymentOrderType)

    One of ‘ach`, `se_bankgirot`, `eft`, `wire`, `check`, `sen`, `book`, `rtp`, `sep

  • receiving_account_id (String)

    The receiving account ID. Can be an ‘external_account`.

  • recipient_email (String, nil)

    The email of the recipient of the invoice. Leaving this value as null will fallb

  • recipient_name (String, nil)

    The name of the recipient of the invoice. Leaving this value as null will fallba

  • remind_after_overdue_days (Array<Integer>, nil)

    Number of days after due date when overdue reminder emails will be sent out to i

  • virtual_account_id (String, nil)

    The ID of the virtual account the invoice should be paid to.

  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
# File 'lib/modern_treasury/resources/invoices.rb', line 71

def create(params)
  parsed, options = ModernTreasury::InvoiceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/invoices",
    body: parsed,
    model: ModernTreasury::Invoice,
    options: options
  )
end

#list(after_cursor: nil, counterparty_id: nil, created_at_end: nil, created_at_start: nil, due_date_end: nil, due_date_start: nil, expected_payment_id: nil, metadata: nil, number: nil, originating_account_id: nil, payment_order_id: nil, per_page: nil, status: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::Invoice>

Some parameter documentations has been truncated, see Models::InvoiceListParams for more details.

list invoices

Parameters:

  • after_cursor (String, nil)
  • counterparty_id (String)
  • created_at_end (Time)

    An inclusive upper bound for searching created_at

  • created_at_start (Time)

    An inclusive lower bound for searching created_at

  • due_date_end (Date)

    An inclusive upper bound for searching due_date

  • due_date_start (Date)

    An inclusive lower bound for searching due_date

  • expected_payment_id (String)
  • metadata (Hash{Symbol=>String})

    For example, if you want to query for records with metadata key ‘Type` and value

  • number (String)

    A unique record number assigned to each invoice that is issued.

  • originating_account_id (String)
  • payment_order_id (String)
  • per_page (Integer)
  • status (Symbol, ModernTreasury::Models::InvoiceListParams::Status)
  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



215
216
217
218
219
220
221
222
223
224
225
# File 'lib/modern_treasury/resources/invoices.rb', line 215

def list(params = {})
  parsed, options = ModernTreasury::InvoiceListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "api/invoices",
    query: parsed,
    page: ModernTreasury::Internal::Page,
    model: ModernTreasury::Invoice,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ ModernTreasury::Models::Invoice

get invoice

Parameters:

Returns:

See Also:



93
94
95
96
97
98
99
100
# File 'lib/modern_treasury/resources/invoices.rb', line 93

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["api/invoices/%1$s", id],
    model: ModernTreasury::Invoice,
    options: params[:request_options]
  )
end

#update(id, contact_details: nil, counterparty_billing_address: nil, counterparty_id: nil, counterparty_shipping_address: nil, currency: nil, description: nil, due_date: nil, fallback_payment_method: nil, ingest_ledger_entries: nil, invoice_line_items: nil, invoicer_address: nil, ledger_account_settlement_id: nil, metadata: nil, notification_email_addresses: nil, notifications_enabled: nil, originating_account_id: nil, payment_effective_date: nil, payment_method: nil, payment_type: nil, receiving_account_id: nil, recipient_email: nil, recipient_name: nil, remind_after_overdue_days: nil, status: nil, virtual_account_id: nil, request_options: {}) ⇒ ModernTreasury::Models::Invoice

Some parameter documentations has been truncated, see Models::InvoiceUpdateParams for more details.

update invoice

Parameters:

  • id (String)

    id

  • contact_details (Array<ModernTreasury::Models::ContactDetail>)

    The invoicer’s contact details displayed at the top of the invoice.

  • counterparty_billing_address (ModernTreasury::Models::InvoiceUpdateParams::CounterpartyBillingAddress, nil)

    The counterparty’s billing address.

  • counterparty_id (String)

    The ID of the counterparty receiving the invoice.

  • counterparty_shipping_address (ModernTreasury::Models::InvoiceUpdateParams::CounterpartyShippingAddress, nil)

    The counterparty’s shipping address where physical goods should be delivered.

  • currency (Symbol, ModernTreasury::Models::Currency)

    Currency that the invoice is denominated in. Defaults to ‘USD` if not provided.

  • description (String)

    A free-form description of the invoice.

  • due_date (Time)

    A future date by when the invoice needs to be paid.

  • fallback_payment_method (String, nil)

    When payment_method is automatic, the fallback payment method to use when an aut

  • ingest_ledger_entries (Boolean, nil)

    Whether to ingest the ledger_entries to populate the invoice line items. If this

  • invoice_line_items (Array<ModernTreasury::Models::InvoiceUpdateParams::InvoiceLineItem>, nil)

    An array of invoice line items. The API supports a maximum of 50 invoice line it

  • invoicer_address (ModernTreasury::Models::InvoiceUpdateParams::InvoicerAddress, nil)

    The invoice issuer’s business address.

  • ledger_account_settlement_id (String, nil)

    The ID of the virtual account the invoice should be paid to.

  • metadata (Hash{Symbol=>String}, nil)

    Additional data represented as key-value pairs. Both the key and value must be s

  • notification_email_addresses (Array<String>, nil)

    Emails in addition to the counterparty email to send invoice status notification

  • notifications_enabled (Boolean)

    If true, the invoice will send email notifications to the invoice recipients abo

  • originating_account_id (String)

    The ID of the internal account the invoice should be paid to.

  • payment_effective_date (Date)

    Date transactions are to be posted to the participants’ account. Defaults to the

  • payment_method (Symbol, ModernTreasury::Models::InvoiceUpdateParams::PaymentMethod)

    The method by which the invoice can be paid. ‘ui` will show the embedded payment

  • payment_type (Symbol, ModernTreasury::Models::PaymentOrderType)

    One of ‘ach`, `se_bankgirot`, `eft`, `wire`, `check`, `sen`, `book`, `rtp`, `sep

  • receiving_account_id (String)

    The receiving account ID. Can be an ‘external_account`.

  • recipient_email (String, nil)

    The email of the recipient of the invoice. Leaving this value as null will fallb

  • recipient_name (String, nil)

    The name of the recipient of the invoice. Leaving this value as null will fallba

  • remind_after_overdue_days (Array<Integer>, nil)

    Number of days after due date when overdue reminder emails will be sent out to i

  • status (String)

    Invoice status must be updated in a ‘PATCH` request that does not modify any oth

  • virtual_account_id (String, nil)

    The ID of the virtual account the invoice should be paid to.

  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



166
167
168
169
170
171
172
173
174
175
# File 'lib/modern_treasury/resources/invoices.rb', line 166

def update(id, params = {})
  parsed, options = ModernTreasury::InvoiceUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/invoices/%1$s", id],
    body: parsed,
    model: ModernTreasury::Invoice,
    options: options
  )
end