prestashop-automation 0.6.2 → 0.7.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.
@@ -18,6 +18,10 @@ module PrestaShopAutomation
18
18
  select_by_value '#id_tax_rules_group', options[:tax_group_id]
19
19
  end
20
20
 
21
+ if options[:ecotax]
22
+ fill_in 'ecotax', :with => options[:ecotax]
23
+ end
24
+
21
25
  if sp = options[:specific_price]
22
26
  save_product
23
27
 
@@ -15,6 +15,29 @@ module PrestaShopAutomation
15
15
  end
16
16
  end
17
17
 
18
+ def set_rounding_method option
19
+ mapping = {
20
+ up: 0,
21
+ down: 1,
22
+ half_up: 2,
23
+ half_down: 3,
24
+ half_even: 4,
25
+ half_odd: 5
26
+ }
27
+
28
+ goto_admin_tab 'AdminTaxes'
29
+ value = mapping[option.to_sym]
30
+
31
+ if value
32
+ goto_admin_tab 'AdminPreferences'
33
+ select_by_value '#PS_PRICE_ROUND_MODE', value
34
+ click_button_named 'submitOptionsconfiguration', :first => true
35
+ standard_success_check
36
+ else
37
+ throw "Unsupported option: #{option}"
38
+ end
39
+ end
40
+
18
41
  def set_friendly_urls on
19
42
  goto_admin_tab 'AdminMeta'
20
43
  if on
@@ -47,5 +70,19 @@ module PrestaShopAutomation
47
70
  standard_success_check
48
71
  end
49
72
 
73
+ def set_ecotax_option on, tax_group_id=nil
74
+ goto_admin_tab 'AdminTaxes'
75
+ click_label_for "PS_USE_ECOTAX_#{onoff on}"
76
+ click_button_named 'submitOptionstax', :first => true
77
+ standard_success_check
78
+
79
+ if on and tax_group_id
80
+ sleep 1
81
+ select_by_value '#PS_ECOTAX_TAX_RULES_GROUP_ID', tax_group_id
82
+ click_button_named 'submitOptionstax', :first => true
83
+ standard_success_check
84
+ end
85
+ end
86
+
50
87
  end
51
88
  end
data/lib/actions/taxes.rb CHANGED
@@ -32,10 +32,15 @@ module PrestaShopAutomation
32
32
  return current_url[/\bid_tax_rules_group=(\d+)/, 1].to_i
33
33
  end
34
34
 
35
- def create_tax_group_from_rate rate, taxes_pool={}
35
+ def create_tax_group_from_rate rate, taxes_pool={}, groups_pool={}
36
+
37
+ if groups_pool[rate]
38
+ return groups_pool[rate]
39
+ end
40
+
36
41
  if /^(?:\d+(?:.\d+)?)$/ =~ rate.to_s
37
- tax_id = create_tax :name => "#{rate}% Tax (Rate)", :rate => rate
38
- taxes_pool[rate] ||= create_tax_group :name => "#{rate}% Tax (Group)", :taxes => [{:tax_id => tax_id}]
42
+ tax_id = taxes_pool[rate] ||= (create_tax :name => "#{rate}% Tax (Rate)", :rate => rate)
43
+ groups_pool[rate] = create_tax_group :name => "#{rate}% Tax (Group)", :taxes => [{:tax_id => tax_id}]
39
44
  elsif /(?:\d+(?:.\d+)?)(?:\s*(?:\+|\*)\s*(?:\d+(?:.\d+)?))+/ =~ rate
40
45
  taxes = []
41
46
  combine = {'+' => :sum, '*' => :multiply}[rate[/(\+|\*)/, 1]] || :no
@@ -52,7 +57,7 @@ module PrestaShopAutomation
52
57
  }
53
58
  end
54
59
  end
55
- create_tax_group :name => "Composite #{rate} Tax (Group)", :taxes => taxes
60
+ groups_pool[rate] = create_tax_group :name => "Composite #{rate} Tax (Group)", :taxes => taxes
56
61
  else
57
62
  throw "Invalid tax rate format: #{rate}"
58
63
  end
@@ -56,7 +56,7 @@ module PrestaShopAutomation
56
56
  url = if rest == nil
57
57
  base
58
58
  else
59
- base.sub(/\/\s*/, '') + rest.sub(/^\s*\//, '')
59
+ base.sub(/\/\s*$/, '') + '/' + rest.sub(/^\s*\//, '')
60
60
  end
61
61
 
62
62
  super url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prestashop-automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -84,16 +84,16 @@ executables: []
84
84
  extensions: []
85
85
  extra_rdoc_files: []
86
86
  files:
87
- - lib/actions/carriers.rb
88
- - lib/actions/cart_rules.rb
89
- - lib/actions/general.rb
87
+ - lib/prestashop-automation.rb
88
+ - lib/helpers/general.rb
89
+ - lib/actions/products.rb
90
90
  - lib/actions/installer.rb
91
+ - lib/actions/cart_rules.rb
92
+ - lib/actions/carriers.rb
91
93
  - lib/actions/orders.rb
92
- - lib/actions/products.rb
93
94
  - lib/actions/settings.rb
95
+ - lib/actions/general.rb
94
96
  - lib/actions/taxes.rb
95
- - lib/helpers/general.rb
96
- - lib/prestashop-automation.rb
97
97
  homepage: https://github.com/djfm/prestashop-automation
98
98
  licenses:
99
99
  - OSL