business-central 1.0.1 → 1.0.6
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 +47 -2
- data/lib/business_central/client.rb +82 -39
- data/lib/business_central/exceptions.rb +30 -10
- data/lib/business_central/object/account.rb +4 -12
- data/lib/business_central/object/aged_account_payable.rb +4 -12
- data/lib/business_central/object/aged_account_receivable.rb +4 -12
- 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 +4 -12
- data/lib/business_central/object/base.rb +100 -49
- data/lib/business_central/object/cash_flow_statement.rb +4 -12
- data/lib/business_central/object/company.rb +9 -2
- data/lib/business_central/object/company_information.rb +7 -15
- 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 +31 -23
- 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 +44 -0
- data/lib/business_central/object/validation.rb +10 -7
- 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 +6 -5
- data/test/business_central/object/aged_account_payable_test.rb +6 -5
- data/test/business_central/object/aged_account_receivable_test.rb +6 -5
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +6 -5
- data/test/business_central/object/base_test.rb +41 -0
- data/test/business_central/object/cash_flow_statement_test.rb +6 -5
- data/test/business_central/object/company_information_test.rb +9 -10
- data/test/business_central/object/company_test.rb +6 -5
- 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 -17
- 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 -15
- data/test/business_central/object/purchase_invoice_test.rb +15 -15
- data/test/business_central/object/request_test.rb +75 -12
- data/test/business_central/object/response_test.rb +34 -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 -16
- data/test/business_central/web_service_test.rb +100 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +16 -6
- metadata +188 -37
- data/lib/business_central/object/helper.rb +0 -15
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class Currency < Base
|
6
|
+
OBJECT = 'currencies'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
code: {
|
10
|
+
required: true
|
11
|
+
},
|
12
|
+
display_name: {
|
13
|
+
required: true,
|
14
|
+
maximum_length: 100
|
15
|
+
},
|
16
|
+
symbol: {
|
17
|
+
required: true
|
18
|
+
}
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
OBJECT_METHODS = %i[
|
22
|
+
get
|
23
|
+
post
|
24
|
+
patch
|
25
|
+
delete
|
26
|
+
].freeze
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class Customer < Base
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'customers'
|
9
|
+
|
10
|
+
OBJECT_VALIDATION = {
|
11
|
+
display_name: {
|
12
|
+
required: true,
|
13
|
+
maximum_length: 100
|
14
|
+
},
|
15
|
+
type: {
|
16
|
+
inclusion_of: %w[
|
17
|
+
Company
|
18
|
+
Person
|
19
|
+
]
|
20
|
+
}
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
OBJECT_METHODS = %i[
|
24
|
+
get
|
25
|
+
post
|
26
|
+
patch
|
27
|
+
delete
|
28
|
+
].freeze
|
29
|
+
|
30
|
+
navigation :default_dimension
|
31
|
+
navigation :picture
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class CustomerPayment < Base
|
6
|
+
OBJECT = 'customerPayments'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
customer_number: {
|
10
|
+
maximum_length: 20
|
11
|
+
},
|
12
|
+
contact_id: {
|
13
|
+
maximum_length: 250
|
14
|
+
},
|
15
|
+
posting_date: {
|
16
|
+
date: true
|
17
|
+
},
|
18
|
+
document_number: {
|
19
|
+
maximum_length: 20
|
20
|
+
},
|
21
|
+
external_document_number: {
|
22
|
+
maximum_length: 20
|
23
|
+
},
|
24
|
+
applies_to_invoice_number: {
|
25
|
+
maximum_length: 20
|
26
|
+
},
|
27
|
+
description: {
|
28
|
+
maximum_length: 50
|
29
|
+
},
|
30
|
+
comment: {
|
31
|
+
maximum_length: 250
|
32
|
+
}
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
OBJECT_METHODS = %i[
|
36
|
+
get
|
37
|
+
post
|
38
|
+
patch
|
39
|
+
delete
|
40
|
+
].freeze
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class CustomerPaymentJournal < Base
|
6
|
+
OBJECT = 'customerPaymentJournals'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
code: {
|
10
|
+
maximum_length: 10
|
11
|
+
},
|
12
|
+
display_name: {
|
13
|
+
maximum_length: 50
|
14
|
+
}
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
OBJECT_METHODS = %i[
|
18
|
+
get
|
19
|
+
post
|
20
|
+
patch
|
21
|
+
delete
|
22
|
+
].freeze
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class DefaultDimension < Base
|
6
|
+
OBJECT = 'defaultDimensions'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
parent_id: {
|
10
|
+
required: true
|
11
|
+
},
|
12
|
+
dimension_code: {
|
13
|
+
maximum_length: 20
|
14
|
+
},
|
15
|
+
dimension_value_code: {
|
16
|
+
maximum_length: 20
|
17
|
+
}
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
OBJECT_METHODS = %i[
|
21
|
+
get
|
22
|
+
post
|
23
|
+
patch
|
24
|
+
delete
|
25
|
+
].freeze
|
26
|
+
|
27
|
+
OBJECT_PARENTS = %w[
|
28
|
+
items
|
29
|
+
customers
|
30
|
+
vendors
|
31
|
+
employees
|
32
|
+
].freeze
|
33
|
+
|
34
|
+
def initialize(client, parent:, parent_id:, **args)
|
35
|
+
return if !valid_parent?(parent)
|
36
|
+
|
37
|
+
super(client, args)
|
38
|
+
@parent_path << {
|
39
|
+
path: parent,
|
40
|
+
id: parent_id
|
41
|
+
}
|
42
|
+
@parent_id = parent_id
|
43
|
+
end
|
44
|
+
|
45
|
+
def create(params = {})
|
46
|
+
params[:parent_id] = @parent_id
|
47
|
+
super(params)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class Dimension < Base
|
6
|
+
OBJECT = 'dimensions'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
code: {
|
10
|
+
required: true,
|
11
|
+
maximum_length: 20
|
12
|
+
}
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
OBJECT_METHODS = %i[
|
16
|
+
get
|
17
|
+
].freeze
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class DimensionLine < Base
|
6
|
+
OBJECT = 'dimensionLines'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
parent_id: {
|
10
|
+
required: true
|
11
|
+
},
|
12
|
+
code: {
|
13
|
+
maximum_length: 20
|
14
|
+
},
|
15
|
+
display_name: {
|
16
|
+
maximum_length: 30
|
17
|
+
},
|
18
|
+
value_id: {
|
19
|
+
required: true
|
20
|
+
},
|
21
|
+
value_code: {
|
22
|
+
maximum_length: 20
|
23
|
+
},
|
24
|
+
value_display_name: {
|
25
|
+
maximum_length: 50
|
26
|
+
}
|
27
|
+
}.freeze
|
28
|
+
|
29
|
+
OBJECT_METHODS = %i[
|
30
|
+
get
|
31
|
+
post
|
32
|
+
patch
|
33
|
+
delete
|
34
|
+
].freeze
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class DimensionValue < Base
|
6
|
+
OBJECT = 'dimensionValues'
|
7
|
+
|
8
|
+
OBJECT_VALIDATION = {
|
9
|
+
code: {
|
10
|
+
required: true,
|
11
|
+
maximum_length: 20
|
12
|
+
}
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
OBJECT_METHODS = %i[
|
16
|
+
get
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
def initialize(client, dimension_id:, **args)
|
20
|
+
super(client, args)
|
21
|
+
@parent_path << {
|
22
|
+
path: 'dimensions',
|
23
|
+
id: dimension_id
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class Employee < Base
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'employees'
|
9
|
+
|
10
|
+
OBJECT_METHODS = %i[
|
11
|
+
get
|
12
|
+
post
|
13
|
+
patch
|
14
|
+
delete
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
navigation :default_dimension
|
18
|
+
navigation :picture
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class FilterQuery
|
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_params(query)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class Item < Base
|
4
|
-
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'items'
|
5
9
|
|
6
10
|
OBJECT_VALIDATION = {
|
7
11
|
number: {
|
@@ -12,10 +16,10 @@ module BusinessCentral
|
|
12
16
|
},
|
13
17
|
type: {
|
14
18
|
required: true,
|
15
|
-
inclusive_of: [
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
inclusive_of: %w[
|
20
|
+
Inventory
|
21
|
+
Service
|
22
|
+
Non-Inventory
|
19
23
|
]
|
20
24
|
},
|
21
25
|
item_category_code: {
|
@@ -29,22 +33,15 @@ module BusinessCentral
|
|
29
33
|
}
|
30
34
|
}.freeze
|
31
35
|
|
32
|
-
OBJECT_METHODS = [
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
OBJECT_METHODS = %i[
|
37
|
+
get
|
38
|
+
post
|
39
|
+
patch
|
40
|
+
delete
|
37
41
|
].freeze
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
@parent_path = [
|
42
|
-
{
|
43
|
-
path: 'companies',
|
44
|
-
id: company_id
|
45
|
-
}
|
46
|
-
]
|
47
|
-
end
|
43
|
+
navigation :default_dimension
|
44
|
+
navigation :picture
|
48
45
|
end
|
49
46
|
end
|
50
47
|
end
|