sk-api 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -30,4 +30,15 @@ module ActiveResource
30
30
  collection.collect! { |record| instantiate_record(record, prefix_options) }
31
31
  end
32
32
  end
33
+ end
34
+
35
+ # Force json decoding using Rufus
36
+ module ActiveResource
37
+ module Formats
38
+ module JsonFormat
39
+ def decode(json)
40
+ Rufus::Json.decode(json)
41
+ end
42
+ end
43
+ end
33
44
  end
@@ -35,7 +35,7 @@ module SKApi
35
35
  "lock_version" => {"type" => "integer", "optional" => true, "readonly" => true},
36
36
  "client_id" => {"type" => "string"},
37
37
  "client" => {"type" => "object", "properties" => SKApi::Resources::Client.schema_props, "optional" => true, "readonly" => true},
38
- "line_items" => {"type" => "array","properties" => SKApi::Resources::LineItem.schema_props, "optional" => true,},
38
+ "line_items" => {"type" => "array","properties" => SKApi::Resources::LineItem.schema_props, "optional" => true}
39
39
  }
40
40
  end
41
41
 
@@ -23,7 +23,7 @@ module SKApi
23
23
  "price_single" => {"type" => "number"},
24
24
  "discount" => {"type" => "number", "optional" => true},
25
25
  "tax" => {"type" => "number", "optional" => true},
26
- "use_product" => {"type" => "boolean", "optional" => true},
26
+ "use_product" => {"type" => "integer", "optional" => true},
27
27
  "created_at" => {"type" => "string", "format" =>"date-time", "optional" => true, "readonly" => true},
28
28
  "updated_at" => {"type" => "string", "format" =>"date-time", "optional" => true, "readonly" => true}
29
29
  }
@@ -115,9 +115,65 @@ describe SKApi::Resources::Invoice, "with line items" do
115
115
 
116
116
  it "should add line item" do
117
117
  item = SKApi::Resources::LineItem.new( { :position=>2, :description => 'Goat-Pie', :price_single => 10, :quantity=>10} )
118
+ product = SKApi::Resources::Product.new(:name=>'Eis am Stiel', :price => 1.50, :tax=>19, :description => 'Mmmhh lecker Eis')
119
+ product.save.should be_true
120
+ item1 = SKApi::Resources::LineItem.new( { :position=>3, :use_product => 1, :product_id=> product.id, :quantity => 10 } )
118
121
  @doc.line_items << item
122
+ @doc.line_items << item1
119
123
  @doc.save
120
- @doc.line_items.length.should == 2
121
- @doc.price_total.should == 220.0
124
+ @doc.line_items.length.should == 3
125
+ @doc.price_total.should == 235.0
122
126
  end
127
+
123
128
  end
129
+ =begin
130
+ describe SKApi::Resources::Invoice, "with line items" do
131
+
132
+ before :all do
133
+ @client = SKApi::Resources::Client.new(:organisation=>'Credit Note API-Tester')
134
+ @client.save.should be_true
135
+ #setup test doc to work with
136
+ @doc = SKApi::Resources::Invoice.new(:client_id => @client.id,
137
+ :line_items => [{ :position=>1, :description => 'Pork Chops', :quantity => 12, :price_single =>'10.00' }] )
138
+ @doc.save.should be_true
139
+ end
140
+
141
+ after :all do
142
+ delete_test_data(@doc, @client)
143
+ end
144
+
145
+ it "should create a line item" do
146
+ @doc.line_items.length.should == 1
147
+ @doc.line_items.first.description.should == 'Pork Chops'
148
+ @doc.price_total.should == 120.0
149
+ end
150
+
151
+ it "should edit line item" do
152
+ @doc.line_items[0].description = 'Egg Sandwich'
153
+ @doc.save
154
+ @doc.line_items.length.should == 1
155
+ @doc.line_items.first.description.should == 'Egg Sandwich'
156
+ end
157
+
158
+ it "should add line item" do
159
+ item = SKApi::Resources::LineItem.new( { :position=>2, :description => 'Goat-Pie', :price_single => 10, :quantity=>10} )
160
+ product = SKApi::Resources::Product.new(:name=>'Eis am Stiel', :price => 1.50, :tax=>19, :description => 'Mmmhh lecker Eis')
161
+ product.save.should be_true
162
+ item1 = SKApi::Resources::LineItem.new( { :position=>3, :use_product => 1, :quantity => 10 } )
163
+ @doc.line_items << item
164
+ @doc.line_items << item1
165
+ @doc.save
166
+ @doc.line_items.length.should == 3
167
+ @doc.price_total.should == 220.0
168
+ end
169
+
170
+ xit "should add line item and use product information" do
171
+
172
+ @doc.line_items << item
173
+ @doc.save
174
+ @doc.line_items.length.should == 3
175
+ @doc.price_total.should == 15.0
176
+
177
+ product.destroy
178
+ end
179
+ =end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 4
9
- version: 1.0.4
8
+ - 5
9
+ version: 1.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Georg Leciejewski
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-07 00:00:00 +01:00
17
+ date: 2010-03-08 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency