Module: Teamlab::CrmInvoices

Extended by:
Gem::Deprecate
Included in:
Crm
Defined in:
lib/teamlab/modules/crm/crm_invoices.rb

Overview

Methods for working with crm invoices

Instance Method Summary collapse

Instance Method Details

#check_invoice_existence_by_number(number) ⇒ Boolean

Returns the existence of an invoice with the number specified in the request

Parameters:

  • number (String)

    Invoice number

Returns:

  • (Boolean)

    Invoice existence



124
125
126
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 124

def check_invoice_existence_by_number(number)
  @request.get(%w[invoice bynumber exist], number: number)
end

#create_invoice(number, issue_date, client_id, due_date, language, currency, exchange_rate, terms, invoice_line, options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 38

def create_invoice(number, issue_date, client_id, due_date, language, currency, exchange_rate, terms, invoice_line, options = {})
  @request.post(%w[invoice], { number: number, issueDate: issue_date, contactId: client_id, dueDate: due_date,
                               language: language, currency: currency, exchangeRate: exchange_rate, terms: terms,
                               invoiceLines: invoice_line }.merge(options))
end

#create_invoice_item(title, description, price, stock_keeping_unit, options = {}) ⇒ Object



48
49
50
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 48

def create_invoice_item(title, description, price, stock_keeping_unit, options = {})
  @request.post(%w[invoiceitem], { title: title, description: description, price: price, sku: stock_keeping_unit.to_s }.merge(options))
end

#create_invoice_line(invoice_id, invoice_item_id, options = {}) ⇒ Object



44
45
46
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 44

def create_invoice_line(invoice_id, invoice_item_id, options = {})
  @request.post(%w[invoiceline], { invoiceId: invoice_id, invoiceItemId: invoice_item_id }.merge(options))
end

#create_invoice_tax(name, description, options = {}) ⇒ Object



52
53
54
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 52

def create_invoice_tax(name, description, options = {})
  @request.post(%w[invoice tax], { name: name, description: description }.merge(options))
end

#delete_batch_invoices(*invoice_ids) ⇒ Object Also known as: delete_invoices_bulk



89
90
91
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 89

def delete_batch_invoices(*invoice_ids)
  @request.delete(%w[invoice], invoiceids: invoice_ids.flatten)
end

#delete_batch_items(*ids) ⇒ Object Also known as: delete_invoice_items_bulk



94
95
96
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 94

def delete_batch_items(*ids)
  @request.delete(%w[invoiceitem], ids: ids.flatten)
end

#delete_invoice(id) ⇒ Object



107
108
109
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 107

def delete_invoice(id)
  @request.delete(['invoice', id.to_s])
end

#delete_invoice_item(id) ⇒ Object



99
100
101
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 99

def delete_invoice_item(id)
  @request.delete(['invoiceitem', id.to_s])
end

#delete_invoice_line(id) ⇒ Object



111
112
113
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 111

def delete_invoice_line(id)
  @request.delete(['invoiceline', id.to_s])
end

#delete_invoice_tax(id) ⇒ Object



103
104
105
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 103

def delete_invoice_tax(id)
  @request.delete(['invoice', 'tax', id.to_s])
end

#get_entity_invoices(entity_type, entity_id) ⇒ Object



34
35
36
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 34

def get_entity_invoices(entity_type, entity_id)
  @request.get([entity_type.to_s, 'invoicelist', entity_id.to_s])
end

#get_invoice_by_id(id) ⇒ Object



30
31
32
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 30

def get_invoice_by_id(id)
  @request.get(['invoice', id.to_s])
end

#get_invoice_by_number(number) ⇒ Hash

Returns the detailed information about an invoice with the number specified in the request

Parameters:

  • number (String)

    Invoice number

Returns:

  • (Hash)

    Invoice data



131
132
133
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 131

def get_invoice_by_number(number)
  @request.get(%w[invoice bynumber], number: number)
end

#get_invoice_item_by_id(invoice_item_id) ⇒ Void

Parameters:

  • invoice_item_id (Integer)

    id of invoice

Returns:

  • (Void)


117
118
119
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 117

def get_invoice_item_by_id(invoice_item_id)
  @request.get(['invoiceitem', invoice_item_id])
end

#get_invoice_items_by_filter(options = {}) ⇒ Object



26
27
28
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 26

def get_invoice_items_by_filter(options = {})
  @request.get(%w[invoiceitem filter], options)
end

#get_invoice_sampleObject



10
11
12
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 10

def get_invoice_sample
  @request.get(%w[invoice sample])
end

#get_invoice_taxesObject



6
7
8
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 6

def get_invoice_taxes
  @request.get(%w[invoice tax])
end

#get_invoices_by_filter(options = {}) ⇒ Object



14
15
16
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 14

def get_invoices_by_filter(options = {})
  @request.get(%w[invoice filter], options)
end

#get_invoices_settingsObject Also known as: get_settings



18
19
20
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 18

def get_invoices_settings
  @request.get(%w[invoice settings])
end

#save_number_settings(options = {}) ⇒ Object



68
69
70
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 68

def save_number_settings(options = {})
  @request.put(%w[invoice settings name], options)
end

#save_terms_settings(options = {}) ⇒ Object



72
73
74
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 72

def save_terms_settings(options = {})
  @request.put(%w[invoice settings terms], options)
end

#update_invoice(id, options = {}) ⇒ Object



64
65
66
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 64

def update_invoice(id, options = {})
  @request.put(['invoice', id.to_s], options)
end

#update_invoice_group_status(status, invoice_ids) ⇒ Teamlab::Response

Updates the status of invoices with the IDs specified in the request

Parameters:

  • status (String)

    status to set

  • invoice_ids (Array<Integer>)

    list of status to set

Returns:



80
81
82
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 80

def update_invoice_group_status(status, invoice_ids)
  @request.put(['invoice', 'status', status.to_s], invoiceids: invoice_ids)
end

#update_invoice_item(id, title, description, price, stock_keeping_unit, options = {}) ⇒ Object



56
57
58
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 56

def update_invoice_item(id, title, description, price, stock_keeping_unit, options = {})
  @request.put(['invoiceitem', id.to_s], { title: title, description: description, price: price, sku: stock_keeping_unit.to_s }.merge(options))
end

#update_invoice_line(invoice_line_id, invoice_id, options = {}) ⇒ Object



84
85
86
87
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 84

def update_invoice_line(invoice_line_id, invoice_id, options = {})
  options[:invoiceId] = invoice_id
  @request.put(['invoiceline', invoice_line_id], options)
end

#update_invoice_tax(id, name, options = {}) ⇒ Object



60
61
62
# File 'lib/teamlab/modules/crm/crm_invoices.rb', line 60

def update_invoice_tax(id, name, options = {})
  @request.put(['invoice', 'tax', id.to_s], { name: name }.merge(options))
end