vyapari 0.1.5dev10 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/vyapari/admin/base_controller.rb +0 -9
  3. data/app/controllers/vyapari/admin/countries_controller.rb +2 -2
  4. data/app/controllers/vyapari/admin/dashboard_controller.rb +1 -3
  5. data/app/controllers/vyapari/admin/exchange_rates_controller.rb +2 -2
  6. data/app/controllers/vyapari/admin/regions_controller.rb +1 -1
  7. data/app/controllers/vyapari/admin/resource_controller.rb +0 -1
  8. data/app/controllers/vyapari/admin/users_controller.rb +130 -0
  9. data/app/controllers/vyapari/application_controller.rb +0 -11
  10. data/app/models/brand.rb +19 -67
  11. data/app/models/category.rb +19 -63
  12. data/app/models/country.rb +7 -31
  13. data/app/models/exchange_rate.rb +7 -32
  14. data/app/models/product.rb +20 -75
  15. data/app/models/region.rb +20 -37
  16. data/app/models/vyapari/application_record.rb +0 -3
  17. data/app/views/layouts/kuppayam/_footer.html.erb +1 -1
  18. data/app/views/layouts/kuppayam/_sidebar.html.erb +44 -45
  19. data/app/views/vyapari/admin/countries/_index.html.erb +1 -1
  20. data/app/views/vyapari/admin/countries/index.html.erb +3 -19
  21. data/app/views/vyapari/admin/exchange_rates/_form.html.erb +4 -3
  22. data/app/views/vyapari/admin/exchange_rates/_index.html.erb +7 -7
  23. data/app/views/vyapari/admin/exchange_rates/_row.html.erb +3 -3
  24. data/app/views/vyapari/admin/exchange_rates/_show.html.erb +0 -1
  25. data/app/views/vyapari/admin/exchange_rates/index.html.erb +3 -19
  26. data/app/views/vyapari/admin/regions/_index.html.erb +1 -1
  27. data/app/views/vyapari/admin/regions/index.html.erb +3 -19
  28. data/app/views/vyapari/admin/users/_form.html.erb +39 -0
  29. data/app/views/vyapari/admin/users/_index.html.erb +101 -0
  30. data/app/views/vyapari/admin/users/_row.html.erb +72 -0
  31. data/app/views/vyapari/admin/users/_show.html.erb +199 -0
  32. data/app/views/vyapari/admin/{categories → users}/index.html.erb +24 -8
  33. data/config/routes.rb +5 -66
  34. data/db/migrate/20170000000200_create_exchange_rates.rb +2 -3
  35. data/lib/tasks/vyapari_tasks.rake +4 -0
  36. data/lib/vyapari/version.rb +1 -1
  37. metadata +15 -167
  38. data/app/assets/images/vyapari/sample_stock_bundle.csv +0 -1
  39. data/app/controllers/vyapari/admin/brands_controller.rb +0 -99
  40. data/app/controllers/vyapari/admin/categories_controller.rb +0 -115
  41. data/app/controllers/vyapari/admin/products_controller.rb +0 -79
  42. data/app/controllers/vyapari/admin/stores_controller.rb +0 -67
  43. data/app/controllers/vyapari/admin/suppliers_controller.rb +0 -67
  44. data/app/controllers/vyapari/admin/terminals_controller.rb +0 -150
  45. data/app/controllers/vyapari/store_manager/base_controller.rb +0 -33
  46. data/app/controllers/vyapari/store_manager/dashboard_controller.rb +0 -31
  47. data/app/controllers/vyapari/store_manager/reports/invoices_controller.rb +0 -249
  48. data/app/controllers/vyapari/store_manager/reports/sales_controller.rb +0 -299
  49. data/app/controllers/vyapari/store_manager/reports/stock_controller.rb +0 -132
  50. data/app/controllers/vyapari/store_manager/resource_controller.rb +0 -17
  51. data/app/controllers/vyapari/store_manager/stock_bundles_controller.rb +0 -206
  52. data/app/controllers/vyapari/store_manager/stock_entries_controller.rb +0 -161
  53. data/app/controllers/vyapari/terminal_staff/base_controller.rb +0 -38
  54. data/app/controllers/vyapari/terminal_staff/dashboard_controller.rb +0 -35
  55. data/app/controllers/vyapari/terminal_staff/invoices_controller.rb +0 -147
  56. data/app/controllers/vyapari/terminal_staff/line_items_controller.rb +0 -139
  57. data/app/controllers/vyapari/terminal_staff/resource_controller.rb +0 -17
  58. data/app/controllers/vyapari/user_dashboard_controller.rb +0 -31
  59. data/app/models/bank_account.rb +0 -44
  60. data/app/models/contact.rb +0 -72
  61. data/app/models/image/brand_image.rb +0 -3
  62. data/app/models/image/category_image.rb +0 -3
  63. data/app/models/image/product_image.rb +0 -3
  64. data/app/models/invoice.rb +0 -256
  65. data/app/models/line_item.rb +0 -207
  66. data/app/models/stock_bundle.rb +0 -249
  67. data/app/models/stock_entry.rb +0 -275
  68. data/app/models/store.rb +0 -302
  69. data/app/models/supplier.rb +0 -79
  70. data/app/models/terminal.rb +0 -158
  71. data/app/uploaders/brand_image_uploader.rb +0 -14
  72. data/app/uploaders/category_image_uploader.rb +0 -14
  73. data/app/uploaders/product_image_uploader.rb +0 -14
  74. data/app/uploaders/stock_bundle_uploader.rb +0 -10
  75. data/app/views/layouts/vyapari/_store_manager_menu.html.erb +0 -126
  76. data/app/views/layouts/vyapari/_terminal_staff_menu.html.erb +0 -106
  77. data/app/views/layouts/vyapari/store_manager.html.erb +0 -112
  78. data/app/views/layouts/vyapari/terminal_staff.html.erb +0 -116
  79. data/app/views/vyapari/admin/brands/_form.html.erb +0 -23
  80. data/app/views/vyapari/admin/brands/_index.html.erb +0 -89
  81. data/app/views/vyapari/admin/brands/_row.html.erb +0 -63
  82. data/app/views/vyapari/admin/brands/_show.html.erb +0 -104
  83. data/app/views/vyapari/admin/brands/index.html.erb +0 -48
  84. data/app/views/vyapari/admin/categories/_form.html.erb +0 -28
  85. data/app/views/vyapari/admin/categories/_index.html.erb +0 -101
  86. data/app/views/vyapari/admin/categories/_row.html.erb +0 -69
  87. data/app/views/vyapari/admin/categories/_show.html.erb +0 -115
  88. data/app/views/vyapari/admin/products/_form.html.erb +0 -32
  89. data/app/views/vyapari/admin/products/_index.html.erb +0 -58
  90. data/app/views/vyapari/admin/products/_row.html.erb +0 -30
  91. data/app/views/vyapari/admin/products/_show.html.erb +0 -81
  92. data/app/views/vyapari/admin/products/index.html.erb +0 -48
  93. data/app/views/vyapari/admin/stores/_form.html.erb +0 -37
  94. data/app/views/vyapari/admin/stores/_index.html.erb +0 -84
  95. data/app/views/vyapari/admin/stores/_row.html.erb +0 -55
  96. data/app/views/vyapari/admin/stores/_show.html.erb +0 -110
  97. data/app/views/vyapari/admin/stores/index.html.erb +0 -48
  98. data/app/views/vyapari/admin/suppliers/_form.html.erb +0 -32
  99. data/app/views/vyapari/admin/suppliers/_index.html.erb +0 -58
  100. data/app/views/vyapari/admin/suppliers/_row.html.erb +0 -30
  101. data/app/views/vyapari/admin/suppliers/_show.html.erb +0 -81
  102. data/app/views/vyapari/admin/suppliers/index.html.erb +0 -48
  103. data/app/views/vyapari/admin/terminals/_form.html.erb +0 -24
  104. data/app/views/vyapari/admin/terminals/_index.html.erb +0 -75
  105. data/app/views/vyapari/admin/terminals/_row.html.erb +0 -49
  106. data/app/views/vyapari/admin/terminals/_show.html.erb +0 -74
  107. data/app/views/vyapari/store_manager/dashboard/_sales_counts.html.erb +0 -90
  108. data/app/views/vyapari/store_manager/dashboard/_stock_counts.html.erb +0 -63
  109. data/app/views/vyapari/store_manager/dashboard/_terminals.html.erb +0 -23
  110. data/app/views/vyapari/store_manager/dashboard/index.html.erb +0 -64
  111. data/app/views/vyapari/store_manager/reports/invoices/_index.html.erb +0 -65
  112. data/app/views/vyapari/store_manager/reports/invoices/index.html.erb +0 -105
  113. data/app/views/vyapari/store_manager/reports/sales/_index.html.erb +0 -64
  114. data/app/views/vyapari/store_manager/reports/sales/index.html.erb +0 -105
  115. data/app/views/vyapari/store_manager/reports/stock/_index.html.erb +0 -72
  116. data/app/views/vyapari/store_manager/reports/stock/index.html.erb +0 -32
  117. data/app/views/vyapari/store_manager/stock_bundles/_form.html.erb +0 -99
  118. data/app/views/vyapari/store_manager/stock_bundles/_index.html.erb +0 -74
  119. data/app/views/vyapari/store_manager/stock_bundles/_row.html.erb +0 -44
  120. data/app/views/vyapari/store_manager/stock_bundles/_show.html.erb +0 -110
  121. data/app/views/vyapari/store_manager/stock_bundles/create.html.erb +0 -57
  122. data/app/views/vyapari/store_manager/stock_bundles/index.html.erb +0 -36
  123. data/app/views/vyapari/store_manager/stock_bundles/update.html.erb +0 -57
  124. data/app/views/vyapari/store_manager/stock_entries/_form.html.erb +0 -50
  125. data/app/views/vyapari/store_manager/stock_entries/_index.html.erb +0 -80
  126. data/app/views/vyapari/store_manager/stock_entries/_row.html.erb +0 -33
  127. data/app/views/vyapari/store_manager/stock_entries/_show.html.erb +0 -110
  128. data/app/views/vyapari/store_manager/stock_entries/_stock_bundle.html.erb +0 -61
  129. data/app/views/vyapari/store_manager/stock_entries/index.html.erb +0 -45
  130. data/app/views/vyapari/terminal_staff/dashboard/_counts.html.erb +0 -131
  131. data/app/views/vyapari/terminal_staff/dashboard/_invoices.html.erb +0 -44
  132. data/app/views/vyapari/terminal_staff/dashboard/_search_form.html.erb +0 -6
  133. data/app/views/vyapari/terminal_staff/dashboard/_search_results.html.erb +0 -24
  134. data/app/views/vyapari/terminal_staff/dashboard/index.html.erb +0 -56
  135. data/app/views/vyapari/terminal_staff/dashboard/search.js.erb +0 -12
  136. data/app/views/vyapari/terminal_staff/invoices/_draft.html.erb +0 -62
  137. data/app/views/vyapari/terminal_staff/invoices/_form.html.erb +0 -134
  138. data/app/views/vyapari/terminal_staff/invoices/_index.html.erb +0 -70
  139. data/app/views/vyapari/terminal_staff/invoices/_row.html.erb +0 -33
  140. data/app/views/vyapari/terminal_staff/invoices/_show.html.erb +0 -204
  141. data/app/views/vyapari/terminal_staff/invoices/index.html.erb +0 -35
  142. data/app/views/vyapari/terminal_staff/invoices/new.js.erb +0 -18
  143. data/app/views/vyapari/terminal_staff/invoices/show.html.erb +0 -1
  144. data/app/views/vyapari/terminal_staff/invoices/show.js.erb +0 -13
  145. data/app/views/vyapari/terminal_staff/line_items/_form.html.erb +0 -40
  146. data/app/views/vyapari/terminal_staff/line_items/_index.html.erb +0 -96
  147. data/app/views/vyapari/terminal_staff/line_items/create.js.erb +0 -34
  148. data/app/views/vyapari/terminal_staff/line_items/destroy.js.erb +0 -25
  149. data/app/views/vyapari/user_dashboard/index.html.erb +0 -51
  150. data/db/import_data/brands.csv +0 -7
  151. data/db/import_data/categories.csv +0 -12
  152. data/db/import_data/countries.csv +0 -1
  153. data/db/import_data/dummy/brands.csv +0 -7
  154. data/db/import_data/dummy/categories.csv +0 -12
  155. data/db/import_data/dummy/countries.csv +0 -1
  156. data/db/import_data/dummy/exchange_rates.csv +0 -5
  157. data/db/import_data/dummy/products-copy.csv +0 -1
  158. data/db/import_data/dummy/products.csv +0 -1
  159. data/db/import_data/dummy/products.xlsx +0 -0
  160. data/db/import_data/dummy/regions.csv +0 -13
  161. data/db/import_data/dummy/stores.csv +0 -10
  162. data/db/import_data/dummy/suppliers.csv +0 -14
  163. data/db/import_data/dummy/terminals.csv +0 -11
  164. data/db/import_data/exchange_rates.csv +0 -5
  165. data/db/import_data/regions.csv +0 -13
  166. data/db/import_data/stores.csv +0 -3
  167. data/db/import_data/suppliers.csv +0 -14
  168. data/db/import_data/terminals.csv +0 -3
  169. data/db/migrate/20170000000203_create_contacts.rb +0 -22
  170. data/db/migrate/20170000000204_create_bank_accounts.rb +0 -21
  171. data/db/migrate/20170000000205_create_suppliers.rb +0 -18
  172. data/db/migrate/20170000000206_create_stores.rb +0 -21
  173. data/db/migrate/20170000000207_create_terminals.rb +0 -18
  174. data/db/migrate/20170000000210_create_brands.rb +0 -14
  175. data/db/migrate/20170000000211_create_categories.rb +0 -22
  176. data/db/migrate/20170000000212_create_products.rb +0 -29
  177. data/db/migrate/20170000000213_create_invoices.rb +0 -61
  178. data/db/migrate/20170000000215_create_stock_bundles.rb +0 -17
  179. data/db/migrate/20170000000216_create_stock_entries.rb +0 -20
  180. data/db/sample_reports/products.xlsx +0 -0
  181. data/lib/tasks/vyapari/all.rake +0 -73
@@ -1,132 +0,0 @@
1
- module Vyapari
2
- module StoreManager
3
- module Reports
4
- class StockController < Vyapari::StoreManager::BaseController
5
-
6
-
7
- # select MAX(p.id) as id, MAX(p.name) as name,
8
- # MAX(p.ean_sku) as ean_sku,
9
- # MAX(p.purchased_price) as purchased_price,
10
- # MAX(p.landed_price) as landed_price,
11
- # MAX(p.selling_price) as selling_price,
12
- # MAX(p.retail_price) as retail_price,
13
- # SUM(se.quantity) as se_quantity,
14
- # MAX(se.status) as se_status
15
- # from products p left join stock_entries se
16
- # on se.product_id = p.id group by p.id;
17
- def index
18
- @relation = Product.select("MAX(products.id) as id,
19
- MAX(products.name) as name,
20
- MAX(products.ean_sku) as ean_sku,
21
- MAX(products.purchased_price) as purchased_price,
22
- MAX(products.landed_price) as landed_price,
23
- MAX(products.selling_price) as selling_price,
24
- MAX(products.retail_price) as retail_price,
25
- MAX(se.status) as se_status,
26
- SUM(se.quantity) as se_quantity").
27
- joins("LEFT JOIN stock_entries se ON se.product_id = products.id")
28
-
29
- parse_filters
30
- apply_filters
31
-
32
- @results = @relation.group("products.id")
33
- @total = @relation.except(:select).
34
- select("SUM(products.id) as id,
35
- SUM(products.purchased_price) as purchased_price,
36
- SUM(products.landed_price) as landed_price,
37
- SUM(products.selling_price) as selling_price,
38
- SUM(products.retail_price) as retail_price")
39
-
40
- render_report
41
- end
42
-
43
- private
44
-
45
- def apply_filters
46
- @relation = @relation.search(@query) if @query
47
- # @relation = @relation.where("se.se_status = ?", @status) if @status
48
-
49
- @order_by = "products.name ASC, products.ean_sku ASC" unless @order_by
50
- @relation = @relation.order(@order_by)
51
- end
52
-
53
- def configure_filter_settings
54
- @filter_settings = {
55
- string_filters: [
56
- { filter_name: :query },
57
- { filter_name: :status, options: {default: :pending} }
58
- ],
59
-
60
- reference_filters: [
61
- { filter_name: :brand, filter_class: Brand },
62
- { filter_name: :category, filter_class: Category },
63
- ],
64
-
65
- variable_filters: [
66
- { variable_name: :store, filter_name: :store },
67
- { variable_name: :terminal, filter_name: :terminal },
68
- ]
69
- }
70
- end
71
-
72
- def configure_filter_ui_settings
73
- @filter_ui_settings = {}
74
- end
75
-
76
- def filter_config_ui
77
- return @filter_config_ui if @filter_config_ui
78
- @filter_config_ui = {
79
- brand: {
80
- object_filter: true,
81
- display_name: 'Select Brand',
82
- current_value: @brand,
83
- values: Brand.order(:name).all,
84
- current_filters: @filters,
85
- url_method_name: 'root_url',
86
- filters_to_remove: [:terminal, :store],
87
- filters_to_add: {},
88
- show_null_filter_on_top: true
89
- },
90
- category: {
91
- object_filter: true,
92
- display_name: 'Select Brand Category',
93
- current_value: @category,
94
- values: Category.order(:name).all,
95
- current_filters: @filters,
96
- url_method_name: 'root_url',
97
- filters_to_remove: [:terminal, :store],
98
- filters_to_add: {},
99
- show_null_filter_on_top: true
100
- }
101
- }
102
- end
103
-
104
- def breadcrumbs_configuration
105
- {
106
- heading: "Stock Report",
107
- description: "In Stock Report",
108
- links: [{name: "Home", link: user_dashboard_path, icon: 'fa-dashboard'},
109
- {name: "Reports", link: user_dashboard_path, icon: 'fa-calendar', active: true}]
110
- }
111
- end
112
-
113
- def set_navs
114
- set_nav("store_manager/reports")
115
- end
116
-
117
- def render_report
118
- respond_to do |format|
119
- format.html {}
120
- format.csv { send_data generate_csv(@results), filename: "#{params[:action]}_#{Date.today}.csv" }
121
- format.pdf do
122
- render :pdf => "#{@heading} (As on #{Date.today})"
123
- #:disposition => 'attachment'
124
- #:show_as_html => true
125
- end
126
- end
127
- end
128
-
129
- end
130
- end
131
- end
132
- end
@@ -1,17 +0,0 @@
1
- module Vyapari
2
- module StoreManager
3
- class ResourceController < Vyapari::StoreManager::BaseController
4
-
5
- include ResourceHelper
6
-
7
- before_action :configure_resource_controller, :set_navs
8
-
9
- private
10
-
11
- def resource_url(obj)
12
- url_for([:store_manager, obj.stock, obj])
13
- end
14
-
15
- end
16
- end
17
- end
@@ -1,206 +0,0 @@
1
- module Vyapari
2
- module StoreManager
3
- class StockBundlesController < ResourceController
4
-
5
- def index
6
- get_collections
7
- respond_to do |format|
8
- format.html {}
9
- format.js {
10
- js_view_path = @resource_options && @resource_options[:js_view_path] ? "#{@resource_options[:js_view_path]}/index" : :index
11
- render js_view_path
12
- }
13
- end
14
- end
15
-
16
- def show
17
- @stock_bundle = @r_object = @resource_options[:class].find_by_id(params[:id])
18
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize)) unless @r_object
19
- render_accordingly
20
- end
21
-
22
- def download_original_file
23
- @stock_bundle = @r_object = @resource_options[:class].find_by_id(params[:id])
24
- send_file @stock_bundle.file.file.path
25
- end
26
-
27
- def download_error_file
28
- @stock_bundle = @r_object = @resource_options[:class].find_by_id(params[:id])
29
- send_file @stock_bundle.error_file.file.path
30
- end
31
-
32
- def new
33
- @stock_bundle = @r_object = @resource_options[:class].new(store: @store)
34
- render_accordingly
35
- end
36
-
37
- def edit
38
- @stock_bundle = @r_object = @resource_options[:class].find_by_id(params[:id])
39
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize)) unless @r_object
40
- render_accordingly
41
- end
42
-
43
- def create
44
- @stock_bundle = @r_object = @resource_options[:class].new(store: @store)
45
- @stock_bundle.assign_attributes(permitted_params)
46
- @stock_bundle.store = @store
47
- @stock_bundle.status = :pending
48
-
49
- @stock_bundle.uploader = @current_user
50
- @stock_bundle.uploaded_date = Time.now
51
-
52
- if @stock_bundle.valid?
53
- @stock_bundle.save!
54
- if @stock_bundle.parse_stocks
55
- @stock_bundle.approve!
56
- set_flash_message("#{I18n.t('status.success')} - #{I18n.t('state.changed', item: default_item_name.titleize, new_state: "uploaded")}", :success)
57
- set_notification(true, I18n.t('status.success'), I18n.t('state.changed', item: default_item_name.titleize, new_state: "uploaded"))
58
- else
59
- message = "Stock Bundle #{@stock_bundle.display_name} has been uploaded successfully. However, some of the jobs had some data issues. You need to approve this job bundle manually."
60
- set_flash_message(message, :warning)
61
- set_notification(false, I18n.t('status.error'), message)
62
- end
63
- else
64
- message = "Error! Stock Bundle #{@stock_bundle.display_name} was not uploaded. #{@stock_bundle.errors.full_messages.to_sentence}"
65
- puts "Error! #{message}".red
66
- set_flash_message(message = message, :danger)
67
- set_notification(false, I18n.t('status.error'), message)
68
- end
69
-
70
- render layout: "kuppayam/document_upload"
71
-
72
- end
73
-
74
- def update
75
- @stock_bundle = @r_object = @resource_options[:class].find_by_id(params[:id])
76
- @stock_bundle.assign_attributes(permitted_params)
77
- @stock_bundle.store = @store
78
- @stock_bundle.status = :pending
79
-
80
- @stock_bundle.uploader = @current_user
81
- @stock_bundle.uploaded_date = Time.now
82
-
83
- if @stock_bundle.valid?
84
- @stock_bundle.save!
85
- if @stock_bundle.parse_stocks
86
- @stock_bundle.approve!
87
- set_flash_message("#{I18n.t('status.success')} - #{I18n.t('state.changed', item: default_item_name.titleize, new_state: "uploaded")}", :success)
88
- set_notification(true, I18n.t('status.success'), I18n.t('state.changed', item: default_item_name.titleize, new_state: "uploaded"))
89
- else
90
- message = "Stock Bundle #{@stock_bundle.display_name} has been uploaded successfully. However, some of the jobs had some data issues. You need to approve this job bundle manually."
91
- set_flash_message(message, :warning)
92
- set_notification(false, I18n.t('status.error'), message)
93
- end
94
- else
95
- message = "Error! Stock Bundle #{@stock_bundle.display_name} was not uploaded. #{@stock_bundle.errors.full_messages.to_sentence}"
96
- puts "Error! #{message}".red
97
- set_flash_message(message = message, :danger)
98
- set_notification(false, I18n.t('status.error'), message)
99
- end
100
-
101
- render layout: "kuppayam/document_upload"
102
-
103
- end
104
-
105
- def destroy
106
- @stock_bundle = @r_object = @resource_options[:class].find_by_id(params[:id])
107
- if @r_object
108
- if @r_object.can_be_deleted?
109
- @r_object.destroy
110
- get_collections
111
- set_flash_message(I18n.t('success.deleted'), :success)
112
- set_notification(false, I18n.t('status.success'), I18n.t('success.deleted', item: default_item_name.titleize))
113
- @destroyed = true
114
- else
115
- message = I18n.t('errors.failed_to_delete', item: default_item_name.titleize)
116
- set_flash_message(message, :failure)
117
- set_notification(false, I18n.t('status.error'), message)
118
- @destroyed = false
119
- end
120
- else
121
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize))
122
- end
123
-
124
- respond_to do |format|
125
- format.html {}
126
- format.js {
127
- js_view_path = @resource_options && @resource_options[:js_view_path] ? "#{@resource_options[:js_view_path]}/destroy" : :destroy
128
- render js_view_path
129
- }
130
- end
131
-
132
- end
133
-
134
- private
135
-
136
- def get_collections
137
- @relation = @store.stock_bundles.includes(:store, :supplier, :uploader).where("")
138
-
139
- parse_filters
140
- apply_filters
141
-
142
- @stock_bundles = @r_objects = @relation.page(@current_page).per(@per_page)
143
-
144
- return true
145
- end
146
-
147
- def apply_filters
148
- @relation = @relation.search(@query) if @query
149
-
150
- @order_by = "created_at desc" unless @order_by
151
- @relation = @relation.order(@order_by)
152
- end
153
-
154
- def configure_filter_settings
155
- @filter_settings = {
156
- string_filters: [
157
- { filter_name: :query }
158
- ],
159
- boolean_filters: [],
160
- reference_filters: [],
161
- variable_filters: [],
162
- }
163
- end
164
-
165
- def configure_filter_ui_settings
166
- @filter_ui_settings = {}
167
- end
168
-
169
- def resource_url(obj)
170
- url_for([:admin, obj.store, obj])
171
- end
172
-
173
- def resource_controller_configuration
174
- {
175
- collection_name: :stock_bundles,
176
- item_name: :stock_bundle,
177
- class: StockBundle,
178
- page_title: "#{@store.name} - Stock Bundle",
179
- js_view_path: "/kuppayam/workflows/peacock",
180
- view_path: "/vyapari/store_manager/stock_bundles"
181
- }
182
- end
183
-
184
- def breadcrumbs_configuration
185
- {
186
- heading: "#{@store.name} - Stock Bundle",
187
- description: "Listing all the stock at #{@store.name}",
188
- links: [
189
- {name: "Home", link: user_dashboard_path, icon: 'fa-dashboard'},
190
- {name: @store.name, link: store_manager_dashboard_path(@store), icon: 'fa-dashboard'},
191
- {name: "Stock Bundle", link: nil, icon: 'fa-truck', active: true}
192
- ]
193
- }
194
- end
195
-
196
- def permitted_params
197
- params.require(:stock_bundle).permit(:name, :supplier_id, :file)
198
- end
199
-
200
- def set_navs
201
- set_nav("store_manager/stocks")
202
- end
203
-
204
- end
205
- end
206
- end
@@ -1,161 +0,0 @@
1
- module Vyapari
2
- module StoreManager
3
- class StockEntriesController < ResourceController
4
-
5
- def index
6
- get_collections
7
- respond_to do |format|
8
- format.html {}
9
- format.js {
10
- js_view_path = @resource_options && @resource_options[:js_view_path] ? "#{@resource_options[:js_view_path]}/index" : :index
11
- render js_view_path
12
- }
13
- end
14
- end
15
-
16
- def show
17
- @stock_entry = @r_object = @resource_options[:class].find_by_id(params[:id])
18
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize)) unless @r_object
19
- render_accordingly
20
- end
21
-
22
- def new
23
- @stock_entry = @r_object = @resource_options[:class].new(store: @store)
24
- render_accordingly
25
- end
26
-
27
- def edit
28
- @stock_entry = @r_object = @resource_options[:class].find_by_id(params[:id])
29
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize)) unless @r_object
30
- render_accordingly
31
- end
32
-
33
- def create
34
- @stock_entry = @r_object = @resource_options[:class].new(store: @store)
35
- @r_object.assign_attributes(permitted_params)
36
- @r_object.store = @store
37
- save_resource
38
- end
39
-
40
- def update
41
- @stock_entry = @r_object = @resource_options[:class].find_by_id(params[:id])
42
- if @r_object
43
- @r_object.assign_attributes(permitted_params)
44
- @r_object.store = @store
45
- save_resource
46
- else
47
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize))
48
- end
49
- end
50
-
51
- def destroy
52
- @stock_entry = @r_object = @resource_options[:class].find_by_id(params[:id])
53
- if @r_object
54
- if @r_object.can_be_deleted?
55
- @r_object.destroy
56
- get_collections
57
- set_flash_message(I18n.t('success.deleted'), :success)
58
- set_notification(false, I18n.t('status.success'), I18n.t('success.deleted', item: default_item_name.titleize))
59
- @destroyed = true
60
- else
61
- message = I18n.t('errors.failed_to_delete', item: default_item_name.titleize)
62
- set_flash_message(message, :failure)
63
- set_notification(false, I18n.t('status.error'), message)
64
- @destroyed = false
65
- end
66
- else
67
- set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize))
68
- end
69
-
70
- respond_to do |format|
71
- format.html {}
72
- format.js {
73
- js_view_path = @resource_options && @resource_options[:js_view_path] ? "#{@resource_options[:js_view_path]}/destroy" : :destroy
74
- render js_view_path
75
- }
76
- end
77
-
78
- end
79
-
80
- private
81
-
82
- def get_collections
83
- @relation = @store.stock_entries.includes(:product, :supplier).where("")
84
-
85
- parse_filters
86
- apply_filters
87
-
88
- @stock_entries = @r_objects = @relation.page(@current_page).per(@per_page)
89
-
90
- return true
91
- end
92
-
93
- def apply_filters
94
-
95
- @relation = @relation.search(@query) if !@query.blank?
96
-
97
- if @stock_bundle == "null"
98
- @relation = @relation.where("stock_entries.stock_bundle_id IS NULL")
99
- elsif @stock_bundle
100
- @relation = @relation.where("stock_entries.stock_bundle_id = ?", @stock_bundle.id)
101
- end
102
-
103
- @order_by = "created_at desc" unless @order_by
104
- @relation = @relation.order(@order_by)
105
- end
106
-
107
- def configure_filter_settings
108
- @filter_settings = {
109
- string_filters: [
110
- { filter_name: :query }
111
- ],
112
- boolean_filters: [],
113
- reference_filters: [
114
- { filter_name: :stock_bundle, filter_class: StockBundle },
115
- ],
116
- variable_filters: [],
117
- }
118
- end
119
-
120
- def configure_filter_ui_settings
121
- @filter_ui_settings = {}
122
- end
123
-
124
- def resource_url(obj)
125
- url_for([:admin, obj.store, obj])
126
- end
127
-
128
- def resource_controller_configuration
129
- {
130
- collection_name: :stock_entries,
131
- item_name: :stock_entry,
132
- class: StockEntry,
133
- page_title: "#{@store.name} - Stock",
134
- js_view_path: "/kuppayam/workflows/parrot",
135
- view_path: "/vyapari/store_manager/stock_entries"
136
- }
137
- end
138
-
139
- def breadcrumbs_configuration
140
- {
141
- heading: "#{@store.name} - Stock",
142
- description: "Listing all the stock at #{@store.name}",
143
- links: [
144
- {name: "Home", link: user_dashboard_path, icon: 'fa-dashboard'},
145
- {name: @store.name, link: store_manager_dashboard_path(@store), icon: 'fa-dashboard'},
146
- {name: "Stock Entries", link: nil, icon: 'fa-truck', active: true}
147
- ]
148
- }
149
- end
150
-
151
- def permitted_params
152
- params.require(:stock_entry).permit(:product_id, :quantity, :status)
153
- end
154
-
155
- def set_navs
156
- set_nav("store_manager/stocks")
157
- end
158
-
159
- end
160
- end
161
- end