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:



250
251
252
253
254
# File 'lib/e_invoice_api/resources/documents.rb', line 250

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_company_id: 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_company_id: 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 for payment. Must be positive and rounded to maximum 2 decimals

  • attachments (Array<EInvoiceAPI::Models::DocumentAttachmentCreate>, nil)
  • billing_address (String, nil)

    The billing address (if different from customer address)

  • billing_address_recipient (String, nil)

    The recipient name at the billing address

  • charges (Array<EInvoiceAPI::Models::DocumentCreate::Charge>, nil)
  • currency (Symbol, EInvoiceAPI::Models::CurrencyCode)

    Currency of the invoice (ISO 4217 currency code)

  • customer_address (String, nil)

    The address of the customer/buyer

  • customer_address_recipient (String, nil)

    The recipient name at the customer address

  • customer_company_id (String, nil)

    Customer company ID. For Belgium this is the CBE number or their EUID (European

  • customer_email (String, nil)

    The email address of the customer

  • customer_id (String, nil)

    The unique identifier for the customer in your system

  • customer_name (String, nil)

    The company name of the customer/buyer

  • customer_tax_id (String, nil)

    Customer tax ID. For Belgium this is the VAT number. Must include the country pr

  • direction (Symbol, EInvoiceAPI::Models::DocumentDirection)

    The direction of the document: INBOUND (purchases) or OUTBOUND (sales)

  • document_type (Symbol, EInvoiceAPI::Models::DocumentType)

    The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE

  • due_date (Date, nil)

    The date when payment is due

  • invoice_date (Date, nil)

    The date when the invoice was issued

  • invoice_id (String, nil)

    The unique invoice identifier/number

  • invoice_total (Float, String, nil)

    The total amount of the invoice including tax (invoice*total = subtotal + total*

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

    At least one line item is required

  • note (String, nil)

    Additional notes or comments for the invoice

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

    The payment terms (e.g., ‘Net 30’, ‘Due on receipt’, ‘2/10 Net 30’)

  • previous_unpaid_balance (Float, String, nil)

    The previous unpaid balance from prior invoices, if any. Must be positive and ro

  • purchase_order (String, nil)

    The purchase order reference number

  • remittance_address (String, nil)

    The address where payment should be sent or remitted to

  • remittance_address_recipient (String, nil)

    The recipient name at the remittance address

  • service_address (String, nil)

    The address where services were performed or goods were delivered

  • service_address_recipient (String, nil)

    The recipient name at the service address

  • service_end_date (Date, nil)

    The end date of the service period or delivery period

  • service_start_date (Date, nil)

    The start date of the service period or delivery period

  • shipping_address (String, nil)

    The shipping/delivery address

  • shipping_address_recipient (String, nil)

    The recipient name at the shipping address

  • state (Symbol, EInvoiceAPI::Models::DocumentState)

    The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED

  • 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 (e.g., S for standard rate, Z for zero rate, E

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

    The net financial discount/charge of the invoice (non-VAT charges minus non-VAT

  • total_tax (Float, String, nil)

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

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

    VATEX code list for VAT exemption reasons

  • vatex_note (String, nil)

    Textual explanation for VAT exemption

  • vendor_address (String, nil)

    The address of the vendor/seller

  • vendor_address_recipient (String, nil)

    The recipient name at the vendor address

  • vendor_company_id (String, nil)

    Vendor company ID. For Belgium this is the CBE number or their EUID (European Un

  • vendor_email (String, nil)

    The email address of the vendor

  • vendor_name (String, nil)

    The name of the vendor/seller/supplier

  • vendor_tax_id (String, nil)

    Vendor tax ID. For Belgium this is the VAT number. Must include the country pref

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

Returns:

See Also:



120
121
122
123
124
125
126
127
128
129
# File 'lib/e_invoice_api/resources/documents.rb', line 120

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:



188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/e_invoice_api/resources/documents.rb', line 188

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:



160
161
162
163
164
165
166
167
# File 'lib/e_invoice_api/resources/documents.rb', line 160

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:



141
142
143
144
145
146
147
148
# File 'lib/e_invoice_api/resources/documents.rb', line 141

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:



217
218
219
220
221
222
223
224
225
226
# File 'lib/e_invoice_api/resources/documents.rb', line 217

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:



238
239
240
241
242
243
244
245
# File 'lib/e_invoice_api/resources/documents.rb', line 238

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