brightpearl-cli 2.5.0 → 2.6.0

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.
data/lib/core/vm.rb DELETED
@@ -1,62 +0,0 @@
1
- module App
2
-
3
- class VM
4
-
5
- def self.run_on_vm(script_name, args = [])
6
-
7
- unless args.is_a? Array
8
- raise RuntimeError, 'args (to run_on_vm) must be an Array'
9
- end
10
-
11
- script_name_vm = "#{App::Config.param(ConfigUnique::VM_USER)}-#{script_name}"
12
-
13
- scripts = get_all_scripts.keys
14
- unless scripts.include?(script_name)
15
- App::Terminal::error("Script doesn't exist: #{App::Terminal::format_invalid(script_name)}", nil, true)
16
- end
17
-
18
- commands = [
19
- "scp #{App::Enum::get_base_path}/vm-scripts/#{script_name} #{App::Config.param(ConfigUnique::VM_USER)}@#{App::Config.param(ConfigUnique::VM_IP)}:/tmp/#{script_name_vm}",
20
- ]
21
-
22
- App::Terminal::command(commands, nil, false, false)
23
-
24
- command("chmod 0755 /tmp/#{script_name_vm}")
25
- command("/tmp/#{script_name_vm} #{args.join(' ')}")
26
- command("rm /tmp/#{script_name_vm}")
27
-
28
- end
29
-
30
- # Runs a series of commands on the VM.
31
- # @return void
32
- def self.command(commands, verbose = true)
33
- unless commands.is_a?(Array)
34
- commands = [commands]
35
- end
36
- if commands.any?
37
- commands.each do |command|
38
- if verbose
39
- puts "\x1B[48;5;136m Executing \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m #{App::Terminal::format_command("#{command}")}"
40
- end
41
- system("sshpass -p#{App::Config.param(ConfigUnique::VM_USER)} ssh #{App::Config.param(ConfigUnique::VM_USER)}@#{App::Config.param(ConfigUnique::VM_IP)} -t \"#{command}\"")
42
- end
43
- end
44
- end
45
-
46
- private
47
-
48
- # Returns all script files as hash, IE: {'sql-updates' => '/Library/Ruby/Gems/2.0.0/gems/brightpearl-cli-1.4.0/vm-scripts/sql-updates.sh'}
49
- # @return Hash
50
-
51
- def self.get_all_scripts
52
- return_hash = {}
53
- all_scripts = App::UtilsFiles::get_files_in_dir("#{App::Enum::get_base_path}/vm-scripts")
54
- all_scripts.each do |file|
55
- return_hash[File.basename(file)] = file
56
- end
57
- return_hash
58
- end
59
-
60
- end
61
-
62
- end
@@ -1,150 +0,0 @@
1
- require 'rest_client'
2
- require 'json'
3
-
4
- module AppCommand
5
-
6
- class DummyOrder < ::Convoy::ActionCommand::Base
7
-
8
- SALES_ORDER = 'so'
9
- SALES_CREDIT = 'sc'
10
- PURCHASE_ORDER = 'po'
11
- PURCHASE_CREDIT = 'pc'
12
-
13
- def execute
14
-
15
- @opts = command_options
16
- # @database = App::MySQL::get_database_connection
17
- opts_validate
18
- opts_routing
19
-
20
- end
21
-
22
- def opts_validate
23
-
24
- if @opts[:salesOrder]
25
- if @opts[:salesCredit] || @opts[:purchaseOrder] || @opts[:purchaseCredit]
26
- error_multi_order
27
- end
28
- elsif @opts[:salesCredit]
29
- if @opts[:salesOrder] || @opts[:purchaseOrder] || @opts[:purchaseCredit]
30
- error_multi_order
31
- end
32
- elsif @opts[:purchaseOrder]
33
- if @opts[:salesCredit] || @opts[:salesOrder] || @opts[:purchaseCredit]
34
- error_multi_order
35
- end
36
- elsif @opts[:purchaseCredit]
37
- if @opts[:salesCredit] || @opts[:salesOrder] || @opts[:purchaseOrder]
38
- error_multi_order
39
- end
40
- else
41
- @opts[:salesOrder] = true
42
- end
43
-
44
- if @opts[:times].nil?
45
- @opts[:times] = 1
46
- elsif @opts[:times] <= 0 || @opts[:times] > 50
47
- error_invalid_quantity
48
- end
49
-
50
- end
51
-
52
- def opts_routing
53
-
54
- if @opts[:salesOrder]
55
- create_order(SALES_ORDER)
56
- elsif @opts[:salesCredit]
57
- create_order(SALES_CREDIT)
58
- elsif @opts[:purchaseOrder]
59
- create_order(PURCHASE_ORDER)
60
- elsif @opts[:purchaseCredit]
61
- create_order(PURCHASE_CREDIT)
62
- else
63
- create_order(SALES_ORDER)
64
- end
65
-
66
- end
67
-
68
- def create_order(type = SALES_ORDER)
69
-
70
- validate_type(type)
71
-
72
- post_data =
73
- {
74
- 'orderTypeCode' => 'SO',
75
- 'reference' => 'order#001',
76
- 'priceListId' => 2,
77
- 'invoices' => [
78
- {
79
- 'taxDate' => '2014-10-19T12:57:25+00:00'
80
- }
81
- ],
82
- 'placedOn' => '2014-10-19T11:12:24.000+01:00',
83
- 'orderStatus' => {
84
- 'orderStatusId' => 1
85
- },
86
- 'delivery' => {
87
- 'deliveryDate' => '2014-10-19T11:12:24.000+01:00',
88
- 'shippingMethodId' => App::MySQL::get_random_shipping_id
89
- },
90
- 'currency' => {
91
- 'orderCurrencyCode' => 'GBP'
92
- },
93
- 'parties' => {
94
- 'customer' => {
95
- 'contactId' => App::MySQL::get_random_customer_id
96
- }
97
- },
98
- 'assignment' => {
99
- 'current' => {
100
- 'channelId' => 1,
101
- 'leadSourceId' => 1,
102
- 'staffOwnerContactId' => 4
103
- }
104
- }
105
- }.to_json
106
-
107
- puts
108
- puts "\x1B[33m#{post_data}\x1B[0m"
109
- puts
110
- exit
111
-
112
- begin
113
- response = RestClient.post(
114
- "http://#{App::Config.param(App::Config::VM_IP)}:#{App::Enum::PORT_ORDER_SERVICE}/order-service/app/order",
115
- post_data,
116
- :content_type => :json, :accept => :json, :'account-version' => 'admindev', :'effective-user-id' => 6
117
- )
118
- rescue
119
- puts response
120
- ensure
121
- puts response
122
- end
123
-
124
-
125
- end
126
-
127
- def validate_type(type)
128
- unless [
129
- SALES_ORDER,
130
- SALES_CREDIT,
131
- PURCHASE_ORDER,
132
- PURCHASE_CREDIT
133
- ].include?(type)
134
- raise RuntimeError, 'Invalid order type.'
135
- end
136
- end
137
-
138
- def error_multi_order
139
- puts "You can only create \x1B[35mONE\x1B[0m type of order at the time. Please specify \x1B[35mONLY ONE\x1B[0m of the following: \x1B[90m-s, -S, -p, -P\x1B[0m"
140
- exit
141
- end
142
-
143
- def error_invalid_quantity
144
- puts "You can only create between 1-50 orders at a time. You tried to create #{@opts[:times]}."
145
- exit
146
- end
147
-
148
- end
149
-
150
- end
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- COUNTER=$1
4
-
5
- while [ ${COUNTER} -lt $2 ]; do
6
- echo "mysql app < /brightpearl-source/brightpearl-db/brightpearl/structure/0${COUNTER}.sql"
7
- mysql app < /brightpearl-source/brightpearl-db/brightpearl/structure/0${COUNTER}.sql
8
- let COUNTER=COUNTER+1
9
- done