educode_sales 0.9.5 → 0.9.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4077a88dda68d0d254896b4edb4b5e4595837753a46af5928bcf9f9a77deb5de
4
- data.tar.gz: 2d0aec24b5793b9ff61095a48e175a7a7d3d6f118588f4497284d67f05cccbd4
3
+ metadata.gz: 2452ba0a38c51eeb2288c262c3749009e8a73482fa5bb3762cf3d8cac604f7fd
4
+ data.tar.gz: c0d98a9cb2d391b3a5c4600bf317c5d47aeb0fc14d8ca95ef12a049f228a67c3
5
5
  SHA512:
6
- metadata.gz: 447ee2216fa0b7a01275361ef69aee2dbc998543e4bc92419f672eb2d5e5ebf9c134018544a61d45497e0ed970c6ad407bb1ebc8431104f1b6ece973528d73b1
7
- data.tar.gz: e9392595b91bd5353f785b586c7bef4367c087eb13b1de1285968f84b9758fb7c967fed2306c25098c056dd4e214870dad8e755ef2f305581f2460bb9692bc0d
6
+ metadata.gz: 523896d3267cec4e5bf9681e8d15b02af20dcdfa1fba104a8f698fffac80f0f553627480f0e8a71df4052a46b8402e92d34b0daac34005cfb347a25395b9546d
7
+ data.tar.gz: f80418f62799d2ccb0c8ed839cb3c5e1aa0cb0e941f666eef5b2e596ff273ec02b5c6a0fda81154631d588bde03aabc0d6cf3a0ca10f7eac2f35f43b91e75a7d
@@ -88,7 +88,7 @@ module EducodeSales
88
88
 
89
89
  end
90
90
 
91
- if params[:q].present? && params[:q][:name].present? && params[:q][:name] == "(销售态势-" + @year + "-已中标商机)"
91
+ if params[:q].present? && params[:q][:name].present? && (params[:q][:name] == "(销售态势-" + @year + "-已中标商机)" || params[:q][:name] == "(销售态势-" + @year + "-应收款商机)")
92
92
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
93
93
  if @year == '全部'
94
94
  @businesses = @businesses.joins("
@@ -119,10 +119,11 @@ module EducodeSales
119
119
  x_id = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
120
120
  year_time = "#{@year}-01-01 00:00:00"
121
121
  year_over_time = "#{@year}-12-31 23:59:59"
122
+ money_plan_clazz = 1
122
123
  if @year == '全部'
123
- @businesses = @businesses.joins(follow_ups: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x_id).where.not("educode_sales_money_plans.clazz!= ?", 1).distinct
124
+ @businesses = @businesses.joins(follow_ups: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x_id).where.not("educode_sales_money_plans.clazz!= ?", money_plan_clazz).distinct
124
125
  else
125
- @businesses = @businesses.joins(follow_ups: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x_id).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).distinct
126
+ @businesses = @businesses.joins(follow_ups: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x_id).where.not("educode_sales_money_plans.clazz!= ?", money_plan_clazz).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).distinct
126
127
  end
127
128
  end
128
129
 
@@ -137,7 +138,7 @@ module EducodeSales
137
138
  end
138
139
 
139
140
  @businesses = @businesses
140
- if params[:q].present? && params[:q][:name].present? && params[:q][:name] != "(销售态势-" + @year + "-已中标商机)" && params[:q][:name] != "(销售态势-" + @year + "-已签单商机)" && params[:q][:name] != "(销售态势-" + @year + "-已回款商机)" && params[:q][:name] != "(销售态势-" + @year + "-现有商机)"
141
+ if params[:q].present? && params[:q][:name].present? && params[:q][:name] != "(销售态势-" + @year + "-已中标商机)" && params[:q][:name] != "(销售态势-" + @year + "-已签单商机)" && params[:q][:name] != "(销售态势-" + @year + "-已回款商机)" && params[:q][:name] != "(销售态势-" + @year + "-现有商机)" && params[:q][:name] != "(销售态势-" + @year + "-应收款商机)"
141
142
  @businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:q][:name]}%")
142
143
  end
143
144
  if params[:q].present? && params[:q][:department].present?
@@ -460,7 +461,7 @@ module EducodeSales
460
461
 
461
462
  end
462
463
 
463
- if params[:name].present? && params[:name] == "(销售态势-" + @year + "-已中标商机)"
464
+ if params[:name].present? && (params[:name] == "(销售态势-" + @year + "-已中标商机)" || params[:name] == "(销售态势-" + @year + "-应收款商机)")
464
465
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
465
466
  if @year == '全部'
466
467
  @businesses = @businesses.joins("
@@ -509,7 +510,7 @@ module EducodeSales
509
510
  end
510
511
 
511
512
  @businesses = @businesses
512
- if params[:name].present? && params[:name] != "(销售态势-" + @year + "-已中标商机)" && params[:name] != "(销售态势-" + @year + "-已签单商机)" && params[:name] != "(销售态势-" + @year + "-已回款商机)" && params[:name] != "(销售态势-" + @year + "-现有商机)"
513
+ if params[:name].present? && params[:name] != "(销售态势-" + @year + "-已中标商机)" && params[:name] != "(销售态势-" + @year + "-已签单商机)" && params[:name] != "(销售态势-" + @year + "-已回款商机)" && params[:name] != "(销售态势-" + @year + "-现有商机)"&& params[:name] != "(销售态势-" + @year + "-应收款商机)"
513
514
  @businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:name]}%")
514
515
  end
515
516
  if params[:department].present?
@@ -13,12 +13,18 @@ module EducodeSales
13
13
  if (@year == '全部')
14
14
  @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).sum(:total_amount).round(2)
15
15
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标', '已签单', '已验收', '回款中', '服务中', '已结束']).pluck(:id)
16
- @goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", stage_ids).sum(:total_amount).round(2)
16
+ # 中标总金额, 已回款总金额
17
+ total_return = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", stage_ids).select("sum(total_amount) AS total, sum(educode_sales_businesses.return_money) AS return_money")
18
+ @goal_amount = total_return[0]['total']&.round(2) || 0
19
+
17
20
  @actual_goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", stage_ids).sum(:actual_amount).round(2)
18
21
  s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单', '已验收', '回款中', '服务中', '已结束']).pluck(:id)
19
22
  @service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", s_stage_ids).sum(:total_amount).round(2)
20
23
  @actual_service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", s_stage_ids).sum(:actual_amount).round(2)
21
- @return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).sum(:amount).round(2)
24
+ # @return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).sum(:amount).round(2)
25
+ @return_amount = total_return[0]['return_money']&.round(2) || 0
26
+ @receivable_amount = @goal_amount - @return_amount
27
+
22
28
  a = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name).pluck(:id)
23
29
  @a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).sum(:total_amount).round(2)
24
30
  b = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name).pluck(:id)
@@ -26,16 +32,23 @@ module EducodeSales
26
32
  else
27
33
  year_time = "#{@year}-01-01 00:00:00"
28
34
  year_over_time = "#{@year}-12-31 23:59:59"
29
-
35
+
30
36
  @sale_trend = SaleTrend.find_or_create_by(year: @year)
31
37
  @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.year = ?", @year).sum(:total_amount).round(2)
32
38
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标', '已签单', '已验收', '回款中', '服务中', '已结束']).pluck(:id)
33
- @goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:total_amount).round(2)
39
+
40
+ # 中标总金额, 已回款总金额
41
+ total_return = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).select("sum(total_amount) AS total, sum(educode_sales_businesses.return_money) AS return_money")
42
+ @goal_amount = total_return[0]['total']&.round(2) || 0
43
+
34
44
  @actual_goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:actual_amount).round(2)
35
45
  s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单', '已验收', '回款中', '服务中', '已结束']).pluck(:id)
36
46
  @service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids).sum(:total_amount).round(2)
37
47
  @actual_service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids).sum(:actual_amount).round(2)
38
- @return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).sum(:amount).round(2)
48
+ # @return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).sum(:amount).round(2)
49
+ @return_amount = total_return[0]['return_money']&.round(2) || 0
50
+ @receivable_amount = @goal_amount - @return_amount
51
+
39
52
  a = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name).pluck(:id)
40
53
  @a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).where("educode_sales_follow_ups.year = ?", @year).sum(:total_amount).round(2)
41
54
  b = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name).pluck(:id)
@@ -63,12 +76,12 @@ module EducodeSales
63
76
  names = EducodeSales::Staff.includes(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id, d.role_id] }
64
77
  x = EducodeSales::Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
65
78
  x_business_ids = EducodeSales::Business.joins(last_follow_up: :clazz).where("educode_sales_commons.id = ?",x).pluck :id
66
-
79
+
67
80
  @follow_count_range = params[:follow_count_range] || "week"
68
81
  # 商机跟进数图表
69
82
  respond_to do |format|
70
83
  format.html do
71
-
84
+
72
85
  end
73
86
  format.js do
74
87
  default_dates = (30.day.ago.to_date..Date.today).map { |d| d.strftime("%Y-%W") }.uniq #默认时间范围
@@ -141,14 +154,14 @@ module EducodeSales
141
154
  render json: {data: @follow_count_data }
142
155
  end
143
156
  end
144
-
157
+
145
158
  end
146
159
 
147
160
  # 销售额分析
148
161
  def sales_analysis
149
162
  respond_to do |format|
150
163
  format.html do
151
-
164
+
152
165
  end
153
166
  format.js do
154
167
  x = EducodeSales::Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
@@ -186,7 +199,7 @@ module EducodeSales
186
199
  def business_area
187
200
  respond_to do |format|
188
201
  format.html do
189
-
202
+
190
203
  end
191
204
  format.js do
192
205
  x = EducodeSales::Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
@@ -238,7 +251,7 @@ module EducodeSales
238
251
  def sales_followup_analysis
239
252
  respond_to do |format|
240
253
  format.html do
241
-
254
+
242
255
  end
243
256
  format.js do
244
257
  # 销售人员跟进分析
@@ -22,7 +22,7 @@
22
22
  </div>
23
23
  </form>
24
24
  </div>
25
- <canvas id="myChart3" width="960" height="200"></canvas>
25
+ <canvas id="myChart3" width="960" height="400"></canvas>
26
26
  </div>
27
27
 
28
28
  </div>
@@ -30,7 +30,7 @@
30
30
 
31
31
  layui.use(['form', 'jquery', 'request', 'element'], function () {
32
32
  form = layui.form;
33
-
33
+
34
34
  var opt = {
35
35
  events: false,
36
36
  tooltips: {
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
  </form>
26
26
  </div>
27
- <canvas id="myChart" width="960" height="200"></canvas>
27
+ <canvas id="myChart" width="960" height="400"></canvas>
28
28
  </div>
29
29
  </div>
30
30
  <script>
@@ -47,7 +47,7 @@
47
47
  elem: '#date',
48
48
  range: true
49
49
  });
50
-
50
+
51
51
  laydate.render({
52
52
  elem: '#date_week',
53
53
  range: true
@@ -94,7 +94,7 @@
94
94
  type: 'GET',
95
95
  dataType: "json",
96
96
  data: $.param(data.field, true),
97
- success: function (res) {
97
+ success: function (res) {
98
98
  layer.close(layer_index);
99
99
  if (res.success == false) {
100
100
  layer.alert(res.msg)
@@ -29,7 +29,7 @@
29
29
  </div>
30
30
  </form>
31
31
  </div>
32
- <canvas id="myChart2" width="960" height="200"></canvas>
32
+ <canvas id="myChart2" width="960" height="400"></canvas>
33
33
 
34
34
  </div>
35
35
  </div>
@@ -37,7 +37,7 @@
37
37
  var goal_type = "<%=@goal_count_range %>";
38
38
  layui.use(['form', 'jquery', 'request', 'element'], function () {
39
39
  form = layui.form;
40
-
40
+
41
41
  var opt = {
42
42
  events: false,
43
43
  tooltips: {
@@ -28,13 +28,13 @@
28
28
  </div>
29
29
  </form>
30
30
  </div>
31
- <canvas id="myChart4" width="960" height="200"></canvas>
31
+ <canvas id="myChart4" width="960" height="400"></canvas>
32
32
  </div>
33
33
  <script>
34
34
  var customer_time_range = "<%= params[:customer_time_range] %>";
35
35
  layui.use(['form', 'jquery', 'request', 'element'], function () {
36
36
  form = layui.form;
37
-
37
+
38
38
  var opt = {
39
39
  events: false,
40
40
  tooltips: {
@@ -184,6 +184,19 @@
184
184
  </div>
185
185
  </div>
186
186
 
187
+ <div class="layui-col-xs3">
188
+ <div class="panel layui-bg-number">
189
+ <div class="panel-body">
190
+ <div class="panel-title">
191
+ <h5>应收款<a href="/missions/businesses?name=(销售态势-<%=@year %>-应收款商机)" style="color: #0000FF;float: right">查看商机</a></h5>
192
+ </div>
193
+ <div class="panel-content y-t-10">
194
+ <h1 class="no-margins"><%= @receivable_amount %>万</h1>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ </div>
199
+
187
200
  <div class="layui-col-xs3">
188
201
  <div class="panel layui-bg-number">
189
202
  <div class="panel-body">
@@ -195,7 +208,7 @@
195
208
  </div>
196
209
  </div>
197
210
  </div>
198
- </div>
211
+ </div>
199
212
  </div>
200
213
  </div>
201
214
  </div>
@@ -243,7 +256,7 @@
243
256
  loadPage('/missions/sale_trends/sales_followup_analysis')
244
257
  }
245
258
  });
246
-
259
+
247
260
 
248
261
  function loadPage(url) {
249
262
  var layer_index = layer.load(0, {shade: [0.1, '#fff']});
@@ -251,7 +264,7 @@
251
264
  url: url,
252
265
  type: 'GET',
253
266
  dataType: "script",
254
- success: function (res) {
267
+ success: function (res) {
255
268
  layer.close(layer_index);
256
269
  }
257
270
  });
@@ -291,7 +304,7 @@
291
304
  year = data.value
292
305
  window.location.href = "/missions/sale_trends/trends?year=" + data.value
293
306
  })
294
-
307
+
295
308
  editForm("chance_money");
296
309
  editForm("ballot_money");
297
310
  editForm("sign_money");
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.5'
2
+ VERSION = '0.9.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: educode_sales
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-04 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails