educode_sales 0.7.0 → 0.7.3

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/businesses_controller.rb +19 -3
  3. data/app/controllers/educode_sales/follow_ups_controller.rb +15 -3
  4. data/app/controllers/educode_sales/money_plans_controller.rb +2 -2
  5. data/app/controllers/educode_sales/operation_plans_controller.rb +5 -2
  6. data/app/controllers/educode_sales/plans_controller.rb +3 -2
  7. data/app/controllers/educode_sales/results_controller.rb +54 -0
  8. data/app/controllers/educode_sales/sale_trends_controller.rb +116 -116
  9. data/app/controllers/educode_sales/staffs_controller.rb +2 -0
  10. data/app/helpers/educode_sales/follow_up_helper.rb +7 -0
  11. data/app/models/educode_sales/money_plan.rb +3 -3
  12. data/app/models/educode_sales/result.rb +4 -0
  13. data/app/views/educode_sales/businesses/edit_follow_record.html.erb +150 -114
  14. data/app/views/educode_sales/businesses/edit_plan.html.erb +4 -4
  15. data/app/views/educode_sales/businesses/export_records.json.jbuilder +1 -2
  16. data/app/views/educode_sales/businesses/get_export_data.json.jbuilder +2 -1
  17. data/app/views/educode_sales/businesses/index.html.erb +132 -109
  18. data/app/views/educode_sales/businesses/index.json.jbuilder +3 -2
  19. data/app/views/educode_sales/businesses/new_follow_record.html.erb +156 -119
  20. data/app/views/educode_sales/businesses/show_follow.html.erb +37 -25
  21. data/app/views/educode_sales/businesses/show_follow.json.jbuilder +2 -0
  22. data/app/views/educode_sales/businesses/show_follow_record.html.erb +8 -1
  23. data/app/views/educode_sales/customers/index.html.erb +1 -2
  24. data/app/views/educode_sales/customers/show_follow.html.erb +1 -1
  25. data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -1
  26. data/app/views/educode_sales/follow_ups/money_plans.json.jbuilder +2 -4
  27. data/app/views/educode_sales/money_plans/index.html.erb +1 -1
  28. data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +8 -3
  29. data/app/views/educode_sales/operation_plans/_monthly.html.erb +2 -2
  30. data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +2 -2
  31. data/app/views/educode_sales/operation_plans/_weekly.html.erb +2 -2
  32. data/app/views/educode_sales/plans/_monthPlan.html.erb +8 -3
  33. data/app/views/educode_sales/plans/_monthly.html.erb +2 -2
  34. data/app/views/educode_sales/plans/_weekPlan.html.erb +2 -2
  35. data/app/views/educode_sales/plans/_weekly.html.erb +2 -2
  36. data/app/views/educode_sales/results/edit.html.erb +111 -0
  37. data/app/views/educode_sales/results/index.html.erb +0 -0
  38. data/app/views/educode_sales/results/index.json.jbuilder +13 -0
  39. data/app/views/educode_sales/results/new.html.erb +58 -0
  40. data/app/views/educode_sales/results/show.json.jbuilder +9 -0
  41. data/app/views/educode_sales/roles/edit.html.erb +1 -1
  42. data/app/views/educode_sales/sale_reports/audit.html.erb +2 -0
  43. data/app/views/educode_sales/sale_reports/edit.html.erb +2 -0
  44. data/app/views/educode_sales/sale_reports/show.html.erb +2 -0
  45. data/app/views/educode_sales/sales/index.html.erb +7 -7
  46. data/app/views/educode_sales/teachers/show_follow.html.erb +1 -1
  47. data/app/views/layouts/educode_sales/application.html.erb +9 -3
  48. data/config/routes.rb +7 -1
  49. data/db/migrate/20220314053856_add_service_start_time_to_follow_ups.rb +6 -0
  50. data/db/migrate/20220314074354_add_service_time_long_to_follow_ups.rb +5 -0
  51. data/lib/educode_sales/version.rb +1 -1
  52. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c243136aa29c06071bc7f5178e7c6eab7a7711c29a664ed12b4141b823102e1
4
- data.tar.gz: db224456ae6c27346fadb5ae65b2ed6973ba11e1c384f2b833f994e6371540cb
3
+ metadata.gz: 32e3ce754e3aeac0c5f424b9188254b88b1da494feb591b5eb1e2d100f0362c2
4
+ data.tar.gz: 2be5f9d03ccc4781ff534e59ffe8aee273185a0d635c08ca09e60403a4b4d221
5
5
  SHA512:
6
- metadata.gz: a5df7256338dc4a0bcc7f3ef6933c573f79b186a77ba12fcb10bcbfc80a11cfb3253d57ae2ea2325346a76c089fe9c9a71751407697bb4e3706ee6b58e11abf1
7
- data.tar.gz: fa152803f2738331a1324e530275b6c31ff0420f5f725c537587b754555ae6eaeb0ce4bf5e522ef81ae109224e74b65effdf4435e7cb71e88fd11d6409c42580
6
+ metadata.gz: ec4b1594bcc4ac5766e6e3c0fc189f17b8b24b0789328ee1ed75a33022438b6d5f2c2c78f221ae6bf3db2dbb9b4253f7d5f428df24f6c336aa0a3ea5bd081aaf
7
+ data.tar.gz: '082c2c1a08570db3b4ea942c932c73ad08fd2e2bde8b4be2cff38816a4d3eed64bf503fb151ece68a0140e2db841c153923335fcf10d1142370b41f8f6a10a2f'
@@ -152,11 +152,16 @@ module EducodeSales
152
152
  JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
153
153
  ").where("educode_sales_follow_ups.stage_id in (?)", params[:q][:business_step].split(",").map(&:to_i))
154
154
  end
155
- if params[:q].present? && params[:q][:place_id].present?
155
+ if params[:q].present? && params[:q][:place_id].present?
156
156
  @businesses = @businesses.joins("
157
157
  JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
158
158
  ").where("educode_sales_follow_ups.place_id = ?", params[:q][:place_id])
159
159
  end
160
+ if params[:q].present? && params[:q][:business_year].present?
161
+ @businesses = @businesses.joins("
162
+ JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
163
+ ").where("educode_sales_follow_ups.year = ?", params[:q][:business_year])
164
+ end
160
165
 
161
166
  if params[:q].present? && params[:q][:area].present?
162
167
  p = EducodeSales::Common.find(params[:q][:area]).name
@@ -193,7 +198,11 @@ module EducodeSales
193
198
  end
194
199
 
195
200
  if params[:sort].present? && params[:sort][:field]
196
- @businesses = @businesses.order("#{params[:sort][:field]} #{params[:sort][:order]}")
201
+ if params[:sort][:field] = "service_end_time"
202
+ @businesses = @businesses.order("service_time_long #{params[:sort][:order]}")
203
+ else
204
+ @businesses = @businesses.order("#{params[:sort][:field]} #{params[:sort][:order]}")
205
+ end
197
206
  else
198
207
  @businesses = @businesses.order("educode_sales_businesses.created_at desc")
199
208
  end
@@ -203,9 +212,13 @@ module EducodeSales
203
212
  @businesses = @businesses.select("
204
213
  educode_sales_businesses.*,
205
214
  last_follow.invitation_at,
215
+ last_follow.service_time_long,
216
+ last_follow.service_end_time,
217
+ last_follow.service_start_time,
206
218
  last_follow.reception_at,
207
219
  last_follow.bidded_date,
208
220
  last_follow.signed_date,
221
+ last_follow.year,
209
222
  last_follow.created_at as latest_time,
210
223
  last_follow.actual_amount,
211
224
  (last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
@@ -370,7 +383,7 @@ module EducodeSales
370
383
  render layout: false
371
384
  end
372
385
  format.json do
373
- @records = BusinessExportRecord.all.page(params[:page]).per(params[:limit])
386
+ @records = BusinessExportRecord.all.order(id: :desc).page(params[:page]).per(params[:limit])
374
387
  end
375
388
  end
376
389
  end
@@ -553,6 +566,9 @@ module EducodeSales
553
566
  educode_sales_businesses.*,
554
567
  last_follow.invitation_at,
555
568
  last_follow.reception_at,
569
+ last_follow.service_time_long,
570
+ last_follow.service_end_time,
571
+ last_follow.service_start_time,
556
572
  last_follow.bidded_date,
557
573
  last_follow.signed_date,
558
574
  last_follow.created_at as latest_time,
@@ -20,7 +20,7 @@ module EducodeSales
20
20
  business_ids = @businesses.pluck(:id)
21
21
  @follow_ups = FollowUp.where(business_id: business_ids)
22
22
  when '区域'
23
- school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
23
+ school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
24
24
  business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
25
25
  @businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_businesses.staff_id = #{@current_admin.id} OR educode_sales_businesses.id in (?)", school_ids, business_ids)
26
26
  business_ids = @businesses.pluck(:id)
@@ -63,11 +63,17 @@ module EducodeSales
63
63
  def create
64
64
  load_business
65
65
  follow_up = @business.follow_ups.build(follow_up_params)
66
+ if params[:service_time].present?
67
+ date = params[:service_time].split(" - ")
68
+ follow_up.service_start_time = date[0]
69
+ follow_up.service_end_time = date[1]
70
+ follow_up.service_time_long = (date[1].to_date - date[0].to_date).to_i
71
+ end
66
72
  follow_up.staff = @current_admin
67
73
  params[:assign_follow_up].each do |d|
68
74
  follow_up.assign_follow_ups.build(staff_id: d)
69
75
  end
70
-
76
+
71
77
  follow_up.profit_amount = follow_up.actual_amount - (follow_up.divide_amount.to_i) if follow_up.actual_amount
72
78
  if follow_up.save
73
79
  if @business.last_follow_up.present?
@@ -95,7 +101,7 @@ module EducodeSales
95
101
  business = follow_up.business
96
102
  if follow_up.soft_destroy(@current_admin.id)
97
103
  if follow_up.id == business.last_follow_up_id
98
- business.update(last_follow_up: business.follow_ups.last, return_money: MoneyPlan.where(clazz: '已完成', follow_up_id: business.follow_ups.last&.id).sum(:amount))
104
+ business.update(last_follow_up: business.follow_ups.last, return_money: MoneyPlan.where(clazz: '实际回款', follow_up_id: business.follow_ups.last&.id).sum(:amount))
99
105
  end
100
106
  render_success
101
107
  else
@@ -106,6 +112,12 @@ module EducodeSales
106
112
  def update
107
113
  follow_up = FollowUp.find(params[:id])
108
114
  follow_up.assign_attributes(follow_up_params)
115
+ if params[:service_time].present?
116
+ date = params[:service_time].split(" - ")
117
+ follow_up.service_start_time = date[0]
118
+ follow_up.service_end_time = date[1]
119
+ follow_up.service_time_long = (date[1].to_date - date[0].to_date).to_i
120
+ end
109
121
  assign_follow_ups = []
110
122
  params[:assign_follow_up].each do |d|
111
123
  assign_follow_ups << follow_up.assign_follow_ups.find_or_initialize_by(staff_id: d)
@@ -21,11 +21,11 @@ module EducodeSales
21
21
  when '自己'
22
22
  @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.id)
23
23
  when '区域'
24
- a_ids = MoneyPlan.where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.id).ids
24
+ a_ids = MoneyPlan.where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.id).pluck(:follow_up_id)
25
25
  school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
26
26
  b_ids = Business.where(school_id: school_ids).pluck(:last_follow_up_id)
27
27
  ids = a_ids + b_ids
28
- @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(id: ids)
28
+ @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: ids)
29
29
  else
30
30
  @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: follow_up_ids)
31
31
  end
@@ -20,8 +20,11 @@ module EducodeSales
20
20
  when '自己'
21
21
  @sale_plans = OperationPlan.where(staff_id: @current_admin.id)
22
22
  when '区域'
23
- staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?) OR schools.id in (?)", @current_admin.areas.pluck(:name), StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)).pluck(:id)
24
- @sale_plans = OperationPlan.where("staff_id in (?) OR educode_sales_operation_plans.staff_id = ?", staff_ids, @current_admin.id)
23
+ staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
24
+ school_ids = StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
25
+ department_ids = Department.where(school_id: school_ids).pluck(:id)
26
+ teacher_ids = Teacher.where(department_id: department_ids).pluck(:id)
27
+ @sale_plans = OperationPlan.where("staff_id in (?) OR educode_sales_operation_plans.staff_id = ? OR educode_sales_operation_plans.teacher_id in (?)", staff_ids, @current_admin.id,teacher_ids)
25
28
  else
26
29
  @sale_plans = OperationPlan
27
30
  end
@@ -21,8 +21,9 @@ module EducodeSales
21
21
  when '自己'
22
22
  @sale_plans = SalePlan.where(staff_id: @current_admin.id)
23
23
  when '区域'
24
- staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?) OR schools.id in (?)", @current_admin.areas.pluck(:name),StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)).pluck(:id)
25
- @sale_plans = SalePlan.where("staff_id in (?) OR educode_sales_sale_plans.staff_id = ?", staff_ids, @current_admin.id)
24
+ staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
25
+ business_ids = Business.where(school_id: StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)).pluck(:id)
26
+ @sale_plans = SalePlan.where("staff_id in (?) OR educode_sales_sale_plans.staff_id = ? OR educode_sales_sale_plans.business_id in (?)", staff_ids, @current_admin.id,business_ids)
26
27
  else
27
28
  @sale_plans = SalePlan
28
29
  end
@@ -0,0 +1,54 @@
1
+ require_dependency "educode_sales/application_controller"
2
+
3
+ module EducodeSales
4
+ class ResultsController < ApplicationController
5
+
6
+ def index
7
+ respond_to do |format|
8
+ format.html do
9
+ end
10
+ format.json do
11
+ # @commons = Common.group("clazz").page(params[:page]).per(params[:limit])
12
+ end
13
+ end
14
+ end
15
+
16
+ # def create
17
+ # common = Common.new(name: params[:name], clazz: params[:clazz])
18
+ # if common.save
19
+ # render_success
20
+ # else
21
+ # render_failure common
22
+ # end
23
+ # end
24
+ #
25
+ # def edit
26
+ # @common = Common.find(params[:id])
27
+ # render layout: false
28
+ # end
29
+ #
30
+ # def update
31
+ # common = Common.find(params[:id])
32
+ # if common.update(common_params)
33
+ # render_success
34
+ # else
35
+ # render_failure common
36
+ # end
37
+ # end
38
+ #
39
+ # def new
40
+ # render layout: false
41
+ # end
42
+ #
43
+ # def show
44
+ # commons = Common.find(params[:id])
45
+ # @commons = Common.where(clazz: commons.clazz).order('position')
46
+ # end
47
+ #
48
+ # private
49
+ #
50
+ # def common_params
51
+ # params.permit(:name, :position)
52
+ # end
53
+ end
54
+ end