Class: EInvoiceAPI::Resources::Documents

Inherits:
Object
  • Object
show all
Defined in:
lib/e_invoice_api/resources/documents.rb,
lib/e_invoice_api/resources/documents/ubl.rb,
lib/e_invoice_api/resources/documents/attachments.rb

Defined Under Namespace

Classes: Attachments, Ubl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Documents

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 Documents.

Parameters:



246
247
248
249
250
# File 'lib/e_invoice_api/resources/documents.rb', line 246

def initialize(client:)
  @client = client
  @attachments = EInvoiceAPI::Resources::Documents::Attachments.new(client: client)
  @ubl = EInvoiceAPI::Resources::Documents::Ubl.new(client: client)
end

Instance Attribute Details

#attachmentsEInvoiceAPI::Resources::Documents::Attachments (readonly)



7
8
9
# File 'lib/e_invoice_api/resources/documents.rb', line 7

def attachments
  @attachments
end

#ublEInvoiceAPI::Resources::Documents::Ubl (readonly)



10
11
12
# File 'lib/e_invoice_api/resources/documents.rb', line 10

def ubl
  @ubl
end

Instance Method Details

#create(allowances: nil, amount_due: nil, attachments: nil, billing_address: nil, billing_address_recipient: nil, charges: nil, currency: nil, customer_address: nil, customer_address_recipient: nil, customer_email: nil, customer_id: nil, customer_name: nil, customer_tax_id: nil, direction: nil, document_type: nil, due_date: nil, invoice_date: nil, invoice_id: nil, invoice_total: nil, items: nil, note: nil, payment_details: nil, payment_term: nil, previous_unpaid_balance: nil, purchase_order: nil, remittance_address: nil, remittance_address_recipient: nil, service_address: nil, service_address_recipient: nil, service_end_date: nil, service_start_date: nil, shipping_address: nil, shipping_address_recipient: nil, state: nil, subtotal: nil, tax_code: nil, tax_details: nil, total_discount: nil, total_tax: nil, vatex: nil, vatex_note: nil, vendor_address: nil, vendor_address_recipient: nil, vendor_email: nil, vendor_name: nil, vendor_tax_id: nil, request_options: {}) ⇒ EInvoiceAPI::Models::DocumentResponse

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

Create a new invoice or credit note

Parameters:

  • allowances (Array<EInvoiceAPI::Models::DocumentCreate::Allowance>, nil)
  • amount_due (Float, String, nil)

    The amount due of the invoice. Must be positive and rounded to maximum 2 decimal

  • attachments (Array<EInvoiceAPI::Models::DocumentAttachmentCreate>, nil)
  • billing_address (String, nil)
  • billing_address_recipient (String, nil)
  • charges (Array<EInvoiceAPI::Models::DocumentCreate::Charge>, nil)
  • currency (Symbol, EInvoiceAPI::Models::CurrencyCode)

    Currency of the invoice

  • customer_address (String, nil)
  • customer_address_recipient (String, nil)
  • customer_email (String, nil)
  • customer_id (String, nil)
  • customer_name (String, nil)
  • customer_tax_id (String, nil)
  • direction (Symbol, EInvoiceAPI::Models::DocumentDirection)
  • document_type (Symbol, EInvoiceAPI::Models::DocumentType)
  • due_date (Date, nil)
  • invoice_date (Date, nil)
  • invoice_id (String, nil)
  • invoice_total (Float, String, nil)

    The total amount of the invoice (so invoice_total = subtotal + total_tax + total

  • items (Array<EInvoiceAPI::Models::DocumentCreate::Item>)

    At least one line item is required

  • note (String, nil)
  • payment_details (Array<EInvoiceAPI::Models::PaymentDetailCreate>, nil)
  • payment_term (String, nil)
  • previous_unpaid_balance (Float, String, nil)

    The previous unpaid balance of the invoice, if any. Must be positive and rounded

  • purchase_order (String, nil)
  • remittance_address (String, nil)
  • remittance_address_recipient (String, nil)
  • service_address (String, nil)
  • service_address_recipient (String, nil)
  • service_end_date (Date, nil)
  • service_start_date (Date, nil)
  • shipping_address (String, nil)
  • shipping_address_recipient (String, nil)
  • state (Symbol, EInvoiceAPI::Models::DocumentState)
  • subtotal (Float, String, nil)

    The taxable base of the invoice. Should be the sum of all line items - allowance

  • tax_code (Symbol, EInvoiceAPI::Models::DocumentCreate::TaxCode)

    Tax category code of the invoice

  • tax_details (Array<EInvoiceAPI::Models::DocumentCreate::TaxDetail>, nil)
  • total_discount (Float, String, nil)

    The total financial discount of the invoice (so discounts not subject to VAT). M

  • total_tax (Float, String, nil)

    The total tax of the invoice. Must be positive and rounded to maximum 2 decimals

  • vatex (Symbol, EInvoiceAPI::Models::DocumentCreate::Vatex, nil)

    VATEX code list for VAT exemption reasons

  • vatex_note (String, nil)

    VAT exemption note of the invoice

  • vendor_address (String, nil)
  • vendor_address_recipient (String, nil)
  • vendor_email (String, nil)
  • vendor_name (String, nil)
  • vendor_tax_id (String, nil)
  • request_options (EInvoiceAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



116
117
118
119
120
121
122
123
124
125
# File 'lib/e_invoice_api/resources/documents.rb', line 116

def create(params = {})
  parsed, options = EInvoiceAPI::DocumentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/documents/",
    body: parsed,
    model: EInvoiceAPI::DocumentResponse,
    options: options
  )
end

#create_from_pdf(file: , customer_tax_id: nil, vendor_tax_id: nil, request_options: {}) ⇒ EInvoiceAPI::Models::DocumentCreateFromPdfResponse

Create a new invoice or credit note from a PDF file. If the ‘ubl_document’ field is set in the response, it indicates that sufficient details were extracted from the PDF to automatically generate a valid UBL document ready for sending. If ‘ubl_document’ is not set, human intervention may be required to ensure compliance.

Parameters:

  • file (Pathname, StringIO, IO, String, EInvoiceAPI::FilePart)

    Body param:

  • customer_tax_id (String, nil)

    Query param:

  • vendor_tax_id (String, nil)

    Query param:

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

Returns:

See Also:



184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/e_invoice_api/resources/documents.rb', line 184

def create_from_pdf(params)
  parsed, options = EInvoiceAPI::DocumentCreateFromPdfParams.dump_request(params)
  query_params = [:customer_tax_id, :vendor_tax_id]
  @client.request(
    method: :post,
    path: "api/documents/pdf",
    query: parsed.slice(*query_params),
    headers: {"content-type" => "multipart/form-data"},
    body: parsed.except(*query_params),
    model: EInvoiceAPI::Models::DocumentCreateFromPdfResponse,
    options: options
  )
end

#delete(document_id, request_options: {}) ⇒ EInvoiceAPI::Models::DocumentDeleteResponse

Delete an invoice or credit note

Parameters:

Returns:

See Also:



156
157
158
159
160
161
162
163
# File 'lib/e_invoice_api/resources/documents.rb', line 156

def delete(document_id, params = {})
  @client.request(
    method: :delete,
    path: ["api/documents/%1$s", document_id],
    model: EInvoiceAPI::Models::DocumentDeleteResponse,
    options: params[:request_options]
  )
end

#retrieve(document_id, request_options: {}) ⇒ EInvoiceAPI::Models::DocumentResponse

Get an invoice or credit note by ID

Parameters:

Returns:

See Also:



137
138
139
140
141
142
143
144
# File 'lib/e_invoice_api/resources/documents.rb', line 137

def retrieve(document_id, params = {})
  @client.request(
    method: :get,
    path: ["api/documents/%1$s", document_id],
    model: EInvoiceAPI::DocumentResponse,
    options: params[:request_options]
  )
end

#send_(document_id, email: nil, receiver_peppol_id: nil, receiver_peppol_scheme: nil, sender_peppol_id: nil, sender_peppol_scheme: nil, request_options: {}) ⇒ EInvoiceAPI::Models::DocumentResponse

Send an invoice or credit note via Peppol

Parameters:

  • document_id (String)
  • email (String, nil)
  • receiver_peppol_id (String, nil)
  • receiver_peppol_scheme (String, nil)
  • sender_peppol_id (String, nil)
  • sender_peppol_scheme (String, nil)
  • request_options (EInvoiceAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



213
214
215
216
217
218
219
220
221
222
# File 'lib/e_invoice_api/resources/documents.rb', line 213

def send_(document_id, params = {})
  parsed, options = EInvoiceAPI::DocumentSendParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/documents/%1$s/send", document_id],
    query: parsed,
    model: EInvoiceAPI::DocumentResponse,
    options: options
  )
end

#validate(document_id, request_options: {}) ⇒ EInvoiceAPI::Models::UblDocumentValidation

Validate a UBL document according to Peppol BIS Billing 3.0

Parameters:

Returns:

See Also:



234
235
236
237
238
239
240
241
# File 'lib/e_invoice_api/resources/documents.rb', line 234

def validate(document_id, params = {})
  @client.request(
    method: :post,
    path: ["api/documents/%1$s/validate", document_id],
    model: EInvoiceAPI::UblDocumentValidation,
    options: params[:request_options]
  )
end