educode_sales 1.0.2 → 1.0.4
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 +4 -4
- data/app/controllers/educode_sales/businesses_controller.rb +4 -1
- data/app/controllers/educode_sales/contracts_controller.rb +17 -1
- data/app/controllers/educode_sales/follow_ups_controller.rb +13 -12
- data/app/controllers/educode_sales/home_controller.rb +14 -0
- data/app/controllers/educode_sales/invoices_controller.rb +219 -0
- data/app/controllers/educode_sales/key_person_controller.rb +1 -1
- data/app/controllers/educode_sales/money_plan_records_controller.rb +116 -0
- data/app/controllers/educode_sales/money_plans_controller.rb +32 -28
- data/app/controllers/educode_sales/sale_trends_controller.rb +2 -2
- data/app/controllers/educode_sales/sales_details_controller.rb +1 -1
- data/app/controllers/educode_sales/teachers_controller.rb +7 -2
- data/app/models/educode_sales/business.rb +7 -0
- data/app/models/educode_sales/invoice.rb +5 -0
- data/app/models/educode_sales/invoice_apply.rb +12 -0
- data/app/models/educode_sales/invoice_detail.rb +10 -0
- data/app/models/educode_sales/key_person.rb +1 -1
- data/app/models/educode_sales/money_plan.rb +27 -0
- data/app/models/educode_sales/money_plan_claim.rb +7 -0
- data/app/models/educode_sales/money_plan_record.rb +7 -0
- data/app/models/educode_sales/staff.rb +2 -0
- data/app/views/educode_sales/businesses/edit_plan.html.erb +1 -1
- data/app/views/educode_sales/businesses/key_person.json.jbuilder +1 -1
- data/app/views/educode_sales/contracts/_list.html.erb +1 -1
- data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -1
- data/app/views/educode_sales/follow_ups/teachers.json.jbuilder +1 -1
- data/app/views/educode_sales/home/search_contracts.json.jbuilder +9 -0
- data/app/views/educode_sales/home/search_money_plans.json.jbuilder +9 -0
- data/app/views/educode_sales/invoices/_apply_records.html.erb +276 -0
- data/app/views/educode_sales/invoices/apply.html.erb +443 -0
- data/app/views/educode_sales/invoices/apply_records.js.erb +1 -0
- data/app/views/educode_sales/invoices/apply_records.json.jbuilder +20 -0
- data/app/views/educode_sales/invoices/details.json.jbuilder +17 -0
- data/app/views/educode_sales/invoices/list.json.jbuilder +14 -0
- data/app/views/educode_sales/invoices/new.html.erb +177 -0
- data/app/views/educode_sales/invoices/sales_details.html.erb +88 -0
- data/app/views/educode_sales/invoices/sales_details.json.jbuilder +14 -0
- data/app/views/educode_sales/money_plan_records/_index.html.erb +258 -0
- data/app/views/educode_sales/money_plan_records/add.html.erb +101 -0
- data/app/views/educode_sales/money_plan_records/confirm_plan.html.erb +167 -0
- data/app/views/educode_sales/money_plan_records/index.js.erb +1 -0
- data/app/views/educode_sales/money_plan_records/index.json.jbuilder +26 -0
- data/app/views/educode_sales/money_plans/_index.html.erb +245 -0
- data/app/views/educode_sales/money_plans/add.html.erb +147 -0
- data/app/views/educode_sales/money_plans/index.json.jbuilder +41 -8
- data/app/views/educode_sales/money_plans/list.html.erb +56 -0
- data/app/views/educode_sales/sales_details/edit.html.erb +6 -0
- data/app/views/educode_sales/teachers/add_keys.html.erb +2 -2
- data/app/views/layouts/educode_sales/application.html.erb +245 -236
- data/config/routes.rb +32 -1
- data/db/migrate/20230527150102_add_category_to_educode_sales_money_plans.rb +7 -0
- data/db/migrate/20230528115654_create_educode_sales_money_plan_records.rb +13 -0
- data/db/migrate/20230529022020_create_educode_sales_money_plan_claims.rb +12 -0
- data/db/migrate/20230531144834_create_educode_sales_invoice_applies.rb +25 -0
- data/db/migrate/20230601011835_create_educode_sales_invoices.rb +14 -0
- data/db/migrate/20230601011943_create_educode_sales_invoice_details.rb +20 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +35 -4
- data/app/views/educode_sales/money_plans/index.html.erb +0 -222
@@ -1,15 +1,42 @@
|
|
1
1
|
module EducodeSales
|
2
2
|
class MoneyPlan < ApplicationRecord
|
3
3
|
belongs_to :staff
|
4
|
+
belongs_to :business
|
4
5
|
belongs_to :follow_up, counter_cache: true
|
5
6
|
|
7
|
+
has_many :money_plan_claims
|
8
|
+
|
6
9
|
# todo 1 :实际回款 0:计划回款
|
7
10
|
enum clazz: ['计划回款', '实际回款']
|
11
|
+
enum category: ['预收款', '交付款', '验收款', '质保金']
|
8
12
|
|
9
13
|
after_save :update_return_money
|
10
14
|
after_destroy :update_return_money
|
11
15
|
|
12
16
|
|
17
|
+
def return_period
|
18
|
+
if self.date_at && self.business&.last_follow_up&.signed_date
|
19
|
+
signed_date = self.business&.last_follow_up&.signed_date
|
20
|
+
month = (self.date_at.year - signed_date.year) * 12 + self.date_at.month - signed_date.month - (self.date_at.day >= signed_date.day ? 0 : 1)
|
21
|
+
if month <= 3
|
22
|
+
'3个月内'
|
23
|
+
elsif month <= 6
|
24
|
+
'4-6个月内'
|
25
|
+
elsif month <= 9
|
26
|
+
'7-9个月'
|
27
|
+
elsif month <= 12
|
28
|
+
'10-12个月'
|
29
|
+
elsif month <= 24
|
30
|
+
'1-2年'
|
31
|
+
elsif month <= 36
|
32
|
+
'2-3年'
|
33
|
+
end
|
34
|
+
else
|
35
|
+
''
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
13
40
|
private
|
14
41
|
|
15
42
|
def update_return_money
|
@@ -27,6 +27,8 @@ module EducodeSales
|
|
27
27
|
|
28
28
|
has_many :business_infos, dependent: :destroy
|
29
29
|
|
30
|
+
has_many :invoice_applys, dependent: :destroy
|
31
|
+
|
30
32
|
has_many :market_areas, dependent: :destroy
|
31
33
|
has_many :areas, through: :market_areas
|
32
34
|
validates :user_id, uniqueness: { message: '已存在' }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= Gon::Base.render_data %>
|
2
2
|
<div class="layuimini-main edit-table">
|
3
|
-
<div class="layui-form layuimini-form" lay-filter="teacher_form" id="show_plan_box">
|
3
|
+
<div class="layui-form layuimini-form" lay-filter="teacher_form" id="show_plan_box" style="display:none;">
|
4
4
|
<fieldset class="table-search-fieldset">
|
5
5
|
<legend>添加回款计划</legend>
|
6
6
|
<div class="layui-form-item">
|
@@ -15,7 +15,7 @@ json.data do
|
|
15
15
|
json.staff_manages d.business.last_follow_up&.assign_follow_ups.present? ? (d.business.last_follow_up.assign_follow_ups.map{ |d| d.staff.user.real_name}.join("、")) : d.business.staff&.user&.real_name
|
16
16
|
# teacher_ids = d.key_person.pluck(:teacher_id)
|
17
17
|
json.tel d.key_person.pluck(:tel).select { |d| d.present? }.join("、")
|
18
|
-
json.key_people d.key_person.map { |d| d.
|
18
|
+
json.key_people d.key_person.map { |d| d.name }.join("、")# key_people(teacher_ids)
|
19
19
|
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
json.data do
|
2
|
+
json.array! @data do |d|
|
3
|
+
json.value d.id
|
4
|
+
json.name "#{d.number} / #{d.department&.school&.name.to_s}#{d.department&.name.to_s} / #{d.name} / #{d.last_follow_up&.actual_amount}万"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
json.count @data.size
|
8
|
+
json.code 0
|
9
|
+
json.msg "success"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
json.data do
|
2
|
+
json.array! @data do |d|
|
3
|
+
json.value d.id
|
4
|
+
json.name "#{d.business.number} / #{d.business.department&.school&.name.to_s}#{d.business.department&.name.to_s} / #{d.business.name} / #{d.business.last_follow_up&.actual_amount}万 / #{d.date_at.to_s(:date)}"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
json.count @data.size
|
8
|
+
json.code 0
|
9
|
+
json.msg "success"
|
@@ -0,0 +1,276 @@
|
|
1
|
+
<div style="margin: 10px 10px 10px 10px" id="invoice_apply">
|
2
|
+
<form class="layui-form layui-form-pane" lay-filter="submit_apply">
|
3
|
+
<div class="layui-form-item">
|
4
|
+
<div class="layui-inline">
|
5
|
+
<label class="layui-form-label">开票申请号</label>
|
6
|
+
<div class="layui-input-inline">
|
7
|
+
<input type="text" name="number" class="layui-input">
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="layui-inline">
|
11
|
+
<label class="layui-form-label">合同名称</label>
|
12
|
+
<div class="layui-input-inline">
|
13
|
+
<input type="text" name="business" class="layui-input">
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="layui-inline">
|
17
|
+
<label class="layui-form-label">客户名称</label>
|
18
|
+
<div class="layui-input-inline">
|
19
|
+
<input type="text" name="school" class="layui-input">
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div class="layui-inline">
|
23
|
+
<label class="layui-form-label">发票号码</label>
|
24
|
+
<div class="layui-input-inline">
|
25
|
+
<input type="text" name="invoice_number" class="layui-input">
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<div class="layui-inline">
|
29
|
+
<label class="layui-form-label">开票金额</label>
|
30
|
+
<div class="layui-input-inline">
|
31
|
+
<input type="text" name="amount" class="layui-input">
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
<div class="layui-inline">
|
35
|
+
<label class="layui-form-label required">申请人</label>
|
36
|
+
<div class="layui-input-inline">
|
37
|
+
<%= select_tag "staff_id", options_for_select(@staffs), { 'lay-filter': 'state', include_blank: true, "lay-search": "" } %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<div class="layui-inline">
|
41
|
+
<label class="layui-form-label">申请日期</label>
|
42
|
+
<div class="layui-input-inline">
|
43
|
+
<input type="text" name="created_at" class="layui-input" id="date">
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
<div class="layui-inline">
|
47
|
+
<label class="layui-form-label">开票日期</label>
|
48
|
+
<div class="layui-input-inline">
|
49
|
+
<input type="text" name="date_at" class="layui-input" id="passed_at">
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
<div class="layui-inline">
|
53
|
+
<button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_business_search_record">重置</button>
|
54
|
+
<button type="submit" class="layui-btn layui-btn-primary" id="search_bt" lay-submit lay-filter="submit_apply">搜 索</button>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
</form>
|
58
|
+
</div>
|
59
|
+
<script type="text/html" id="apply_tool">
|
60
|
+
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" style="margin-left: 20px;" lay-event="apply_invoice">开票申请</button>
|
61
|
+
</script>
|
62
|
+
|
63
|
+
<table class="layui-hide" id="apply_invoice_table" lay-filter="apply_invoice_table"></table>
|
64
|
+
|
65
|
+
<script type="text/html" id="invoice_num">
|
66
|
+
<a href="javascript:void(0);" lay-event="invoices_count" class="layui-table-link">{{ d.invoices_count }}</a>
|
67
|
+
</script>
|
68
|
+
<script type="text/html" id="apply_toolbar">
|
69
|
+
<!-- <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="audit">审核</a> -->
|
70
|
+
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="invoice">提交发票信息</a>
|
71
|
+
</script>
|
72
|
+
|
73
|
+
<script>
|
74
|
+
layui.use(['form', 'table', 'miniPage', 'element', 'request'], function() {
|
75
|
+
var $ = layui.jquery,
|
76
|
+
form = layui.form,
|
77
|
+
request = layui.request,
|
78
|
+
miniPage = layui.miniPage;
|
79
|
+
laydate = layui.laydate;
|
80
|
+
table = layui.table;
|
81
|
+
laydate.render({
|
82
|
+
elem: '#date',
|
83
|
+
range: true
|
84
|
+
});
|
85
|
+
laydate.render({
|
86
|
+
elem: '#passed_at',
|
87
|
+
range: true
|
88
|
+
});
|
89
|
+
form.render();
|
90
|
+
table.render({
|
91
|
+
elem: '#apply_invoice_table',
|
92
|
+
url: '/missions/invoices/apply_records',
|
93
|
+
toolbar: '#apply_tool',
|
94
|
+
defaultToolbar: ['filter'],
|
95
|
+
initSort: {
|
96
|
+
field: 'created_at',
|
97
|
+
type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
98
|
+
},
|
99
|
+
cols: [
|
100
|
+
[{
|
101
|
+
field: 'id',
|
102
|
+
width: 80,
|
103
|
+
title: '序号',
|
104
|
+
type: 'numbers',
|
105
|
+
}, {
|
106
|
+
field: 'number',
|
107
|
+
width: 180,
|
108
|
+
title: '开票申请号'
|
109
|
+
}, {
|
110
|
+
field: 'business_number',
|
111
|
+
width: 150,
|
112
|
+
title: '合同编号'
|
113
|
+
}, {
|
114
|
+
field: 'business_name',
|
115
|
+
width: 180,
|
116
|
+
title: '合同名称'
|
117
|
+
}, {
|
118
|
+
field: 'school',
|
119
|
+
width: 180,
|
120
|
+
title: '客户名称'
|
121
|
+
}, {
|
122
|
+
field: 'staff',
|
123
|
+
width: 120,
|
124
|
+
title: '申请人',
|
125
|
+
}, {
|
126
|
+
field: 'created_at',
|
127
|
+
width: 220,
|
128
|
+
title: '申请日期',
|
129
|
+
}, {
|
130
|
+
field: 'amount',
|
131
|
+
width: 120,
|
132
|
+
title: '开票金额',
|
133
|
+
}, {
|
134
|
+
field: 'state',
|
135
|
+
width: 120,
|
136
|
+
title: '开票状态',
|
137
|
+
}, {
|
138
|
+
field: 'invoices_count',
|
139
|
+
width: 120,
|
140
|
+
title: '发票信息',
|
141
|
+
templet: "#invoice_num"
|
142
|
+
}, {
|
143
|
+
field: 'take_ticket',
|
144
|
+
width: 120,
|
145
|
+
title: '领票人',
|
146
|
+
}, {
|
147
|
+
field: 'delivery',
|
148
|
+
width: 120,
|
149
|
+
title: '送达方式',
|
150
|
+
}, {
|
151
|
+
title: '操作',
|
152
|
+
minWidth: 200,
|
153
|
+
toolbar: '#apply_toolbar',
|
154
|
+
align: "center",
|
155
|
+
fixed: 'right'
|
156
|
+
}]
|
157
|
+
],
|
158
|
+
limit: 20,
|
159
|
+
limits: [10, 15, 20, 30, 40, 50, 60, 70, 80, 90],
|
160
|
+
page: true
|
161
|
+
});
|
162
|
+
var sort = {},
|
163
|
+
search = {};
|
164
|
+
table.on('sort(apply_invoice_table)', function(obj) {
|
165
|
+
sort.field = obj.field;
|
166
|
+
sort.order = obj.type;
|
167
|
+
table.reload('apply_invoice_table', {
|
168
|
+
initSort: obj,
|
169
|
+
where: {
|
170
|
+
sort: sort,
|
171
|
+
q: search
|
172
|
+
}
|
173
|
+
});
|
174
|
+
})
|
175
|
+
// 监听搜索操作
|
176
|
+
form.on('submit(submit_apply)', function(data) {
|
177
|
+
search = data.field
|
178
|
+
table.reload('apply_invoice_table', {
|
179
|
+
page: {
|
180
|
+
curr: 1
|
181
|
+
},
|
182
|
+
where: {
|
183
|
+
q: search,
|
184
|
+
sort: sort
|
185
|
+
}
|
186
|
+
}, 'data');
|
187
|
+
return false;
|
188
|
+
});
|
189
|
+
form.on('submit(reset_business_search_record)', function(data) {
|
190
|
+
var field = data.field;
|
191
|
+
form.val('submit_apply', {
|
192
|
+
area: "",
|
193
|
+
date: "",
|
194
|
+
staff_id: "",
|
195
|
+
clazz: "",
|
196
|
+
professional_title: "",
|
197
|
+
school: "",
|
198
|
+
business: ""
|
199
|
+
});
|
200
|
+
return false;
|
201
|
+
});
|
202
|
+
table.on('toolbar(apply_invoice_table)', function(obj) {
|
203
|
+
if (obj.event == 'apply_invoice') {
|
204
|
+
var content = miniPage.getHrefContent('/missions/invoices/apply')
|
205
|
+
var openWH = miniPage.getOpenWidthHeight();
|
206
|
+
business_id = "";
|
207
|
+
sindex = layer.open({
|
208
|
+
title: '开票申请',
|
209
|
+
type: 1,
|
210
|
+
shade: 0.2,
|
211
|
+
maxmin: true,
|
212
|
+
shadeClose: true,
|
213
|
+
area: [openWH[0] + 'px', openWH[1] + 'px'],
|
214
|
+
offset: [openWH[2] + 'px', openWH[3] + 'px'],
|
215
|
+
content: content
|
216
|
+
});
|
217
|
+
$(window).on("resize", function() {
|
218
|
+
layer.full(sindex);
|
219
|
+
});
|
220
|
+
}
|
221
|
+
})
|
222
|
+
table.on('tool(apply_invoice_table)', function(obj) {
|
223
|
+
var data = obj.data;
|
224
|
+
id = data.id;
|
225
|
+
state = data.state;
|
226
|
+
if (obj.event === 'confirm') { // 监听添加操作
|
227
|
+
var content = miniPage.getHrefContent('/missions/money_plan_records/confirm_plan?id=' + id)
|
228
|
+
var openWH = miniPage.getOpenWidthHeight();
|
229
|
+
sindex = layer.open({
|
230
|
+
title: '认领回款',
|
231
|
+
type: 1,
|
232
|
+
shade: 0.2,
|
233
|
+
maxmin: true,
|
234
|
+
shadeClose: true,
|
235
|
+
area: [openWH[0] + 'px', openWH[1] + 'px'],
|
236
|
+
offset: [openWH[2] + 'px', openWH[3] + 'px'],
|
237
|
+
content: content
|
238
|
+
});
|
239
|
+
$(window).on("resize", function() {
|
240
|
+
layer.full(sindex);
|
241
|
+
});
|
242
|
+
} else if (obj.event === 'invoices_count' || obj.event == 'invoice') {
|
243
|
+
invoice_apply_id = id;
|
244
|
+
var content = miniPage.getHrefContent('/missions/invoices/new')
|
245
|
+
var openWH = miniPage.getOpenWidthHeight();
|
246
|
+
sindex = layer.open({
|
247
|
+
title: '添加发票',
|
248
|
+
type: 1,
|
249
|
+
shade: 0.2,
|
250
|
+
maxmin: true,
|
251
|
+
shadeClose: true,
|
252
|
+
area: [openWH[0] + 'px', openWH[1] + 'px'],
|
253
|
+
offset: [openWH[2] + 'px', openWH[3] + 'px'],
|
254
|
+
content: content
|
255
|
+
});
|
256
|
+
$(window).on("resize", function() {
|
257
|
+
layer.full(sindex);
|
258
|
+
});
|
259
|
+
}
|
260
|
+
});
|
261
|
+
});
|
262
|
+
</script>
|
263
|
+
<style>
|
264
|
+
.layui-table-tool-temp {
|
265
|
+
padding-right: 30px;
|
266
|
+
!important;
|
267
|
+
}
|
268
|
+
|
269
|
+
.layui-table-fixed .layui-table-body {
|
270
|
+
height: auto !important;
|
271
|
+
}
|
272
|
+
|
273
|
+
.layui-table-fixed.layui-hide {
|
274
|
+
display: block !important;
|
275
|
+
}
|
276
|
+
</style>
|