qbwc_requests 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/qbwc_requests/estimate/v07/add.rb +27 -5
- data/lib/qbwc_requests/estimate/v07/mod.rb +40 -0
- data/lib/qbwc_requests/ordered_fields.rb +10 -9
- data/lib/qbwc_requests/sub_models/estimate_line_add.rb +28 -0
- data/lib/qbwc_requests/sub_models/estimate_line_group_add.rb +12 -0
- data/lib/qbwc_requests/sub_models/estimate_line_group_mod.rb +14 -0
- data/lib/qbwc_requests/sub_models/estimate_line_mod.rb +31 -0
- data/lib/qbwc_requests/version.rb +1 -1
- data/spec/estimate_qbxml_spec.rb +51 -7
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9a7aa265bf40dc3d57bc60db95c9b6f61ba117
|
4
|
+
data.tar.gz: 901daa4921c5cac53fa562e1015dd0462f0b22dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34c0d5ebd6cf606c2d442e975afe369f799a1f9d10d00a4d43a0dba10608f2542701c658517c86643d307886fb6cc0c2beefaffe956d4b9489cb2a4fe431728
|
7
|
+
data.tar.gz: 793b7d2f7fc62aeb4521a577b362b767c787029351e7179203504b106e3871e913a508e853736e0ecbccd8da2c5fcc8389c9b8861130cf4a1fafbb4c7ea04b48
|
@@ -2,13 +2,35 @@ module QbwcRequests
|
|
2
2
|
module Estimate
|
3
3
|
module V07
|
4
4
|
class Add < QbwcRequests::Base
|
5
|
-
|
6
|
-
ref_to
|
7
|
-
|
5
|
+
field :def_macro
|
6
|
+
ref_to :customer, 209
|
7
|
+
ref_to :class, 159
|
8
|
+
ref_to :template, 31
|
9
|
+
field :txn_date
|
10
|
+
field :ref_number
|
11
|
+
field :bill_address
|
12
|
+
field :ship_address
|
13
|
+
field :is_active
|
14
|
+
field :po_number
|
15
|
+
ref_to :terms, 31
|
16
|
+
field :due_date
|
17
|
+
ref_to :sales_rep, 5
|
18
|
+
field :fob
|
19
|
+
ref_to :item_sales_tax, 31
|
20
|
+
field :memo
|
21
|
+
ref_to :customer_msg, 101
|
22
|
+
field :is_to_be_emailed
|
23
|
+
ref_to :customer_sales_tax_code, 3
|
24
|
+
field :other
|
25
|
+
field :estimate_line_add
|
26
|
+
field :estimate_line_group_add
|
8
27
|
|
9
28
|
validates :customer_ref, presence: true
|
10
|
-
validates :
|
11
|
-
|
29
|
+
validates :ref_number, length: { maximum: 11 }
|
30
|
+
validates :po_number, length: { maximum: 25 }
|
31
|
+
validates :fob, length: { maximum: 13 }
|
32
|
+
validates :memo, length: { maximum: 4095 }
|
33
|
+
validates :other, length: { maximum: 29 }
|
12
34
|
end
|
13
35
|
end
|
14
36
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module QbwcRequests
|
2
|
+
module Estimate
|
3
|
+
module V07
|
4
|
+
class Mod < QbwcRequests::Base
|
5
|
+
field :txn_id
|
6
|
+
field :edit_sequence
|
7
|
+
ref_to :customer, 209
|
8
|
+
ref_to :class, 159
|
9
|
+
ref_to :template, 31
|
10
|
+
field :txn_date
|
11
|
+
field :ref_number
|
12
|
+
field :bill_address
|
13
|
+
field :ship_address
|
14
|
+
field :is_active
|
15
|
+
field :create_change_order
|
16
|
+
field :po_number
|
17
|
+
ref_to :terms, 31
|
18
|
+
field :due_date
|
19
|
+
ref_to :sales_rep, 5
|
20
|
+
field :fob
|
21
|
+
ref_to :item_sales_tax, 31
|
22
|
+
field :memo
|
23
|
+
ref_to :customer_msg, 101
|
24
|
+
field :is_to_be_emailed
|
25
|
+
ref_to :customer_sales_tax_code, 3
|
26
|
+
field :other
|
27
|
+
field :estimate_line_mod
|
28
|
+
field :estimate_line_group_mod
|
29
|
+
|
30
|
+
validates :txn_id, presence: true
|
31
|
+
validates :edit_sequence, presence: true, length: { maximum: 16 }
|
32
|
+
validates :ref_number, length: { maximum: 11 }
|
33
|
+
validates :po_number, length: { maximum: 25 }
|
34
|
+
validates :fob, length: { maximum: 13 }
|
35
|
+
validates :memo, length: { maximum: 4095 }
|
36
|
+
validates :other, length: { maximum: 29 }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -12,21 +12,21 @@ module QbwcRequests
|
|
12
12
|
attr_accessor attribute_name
|
13
13
|
validates_each attribute_name do |record, attribute, value|
|
14
14
|
if !value.blank? and value.class != klass
|
15
|
-
record.errors.add(attribute, "must be of type #{klass}")
|
15
|
+
record.errors.add(attribute, "must be of type #{klass}")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
def ref_to attribute_prefix, name_length
|
19
|
+
def ref_to attribute_prefix, name_length=nil
|
20
20
|
attribute_name = "#{attribute_prefix}_ref".to_sym
|
21
21
|
@attr_order ||= Set.new
|
22
22
|
@attr_order << attribute_name
|
23
23
|
attr_accessor attribute_name
|
24
24
|
validates_each attribute_name do |record, attribute, value|
|
25
|
-
if value.present?
|
25
|
+
if value.present?
|
26
26
|
if value.is_a?(Hash)
|
27
27
|
if !(value[:list_id].present? ^ value[:full_name].present?)
|
28
28
|
record.errors.add(attribute, "Must have list_id or full_name")
|
29
|
-
elsif value.fetch(:full_name, "").length > name_length
|
29
|
+
elsif name_length && value.fetch(:full_name, "").length > name_length
|
30
30
|
record.errors.add(attribute, "- maximum 'full name' length is: #{name_length}")
|
31
31
|
end
|
32
32
|
else
|
@@ -61,21 +61,22 @@ module QbwcRequests
|
|
61
61
|
base.extend(ClassMethods)
|
62
62
|
base.validates_with(SubModelsValidator)
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def ordered_fields
|
66
66
|
return {} if self.class.attr_order.blank?
|
67
67
|
new_hash = {}
|
68
68
|
for attribute in self.class.attr_order
|
69
69
|
value = send(attribute)
|
70
70
|
if value.present?
|
71
|
-
if value.
|
72
|
-
|
71
|
+
if value.kind_of?(Array)
|
72
|
+
result = value.map { |item | item.respond_to?(:ordered_fields) ? item.ordered_fields : item }
|
73
73
|
else
|
74
|
-
|
74
|
+
result = value.respond_to?(:ordered_fields) ? value.ordered_fields : value
|
75
75
|
end
|
76
|
+
new_hash[attribute] = result
|
76
77
|
end
|
77
78
|
end
|
78
79
|
new_hash
|
79
|
-
end
|
80
|
+
end
|
80
81
|
end
|
81
82
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module QbwcRequests
|
2
|
+
module SubModels
|
3
|
+
class EstimateLineAdd < QbwcRequests::Base
|
4
|
+
ref_to :item
|
5
|
+
field :desc
|
6
|
+
field :quantity
|
7
|
+
field :unit_of_measure
|
8
|
+
field :rate
|
9
|
+
field :rate_percent
|
10
|
+
ref_to :class, 159
|
11
|
+
field :amount
|
12
|
+
ref_to :sales_tax_code, 3
|
13
|
+
field :markup_rate
|
14
|
+
field :markup_rate_percent
|
15
|
+
ref_to :price_level, 31
|
16
|
+
ref_to :override_item_account_ref, 159
|
17
|
+
field :other1
|
18
|
+
field :other2
|
19
|
+
field :data_ext_list
|
20
|
+
|
21
|
+
validates :item, presence: true
|
22
|
+
validates :desc, length: { maximum: 4095 }
|
23
|
+
validates :unit_of_measure, length: { maximum: 31 }
|
24
|
+
validates :other1, length: { maximum: 29 }
|
25
|
+
validates :other2, length: { maximum: 29 }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module QbwcRequests
|
2
|
+
module SubModels
|
3
|
+
class EstimateLineGroupMod < QbwcRequests::Base
|
4
|
+
field :txn_line_id
|
5
|
+
ref_to :item_group, 31
|
6
|
+
field :quantity
|
7
|
+
field :unit_of_measure
|
8
|
+
ref_to :override_uom_set_ref, 31
|
9
|
+
field :estimate_line_mod
|
10
|
+
|
11
|
+
validates :unit_of_measure, length: { maximum: 31 }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module QbwcRequests
|
2
|
+
module SubModels
|
3
|
+
class EstimateLineMod < QbwcRequests::Base
|
4
|
+
field :txn_line_id
|
5
|
+
ref_to :item
|
6
|
+
field :desc
|
7
|
+
field :quantity
|
8
|
+
field :unit_of_measure
|
9
|
+
ref_to :override_uom_set, 31
|
10
|
+
field :rate
|
11
|
+
field :rate_percent
|
12
|
+
ref_to :class, 159
|
13
|
+
field :amount
|
14
|
+
ref_to :sales_tax_code, 3
|
15
|
+
field :markup_rate
|
16
|
+
field :markup_rate_percent
|
17
|
+
ref_to :price_level, 31
|
18
|
+
ref_to :override_item_account_ref, 159
|
19
|
+
field :other1
|
20
|
+
field :other2
|
21
|
+
field :data_ext_list
|
22
|
+
|
23
|
+
validates :txn_line_id, presence: true
|
24
|
+
validates :item, presence: true
|
25
|
+
validates :desc, length: { maximum: 4095 }
|
26
|
+
validates :unit_of_measure, length: { maximum: 31 }
|
27
|
+
validates :other1, length: { maximum: 29 }
|
28
|
+
validates :other2, length: { maximum: 29 }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/estimate_qbxml_spec.rb
CHANGED
@@ -11,16 +11,15 @@ RSpec.describe EstimateQbxml do
|
|
11
11
|
describe EstimateQbxml::Add do
|
12
12
|
|
13
13
|
it{ is_expected.to validate_field_presence_of :customer_ref }
|
14
|
-
it{ is_expected.to validate_field_presence_of :estimate_line_add }
|
15
14
|
|
16
|
-
let(:estimate)
|
15
|
+
let(:estimate) do
|
17
16
|
EstimateQbxml::Add.factory(
|
18
17
|
customer_ref: {full_name: 'Some customer name'},
|
19
|
-
estimate_line_add:
|
20
|
-
item_ref: {full_name: '
|
21
|
-
|
18
|
+
estimate_line_add: [
|
19
|
+
{item_ref: {full_name: 'item1'}},
|
20
|
+
{item_ref: {full_name: 'item2'}}]
|
22
21
|
)
|
23
|
-
|
22
|
+
end
|
24
23
|
|
25
24
|
it "should create an add estimate xml" do
|
26
25
|
xml = <<-XML
|
@@ -35,7 +34,12 @@ RSpec.describe EstimateQbxml do
|
|
35
34
|
</CustomerRef>
|
36
35
|
<EstimateLineAdd>
|
37
36
|
<ItemRef>
|
38
|
-
<FullName>
|
37
|
+
<FullName>item1</FullName>
|
38
|
+
</ItemRef>
|
39
|
+
</EstimateLineAdd>
|
40
|
+
<EstimateLineAdd>
|
41
|
+
<ItemRef>
|
42
|
+
<FullName>item2</FullName>
|
39
43
|
</ItemRef>
|
40
44
|
</EstimateLineAdd>
|
41
45
|
</EstimateAdd>
|
@@ -45,6 +49,46 @@ RSpec.describe EstimateQbxml do
|
|
45
49
|
XML
|
46
50
|
expect( estimate.to_xml("request_id") ).to be_xml_equal_to xml
|
47
51
|
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe EstimateQbxml::Mod do
|
55
|
+
|
56
|
+
it{ is_expected.to validate_field_presence_of :txn_id }
|
57
|
+
it{ is_expected.to validate_field_presence_of :edit_sequence }
|
58
|
+
|
59
|
+
let(:estimate) do
|
60
|
+
EstimateQbxml::Mod.factory(
|
61
|
+
txn_id: 'transaction id',
|
62
|
+
edit_sequence: 'edit sequence',
|
63
|
+
estimate_line_mod: [
|
64
|
+
{txn_line_id: 'line id 1'},
|
65
|
+
{txn_line_id: 'line id 2'}]
|
66
|
+
)
|
67
|
+
end
|
48
68
|
|
69
|
+
it "should create an add estimate xml" do
|
70
|
+
xml = <<-XML
|
71
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
72
|
+
<?qbxml version="7.0"?>
|
73
|
+
<QBXML>
|
74
|
+
<QBXMLMsgsRq onError="stopOnError">
|
75
|
+
<EstimateModRq requestID="request_id">
|
76
|
+
<EstimateMod>
|
77
|
+
<TxnID>transaction id</TxnID>
|
78
|
+
<EditSequence>edit sequence</EditSequence>
|
79
|
+
<EstimateLineMod>
|
80
|
+
<TxnLineID>line id 1</TxnLineID>
|
81
|
+
</EstimateLineMod>
|
82
|
+
<EstimateLineMod>
|
83
|
+
<TxnLineID>line id 2</TxnLineID>
|
84
|
+
</EstimateLineMod>
|
85
|
+
</EstimateMod>
|
86
|
+
</EstimateModRq>
|
87
|
+
</QBXMLMsgsRq>
|
88
|
+
</QBXML>
|
89
|
+
XML
|
90
|
+
expect( estimate.to_xml("request_id") ).to be_xml_equal_to xml
|
91
|
+
end
|
49
92
|
end
|
93
|
+
|
50
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbwc_requests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Mondaini Calvão
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/qbwc_requests/customer/v07/add.rb
|
119
119
|
- lib/qbwc_requests/customer/v07/query.rb
|
120
120
|
- lib/qbwc_requests/estimate/v07/add.rb
|
121
|
+
- lib/qbwc_requests/estimate/v07/mod.rb
|
121
122
|
- lib/qbwc_requests/estimate/v07/query.rb
|
122
123
|
- lib/qbwc_requests/factory.rb
|
123
124
|
- lib/qbwc_requests/general_detail_report/v07/query.rb
|
@@ -144,6 +145,10 @@ files:
|
|
144
145
|
- lib/qbwc_requests/purchase_order/v07/mod.rb
|
145
146
|
- lib/qbwc_requests/purchase_order/v07/query.rb
|
146
147
|
- lib/qbwc_requests/sub_models/address.rb
|
148
|
+
- lib/qbwc_requests/sub_models/estimate_line_add.rb
|
149
|
+
- lib/qbwc_requests/sub_models/estimate_line_group_add.rb
|
150
|
+
- lib/qbwc_requests/sub_models/estimate_line_group_mod.rb
|
151
|
+
- lib/qbwc_requests/sub_models/estimate_line_mod.rb
|
147
152
|
- lib/qbwc_requests/sub_models/sales_and_puchase.rb
|
148
153
|
- lib/qbwc_requests/sub_models/sales_or_puchase.rb
|
149
154
|
- lib/qbwc_requests/vendor/v07/add.rb
|