vyapari 0.1.4 → 0.1.5dev

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.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/vyapari/sample_stock_bundle.csv +1 -0
  3. data/app/controllers/vyapari/admin/base_controller.rb +10 -0
  4. data/app/controllers/vyapari/admin/brands_controller.rb +99 -0
  5. data/app/controllers/vyapari/admin/categories_controller.rb +115 -0
  6. data/app/controllers/vyapari/admin/countries_controller.rb +2 -2
  7. data/app/controllers/vyapari/admin/dashboard_controller.rb +3 -1
  8. data/app/controllers/vyapari/admin/exchange_rates_controller.rb +2 -2
  9. data/app/controllers/vyapari/admin/products_controller.rb +79 -0
  10. data/app/controllers/vyapari/admin/regions_controller.rb +1 -1
  11. data/app/controllers/vyapari/admin/resource_controller.rb +1 -0
  12. data/app/controllers/vyapari/admin/stores_controller.rb +67 -0
  13. data/app/controllers/vyapari/admin/suppliers_controller.rb +67 -0
  14. data/app/controllers/vyapari/admin/terminals_controller.rb +150 -0
  15. data/app/controllers/vyapari/application_controller.rb +12 -0
  16. data/app/controllers/vyapari/store_manager/base_controller.rb +28 -0
  17. data/app/controllers/vyapari/store_manager/dashboard_controller.rb +30 -0
  18. data/app/controllers/vyapari/store_manager/resource_controller.rb +17 -0
  19. data/app/controllers/vyapari/store_manager/stock_bundles_controller.rb +206 -0
  20. data/app/controllers/vyapari/store_manager/stock_entries_controller.rb +161 -0
  21. data/app/controllers/vyapari/terminal_staff/base_controller.rb +29 -0
  22. data/app/controllers/vyapari/terminal_staff/dashboard_controller.rb +29 -0
  23. data/app/controllers/vyapari/terminal_staff/invoices_controller.rb +138 -0
  24. data/app/controllers/vyapari/terminal_staff/line_items_controller.rb +123 -0
  25. data/app/controllers/vyapari/terminal_staff/resource_controller.rb +17 -0
  26. data/app/controllers/vyapari/user_dashboard_controller.rb +31 -0
  27. data/app/models/brand.rb +63 -10
  28. data/app/models/category.rb +60 -16
  29. data/app/models/country.rb +27 -5
  30. data/app/models/exchange_rate.rb +31 -6
  31. data/app/models/image/brand_image.rb +3 -0
  32. data/app/models/image/category_image.rb +3 -0
  33. data/app/models/image/product_image.rb +3 -0
  34. data/app/models/invoice.rb +223 -0
  35. data/app/models/line_item.rb +206 -0
  36. data/app/models/product.rb +67 -13
  37. data/app/models/region.rb +26 -3
  38. data/app/models/stock_bundle.rb +249 -0
  39. data/app/models/stock_entry.rb +271 -0
  40. data/app/models/store.rb +216 -0
  41. data/app/models/supplier.rb +85 -0
  42. data/app/models/terminal.rb +158 -0
  43. data/app/models/vyapari/application_record.rb +4 -0
  44. data/app/uploaders/brand_image_uploader.rb +14 -0
  45. data/app/uploaders/category_image_uploader.rb +14 -0
  46. data/app/uploaders/product_image_uploader.rb +14 -0
  47. data/app/uploaders/stock_bundle_uploader.rb +10 -0
  48. data/app/views/layouts/kuppayam/_footer.html.erb +1 -1
  49. data/app/views/layouts/kuppayam/_sidebar.html.erb +45 -44
  50. data/app/views/layouts/vyapari/_store_manager_menu.html.erb +107 -0
  51. data/app/views/layouts/vyapari/_terminal_staff_menu.html.erb +103 -0
  52. data/app/views/layouts/vyapari/store_manager.html.erb +112 -0
  53. data/app/views/layouts/vyapari/terminal_staff.html.erb +116 -0
  54. data/app/views/vyapari/admin/brands/_form.html.erb +23 -0
  55. data/app/views/vyapari/admin/brands/_index.html.erb +89 -0
  56. data/app/views/vyapari/admin/brands/_row.html.erb +63 -0
  57. data/app/views/vyapari/admin/brands/_show.html.erb +104 -0
  58. data/app/views/vyapari/admin/brands/index.html.erb +48 -0
  59. data/app/views/vyapari/admin/categories/_form.html.erb +28 -0
  60. data/app/views/vyapari/admin/categories/_index.html.erb +101 -0
  61. data/app/views/vyapari/admin/categories/_row.html.erb +69 -0
  62. data/app/views/vyapari/admin/categories/_show.html.erb +115 -0
  63. data/app/views/vyapari/admin/{users → categories}/index.html.erb +8 -24
  64. data/app/views/vyapari/admin/countries/_index.html.erb +1 -1
  65. data/app/views/vyapari/admin/countries/index.html.erb +19 -3
  66. data/app/views/vyapari/admin/exchange_rates/_form.html.erb +3 -4
  67. data/app/views/vyapari/admin/exchange_rates/_index.html.erb +7 -7
  68. data/app/views/vyapari/admin/exchange_rates/_row.html.erb +3 -3
  69. data/app/views/vyapari/admin/exchange_rates/_show.html.erb +1 -0
  70. data/app/views/vyapari/admin/exchange_rates/index.html.erb +19 -3
  71. data/app/views/vyapari/admin/products/_form.html.erb +32 -0
  72. data/app/views/vyapari/admin/products/_index.html.erb +58 -0
  73. data/app/views/vyapari/admin/products/_row.html.erb +30 -0
  74. data/app/views/vyapari/admin/products/_show.html.erb +81 -0
  75. data/app/views/vyapari/admin/products/index.html.erb +48 -0
  76. data/app/views/vyapari/admin/regions/_index.html.erb +1 -1
  77. data/app/views/vyapari/admin/regions/index.html.erb +19 -3
  78. data/app/views/vyapari/admin/stores/_form.html.erb +37 -0
  79. data/app/views/vyapari/admin/stores/_index.html.erb +84 -0
  80. data/app/views/vyapari/admin/stores/_row.html.erb +55 -0
  81. data/app/views/vyapari/admin/stores/_show.html.erb +110 -0
  82. data/app/views/vyapari/admin/stores/index.html.erb +48 -0
  83. data/app/views/vyapari/admin/suppliers/_form.html.erb +32 -0
  84. data/app/views/vyapari/admin/suppliers/_index.html.erb +58 -0
  85. data/app/views/vyapari/admin/suppliers/_row.html.erb +30 -0
  86. data/app/views/vyapari/admin/suppliers/_show.html.erb +81 -0
  87. data/app/views/vyapari/admin/suppliers/index.html.erb +48 -0
  88. data/app/views/vyapari/admin/terminals/_form.html.erb +24 -0
  89. data/app/views/vyapari/admin/terminals/_index.html.erb +75 -0
  90. data/app/views/vyapari/admin/terminals/_row.html.erb +49 -0
  91. data/app/views/vyapari/admin/terminals/_show.html.erb +74 -0
  92. data/app/views/vyapari/store_manager/dashboard/index.html.erb +93 -0
  93. data/app/views/vyapari/store_manager/stock_bundles/_form.html.erb +99 -0
  94. data/app/views/vyapari/store_manager/stock_bundles/_index.html.erb +74 -0
  95. data/app/views/vyapari/store_manager/stock_bundles/_row.html.erb +44 -0
  96. data/app/views/vyapari/store_manager/stock_bundles/_show.html.erb +110 -0
  97. data/app/views/vyapari/store_manager/stock_bundles/create.html.erb +57 -0
  98. data/app/views/vyapari/store_manager/stock_bundles/index.html.erb +36 -0
  99. data/app/views/vyapari/store_manager/stock_bundles/update.html.erb +57 -0
  100. data/app/views/vyapari/store_manager/stock_entries/_form.html.erb +50 -0
  101. data/app/views/vyapari/store_manager/stock_entries/_index.html.erb +80 -0
  102. data/app/views/vyapari/store_manager/stock_entries/_row.html.erb +33 -0
  103. data/app/views/vyapari/store_manager/stock_entries/_show.html.erb +110 -0
  104. data/app/views/vyapari/store_manager/stock_entries/_stock_bundle.html.erb +61 -0
  105. data/app/views/vyapari/store_manager/stock_entries/index.html.erb +45 -0
  106. data/app/views/vyapari/terminal_staff/dashboard/_counts.html.erb +88 -0
  107. data/app/views/vyapari/terminal_staff/dashboard/_invoices.html.erb +37 -0
  108. data/app/views/vyapari/terminal_staff/dashboard/index.html.erb +36 -0
  109. data/app/views/vyapari/terminal_staff/invoices/_draft.html.erb +62 -0
  110. data/app/views/vyapari/terminal_staff/invoices/_form.html.erb +120 -0
  111. data/app/views/vyapari/terminal_staff/invoices/_index.html.erb +64 -0
  112. data/app/views/vyapari/terminal_staff/invoices/_row.html.erb +33 -0
  113. data/app/views/vyapari/terminal_staff/invoices/_show.html.erb +171 -0
  114. data/app/views/vyapari/terminal_staff/invoices/index.html.erb +37 -0
  115. data/app/views/vyapari/terminal_staff/invoices/new.js.erb +13 -0
  116. data/app/views/vyapari/terminal_staff/invoices/show.html.erb +1 -0
  117. data/app/views/vyapari/terminal_staff/line_items/_form.html.erb +40 -0
  118. data/app/views/vyapari/terminal_staff/line_items/_index.html.erb +94 -0
  119. data/app/views/vyapari/terminal_staff/line_items/create.js.erb +34 -0
  120. data/app/views/vyapari/terminal_staff/line_items/destroy.js.erb +25 -0
  121. data/app/views/vyapari/terminal_staff/stores/index.html.erb +24 -0
  122. data/app/views/vyapari/user_dashboard/index.html.erb +51 -0
  123. data/config/routes.rb +62 -5
  124. data/db/import_data/brands.csv +7 -0
  125. data/db/import_data/categories.csv +12 -0
  126. data/db/import_data/countries.csv +1 -0
  127. data/db/import_data/dummy/brands.csv +7 -0
  128. data/db/import_data/dummy/categories.csv +12 -0
  129. data/db/import_data/dummy/countries.csv +1 -0
  130. data/db/import_data/dummy/exchange_rates.csv +5 -0
  131. data/db/import_data/dummy/products-copy.csv +1 -0
  132. data/db/import_data/dummy/products.csv +1 -0
  133. data/db/import_data/dummy/products.xlsx +0 -0
  134. data/db/import_data/dummy/regions.csv +13 -0
  135. data/db/import_data/dummy/stores.csv +10 -0
  136. data/db/import_data/dummy/suppliers.csv +14 -0
  137. data/db/import_data/dummy/terminals.csv +11 -0
  138. data/db/import_data/exchange_rates.csv +5 -0
  139. data/db/import_data/regions.csv +13 -0
  140. data/db/import_data/stores.csv +3 -0
  141. data/db/import_data/suppliers.csv +14 -0
  142. data/db/import_data/terminals.csv +3 -0
  143. data/db/migrate/20170000000200_create_exchange_rates.rb +3 -2
  144. data/db/migrate/20170000000203_create_contacts.rb +22 -0
  145. data/db/migrate/20170000000204_create_bank_accounts.rb +21 -0
  146. data/db/migrate/20170000000205_create_suppliers.rb +18 -0
  147. data/db/migrate/20170000000206_create_stores.rb +21 -0
  148. data/db/migrate/20170000000207_create_terminals.rb +18 -0
  149. data/db/migrate/20170000000210_create_brands.rb +14 -0
  150. data/db/migrate/20170000000211_create_categories.rb +22 -0
  151. data/db/migrate/20170000000212_create_products.rb +29 -0
  152. data/db/migrate/20170000000213_create_invoices.rb +58 -0
  153. data/db/migrate/20170000000215_create_stock_bundles.rb +17 -0
  154. data/db/migrate/20170000000216_create_stock_entries.rb +20 -0
  155. data/db/sample_reports/products.xlsx +0 -0
  156. data/lib/tasks/vyapari/all.rake +73 -0
  157. data/lib/vyapari/version.rb +1 -1
  158. metadata +150 -15
  159. data/app/controllers/vyapari/admin/users_controller.rb +0 -130
  160. data/app/views/vyapari/admin/users/_form.html.erb +0 -39
  161. data/app/views/vyapari/admin/users/_index.html.erb +0 -101
  162. data/app/views/vyapari/admin/users/_row.html.erb +0 -72
  163. data/app/views/vyapari/admin/users/_show.html.erb +0 -199
  164. data/lib/tasks/vyapari_tasks.rake +0 -4
@@ -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
@@ -1,6 +1,10 @@
1
1
  module Vyapari
2
2
  class ApplicationRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
+
5
+ require 'kuppayam/importer.rb'
6
+ extend Kuppayam::Importer
7
+ extend KuppayamValidators
4
8
  end
5
9
  end
6
10
 
@@ -0,0 +1,14 @@
1
+ class BrandImageUploader < ImageUploader
2
+ def store_dir
3
+ "uploads/brand_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
@@ -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
@@ -0,0 +1,14 @@
1
+ class ProductImageUploader < ImageUploader
2
+ def store_dir
3
+ "uploads/product_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
@@ -0,0 +1,10 @@
1
+ class StockBundleUploader < DocumentUploader
2
+ def store_dir
3
+ # /#{Rails.root}/
4
+ "uploads/stock_bundles/#{model.id}"
5
+ end
6
+
7
+ def extension_white_list
8
+ %w(csv)
9
+ end
10
+ end
@@ -5,7 +5,7 @@
5
5
  <!-- Add your copyright text here -->
6
6
  <div class="footer-text">
7
7
  &copy; 2017
8
- <strong>Kuppayam</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="/xenon/xenon-files/html/dashboard-1.html">
46
- <i class="linecons-database"></i>
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-diamond\"></i> <span class='title'>Features</span>"), usman.admin_features_url %>
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-diamond\"></i> <span class='title'>Roles</span>"), usman.admin_roles_url %>
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-database\"></i> <span class='title'>Countries</span>"), vyapari.admin_countries_url %>
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-database\"></i> <span class='title'>Regions</span>"), vyapari.admin_regions_url %>
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-database\"></i> <span class='title'>Exchange Rates</span>"), vyapari.admin_exchange_rates_url %>
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="/xenon/xenon-files/html/dashboard-1.html">
84
- <i class="linecons-database"></i>
85
- <span class="title">Stock Management</span>
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
- <%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Stores</span>"), vyapari.admin_stores_url %>
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="/xenon/xenon-files/html/dashboard-1.html">
119
+ <a href="#">
109
120
  <i class="linecons-database"></i>
110
- <span class="title">POS</span>
121
+ <span class="title">Monitoring</span>
111
122
  </a>
112
123
  <ul>
124
+
113
125
  <li class="">
114
- <%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Suppliers</span>"), vyapari.admin_suppliers_url %>
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