vyapari 0.1.4 → 0.1.5dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/vyapari/sample_stock_bundle.csv +1 -0
- data/app/controllers/vyapari/admin/base_controller.rb +10 -0
- data/app/controllers/vyapari/admin/brands_controller.rb +99 -0
- data/app/controllers/vyapari/admin/categories_controller.rb +115 -0
- data/app/controllers/vyapari/admin/countries_controller.rb +2 -2
- data/app/controllers/vyapari/admin/dashboard_controller.rb +3 -1
- data/app/controllers/vyapari/admin/exchange_rates_controller.rb +2 -2
- data/app/controllers/vyapari/admin/products_controller.rb +79 -0
- data/app/controllers/vyapari/admin/regions_controller.rb +1 -1
- data/app/controllers/vyapari/admin/resource_controller.rb +1 -0
- data/app/controllers/vyapari/admin/stores_controller.rb +67 -0
- data/app/controllers/vyapari/admin/suppliers_controller.rb +67 -0
- data/app/controllers/vyapari/admin/terminals_controller.rb +150 -0
- data/app/controllers/vyapari/application_controller.rb +12 -0
- data/app/controllers/vyapari/store_manager/base_controller.rb +28 -0
- data/app/controllers/vyapari/store_manager/dashboard_controller.rb +30 -0
- data/app/controllers/vyapari/store_manager/resource_controller.rb +17 -0
- data/app/controllers/vyapari/store_manager/stock_bundles_controller.rb +206 -0
- data/app/controllers/vyapari/store_manager/stock_entries_controller.rb +161 -0
- data/app/controllers/vyapari/terminal_staff/base_controller.rb +29 -0
- data/app/controllers/vyapari/terminal_staff/dashboard_controller.rb +29 -0
- data/app/controllers/vyapari/terminal_staff/invoices_controller.rb +138 -0
- data/app/controllers/vyapari/terminal_staff/line_items_controller.rb +123 -0
- data/app/controllers/vyapari/terminal_staff/resource_controller.rb +17 -0
- data/app/controllers/vyapari/user_dashboard_controller.rb +31 -0
- data/app/models/brand.rb +63 -10
- data/app/models/category.rb +60 -16
- data/app/models/country.rb +27 -5
- data/app/models/exchange_rate.rb +31 -6
- data/app/models/image/brand_image.rb +3 -0
- data/app/models/image/category_image.rb +3 -0
- data/app/models/image/product_image.rb +3 -0
- data/app/models/invoice.rb +223 -0
- data/app/models/line_item.rb +206 -0
- data/app/models/product.rb +67 -13
- data/app/models/region.rb +26 -3
- data/app/models/stock_bundle.rb +249 -0
- data/app/models/stock_entry.rb +271 -0
- data/app/models/store.rb +216 -0
- data/app/models/supplier.rb +85 -0
- data/app/models/terminal.rb +158 -0
- data/app/models/vyapari/application_record.rb +4 -0
- data/app/uploaders/brand_image_uploader.rb +14 -0
- data/app/uploaders/category_image_uploader.rb +14 -0
- data/app/uploaders/product_image_uploader.rb +14 -0
- data/app/uploaders/stock_bundle_uploader.rb +10 -0
- data/app/views/layouts/kuppayam/_footer.html.erb +1 -1
- data/app/views/layouts/kuppayam/_sidebar.html.erb +45 -44
- data/app/views/layouts/vyapari/_store_manager_menu.html.erb +107 -0
- data/app/views/layouts/vyapari/_terminal_staff_menu.html.erb +103 -0
- data/app/views/layouts/vyapari/store_manager.html.erb +112 -0
- data/app/views/layouts/vyapari/terminal_staff.html.erb +116 -0
- data/app/views/vyapari/admin/brands/_form.html.erb +23 -0
- data/app/views/vyapari/admin/brands/_index.html.erb +89 -0
- data/app/views/vyapari/admin/brands/_row.html.erb +63 -0
- data/app/views/vyapari/admin/brands/_show.html.erb +104 -0
- data/app/views/vyapari/admin/brands/index.html.erb +48 -0
- data/app/views/vyapari/admin/categories/_form.html.erb +28 -0
- data/app/views/vyapari/admin/categories/_index.html.erb +101 -0
- data/app/views/vyapari/admin/categories/_row.html.erb +69 -0
- data/app/views/vyapari/admin/categories/_show.html.erb +115 -0
- data/app/views/vyapari/admin/{users → categories}/index.html.erb +8 -24
- data/app/views/vyapari/admin/countries/_index.html.erb +1 -1
- data/app/views/vyapari/admin/countries/index.html.erb +19 -3
- data/app/views/vyapari/admin/exchange_rates/_form.html.erb +3 -4
- data/app/views/vyapari/admin/exchange_rates/_index.html.erb +7 -7
- data/app/views/vyapari/admin/exchange_rates/_row.html.erb +3 -3
- data/app/views/vyapari/admin/exchange_rates/_show.html.erb +1 -0
- data/app/views/vyapari/admin/exchange_rates/index.html.erb +19 -3
- data/app/views/vyapari/admin/products/_form.html.erb +32 -0
- data/app/views/vyapari/admin/products/_index.html.erb +58 -0
- data/app/views/vyapari/admin/products/_row.html.erb +30 -0
- data/app/views/vyapari/admin/products/_show.html.erb +81 -0
- data/app/views/vyapari/admin/products/index.html.erb +48 -0
- data/app/views/vyapari/admin/regions/_index.html.erb +1 -1
- data/app/views/vyapari/admin/regions/index.html.erb +19 -3
- data/app/views/vyapari/admin/stores/_form.html.erb +37 -0
- data/app/views/vyapari/admin/stores/_index.html.erb +84 -0
- data/app/views/vyapari/admin/stores/_row.html.erb +55 -0
- data/app/views/vyapari/admin/stores/_show.html.erb +110 -0
- data/app/views/vyapari/admin/stores/index.html.erb +48 -0
- data/app/views/vyapari/admin/suppliers/_form.html.erb +32 -0
- data/app/views/vyapari/admin/suppliers/_index.html.erb +58 -0
- data/app/views/vyapari/admin/suppliers/_row.html.erb +30 -0
- data/app/views/vyapari/admin/suppliers/_show.html.erb +81 -0
- data/app/views/vyapari/admin/suppliers/index.html.erb +48 -0
- data/app/views/vyapari/admin/terminals/_form.html.erb +24 -0
- data/app/views/vyapari/admin/terminals/_index.html.erb +75 -0
- data/app/views/vyapari/admin/terminals/_row.html.erb +49 -0
- data/app/views/vyapari/admin/terminals/_show.html.erb +74 -0
- data/app/views/vyapari/store_manager/dashboard/index.html.erb +93 -0
- data/app/views/vyapari/store_manager/stock_bundles/_form.html.erb +99 -0
- data/app/views/vyapari/store_manager/stock_bundles/_index.html.erb +74 -0
- data/app/views/vyapari/store_manager/stock_bundles/_row.html.erb +44 -0
- data/app/views/vyapari/store_manager/stock_bundles/_show.html.erb +110 -0
- data/app/views/vyapari/store_manager/stock_bundles/create.html.erb +57 -0
- data/app/views/vyapari/store_manager/stock_bundles/index.html.erb +36 -0
- data/app/views/vyapari/store_manager/stock_bundles/update.html.erb +57 -0
- data/app/views/vyapari/store_manager/stock_entries/_form.html.erb +50 -0
- data/app/views/vyapari/store_manager/stock_entries/_index.html.erb +80 -0
- data/app/views/vyapari/store_manager/stock_entries/_row.html.erb +33 -0
- data/app/views/vyapari/store_manager/stock_entries/_show.html.erb +110 -0
- data/app/views/vyapari/store_manager/stock_entries/_stock_bundle.html.erb +61 -0
- data/app/views/vyapari/store_manager/stock_entries/index.html.erb +45 -0
- data/app/views/vyapari/terminal_staff/dashboard/_counts.html.erb +88 -0
- data/app/views/vyapari/terminal_staff/dashboard/_invoices.html.erb +37 -0
- data/app/views/vyapari/terminal_staff/dashboard/index.html.erb +36 -0
- data/app/views/vyapari/terminal_staff/invoices/_draft.html.erb +62 -0
- data/app/views/vyapari/terminal_staff/invoices/_form.html.erb +120 -0
- data/app/views/vyapari/terminal_staff/invoices/_index.html.erb +64 -0
- data/app/views/vyapari/terminal_staff/invoices/_row.html.erb +33 -0
- data/app/views/vyapari/terminal_staff/invoices/_show.html.erb +171 -0
- data/app/views/vyapari/terminal_staff/invoices/index.html.erb +37 -0
- data/app/views/vyapari/terminal_staff/invoices/new.js.erb +13 -0
- data/app/views/vyapari/terminal_staff/invoices/show.html.erb +1 -0
- data/app/views/vyapari/terminal_staff/line_items/_form.html.erb +40 -0
- data/app/views/vyapari/terminal_staff/line_items/_index.html.erb +94 -0
- data/app/views/vyapari/terminal_staff/line_items/create.js.erb +34 -0
- data/app/views/vyapari/terminal_staff/line_items/destroy.js.erb +25 -0
- data/app/views/vyapari/terminal_staff/stores/index.html.erb +24 -0
- data/app/views/vyapari/user_dashboard/index.html.erb +51 -0
- data/config/routes.rb +62 -5
- data/db/import_data/brands.csv +7 -0
- data/db/import_data/categories.csv +12 -0
- data/db/import_data/countries.csv +1 -0
- data/db/import_data/dummy/brands.csv +7 -0
- data/db/import_data/dummy/categories.csv +12 -0
- data/db/import_data/dummy/countries.csv +1 -0
- data/db/import_data/dummy/exchange_rates.csv +5 -0
- data/db/import_data/dummy/products-copy.csv +1 -0
- data/db/import_data/dummy/products.csv +1 -0
- data/db/import_data/dummy/products.xlsx +0 -0
- data/db/import_data/dummy/regions.csv +13 -0
- data/db/import_data/dummy/stores.csv +10 -0
- data/db/import_data/dummy/suppliers.csv +14 -0
- data/db/import_data/dummy/terminals.csv +11 -0
- data/db/import_data/exchange_rates.csv +5 -0
- data/db/import_data/regions.csv +13 -0
- data/db/import_data/stores.csv +3 -0
- data/db/import_data/suppliers.csv +14 -0
- data/db/import_data/terminals.csv +3 -0
- data/db/migrate/20170000000200_create_exchange_rates.rb +3 -2
- data/db/migrate/20170000000203_create_contacts.rb +22 -0
- data/db/migrate/20170000000204_create_bank_accounts.rb +21 -0
- data/db/migrate/20170000000205_create_suppliers.rb +18 -0
- data/db/migrate/20170000000206_create_stores.rb +21 -0
- data/db/migrate/20170000000207_create_terminals.rb +18 -0
- data/db/migrate/20170000000210_create_brands.rb +14 -0
- data/db/migrate/20170000000211_create_categories.rb +22 -0
- data/db/migrate/20170000000212_create_products.rb +29 -0
- data/db/migrate/20170000000213_create_invoices.rb +58 -0
- data/db/migrate/20170000000215_create_stock_bundles.rb +17 -0
- data/db/migrate/20170000000216_create_stock_entries.rb +20 -0
- data/db/sample_reports/products.xlsx +0 -0
- data/lib/tasks/vyapari/all.rake +73 -0
- data/lib/vyapari/version.rb +1 -1
- metadata +150 -15
- data/app/controllers/vyapari/admin/users_controller.rb +0 -130
- data/app/views/vyapari/admin/users/_form.html.erb +0 -39
- data/app/views/vyapari/admin/users/_index.html.erb +0 -101
- data/app/views/vyapari/admin/users/_row.html.erb +0 -72
- data/app/views/vyapari/admin/users/_show.html.erb +0 -199
- data/lib/tasks/vyapari_tasks.rake +0 -4
data/app/models/store.rb
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
class Store < Vyapari::ApplicationRecord
|
2
|
+
|
3
|
+
# Constants
|
4
|
+
ACTIVE = "active"
|
5
|
+
INACTIVE = "inactive"
|
6
|
+
CLOSED = "closed"
|
7
|
+
|
8
|
+
STATUS_HASH = {"Active" => ACTIVE, "Inactive" => INACTIVE, "Closed" => CLOSED}
|
9
|
+
STATUS_HASH_REVERSE = {ACTIVE => "Active", INACTIVE => "Inactive", CLOSED => "Closed"}
|
10
|
+
|
11
|
+
# Constants
|
12
|
+
WAREHOUSE = "warehouse"
|
13
|
+
POS_STORE = "pos_store"
|
14
|
+
|
15
|
+
STORE_TYPES = {
|
16
|
+
WAREHOUSE => "Warehouse",
|
17
|
+
POS_STORE => "POS Store"
|
18
|
+
}
|
19
|
+
|
20
|
+
STORE_TYPES_REVERSE = {
|
21
|
+
"Warehouse" => WAREHOUSE,
|
22
|
+
"POS Store" => POS_STORE
|
23
|
+
}
|
24
|
+
|
25
|
+
# Validations
|
26
|
+
validates :name, presence: true, length: {minimum: 2, maximum: 250}, allow_blank: false
|
27
|
+
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 24}, allow_blank: false
|
28
|
+
validates :store_type, :presence => true, :inclusion => {:in => STORE_TYPES.keys, :presence_of => :store_type, :message => "%{value} is not a valid store type" }
|
29
|
+
validates :status, :presence=> true, :inclusion => {:in => STATUS_HASH_REVERSE.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
|
30
|
+
|
31
|
+
# Associations
|
32
|
+
belongs_to :region, optional: true
|
33
|
+
belongs_to :country, optional: true
|
34
|
+
|
35
|
+
has_many :terminals
|
36
|
+
has_many :stock_entries
|
37
|
+
has_many :stock_bundles
|
38
|
+
|
39
|
+
# ------------------
|
40
|
+
# Class Methods
|
41
|
+
# ------------------
|
42
|
+
|
43
|
+
# return an active record relation object with the search query in its where clause
|
44
|
+
# Return the ActiveRecord::Relation object
|
45
|
+
# == Examples
|
46
|
+
# >>> obj.search(query)
|
47
|
+
# => ActiveRecord::Relation object
|
48
|
+
scope :search, lambda {|query| joins(:country, :region).where("LOWER(name) LIKE LOWER('%#{query}%') OR
|
49
|
+
LOWER(code) LIKE LOWER('%#{query}%') OR
|
50
|
+
LOWER(store_type) LIKE LOWER('%#{query}%') OR
|
51
|
+
LOWER(regions.name) LIKE LOWER('%#{query}%') OR
|
52
|
+
LOWER(countries.name) LIKE LOWER('%#{query}%')")}
|
53
|
+
|
54
|
+
|
55
|
+
scope :warehouse, -> { where(store_type: WAREHOUSE) }
|
56
|
+
scope :pos_store, -> { where(store_type: POS_STORE) }
|
57
|
+
|
58
|
+
scope :active, -> { where(status: ACTIVE) }
|
59
|
+
scope :inactive, -> { where(status: INACTIVE) }
|
60
|
+
scope :close, -> { where(status: CLOSED) }
|
61
|
+
|
62
|
+
scope :active_and_inactive, -> { where(status: [ACTIVE, INACTIVE]) }
|
63
|
+
|
64
|
+
def self.save_row_data(row)
|
65
|
+
|
66
|
+
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
67
|
+
|
68
|
+
return if row[:name].blank?
|
69
|
+
|
70
|
+
store = Store.find_by_code(row[:code]) || Store.new
|
71
|
+
|
72
|
+
store.name = row[:name]
|
73
|
+
store.code = row[:code]
|
74
|
+
|
75
|
+
store.set_store_type(row[:store_type])
|
76
|
+
|
77
|
+
store.region = Region.find_by_code(row[:region]) || Country.find_by_name(row[:country])
|
78
|
+
store.country = Country.find_by_code(row[:country]) || Country.find_by_name(row[:country])
|
79
|
+
|
80
|
+
# Initializing error hash for displaying all errors altogether
|
81
|
+
error_object = Kuppayam::Importer::ErrorHash.new
|
82
|
+
|
83
|
+
if store.valid?
|
84
|
+
store.save!
|
85
|
+
else
|
86
|
+
summary = "Error while saving store: #{store.name}"
|
87
|
+
details = "Error! #{store.errors.full_messages.to_sentence}"
|
88
|
+
error_object.errors << { summary: summary, details: details }
|
89
|
+
end
|
90
|
+
return error_object
|
91
|
+
end
|
92
|
+
|
93
|
+
# ------------------
|
94
|
+
# Instance Methods
|
95
|
+
# ------------------
|
96
|
+
|
97
|
+
def display_name
|
98
|
+
self.country ? "#{self.code_was}-#{self.name_was}, #{self.country.name}" : "#{self.code_was}-#{self.name_was}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def display_store_type
|
102
|
+
STORE_TYPES[self.store_type]
|
103
|
+
end
|
104
|
+
|
105
|
+
def set_store_type(st)
|
106
|
+
if STORE_TYPES.keys.include?(st)
|
107
|
+
self.store_type = st
|
108
|
+
elsif STORE_TYPES_REVERSE.keys.include?(st)
|
109
|
+
self.store_type = STORE_TYPES_REVERSE[st]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def slug
|
114
|
+
self.name.parameterize
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_param
|
118
|
+
"#{id}-#{slug}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def warehouse?
|
122
|
+
self.store_type == WAREHOUSE
|
123
|
+
end
|
124
|
+
|
125
|
+
def pos_store?
|
126
|
+
self.store_type == POS_STORE
|
127
|
+
end
|
128
|
+
|
129
|
+
def in_stock?(product)
|
130
|
+
false
|
131
|
+
end
|
132
|
+
|
133
|
+
# * Return true if the brand is active, else false.
|
134
|
+
# == Examples
|
135
|
+
# >>> brand.active?
|
136
|
+
# => true
|
137
|
+
def active?
|
138
|
+
(status == ACTIVE)
|
139
|
+
end
|
140
|
+
|
141
|
+
# * Return true if the brand is inactive, else false.
|
142
|
+
# == Examples
|
143
|
+
# >>> brand.inactive?
|
144
|
+
# => true
|
145
|
+
def inactive?
|
146
|
+
(status == INACTIVE)
|
147
|
+
end
|
148
|
+
|
149
|
+
# * Return true if the brand is closed, else false.
|
150
|
+
# == Examples
|
151
|
+
# >>> brand.closed?
|
152
|
+
# => true
|
153
|
+
def closed?
|
154
|
+
(status == CLOSED)
|
155
|
+
end
|
156
|
+
|
157
|
+
# change the status to :active
|
158
|
+
# Return the status
|
159
|
+
# == Examples
|
160
|
+
# >>> brand.publish!
|
161
|
+
# => "active"
|
162
|
+
def activate!
|
163
|
+
self.update_attribute(:status, ACTIVE)
|
164
|
+
end
|
165
|
+
|
166
|
+
# change the status to :inactive
|
167
|
+
# Return the status
|
168
|
+
# == Examples
|
169
|
+
# >>> brand.publish!
|
170
|
+
# => "inactive"
|
171
|
+
def inactive!
|
172
|
+
self.update_attribute(:status, INACTIVE)
|
173
|
+
end
|
174
|
+
|
175
|
+
# change the status to :closed
|
176
|
+
# Return the status
|
177
|
+
# == Examples
|
178
|
+
# >>> brand.publish!
|
179
|
+
# => "closed"
|
180
|
+
def close!
|
181
|
+
self.update_attribute(:status, CLOSED)
|
182
|
+
end
|
183
|
+
|
184
|
+
def can_be_activated?
|
185
|
+
inactive? or closed?
|
186
|
+
end
|
187
|
+
|
188
|
+
def can_be_inactivated?
|
189
|
+
active?
|
190
|
+
end
|
191
|
+
|
192
|
+
def can_be_closed?
|
193
|
+
active? or inactive?
|
194
|
+
end
|
195
|
+
|
196
|
+
def can_be_edited?
|
197
|
+
!closed?
|
198
|
+
end
|
199
|
+
|
200
|
+
def can_be_deleted?
|
201
|
+
if self.terminals.any?
|
202
|
+
#self.errors.add(:base, DELETE_MESSAGE)
|
203
|
+
return false
|
204
|
+
else
|
205
|
+
return true
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def report_heading
|
210
|
+
rh = []
|
211
|
+
rh << self.company.try(:name) if self.company.name
|
212
|
+
rh << self.display_name
|
213
|
+
rh.join(", ")
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class Supplier < Vyapari::ApplicationRecord
|
2
|
+
|
3
|
+
# Validations
|
4
|
+
validates :name, presence: true, length: {minimum: 2, maximum: 250}, allow_blank: false
|
5
|
+
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 24}, allow_blank: false
|
6
|
+
validates :address, presence: true, length: {minimum: 3, maximum: 1024}, allow_blank: true
|
7
|
+
validates :city, presence: true, length: {minimum: 2, maximum: 56}, allow_blank: true
|
8
|
+
validates :country, presence: true
|
9
|
+
|
10
|
+
# Associations
|
11
|
+
belongs_to :country
|
12
|
+
has_many :products
|
13
|
+
|
14
|
+
# ------------------
|
15
|
+
# Class Methods
|
16
|
+
# ------------------
|
17
|
+
|
18
|
+
# return an active record relation object with the search query in its where clause
|
19
|
+
# Return the ActiveRecord::Relation object
|
20
|
+
# == Examples
|
21
|
+
# >>> obj.search(query)
|
22
|
+
# => ActiveRecord::Relation object
|
23
|
+
scope :search, lambda {|query| joins(:country).where("LOWER(name) LIKE LOWER('%#{query}%') OR
|
24
|
+
LOWER(code) LIKE LOWER('%#{query}%') OR
|
25
|
+
LOWER(address) LIKE LOWER('%#{query}%') OR
|
26
|
+
LOWER(city) LIKE LOWER('%#{query}%')")}
|
27
|
+
|
28
|
+
|
29
|
+
def self.save_row_data(row)
|
30
|
+
|
31
|
+
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
32
|
+
|
33
|
+
return if row[:name].blank?
|
34
|
+
|
35
|
+
supplier = Supplier.find_by_code(row[:code]) || Supplier.new
|
36
|
+
|
37
|
+
supplier.name = row[:name]
|
38
|
+
supplier.code = row[:code]
|
39
|
+
supplier.address = row[:address]
|
40
|
+
supplier.city = row[:city]
|
41
|
+
supplier.country = Country.find_by_code(row[:country]) || Country.find_by_name(row[:country])
|
42
|
+
|
43
|
+
# Initializing error hash for displaying all errors altogether
|
44
|
+
error_object = Kuppayam::Importer::ErrorHash.new
|
45
|
+
|
46
|
+
if supplier.valid?
|
47
|
+
supplier.save!
|
48
|
+
else
|
49
|
+
summary = "Error while saving supplier: #{supplier.name}"
|
50
|
+
details = "Error! #{supplier.errors.full_messages.to_sentence}"
|
51
|
+
error_object.errors << { summary: summary, details: details }
|
52
|
+
end
|
53
|
+
return error_object
|
54
|
+
end
|
55
|
+
|
56
|
+
# ------------------
|
57
|
+
# Instance Methods
|
58
|
+
# ------------------
|
59
|
+
|
60
|
+
def display_name
|
61
|
+
self.country ? "#{self.code_was}-#{self.name_was}, #{self.country.name}" : "#{self.code_was}-#{self.name_was}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def can_be_edited?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def can_be_deleted?
|
69
|
+
# if self.products.any?
|
70
|
+
# #self.errors.add(:base, DELETE_MESSAGE)
|
71
|
+
# return false
|
72
|
+
# else
|
73
|
+
# return true
|
74
|
+
# end
|
75
|
+
return true
|
76
|
+
end
|
77
|
+
|
78
|
+
def report_heading
|
79
|
+
rh = []
|
80
|
+
rh << self.company.try(:name) if self.company.name
|
81
|
+
rh << self.display_name
|
82
|
+
rh.join(", ")
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
class Terminal < Vyapari::ApplicationRecord
|
2
|
+
|
3
|
+
# Constants
|
4
|
+
ACTIVE = "active"
|
5
|
+
INACTIVE = "inactive"
|
6
|
+
CLOSED = "closed"
|
7
|
+
|
8
|
+
STATUS_HASH = {"Active" => ACTIVE, "Inactive" => INACTIVE, "Closed" => CLOSED}
|
9
|
+
STATUS_HASH_REVERSE = {ACTIVE => "Active", INACTIVE => "Inactive", CLOSED => "Closed"}
|
10
|
+
|
11
|
+
# Validations
|
12
|
+
validates :name, presence: true, length: {minimum: 2, maximum: 250}, allow_blank: false
|
13
|
+
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 24}, allow_blank: false
|
14
|
+
validates :status, :presence=> true, :inclusion => {:in => STATUS_HASH_REVERSE.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
|
15
|
+
|
16
|
+
# Associations
|
17
|
+
belongs_to :store
|
18
|
+
has_many :invoices
|
19
|
+
|
20
|
+
# ------------------
|
21
|
+
# Class Methods
|
22
|
+
# ------------------
|
23
|
+
|
24
|
+
# return an active record relation object with the search query in its where clause
|
25
|
+
# Return the ActiveRecord::Relation object
|
26
|
+
# == Examples
|
27
|
+
# >>> obj.search(query)
|
28
|
+
# => ActiveRecord::Relation object
|
29
|
+
scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%') OR
|
30
|
+
LOWER(code) LIKE LOWER('%#{query}%')")}
|
31
|
+
|
32
|
+
|
33
|
+
scope :active, -> { where(status: ACTIVE) }
|
34
|
+
scope :inactive, -> { where(status: INACTIVE) }
|
35
|
+
scope :close, -> { where(status: CLOSED) }
|
36
|
+
|
37
|
+
scope :active_and_inactive, -> { where(status: [ACTIVE, INACTIVE]) }
|
38
|
+
|
39
|
+
def self.save_row_data(row)
|
40
|
+
|
41
|
+
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
42
|
+
|
43
|
+
return if row[:name].blank?
|
44
|
+
|
45
|
+
terminal = Terminal.find_by_code(row[:code]) || Terminal.new
|
46
|
+
|
47
|
+
terminal.name = row[:name]
|
48
|
+
terminal.code = row[:code]
|
49
|
+
|
50
|
+
terminal.store = Store.find_by_code(row[:store])
|
51
|
+
|
52
|
+
# Initializing error hash for displaying all errors altogether
|
53
|
+
error_object = Kuppayam::Importer::ErrorHash.new
|
54
|
+
|
55
|
+
if terminal.valid?
|
56
|
+
terminal.save!
|
57
|
+
else
|
58
|
+
summary = "Error while saving terminal: #{terminal.name}"
|
59
|
+
details = "Error! #{terminal.errors.full_messages.to_sentence}"
|
60
|
+
error_object.errors << { summary: summary, details: details }
|
61
|
+
end
|
62
|
+
|
63
|
+
return error_object
|
64
|
+
end
|
65
|
+
|
66
|
+
# ------------------
|
67
|
+
# Instance Methods
|
68
|
+
# ------------------
|
69
|
+
|
70
|
+
def display_name
|
71
|
+
"#{self.code_was}-#{self.name_was}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def slug
|
75
|
+
self.name.parameterize
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_param
|
79
|
+
"#{id}-#{slug}"
|
80
|
+
end
|
81
|
+
|
82
|
+
# * Return true if the brand is active, else false.
|
83
|
+
# == Examples
|
84
|
+
# >>> brand.active?
|
85
|
+
# => true
|
86
|
+
def active?
|
87
|
+
(status == ACTIVE)
|
88
|
+
end
|
89
|
+
|
90
|
+
# * Return true if the brand is inactive, else false.
|
91
|
+
# == Examples
|
92
|
+
# >>> brand.inactive?
|
93
|
+
# => true
|
94
|
+
def inactive?
|
95
|
+
(status == INACTIVE)
|
96
|
+
end
|
97
|
+
|
98
|
+
# * Return true if the brand is closed, else false.
|
99
|
+
# == Examples
|
100
|
+
# >>> brand.closed?
|
101
|
+
# => true
|
102
|
+
def closed?
|
103
|
+
(status == CLOSED)
|
104
|
+
end
|
105
|
+
|
106
|
+
# change the status to :active
|
107
|
+
# Return the status
|
108
|
+
# == Examples
|
109
|
+
# >>> brand.publish!
|
110
|
+
# => "active"
|
111
|
+
def activate!
|
112
|
+
self.update_attribute(:status, ACTIVE)
|
113
|
+
end
|
114
|
+
|
115
|
+
# change the status to :inactive
|
116
|
+
# Return the status
|
117
|
+
# == Examples
|
118
|
+
# >>> brand.publish!
|
119
|
+
# => "inactive"
|
120
|
+
def inactive!
|
121
|
+
self.update_attribute(:status, INACTIVE)
|
122
|
+
end
|
123
|
+
|
124
|
+
# change the status to :closed
|
125
|
+
# Return the status
|
126
|
+
# == Examples
|
127
|
+
# >>> brand.publish!
|
128
|
+
# => "closed"
|
129
|
+
def close!
|
130
|
+
self.update_attribute(:status, CLOSED)
|
131
|
+
end
|
132
|
+
|
133
|
+
def can_be_activated?
|
134
|
+
inactive? or closed?
|
135
|
+
end
|
136
|
+
|
137
|
+
def can_be_inactivated?
|
138
|
+
active?
|
139
|
+
end
|
140
|
+
|
141
|
+
def can_be_closed?
|
142
|
+
active? or inactive?
|
143
|
+
end
|
144
|
+
|
145
|
+
def can_be_edited?
|
146
|
+
!closed?
|
147
|
+
end
|
148
|
+
|
149
|
+
def can_be_deleted?
|
150
|
+
if self.invoices.any?
|
151
|
+
#self.errors.add(:base, DELETE_MESSAGE)
|
152
|
+
return false
|
153
|
+
else
|
154
|
+
return true
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CategoryImageUploader < ImageUploader
|
2
|
+
def store_dir
|
3
|
+
"uploads/category_images/#{model.id}"
|
4
|
+
end
|
5
|
+
|
6
|
+
version :large do
|
7
|
+
process :resize_to_fill => [400, 400]
|
8
|
+
end
|
9
|
+
|
10
|
+
version :small do
|
11
|
+
process :resize_to_fill => [100, 100]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<!-- Add your copyright text here -->
|
6
6
|
<div class="footer-text">
|
7
7
|
© 2017
|
8
|
-
<strong>
|
8
|
+
<strong>Company Name</strong>
|
9
9
|
|
10
10
|
All rights reserved. <br>developed, maintained and hosted by <a href="http://rightsolutions.io" target="_blank" style="color:red">Right Solutions</a>
|
11
11
|
</div>
|
@@ -26,71 +26,72 @@
|
|
26
26
|
<i class="fa-bars"></i>
|
27
27
|
</a>
|
28
28
|
</div>
|
29
|
-
|
30
29
|
</header>
|
31
30
|
|
32
|
-
|
33
|
-
|
34
31
|
<ul id="main-menu" class="main-menu">
|
35
32
|
|
36
33
|
<!-- add class "multiple-expanded" to allow multiple submenus to open -->
|
37
34
|
|
38
35
|
<!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
|
39
36
|
|
37
|
+
<!-- Dashboard -->
|
40
38
|
<li class="<%= nav_active?('admin/dashboard') ? 'active' : '' %>">
|
41
|
-
<%= link_to raw("<i class=\"linecons-desktop\"></i> <span class='title'>Dashboard</span>"), vyapari.admin_dashboard_url %>
|
39
|
+
<%= link_to raw("<i class=\"linecons-desktop\"></i> <span class='title'>Admin Dashboard</span>"), vyapari.admin_dashboard_url %>
|
42
40
|
</li>
|
43
|
-
|
41
|
+
|
42
|
+
<!-- Manage Store -->
|
43
|
+
<li class="<%= nav_active?('store_manager/stores') ? 'active' : '' %>">
|
44
|
+
<%= link_to raw("<i class=\"linecons-shop\"></i> <span class='title'>Store Dashboard</span>"), vyapari.store_manager_stores_url %>
|
45
|
+
</li>
|
46
|
+
|
47
|
+
<!-- Configurations -->
|
48
|
+
<% if @current_user.super_admin? %>
|
44
49
|
<li class="">
|
45
|
-
<a href="
|
46
|
-
<i class="linecons-
|
50
|
+
<a href="#">
|
51
|
+
<i class="linecons-params"></i>
|
47
52
|
<span class="title">Configurations</span>
|
48
53
|
</a>
|
49
54
|
<ul>
|
50
55
|
|
51
|
-
<li class="<%= nav_class("admin/users") %>">
|
52
|
-
<%= link_to raw("<i class=\"linecons-user\"></i> <span class='title'>Manage Users</span>"), usman.admin_users_url %>
|
53
|
-
</li>
|
54
|
-
|
55
|
-
<li class="<%= nav_class("admin/users") %>">
|
56
|
-
<%= link_to raw("<i class=\"linecons-lock\"></i> <span class='title'>Manage Permissions</span>"), usman.admin_permissions_url %>
|
57
|
-
</li>
|
58
|
-
|
59
56
|
<li class="">
|
60
|
-
<%= link_to raw("<i class=\"linecons-
|
57
|
+
<%= link_to raw("<i class=\"linecons-globe\"></i> <span class='title'>Countries</span>"), vyapari.admin_countries_url %>
|
61
58
|
</li>
|
62
59
|
|
63
60
|
<li class="">
|
64
|
-
<%= link_to raw("<i class=\"linecons-
|
61
|
+
<%= link_to raw("<i class=\"linecons-location\"></i> <span class='title'>Manage Regions</span>"), vyapari.admin_regions_url %>
|
65
62
|
</li>
|
66
63
|
|
67
64
|
<li class="">
|
68
|
-
<%= link_to raw("<i class=\"linecons-
|
65
|
+
<%= link_to raw("<i class=\"linecons-money\"></i> <span class='title'>Exchange Rates</span>"), vyapari.admin_exchange_rates_url %>
|
69
66
|
</li>
|
70
67
|
|
71
68
|
<li class="">
|
72
|
-
<%= link_to raw("<i class=\"linecons-
|
69
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Features</span>"), usman.admin_features_url %>
|
73
70
|
</li>
|
74
71
|
|
75
|
-
<li class="">
|
76
|
-
<%= link_to raw("<i class=\"linecons-
|
72
|
+
<li class="<%= nav_class("admin/users") %>">
|
73
|
+
<%= link_to raw("<i class=\"linecons-lock\"></i> <span class='title'>Manage Permissions</span>"), usman.admin_permissions_url %>
|
77
74
|
</li>
|
78
75
|
|
79
76
|
</ul>
|
80
77
|
</li>
|
78
|
+
<% end %>
|
81
79
|
|
80
|
+
<!-- Administration -->
|
81
|
+
<% if @current_user.super_admin? || @current_user.has_role?("Site Admin") %>
|
82
82
|
<li class="">
|
83
|
-
<a href="
|
84
|
-
<i class="linecons-
|
85
|
-
<span class="title">
|
83
|
+
<a href="#">
|
84
|
+
<i class="linecons-cog"></i>
|
85
|
+
<span class="title">Administration</span>
|
86
86
|
</a>
|
87
87
|
<ul>
|
88
|
-
<li class="">
|
89
|
-
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Suppliers</span>"), vyapari.admin_suppliers_url %>
|
90
|
-
</li>
|
91
88
|
|
92
|
-
<li class="">
|
93
|
-
|
89
|
+
<li class="<%= nav_class("admin/users") %>">
|
90
|
+
<%= link_to raw("<i class=\"linecons-user\"></i> <span class='title'>Manage Users</span>"), usman.admin_users_url %>
|
91
|
+
</li>
|
92
|
+
|
93
|
+
<li class="">
|
94
|
+
<%= link_to raw("<i class=\"linecons-graduation-cap\"></i> <span class='title'>Manage Roles</span>"), usman.admin_roles_url %>
|
94
95
|
</li>
|
95
96
|
|
96
97
|
<li class="">
|
@@ -100,34 +101,34 @@
|
|
100
101
|
<li class="">
|
101
102
|
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Categories</span>"), vyapari.admin_categories_url %>
|
102
103
|
</li>
|
104
|
+
|
105
|
+
<li class="">
|
106
|
+
<%= link_to raw("<i class=\"linecons-shop\"></i> <span class='title'>Manage Stores</span>"), vyapari.admin_stores_url %>
|
107
|
+
</li>
|
108
|
+
|
109
|
+
<li class="">
|
110
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Suppliers</span>"), vyapari.admin_suppliers_url %>
|
111
|
+
</li>
|
103
112
|
|
104
113
|
</ul>
|
105
114
|
</li>
|
115
|
+
<% end %>
|
106
116
|
|
117
|
+
<% if @current_user.super_admin? %>
|
107
118
|
<li class="">
|
108
|
-
<a href="
|
119
|
+
<a href="#">
|
109
120
|
<i class="linecons-database"></i>
|
110
|
-
<span class="title">
|
121
|
+
<span class="title">Monitoring</span>
|
111
122
|
</a>
|
112
123
|
<ul>
|
124
|
+
|
113
125
|
<li class="">
|
114
|
-
<%= link_to raw("<i class=\"linecons-
|
115
|
-
</li>
|
116
|
-
|
117
|
-
<li class="">
|
118
|
-
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Stores</span>"), vyapari.admin_stores_url %>
|
119
|
-
</li>
|
120
|
-
|
121
|
-
<li class="">
|
122
|
-
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Brands</span>"), vyapari.admin_brands_url %>
|
123
|
-
</li>
|
124
|
-
|
125
|
-
<li class="">
|
126
|
-
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Categories</span>"), vyapari.admin_categories_url %>
|
126
|
+
<%= link_to raw("<i class=\"linecons-truck\"></i> <span class='title'>Manage Products</span>"), vyapari.admin_products_url %>
|
127
127
|
</li>
|
128
128
|
|
129
129
|
</ul>
|
130
130
|
</li>
|
131
|
+
<% end %>
|
131
132
|
|
132
133
|
</ul>
|
133
134
|
|