spree-point-of-sale 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
1
  source "https://rubygems.org"
2
- gem 'rails', '4.0.2'
2
+ gem 'rails', '4.0.3'
3
3
  gem 'mysql2'
4
4
 
5
5
 
6
- gem 'spree', :git => 'git://github.com/spree/spree.git', :tag => 'v2.1.4'
6
+ gem 'spree', '> 2.1' #, :git => 'https://github.com/spree/spree.git', :tag => 'v2.2.0'
7
7
  # gem 'spree_html_invoice' , :git => 'git://github.com/dancinglightning/spree-html-invoice.git'
8
8
 
9
9
  # Provides basic authentication functionality for testing parts of your engine
10
- gem 'spree_auth_devise', github: 'spree/spree_auth_devise', :branch => '2-1-stable'
10
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable'
11
11
 
12
12
  gemspec
13
13
 
data/README.md CHANGED
@@ -29,17 +29,22 @@ Add spree-point-of-sale to your Gemfile:
29
29
  gem "spree-point-of-sale", require: 'spree_pos'
30
30
  ```
31
31
 
32
- If you're still using Spree 2.0.x, you should do this instead:
32
+ For specific spree versions:
33
33
 
34
34
  ```ruby
35
+ #Spree 2.0.x
35
36
  gem "spree-point-of-sale", '1.0.3', require: 'spree_pos'
36
37
  ```
37
38
 
39
+ ```ruby
40
+ #Spree 2.1.x
41
+ gem "spree-point-of-sale", '1.1.1', require: 'spree_pos'
42
+ ```
38
43
 
39
44
  If you DONT change the :pos_printing config as described above, you must also add
40
45
 
41
46
  ```ruby
42
- gem 'spree_html_invoice' , :git => 'git://github.com/dancinglightning/spree-html-invoice.git'
47
+ gem 'spree_html_invoice' , :git => 'git://github.com/vinsol/spree-html-invoice.git', tag: '1.2'
43
48
  ```
44
49
 
45
50
  ```ruby
@@ -17,8 +17,7 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
17
17
 
18
18
  def find
19
19
  init_search
20
- #TODO -> create one method for last_shipment in order_model as it is used in verious locations.
21
- stock_location = @order.shipments.last.stock_location
20
+ stock_location = @order.pos_shipment.stock_location
22
21
  @search = Spree::Variant.includes([:product]).available_at_stock_location(stock_location.id).ransack(params[:q])
23
22
  @variants = @search.result(:distinct => true).page(params[:page]).per(PRODUCTS_PER_SEARCH_PAGE)
24
23
  end
@@ -31,8 +30,8 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
31
30
  end
32
31
 
33
32
  def remove
34
- line_item = @order.contents.remove(@variant, 1, @order.shipments.last)
35
- @order.assign_shipment_for_pos if @order.reload.shipments.blank?
33
+ line_item = @order.contents.remove(@variant, 1, @order.pos_shipment)
34
+ @order.assign_shipment_for_pos if @order.reload.pos_shipment.blank?
36
35
  flash.notice = line_item.quantity.zero? ? Spree.t('product_removed') : 'Quantity Updated'
37
36
  redirect_to admin_pos_show_order_path(:number => @order.number)
38
37
  end
@@ -82,7 +81,7 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
82
81
  end
83
82
 
84
83
  def update_stock_location
85
- @shipment = @order.shipments.last
84
+ @shipment = @order.pos_shipment
86
85
  @shipment.stock_location = user_stock_locations(spree_current_user).where(:id => params[:stock_location_id]).first
87
86
  if @shipment.save
88
87
  flash[:notice] = "Updated Successfully"
@@ -186,7 +185,7 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
186
185
  end
187
186
 
188
187
  def add_variant var , quant = 1
189
- line_item = @order.contents.add(var, quant, nil, @order.shipments.last)
188
+ line_item = @order.contents.add(var, quant, nil, @order.pos_shipment)
190
189
  var.product.save
191
190
  line_item
192
191
  end
@@ -7,7 +7,7 @@ Spree::Order.class_eval do
7
7
 
8
8
  def clean!
9
9
  payments.delete_all
10
- line_items.each { |line_item| contents.remove(line_item.variant, line_item.quantity, shipments.last) }
10
+ line_items.each { |line_item| contents.remove(line_item.variant, line_item.quantity, pos_shipment) }
11
11
  #shipment is removed on removing all items, so initializing a new shipment
12
12
  assign_shipment_for_pos
13
13
  end
@@ -35,4 +35,8 @@ Spree::Order.class_eval do
35
35
  self.email = new_user_email if associate_with_user.valid?
36
36
  associate_with_user
37
37
  end
38
+
39
+ def pos_shipment
40
+ shipments.last
41
+ end
38
42
  end
@@ -3,7 +3,7 @@ module Spree
3
3
  class PosAvailabilityValidator < ActiveModel::Validator
4
4
  def validate(line_item)
5
5
  variant = line_item.variant
6
- stock_location = line_item.order.shipments.last.try(:stock_location)
6
+ stock_location = line_item.order.pos_shipment.try(:stock_location)
7
7
  quantity_required = line_item.quantity - line_item.quantity_was.to_i
8
8
  if !stock_location || !stock_location.active? || !stock_location.store?
9
9
  line_item.errors[:stock_location] << 'No Active Store Associated'
@@ -39,7 +39,7 @@ No Result Found
39
39
  <% end %>
40
40
  <% content_for :sidebar do %>
41
41
  <div>
42
- <%= button_to "Back To Order", admin_pos_show_order_path(:number => @order.number) %>
42
+ <%= button_to "Back To Order", admin_pos_show_order_path(:number => @order.number), method: :get %>
43
43
  </div>
44
44
  <%= search_form_for @search , :url => "/admin/pos/find/#{@order.number}/" do |f| %>
45
45
  <div class="box">
@@ -6,7 +6,7 @@
6
6
  <legend>Change Stock Location</legend>
7
7
  <%= form_tag "/admin/pos/update_stock_location/#{@order.number}", :class => 'modify_stock_location_form' do %>
8
8
  <% user_stock_locations(spree_current_user).all.each do |stock_location| %>
9
- <%= radio_button_tag :stock_location_id, stock_location.id, (stock_location.id == @order.shipments.last.stock_location.id), :id => "stock_location_#{ stock_location.id }", :class => 'stock_location_checkbox' %><%= stock_location.name %><br />
9
+ <%= radio_button_tag :stock_location_id, stock_location.id, (stock_location.id == @order.pos_shipment.stock_location.id), :id => "stock_location_#{ stock_location.id }", :class => 'stock_location_checkbox' %><%= stock_location.name %><br />
10
10
  <% end %>
11
11
  <br />
12
12
  <%= submit_tag 'Update', :confirm => 'The Order will be cleaned. Are you sure?' %>
@@ -3,11 +3,11 @@ module SpreePos
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
 
5
5
  def add_javascripts
6
- append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_pos\n"
6
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require admin/spree_pos\n"
7
7
  end
8
8
 
9
9
  def add_stylesheets
10
- inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_pos\n", :before => /\*\//, :verbose => true
10
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require admin/spree_pos\n", :before => /\*\//, :verbose => true
11
11
  end
12
12
 
13
13
  def add_migrations
@@ -503,7 +503,7 @@ describe Spree::Admin::PosController do
503
503
  @orders.stub(:includes).with([{ :line_items => [{ :variant => [:default_price, { :product => [:master] } ] }] } , { :adjustments => :adjustable }]).and_return(@orders)
504
504
  @stock_location = mock_model(Spree::StockLocation)
505
505
  @shipment = mock_model(Spree::Shipment)
506
- order.stub(:shipments).and_return([@shipment])
506
+ order.stub(:pos_shipment).and_return(@shipment)
507
507
  @shipment.stub(:stock_location).and_return(@stock_location)
508
508
  @variants = [variant]
509
509
  @variants.stub(:result).with(:distinct => true).and_return(@variants)
@@ -519,7 +519,7 @@ describe Spree::Admin::PosController do
519
519
  it { controller.should_receive(:ensure_pos_shipping_method).and_return(true) }
520
520
  it { controller.should_receive(:ensure_active_store).and_return(true) }
521
521
  it { controller.should_not_receive(:ensure_payment_method) }
522
- it { order.should_receive(:shipments).and_return([@shipment]) }
522
+ it { order.should_receive(:pos_shipment).and_return(@shipment) }
523
523
  it { @shipment.should_receive(:stock_location).and_return(@stock_location) }
524
524
  it { Spree::Variant.should_receive(:ransack).with({"product_name_cont"=>"test-product", "meta_sort"=>"product_name asc", "deleted_at_null"=>"1", "product_deleted_at_null"=>"1", "published_at_not_null"=>"1"}).and_return(@variants) }
525
525
  it { @variants.should_receive(:result).with(:distinct => true).and_return(@variants) }
@@ -563,7 +563,7 @@ describe Spree::Admin::PosController do
563
563
  Spree::Variant.stub(:where).with(:id => variant.id.to_s).and_return([variant])
564
564
  @order_contents = double(Spree::OrderContents)
565
565
  @shipment = mock_model(Spree::Shipment)
566
- order.stub(:shipments).and_return([@shipment])
566
+ order.stub(:pos_shipment).and_return(@shipment)
567
567
  order.stub(:contents).and_return(@order_contents)
568
568
  @order_contents.stub(:add).with(variant, 1, nil, @shipment).and_return(line_item)
569
569
  end
@@ -629,7 +629,7 @@ describe Spree::Admin::PosController do
629
629
  Spree::Variant.stub(:where).with(:id => variant.id.to_s).and_return([variant])
630
630
  @order_contents = double(Spree::OrderContents)
631
631
  @shipment = mock_model(Spree::Shipment)
632
- order.stub(:shipments).and_return([@shipment])
632
+ order.stub(:pos_shipment).and_return(@shipment)
633
633
  order.stub(:assign_shipment_for_pos).and_return(true)
634
634
  order.stub(:contents).and_return(@order_contents)
635
635
  @order_contents.stub(:remove).with(variant, 1, @shipment).and_return(line_item)
@@ -676,7 +676,7 @@ describe Spree::Admin::PosController do
676
676
  end
677
677
 
678
678
  context 'shipment destroyed after remove' do
679
- before { order.stub_chain(:shipments, :blank?).and_return(true) }
679
+ before { order.stub_chain(:pos_shipment, :blank?).and_return(true) }
680
680
 
681
681
  it 'assigns shipment' do
682
682
  order.should_receive(:assign_shipment_for_pos).and_return(true)
@@ -873,8 +873,8 @@ describe Spree::Admin::PosController do
873
873
  order.stub(:bill_address=).with(address).and_return(address)
874
874
  @shipment.stub(:stock_location=).with(@stock_location).and_return(@stock_location)
875
875
  @shipment.stub(:stock_location).and_return(@stock_location)
876
+ order.stub(:pos_shipment).and_return(@shipment)
876
877
 
877
- order.stub(:shipments).and_return([@shipment])
878
878
  order.stub(:save).and_return(true)
879
879
  @shipment.stub(:save).and_return(true)
880
880
  end
@@ -883,7 +883,7 @@ describe Spree::Admin::PosController do
883
883
  it { order.should_receive(:clean!).and_return(true) }
884
884
  it { controller.should_receive(:load_order).twice.and_return(true) }
885
885
  it { @shipment.should_receive(:stock_location=).with(@stock_location).and_return(@stock_location) }
886
- it { order.should_receive(:shipments).and_return([@shipment]) }
886
+ it { order.should_receive(:pos_shipment).and_return(@shipment) }
887
887
  it { @shipment.should_receive(:save).and_return(true) }
888
888
  it { controller.should_receive(:ensure_pos_shipping_method).and_return(true) }
889
889
  it { controller.should_receive(:ensure_active_store).and_return(true) }
@@ -172,4 +172,14 @@ describe Spree::Order do
172
172
  it { @order.associate_user_for_pos('new-user@pos.com').should eq(@new_user) }
173
173
  end
174
174
  end
175
+
176
+ describe '#pos_shipment' do
177
+ before { @shipments = [@shipment] }
178
+
179
+ it 'should fetch all shipments' do
180
+ @order.should_receive(:shipments).and_return(@shipments)
181
+ @shipments.should_receive(:last).and_return(@shipment)
182
+ @order.pos_shipment.should eq(@shipment)
183
+ end
184
+ end
175
185
  end
@@ -19,7 +19,7 @@ describe Spree::Stock::PosAvailabilityValidator do
19
19
 
20
20
  describe 'ensures stock location' do
21
21
  it 'presence' do
22
- @line_item.order.shipments.last.stock_location.should be_nil
22
+ @line_item.order.pos_shipment.stock_location.should be_nil
23
23
  @line_item.save
24
24
  @line_item.errors[:stock_location].should eq(['No Active Store Associated'])
25
25
  end
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = "spree-point-of-sale"
6
- s.version = "1.1.0"
6
+ s.version = "1.1.1"
7
7
 
8
8
  s.author = ["Torsten R, Nishant Tuteja, Manish Kangia"]
9
9
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree-point-of-sale
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Torsten R, Nishant Tuteja, Manish Kangia
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-03-07 00:00:00 Z
18
+ date: 2014-03-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: spree_core
@@ -102,7 +102,6 @@ files:
102
102
  - app/controllers/spree/admin/barcode_controller.rb
103
103
  - app/controllers/spree/admin/checkout_controller_decorator.rb
104
104
  - app/controllers/spree/admin/pos_controller.rb
105
- - app/controllers/spree/admin/stock_locations_controller_decorator.rb
106
105
  - app/helpers/admin/barcode_helper.rb
107
106
  - app/models/spree/line_item_decorator.rb
108
107
  - app/models/spree/order_decorator.rb
@@ -122,10 +121,6 @@ files:
122
121
  - app/overrides/codes.rb
123
122
  - app/overrides/pos_tab.rb
124
123
  - app/views/spree/admin/barcode/basic.html.erb
125
- - app/views/spree/admin/invoice/_line_items_invoice.html.erb
126
- - app/views/spree/admin/invoice/_receipt_header.html.erb
127
- - app/views/spree/admin/invoice/_totals_receipt.html.erb
128
- - app/views/spree/admin/invoice/receipt.html.erb
129
124
  - app/views/spree/admin/orders/_admin_pos_config.html.erb
130
125
  - app/views/spree/admin/orders/_pos_button.html.erb
131
126
  - app/views/spree/admin/pos/find.html.erb
@@ -1,14 +0,0 @@
1
- Spree::Admin::StockLocationsController.class_eval do
2
- #TODO -> Is this method different from resource_controller update action ?
3
- def update
4
- if @stock_location.update_attributes(permitted_resource_params)
5
- flash[:success] = flash_message_for(@object, :successfully_updated)
6
- respond_with(@object) do |format|
7
- format.html { redirect_to location_after_save }
8
- format.js { render :layout => false }
9
- end
10
- else
11
- render :edit
12
- end
13
- end
14
- end
@@ -1,34 +0,0 @@
1
- <table width="700" cellspacing="0" cellpadding="7" border="0" class="line_items" style="border:solid 1px #cccccc; border-bottom:none; margin:30px 0;" >
2
- <colgroup>
3
- <col/>
4
- <col/>
5
- <col class="price"/>
6
- <col class="qty"/>
7
- <col class="total"/>
8
- </colgroup>
9
- <tr>
10
- <th align="left" bgcolor="#cccccc" style="background:#cccccc;" class="sku bold"><font face="Arial, Helvetica, sans-serif" size="2"><%= t(:sku) %></font></th>
11
- <th align="left" bgcolor="#cccccc" style="background:#cccccc;" class="desc bold"><font face="Arial, Helvetica, sans-serif" size="2"><%= t(:item_description) %></font></th>
12
- <th align="left" bgcolor="#cccccc" style="background:#cccccc;" class="price bold"><font face="Arial, Helvetica, sans-serif" size="2"><%=t(:price) unless @receipt%></font></th>
13
- <th align="left" bgcolor="#cccccc" style="background:#cccccc;" class="qty bold"><font face="Arial, Helvetica, sans-serif" size="2"><%= t(:qty) %> </font></th>
14
- <th align="right" bgcolor="#cccccc" style="background:#cccccc;" class="total bold"><font face="Arial, Helvetica, sans-serif" size="2"><%= t(:total) %></font></th>
15
- </tr>
16
- <% @order.line_items.each do |item| %>
17
- <tr >
18
- <td class="cell" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%=item.variant.sku %></font></td>
19
- <td class="cell" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%= item.variant.product.fullname rescue item.variant.product.name %></font></td>
20
- <td class="cell price" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%=number_to_currency(item.price) unless @receipt%></font></td>
21
- <td class="cell qty" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%=item.quantity %></font></td>
22
- <td align="right" class="cell total" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%=number_to_currency(item.price * item.quantity) %></font></td>
23
- </tr>
24
- <% if item.respond_to? :discount and item.discount > 0 %>
25
- <tr style="border-bottom:solid 1px #cccccc;">
26
- <td class="cell" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;</font></td>
27
- <td class="cell" style="border-bottom:solid 1px #cccccc;">(<font face="Arial, Helvetica, sans-serif" size="2"><%= t(:discount) %>)</font></td>
28
- <td class="cell price" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%=number_to_currency(-1 * item.discount) %></font></td>
29
- <td class="cell qty" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;</font></td>
30
- <td class="cell total" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%=number_to_currency(-1 * item.discount * item.quantity) %></font></td>
31
- </tr>
32
- <% end %>
33
- <% end %>
34
- </table>
@@ -1,13 +0,0 @@
1
- <table width="700" border="0" cellspacing="0" cellpadding="0">
2
- <tr>
3
- <td width="272"><%= logo %></td>
4
- <td class="info" align="center" style=" font-size: 14px; letter-spacing: 2px; line-height: 1.3; padding: 6px; text-align: center; text-transform: uppercase; width: 700px;">
5
- <font face="Georgia,"Times New Roman",Times,serif" color="black">
6
- <!--<div class="shop"><%= Spree::Config[:site_name] %></div>-->
7
- Fredrikinkatu 19 (Viiskulma) <br>
8
- 00120 Helsinki<br><br>
9
- <%=I18n.l(@order.completed_at.to_date) if @order.completed_at %>&nbsp;/&nbsp;
10
- <%= Spree.t(:order_number) %> <%=@order.number%></font>
11
- </td>
12
- </tr>
13
- </table>
@@ -1,25 +0,0 @@
1
- <table width="700" cellspacing="0" cellpadding="7" border="0" class="line_items" style="border:solid 1px #cccccc; border-bottom:none; margin:30px 0;" >
2
- <% @order.adjustments.eligible.each do |adjustment| %>
3
- <tr class="total">
4
- <td class="cel1 bold" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%= adjustment.label %>:</font></td>
5
- <td class="cel2 cell" align="right" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%= adjustment.display_amount.to_html %></font></td>
6
- </tr>
7
- <% end %>
8
- <tr>
9
- <td class="cel1 bold" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><strong><%= t(:order_total) %>:</strong></font></td>
10
- <td class="cel2 cell" align="right" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><strong><span id='summary-order-total'><%= number_to_currency @order.total %></span></strong></font></td>
11
- </tr>
12
- <% if @order.price_adjustment_totals.present? %>
13
- <tr>
14
- <td class="cel1" style="border-bottom:solid 1px #cccccc;" style="border-bottom:solid 1px #cccccc;"></td>
15
- <td class="cel2" style="border-bottom:solid 1px #cccccc;"></td>
16
- </tr>
17
- <% @order.price_adjustment_totals.keys.each do |key| %>
18
- <% next unless @order.price_adjustment_totals[key] %>
19
- <tr class="total">
20
- <td class="cel1 bold" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%= key %>:</font></td>
21
- <td class="cel2 cell" align="right" style="border-bottom:solid 1px #cccccc;"><font face="Arial, Helvetica, sans-serif" size="2"><%= number_to_currency @order.price_adjustment_totals[key] %></font></td>
22
- </tr>
23
- <% end %>
24
- <% end %>
25
- </table>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
- <title><%= Spree.t("#{params[:template]}.header") %></title>
6
- </head>
7
-
8
- <body onLoad="self.print()">
9
- <div class="receipt">
10
- <div id="header">
11
- <%= render :partial => "spree/admin/invoice/receipt_header" %>
12
- </div>
13
-
14
- <div class="wrapper">
15
- <div class="line_items">
16
- <%= render :partial => "spree/admin/invoice/line_items_invoice" %>
17
- </div>
18
- <!--<div class="spacer"> &nbsp;</div>-->
19
- <div class="totals">
20
- <%= render :partial => "spree/admin/invoice/totals_receipt" %>
21
- </div>
22
- </div>
23
- </div>
24
- </body>
25
- </html>
26
-