business-central 1.0.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -15
- data/lib/business_central.rb +52 -2
- data/lib/business_central/client.rb +87 -39
- data/lib/business_central/exceptions.rb +30 -10
- data/lib/business_central/object/account.rb +4 -2
- data/lib/business_central/object/aged_account_payable.rb +13 -0
- data/lib/business_central/object/aged_account_receivable.rb +13 -0
- data/lib/business_central/object/argument_helper.rb +22 -0
- data/lib/business_central/object/attachment.rb +30 -0
- data/lib/business_central/object/balance_sheet.rb +13 -0
- data/lib/business_central/object/base.rb +100 -49
- data/lib/business_central/object/cash_flow_statement.rb +13 -0
- data/lib/business_central/object/company.rb +9 -2
- data/lib/business_central/object/company_information.rb +14 -0
- data/lib/business_central/object/country_region.rb +26 -0
- data/lib/business_central/object/currency.rb +29 -0
- data/lib/business_central/object/customer.rb +34 -0
- data/lib/business_central/object/customer_financial_detail.rb +13 -0
- data/lib/business_central/object/customer_payment.rb +43 -0
- data/lib/business_central/object/customer_payment_journal.rb +25 -0
- data/lib/business_central/object/customer_sale.rb +13 -0
- data/lib/business_central/object/default_dimension.rb +51 -0
- data/lib/business_central/object/dimension.rb +20 -0
- data/lib/business_central/object/dimension_line.rb +37 -0
- data/lib/business_central/object/dimension_value.rb +28 -0
- data/lib/business_central/object/employee.rb +21 -0
- data/lib/business_central/object/filter_query.rb +18 -0
- data/lib/business_central/object/general_ledger_entry.rb +13 -0
- data/lib/business_central/object/income_statement.rb +13 -0
- data/lib/business_central/object/irs1099_code.rb +16 -0
- data/lib/business_central/object/item.rb +16 -19
- data/lib/business_central/object/item_category.rb +16 -0
- data/lib/business_central/object/journal.rb +29 -0
- data/lib/business_central/object/journal_line.rb +48 -0
- data/lib/business_central/object/object_helper.rb +49 -0
- data/lib/business_central/object/payment_method.rb +16 -0
- data/lib/business_central/object/payment_term.rb +16 -0
- data/lib/business_central/object/picture.rb +53 -0
- data/lib/business_central/object/purchase_invoice.rb +8 -16
- data/lib/business_central/object/purchase_invoice_line.rb +14 -18
- data/lib/business_central/object/request.rb +61 -50
- data/lib/business_central/object/response.rb +28 -22
- data/lib/business_central/object/retained_earning_statement.rb +13 -0
- data/lib/business_central/object/sales_credit_memo.rb +20 -0
- data/lib/business_central/object/sales_credit_memo_line.rb +30 -0
- data/lib/business_central/object/sales_invoice.rb +62 -0
- data/lib/business_central/object/sales_invoice_line.rb +30 -0
- data/lib/business_central/object/sales_order.rb +20 -0
- data/lib/business_central/object/sales_order_line.rb +30 -0
- data/lib/business_central/object/sales_quote.rb +20 -0
- data/lib/business_central/object/sales_quote_line.rb +30 -0
- data/lib/business_central/object/shipment_method.rb +16 -0
- data/lib/business_central/object/subscription.rb +16 -0
- data/lib/business_central/object/tax_area.rb +16 -0
- data/lib/business_central/object/tax_group.rb +16 -0
- data/lib/business_central/object/time_registration_entry.rb +16 -0
- data/lib/business_central/object/trial_balance.rb +13 -0
- data/lib/business_central/object/units_of_measure.rb +16 -0
- data/lib/business_central/object/url_builder.rb +59 -0
- data/lib/business_central/object/url_helper.rb +32 -0
- data/lib/business_central/object/validation.rb +11 -8
- data/lib/business_central/object/vendor.rb +12 -15
- data/lib/business_central/object/vendor_purchase.rb +13 -0
- data/lib/business_central/version.rb +4 -2
- data/lib/business_central/web_service.rb +78 -0
- data/lib/core_ext/string.rb +18 -12
- data/test/business_central/client_test.rb +49 -7
- data/test/business_central/object/account_test.rb +24 -5
- data/test/business_central/object/aged_account_payable_test.rb +61 -0
- data/test/business_central/object/aged_account_receivable_test.rb +61 -0
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +61 -0
- data/test/business_central/object/base_test.rb +41 -0
- data/test/business_central/object/cash_flow_statement_test.rb +61 -0
- data/test/business_central/object/company_information_test.rb +81 -0
- data/test/business_central/object/company_test.rb +24 -11
- data/test/business_central/object/country_region_test.rb +129 -0
- data/test/business_central/object/currency_test.rb +150 -0
- data/test/business_central/object/customer_financial_detail_test.rb +68 -0
- data/test/business_central/object/customer_payment_journal_test.rb +134 -0
- data/test/business_central/object/customer_payment_test.rb +141 -0
- data/test/business_central/object/customer_sale_test.rb +72 -0
- data/test/business_central/object/customer_test.rb +168 -0
- data/test/business_central/object/default_dimension_test.rb +170 -0
- data/test/business_central/object/dimension_line_test.rb +165 -0
- data/test/business_central/object/dimension_test.rb +65 -0
- data/test/business_central/object/dimension_value_test.rb +68 -0
- data/test/business_central/object/employee_test.rb +141 -0
- data/test/business_central/object/filter_query_test.rb +36 -0
- data/test/business_central/object/general_ledger_entry_test.rb +82 -0
- data/test/business_central/object/income_statement_test.rb +82 -0
- data/test/business_central/object/irs1099_code_test.rb +124 -0
- data/test/business_central/object/item_category_test.rb +122 -0
- data/test/business_central/object/item_test.rb +16 -23
- data/test/business_central/object/journal_line_test.rb +152 -0
- data/test/business_central/object/journal_test.rb +144 -0
- data/test/business_central/object/payment_method_test.rb +134 -0
- data/test/business_central/object/payment_term_test.rb +134 -0
- data/test/business_central/object/picture_test.rb +74 -0
- data/test/business_central/object/purchase_invoice_line_test.rb +15 -21
- data/test/business_central/object/purchase_invoice_test.rb +15 -21
- data/test/business_central/object/request_test.rb +75 -18
- data/test/business_central/object/response_test.rb +29 -9
- data/test/business_central/object/retained_earning_statement_test.rb +52 -0
- data/test/business_central/object/sales_credit_memo_line_test.rb +134 -0
- data/test/business_central/object/sales_credit_memo_test.rb +146 -0
- data/test/business_central/object/sales_invoice_line_test.rb +164 -0
- data/test/business_central/object/sales_invoice_test.rb +156 -0
- data/test/business_central/object/sales_order_line_test.rb +134 -0
- data/test/business_central/object/sales_order_test.rb +146 -0
- data/test/business_central/object/sales_quote_line_test.rb +134 -0
- data/test/business_central/object/sales_quote_test.rb +146 -0
- data/test/business_central/object/shipment_method_test.rb +133 -0
- data/test/business_central/object/subscription_test.rb +126 -0
- data/test/business_central/object/tax_area_test.rb +126 -0
- data/test/business_central/object/tax_group_test.rb +126 -0
- data/test/business_central/object/time_registration_entry_test.rb +126 -0
- data/test/business_central/object/trial_balance_test.rb +82 -0
- data/test/business_central/object/units_of_measure_test.rb +126 -0
- data/test/business_central/object/validation_test.rb +5 -4
- data/test/business_central/object/vendor_purchase_test.rb +82 -0
- data/test/business_central/object/vendor_test.rb +16 -22
- data/test/business_central/web_service_test.rb +95 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +16 -6
- metadata +199 -33
- data/lib/business_central/object/helper.rb +0 -15
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesCreditMemo < Base
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'salesCreditMemos'
|
9
|
+
|
10
|
+
OBJECT_METHODS = %i[
|
11
|
+
get
|
12
|
+
post
|
13
|
+
patch
|
14
|
+
delete
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
navigation :sales_credit_memo_line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesCreditMemoLine < Base
|
6
|
+
OBJECT = 'salesCreditMemoLines'
|
7
|
+
|
8
|
+
OBJECT_METHODS = %i[
|
9
|
+
get
|
10
|
+
post
|
11
|
+
patch
|
12
|
+
delete
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
OBJECT_PARENTS = %w[
|
16
|
+
salesCreditMemos
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
def initialize(client, parent: 'salesCreditMemos', parent_id:, **args)
|
20
|
+
return if !valid_parent?(parent)
|
21
|
+
|
22
|
+
super(client, args)
|
23
|
+
@parent_path << {
|
24
|
+
path: parent,
|
25
|
+
id: parent_id
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesInvoice < Base
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'salesInvoices'
|
9
|
+
|
10
|
+
OBJECT_VALIDATION = {
|
11
|
+
customer_purchase_order_reference: {
|
12
|
+
maximum_length: 10
|
13
|
+
},
|
14
|
+
customer_number: {
|
15
|
+
maximum_length: 20
|
16
|
+
},
|
17
|
+
contact_id: {
|
18
|
+
maximum_length: 250
|
19
|
+
},
|
20
|
+
currency_code: {
|
21
|
+
maximum_length: 10
|
22
|
+
},
|
23
|
+
email: {
|
24
|
+
maximum_length: 80
|
25
|
+
},
|
26
|
+
phone: {
|
27
|
+
maximum_length: 30
|
28
|
+
},
|
29
|
+
payment_terms: {
|
30
|
+
maximum_length: 10
|
31
|
+
},
|
32
|
+
shipment_method: {
|
33
|
+
maximum_length: 10
|
34
|
+
},
|
35
|
+
salesperson: {
|
36
|
+
maximum_length: 20
|
37
|
+
},
|
38
|
+
bill_to_name: {
|
39
|
+
maximum_length: 100
|
40
|
+
},
|
41
|
+
bill_to_customer_number: {
|
42
|
+
maximum_length: 20
|
43
|
+
},
|
44
|
+
ship_to_name: {
|
45
|
+
maximum_length: 100
|
46
|
+
},
|
47
|
+
ship_to_contact: {
|
48
|
+
maximum_length: 100
|
49
|
+
}
|
50
|
+
}.freeze
|
51
|
+
|
52
|
+
OBJECT_METHODS = %i[
|
53
|
+
get
|
54
|
+
post
|
55
|
+
patch
|
56
|
+
delete
|
57
|
+
].freeze
|
58
|
+
|
59
|
+
navigation :sales_invoice_line
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesInvoiceLine < Base
|
6
|
+
OBJECT = 'salesInvoiceLines'
|
7
|
+
|
8
|
+
OBJECT_METHODS = %i[
|
9
|
+
get
|
10
|
+
post
|
11
|
+
patch
|
12
|
+
delete
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
OBJECT_PARENTS = %w[
|
16
|
+
salesInvoices
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
def initialize(client, parent: 'salesInvoices', parent_id:, **args)
|
20
|
+
return if !valid_parent?(parent)
|
21
|
+
|
22
|
+
super(client, args)
|
23
|
+
@parent_path << {
|
24
|
+
path: parent,
|
25
|
+
id: parent_id
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesOrder < Base
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'salesOrders'
|
9
|
+
|
10
|
+
OBJECT_METHODS = %i[
|
11
|
+
get
|
12
|
+
post
|
13
|
+
patch
|
14
|
+
delete
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
navigation :sales_order_line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesOrderLine < Base
|
6
|
+
OBJECT = 'salesOrderLines'
|
7
|
+
|
8
|
+
OBJECT_METHODS = %i[
|
9
|
+
get
|
10
|
+
post
|
11
|
+
patch
|
12
|
+
delete
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
OBJECT_PARENTS = %w[
|
16
|
+
salesOrders
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
def initialize(client, parent: 'salesOrders', parent_id:, **args)
|
20
|
+
return if !valid_parent?(parent)
|
21
|
+
|
22
|
+
super(client, args)
|
23
|
+
@parent_path << {
|
24
|
+
path: parent,
|
25
|
+
id: parent_id
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesQuote < Base
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'salesQuotes'
|
9
|
+
|
10
|
+
OBJECT_METHODS = %i[
|
11
|
+
get
|
12
|
+
post
|
13
|
+
patch
|
14
|
+
delete
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
navigation :sales_quote_line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class SalesQuoteLine < Base
|
6
|
+
OBJECT = 'salesQuoteLines'
|
7
|
+
|
8
|
+
OBJECT_METHODS = %i[
|
9
|
+
get
|
10
|
+
post
|
11
|
+
patch
|
12
|
+
delete
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
OBJECT_PARENTS = %w[
|
16
|
+
salesQuotes
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
def initialize(client, parent: 'salesQuotes', parent_id:, **args)
|
20
|
+
return if !valid_parent?(parent)
|
21
|
+
|
22
|
+
super(client, args)
|
23
|
+
@parent_path << {
|
24
|
+
path: parent,
|
25
|
+
id: parent_id
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class URLBuilder
|
6
|
+
extend URLHelper
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def sanitize(query = '', values = [])
|
10
|
+
return encode_url_params(query) if values.length.zero?
|
11
|
+
|
12
|
+
query = replace_template_with_value(query, values)
|
13
|
+
encode_url_object(query)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(base_url:, parent_path: [], child_path: '', child_id: '', child_code: '', filter: '')
|
18
|
+
@base_url = base_url.to_s
|
19
|
+
@parent_path = parent_path || []
|
20
|
+
@child_path = child_path.to_s
|
21
|
+
@child_id = child_id.to_s
|
22
|
+
@child_code = child_code.to_s
|
23
|
+
@filter = filter.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def build
|
27
|
+
url = @base_url
|
28
|
+
url += build_parent_path
|
29
|
+
url += build_child_path
|
30
|
+
url += build_filter
|
31
|
+
url
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def build_parent_path
|
37
|
+
return '' if @parent_path.empty?
|
38
|
+
|
39
|
+
@parent_path.map do |parent|
|
40
|
+
"/#{parent[:path]}(#{parent[:id]})" if !parent[:id].nil?
|
41
|
+
end.join('')
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_child_path
|
45
|
+
url = ''
|
46
|
+
url += "/#{@child_path}" if @child_path.present?
|
47
|
+
url += "(#{@child_id})" if @child_id.present?
|
48
|
+
url += "('#{odata_encode(@child_code)}')" if @child_code.present?
|
49
|
+
url
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_filter
|
53
|
+
url = ''
|
54
|
+
url += "?$filter=#{@filter}" if @filter.present?
|
55
|
+
url
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|