rawbotz 0.1.4 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 788bb5000f74251dc1c2aadd371f6260ea4ff84f
4
- data.tar.gz: bd7d6705020f6fedeccdda86e96d798fb6f7be98
3
+ metadata.gz: d73846461722f121dd6dd7a7e237dc6a385c7e50
4
+ data.tar.gz: d48bbb7113198c076bf2b5508eebfc3fb1e542e8
5
5
  SHA512:
6
- metadata.gz: 35d61d51553864fe25bd25896e04372a9603578e111562e8dcb0447b7f3c10af8818862b970d946bfebf59904b18c1cf145859b062f3e63c5201e77fc2cc40d0
7
- data.tar.gz: 2f9bebba8f40938e0433c3a94323a001ef2af91467698201f368b934d277ba929b51280734b61cf209a38822eabdee0db1cd89b1af124e5952d2b873a3f0369f
6
+ metadata.gz: f5a7decce42fd359fa610217cd1a7cea7d87d6e6d7584b79fe665037219a57771d5e6b6c570c81b0c96c47c9648e97e0e0b870f2fabf7d45df886cbb9c28ca23
7
+ data.tar.gz: e5a20092222188225fe5c78b1bef1069bb5b3bd9f909e280dfa8604deffc0aa27107a59de7801ab2a96cb929589279d1839b85b12299bfc1ce602c2a7adde3a4
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ Changelog, History of changes for Rawbotz
4
+
5
+ ## 0.1.5 (released 2016-07-12)
6
+ - Add new attributes to ease non remote orders.
7
+
8
+ ## glass ball future version 0.2
9
+ - create first-class orders for non-remote-magento orders
10
+ - check for refunds in remote orders
11
+ - add 'stockings' to link local orders with remote orders and put the
12
+ delivered qty of products into the magento database.
data/README.md CHANGED
@@ -29,6 +29,8 @@ Anyway, the application is so specific to RawLiving Germanys needs that you prob
29
29
  - supplier attribute
30
30
  - shelve attribute
31
31
  - packsize attribute
32
+ - supplier_sku attribute
33
+ - supplier_prod_name attribute
32
34
  - Ubuntu 14.04 installation, using rvm in an unprivileged users home.
33
35
 
34
36
  ## Usage
@@ -70,6 +72,8 @@ Create a `rawbotz.conf` YAML-file with the unified keys needed. Note that you c
70
72
  supplier_name: 666
71
73
  shelve_nr: 42
72
74
  packsize: 1337
75
+ supplier_sku: 1222
76
+ supplier_prod_name: 1921
73
77
 
74
78
  # Remote Magento Web Interface (for our mech)
75
79
  remote_shop:
@@ -26,7 +26,8 @@ begin
26
26
  products = RawgentoDB::Query.products
27
27
  rescue
28
28
  logger.error "Could not connect to MySQL database or other error"
29
- #logger.error "$!.inspect" $@ -> backtrace
29
+ logger.error $!.inspect
30
+ # $@ -> backtrace would be available, too
30
31
  exit 1
31
32
  end
32
33
 
data/lib/rawbotz/app.rb CHANGED
@@ -55,7 +55,7 @@ class RawbotzApp < Sinatra::Base
55
55
  # post '/product/:id/unhide'
56
56
  # get '/remote_products'
57
57
  # post '/remote_products/search'
58
- # get '/remote_product/id'
58
+ # get '/remote_product/:id'
59
59
  register Rawbotz::RawbotzApp::Routing::Products
60
60
 
61
61
  # get '/products/links'
@@ -47,9 +47,12 @@ module Rawbotz::CLI
47
47
  end
48
48
 
49
49
  if !diffs[:extra].empty?
50
+ extra_items = diffs[:extra].map do |n,q|
51
+ [n[0..35], q]
52
+ end
50
53
  out << Terminal::Table.new(title: "Extra (not in rawbotz)",
51
54
  headings: ['Product', 'In Cart'],
52
- rows: diffs[:extra],
55
+ rows: extra_items,
53
56
  style: {width:60}).to_s
54
57
  end
55
58
  end
@@ -16,12 +16,14 @@ module Rawbotz
16
16
  end
17
17
 
18
18
  def self.explode_days min_date, max_date
19
+ return [] if min_date.nil? || max_date.nil?
19
20
  (min_date.to_date..max_date.to_date).to_a
20
21
  end
21
22
 
22
23
  def self.create_data sales, stock
23
24
  # from [date, sales] and [date, stock] create realistic list
24
25
  from_date, to_date = date_minmax sales, stock
26
+ return {} if from_date.nil? || to_date.nil?
25
27
  days = explode_days from_date, to_date
26
28
 
27
29
  stock_data = Hash.new(nil)
@@ -11,7 +11,7 @@ module Rawbotz
11
11
  order_lines = order[:order_items].map do |oi|
12
12
  next if product_line.nil?
13
13
  order_item_line = product_line[2..-1]
14
- order_item_line.gsub!(/PRODUCTCODE/, '')
14
+ order_item_line.gsub!(/SUPPLIERSKU/, oi[:local_product][:supplier_sku].to_s)
15
15
  order_item_line.gsub!(/QTY/, oi[:num_wished].to_s)
16
16
  if oi[:local_product][:packsize].to_s != ""
17
17
  order_item_line.gsub!(/NUM_PACKS/, (oi[:num_wished] / oi[:local_product][:packsize].to_f).to_s)
@@ -19,7 +19,7 @@ module Rawbotz
19
19
  order_item_line.gsub!(/NUM_PACKS/, '')
20
20
  end
21
21
  order_item_line.gsub!(/PACKSIZE/, oi[:local_product][:packsize].to_s)
22
- order_item_line.gsub!(/PRODUCTNAME/, oi[:local_product][:name].to_s)
22
+ order_item_line.gsub!(/PRODUCTNAME/, oi[:local_product][:supplier_prod_name] || oi[:local_product][:name].to_s)
23
23
  order_item_line
24
24
  end
25
25
  lines[lines.find_index(product_line)] = order_lines if product_line
@@ -3,7 +3,8 @@ module Rawbotz
3
3
  attr_accessor :local_products
4
4
  attr_accessor :logger
5
5
  attr_accessor :name_attribute_id, :supplier_attribute_id,
6
- :shelve_attribute_id, :packsize_attribute_id
6
+ :shelve_attribute_id, :packsize_attribute_id,
7
+ :supplier_sku_attribute_id, :supplier_prod_name_attribute_id
7
8
 
8
9
  def initialize logger
9
10
  @local_products = {}
@@ -13,10 +14,14 @@ module Rawbotz
13
14
  @supplier_attribute_id = Rawbotz.attribute_ids["supplier_name"]
14
15
  @shelve_attribute_id = Rawbotz.attribute_ids["shelve_nr"]
15
16
  @packsize_attribute_id = Rawbotz.attribute_ids["packsize"]
17
+ @supplier_sku_attribute_id = Rawbotz.attribute_ids["supplier_sku"]
18
+ @supplier_prod_name_attribute_id = Rawbotz.attribute_ids["supplier_prod_name"]
16
19
  @logger.debug "Attribute-ids: Name: #{@name_attribute_id}, "\
17
20
  "Supplier: #{@supplier_attribute_id}, "\
18
21
  "Shelve-Nr: #{@shelve_attribute_id}, "\
19
- "Packsize: #{@packsize_attribute_id}"
22
+ "Packsize: #{@packsize_attribute_id}"\
23
+ "Supplier-SKU: #{@supplier_sku_attribute_id}"\
24
+ "Supplier-Prod-Name: #{@supplier_prod_name_attribute_id}"
20
25
  end
21
26
 
22
27
  def sync
@@ -31,6 +36,10 @@ module Rawbotz
31
36
  update_attribute(@shelve_attribute_id, :shelve_nr)
32
37
  # Packsize
33
38
  update_attribute(@packsize_attribute_id, :packsize, :integer)
39
+ # Supplier SKU
40
+ update_attribute(@supplier_sku_attribute_id, :supplier_sku)
41
+ # Supplier Product name
42
+ update_attribute(@supplier_prod_name_attribute_id, :supplier_prod_name)
34
43
 
35
44
  log_changes
36
45
 
@@ -31,7 +31,7 @@ $(document).ready(function() {
31
31
  };
32
32
 
33
33
  // For Non-Remote Order Forms: add a pack
34
- $("button.plus-pack").click(function(e) {
34
+ $("a.plus-pack").click(function(e) {
35
35
  e.preventDefault();
36
36
 
37
37
  input_id = $(this).data("reference_input_id");
@@ -50,7 +50,7 @@ $(document).ready(function() {
50
50
  });
51
51
 
52
52
  // For Non-Remote Order Forms: subtract a pack
53
- $("button.minus-pack").click(function(e) {
53
+ $("a.minus-pack").click(function(e) {
54
54
  e.preventDefault();
55
55
 
56
56
  input_id = $(this).data("reference_input_id");
@@ -17,6 +17,21 @@ module Rawbotz::RawbotzApp::Routing::NonRemoteOrders
17
17
  redirect "/supplier/#{@supplier.id}"
18
18
  else
19
19
  @products = LocalProduct.supplied_by(@supplier)
20
+
21
+ begin
22
+ db = RawgentoDB::Query
23
+ @monthly_sales = @products.map{|p| [p.product_id,
24
+ db.sales_monthly_between(p.product_id,
25
+ Date.today,
26
+ Date.today - 31 * 4)]}.to_h
27
+ @monthly_sales.each{|k,v| @monthly_sales[k] = v.inject(0){|a,s| a + s[1].to_i}/v.length rescue 0}
28
+ @stock = {}
29
+ db.stock.each {|s| @stock[s.product_id] = s.qty}
30
+ rescue Exception => e
31
+ @monthly_sales = {}
32
+ @stock = {}
33
+ add_flash :error, "Cannot connect to MySQL database (#{e.message})"
34
+ end
20
35
  haml "order/non_remote".to_sym
21
36
  end
22
37
  end
@@ -26,6 +41,20 @@ module Rawbotz::RawbotzApp::Routing::NonRemoteOrders
26
41
  @supplier = Supplier.find(params[:supplier_id])
27
42
  @products = @supplier.local_products
28
43
 
44
+ begin
45
+ db = RawgentoDB::Query
46
+ @monthly_sales = @products.map{|p| [p.product_id,
47
+ db.sales_monthly_between(p.product_id,
48
+ Date.today,
49
+ Date.today - 31 * 4)]}.to_h
50
+ # this is not avg
51
+ @monthly_sales.each{|k,v| @monthly_sales[k] = v.inject(0){|a,s| a + s[1].to_i}/v.length rescue 0}
52
+ @stock = {}
53
+ db.stock.each {|s| @stock[s.product_id] = s.qty}
54
+ rescue Exception => e
55
+ @stock = {}
56
+ end
57
+
29
58
  order = {supplier: @supplier, order_items: []}
30
59
  params.select{|p| p.start_with?("item_")}.each do |p, val|
31
60
  if val && val.to_i > 0
@@ -89,7 +89,7 @@ module Rawbotz::RawbotzApp::Routing::Products
89
89
  @products.map{|p| {name: p[0], product_id: p[1]}}.to_json
90
90
  end
91
91
 
92
- # app.get '/remote_product/id', &show_remote_product
92
+ # app.get '/remote_product/:id', &show_remote_product
93
93
  show_remote_product = lambda do
94
94
  @product = RawgentoModels::RemoteProduct.find(params[:id])
95
95
  haml "remote_product/view".to_sym
@@ -104,6 +104,6 @@ module Rawbotz::RawbotzApp::Routing::Products
104
104
 
105
105
  app.get '/remote_products', &show_remote_products
106
106
  app.post '/remote_products/search', &search_remote_products
107
- app.get '/remote_product/id', &show_remote_product
107
+ app.get '/remote_product/:id', &show_remote_product
108
108
  end
109
109
  end
@@ -1,3 +1,3 @@
1
1
  module Rawbotz
2
- VERSION = "0.1.4".freeze
2
+ VERSION = "0.1.5".freeze
3
3
  end
@@ -7,7 +7,8 @@
7
7
  %br
8
8
  %h3 Last 3 Orders
9
9
  %table.pure-table-horizontal.pure-table
10
- - Order.where(state: [Order::STATES.new, Order::STATES.processing, Order::STATES.queued, Order::STATES.ordered]).order("updated_at DESC").first(3).each do |order|
10
+ -# Order.where(state: [Order::STATES.new, Order::STATES.processing, Order::STATES.queued, Order::STATES.ordered]).order("updated_at DESC").first(3).each do |order|
11
+ - Order.where(state: ["new", "processing", "ordered"]).order("updated_at DESC").first(3).each do |order|
11
12
  %tr
12
13
  %td
13
14
  %a(href="/order/#{order.id}")
@@ -52,4 +52,4 @@
52
52
  %center
53
53
  %ul.pure-menu-list
54
54
  %li.pure-menu-item
55
- Rawbotz 2016 (c) Felix Wolfsteller
55
+ Rawbotz #{Rawbotz::VERSION} 2016 (c) Felix Wolfsteller
@@ -34,7 +34,7 @@
34
34
  = last_order_item.num_ordered
35
35
  %td
36
36
  - if order_item.remote_product_id.present?
37
- = haml "widgets/_qty_wished_input".to_sym, locals: {product: order_item.local_product}
37
+ = haml "widgets/_qty_wished_input".to_sym, locals: {product: order_item.local_product, input_id_num: order_item.id, num_wished: order_item.num_wished}
38
38
  - else
39
39
  No remote product
40
40
  %td= order_item.local_product.packsize
@@ -8,6 +8,7 @@
8
8
  %h2 Mail preview
9
9
  %pre~ @mail_preview
10
10
  %a{:href => "mailto:#{@supplier.email}?Subject=Order&body=%s" % URI::escape(@mail_preview).gsub(/&/,'%26')} Open mail
11
+ %br
11
12
 
12
13
  %center
13
14
  %form#non_remote_order.pure-form(action="" method="post")
@@ -18,19 +19,31 @@
18
19
  %th Name
19
20
  %th Qty
20
21
  %th Packsize
21
- %th Stock/ Sales
22
+ %th Rough Avg. sales/ m
23
+ %th Stock
24
+ %th Chart
22
25
  %tbody
23
26
  - @products.find_each do |product|
24
27
  %tr
25
28
  %td
26
29
  = product_link product
30
+ - if product.supplier_prod_name
31
+ %br
32
+ %small
33
+ = product.supplier_sku
34
+ = product.supplier_prod_name
27
35
  %td
28
- = haml "widgets/_qty_wished_input".to_sym, locals: {product: product}
36
+ = haml "widgets/_qty_wished_input".to_sym, locals: {product: product, input_id_num: product.id}
29
37
  %td
30
38
  - if product.packsize.present?
31
39
  = product.packsize
32
40
  - else
33
41
  %i.fa.fa-ban
42
+ %td
43
+ - if @monthly_sales
44
+ = @monthly_sales[product.product_id]
45
+ %td
46
+ = @stock[product.product_id]
34
47
  %td
35
48
  - stock_url = "/product/#{product.id}/stock_sales_plot"
36
49
  %a.stock_show_action{:href => "", :data => {url: stock_url, product: product.name}}
@@ -41,7 +54,7 @@
41
54
  %center
42
55
  %button.pure-button.pure-button-primary
43
56
  %i.fa.fa-envelope
44
- Send me the mail!
57
+ Show me the mail!
45
58
  -#%button#ajax_mailto.pure-button.pure-button-secondary
46
59
  -# %i.fa.fa-envelope
47
60
  -# Open mail
@@ -44,7 +44,7 @@
44
44
  %br
45
45
  %h2 Action
46
46
  %center
47
- (Find remote order? Delete?)
47
+ -#(Find remote order? Delete?)
48
48
  %button.pure-button.pure-button-secondary(name="action" value="save")
49
49
  Save
50
50
  %button.pure-button.pure-button-primary(name="action" value="order")
@@ -74,6 +74,6 @@
74
74
  =item.num_ordered
75
75
  %td
76
76
  =item.current_stock
77
- %h2 Action
78
- (Find remote order? Delete?)
77
+ -# %h2 Action
78
+ -# (Find remote order? Delete?)
79
79
 
@@ -33,6 +33,14 @@
33
33
  .pure-control-group
34
34
  %label(for="shelve") Shelve
35
35
  = @product.shelve_nr
36
+ - if @product.supplier_sku != ""
37
+ .pure-control-group
38
+ %label(for="supplier_sku") Supplier SKU
39
+ = @product.supplier_sku
40
+ - if @product.supplier_prod_name != ""
41
+ .pure-control-group
42
+ %label(for="supplier_prod_name") Supplier Product Name
43
+ = @product.supplier_prod_name
36
44
 
37
45
  %h2 Actions
38
46
  - if !@product.remote_product.present?
@@ -31,6 +31,12 @@
31
31
  %h2 Orders of #{@supplier.name}
32
32
  - @supplier.orders.find_each do |order|
33
33
  = order.id
34
+ - if @supplier != settings.supplier
35
+ - if @supplier.order_template.present?
36
+ %a(href="/order/non_remote/#{@supplier.id}")
37
+ Create mail order
38
+ - else
39
+ Please specify mail order template (in Settings tab) before continuing.
34
40
  #tab_order_settings
35
41
  %h2 Settings for #{@supplier.name}
36
42
 
@@ -64,7 +70,7 @@
64
70
 
65
71
  We will order
66
72
 
67
- * PRODUCTCODE QTY (NUM_PACKS of PACKSIZE) PRODUCTNAME
73
+ * SUPPLIERSKU QTY (NUM_PACKS of PACKSIZE) PRODUCTNAME
68
74
 
69
75
  Thank you,
70
76
 
@@ -79,8 +85,6 @@
79
85
  %dd will be replaced by this suppliers name
80
86
  %dt *
81
87
  %dd the line starting with a star will be iterated over with every product
82
- %dt PRODUCTCODE
83
- %dd the product code as stored in magento
84
88
  %dt QTY
85
89
  %dd quantity ordered
86
90
  %dt NUM_PACKS
@@ -88,5 +92,7 @@
88
92
  %dt PACKSIZE
89
93
  %dd packsize as stored in magento
90
94
  %dt PRODUCTNAME
91
- %dd the products name
95
+ %dd the products name, (prefers supplier_prod_name property of product)
96
+ %dt SUPPLIERSKU
97
+ %dd 'remote' SKU of the product
92
98
  %br
@@ -1,32 +1,17 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title Rawbotz
5
- %meta(name="viewport" content="width=device-width, initial-scale=1")
6
- %meta(charset="utf-8")
7
- %link(rel="stylesheet" txpe="text/css" href="/pure-min.css")
8
- %link(rel="stylesheet" txpe="text/css" href="/font-awesome-4.5.0/css/font-awesome.min.css")
9
- %link(rel="stylesheet" txpe="text/css" href="/rawbotz.css")
10
- %script{:type => 'text/javascript', :src => "/Chart.min.js"}
11
- %script{:type => 'text/javascript', :src => "/jquery-2.2.0.min.js"}
12
- %script{:type => 'text/javascript', :src => "/jui/jquery-ui.min.js"}
13
- %link(rel="stylesheet" type='text/css' href="/jui/jquery-ui.min.css")
14
- %script{:type => 'text/javascript', :src => "/rawbotz.js"}
15
- %body
16
- .pure-g
17
- .pure-u-1#main
18
- - if flash
19
- - if msg = flash.delete(:error)
20
- #flash.ui-state-error
21
- = msg.join(" | ")
22
- - if msg = flash.delete(:success)
23
- #flash.ui-state-highlight
24
- = msg.join(" | ")
25
- - if msg = flash.delete(:failure)
26
- #flash.ui-state-highlight
27
- = msg.join(" | ")
28
- - if msg = flash.delete(:info)
29
- #flash.ui-state-highlight
30
- = msg.join(" | ")
1
+ .pure-g
2
+ .pure-u-1#main
3
+ - if flash
4
+ - if msg = flash.delete(:error)
5
+ #flash.ui-state-error
6
+ = msg.join(" | ")
7
+ - if msg = flash.delete(:success)
8
+ #flash.ui-state-highlight
9
+ = msg.join(" | ")
10
+ - if msg = flash.delete(:failure)
11
+ #flash.ui-state-highlight
12
+ = msg.join(" | ")
13
+ - if msg = flash.delete(:info)
14
+ #flash.ui-state-highlight
15
+ = msg.join(" | ")
31
16
 
32
- =yield
17
+ =yield
@@ -1,13 +1,14 @@
1
1
  .wished_qty_input
2
- - input_id = "item_#{product.id}"
3
- %input.qty(id=input_id name=input_id size="2")
2
+ - input_id = "item_#{input_id_num}"
3
+ - num_wished ||= nil
4
+ %input.qty(id=input_id name=input_id size="2" value=num_wished)
4
5
  - packsize = product.packsize
5
6
  - if packsize.present?
6
7
  .packsize-buttons
7
- %button.pure-button.plus-pack(data-packsize=packsize data-reference_input_id=input_id)
8
+ %a.pure-button.plus-pack(data-packsize=packsize data-reference_input_id=input_id)
8
9
  %i.fa.fa-plus-square
9
10
  %i.fa.fa-cube
10
- %button.pure-button.minus-pack(data-packsize=packsize data-reference_input_id=input_id)
11
+ %a.pure-button.minus-pack(data-packsize=packsize data-reference_input_id=input_id)
11
12
  %i.fa.fa-minus-square
12
13
  %i.fa.fa-cube
13
14
  %button.pure-button.order-none
data/rawbotz.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "sinatra", '~> 1.4'
23
23
  spec.add_dependency 'pony', '~> 1.11'
24
24
  spec.add_dependency 'haml', '~> 4.0'
25
- spec.add_dependency "rawgento_models", '~> 0.2.3'
25
+ spec.add_dependency "rawgento_models", '~> 0.2.4'
26
26
  spec.add_dependency "rawgento_db", "~> 0.1.1"
27
27
  spec.add_dependency "magento_remote"
28
28
  spec.add_dependency "terminal-table", '~> 1.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rawbotz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-14 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.2.3
61
+ version: 0.2.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.2.3
68
+ version: 0.2.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rawgento_db
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +167,7 @@ extensions: []
167
167
  extra_rdoc_files: []
168
168
  files:
169
169
  - ".gitignore"
170
+ - CHANGELOG.md
170
171
  - CODE_OF_CONDUCT.md
171
172
  - Gemfile
172
173
  - README.md