rails_finance 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +20 -0
- data/Rakefile +32 -0
- data/app/controllers/finance/admin/assessments_controller.rb +55 -0
- data/app/controllers/finance/admin/base_controller.rb +4 -0
- data/app/controllers/finance/admin/budgets_controller.rb +83 -0
- data/app/controllers/finance/admin/expense_members_controller.rb +59 -0
- data/app/controllers/finance/admin/expenses_controller.rb +71 -0
- data/app/controllers/finance/admin/financial_taxons_controller.rb +67 -0
- data/app/controllers/finance/admin/fund_incomes_controller.rb +59 -0
- data/app/controllers/finance/admin/funds_controller.rb +58 -0
- data/app/controllers/finance/admin/home_controller.rb +8 -0
- data/app/controllers/finance/admin/stocks_controller.rb +60 -0
- data/app/controllers/finance/me/base_controller.rb +4 -0
- data/app/controllers/finance/me/budgets_controller.rb +111 -0
- data/app/controllers/finance/me/expense_members_controller.rb +73 -0
- data/app/controllers/finance/me/expenses_controller.rb +129 -0
- data/app/controllers/finance_controller/me.rb +14 -0
- data/app/models/budget/finance/fund_budget.rb +5 -0
- data/app/models/budget/finance/stock_budget.rb +5 -0
- data/app/models/expense/finance/payable_expense.rb +5 -0
- data/app/models/expense/finance/prepay_expense.rb +5 -0
- data/app/models/finance/application_record.rb +5 -0
- data/app/models/finance/assessment.rb +5 -0
- data/app/models/finance/budget.rb +7 -0
- data/app/models/finance/expense.rb +7 -0
- data/app/models/finance/expense_item.rb +5 -0
- data/app/models/finance/expense_member.rb +6 -0
- data/app/models/finance/ext/financial.rb +24 -0
- data/app/models/finance/ext/member.rb +13 -0
- data/app/models/finance/financial_taxon.rb +7 -0
- data/app/models/finance/fund.rb +6 -0
- data/app/models/finance/fund_income.rb +5 -0
- data/app/models/finance/model/assessment.rb +26 -0
- data/app/models/finance/model/budget/fund_budget.rb +5 -0
- data/app/models/finance/model/budget/stock_budget.rb +10 -0
- data/app/models/finance/model/budget.rb +152 -0
- data/app/models/finance/model/expense/payable_expense.rb +5 -0
- data/app/models/finance/model/expense/prepay_expense.rb +5 -0
- data/app/models/finance/model/expense.rb +168 -0
- data/app/models/finance/model/expense_item.rb +36 -0
- data/app/models/finance/model/expense_member.rb +130 -0
- data/app/models/finance/model/financial_taxon.rb +27 -0
- data/app/models/finance/model/fund.rb +36 -0
- data/app/models/finance/model/fund_income.rb +30 -0
- data/app/models/finance/model/stock.rb +33 -0
- data/app/models/finance/stock.rb +5 -0
- data/app/models/finance.rb +12 -0
- data/app/pdfs/borrow_expense_pdf.rb +70 -0
- data/app/pdfs/payout_expense_pdf.rb +70 -0
- data/app/pdfs/prepay_expense_pdf.rb +70 -0
- data/app/records/borrow_expense_record.rb +10 -0
- data/app/records/prepay_expense_record.rb +16 -0
- data/app/views/admin/_finance_nav.html.erb +14 -0
- data/app/views/admin/_nav_expense.html.erb +4 -0
- data/app/views/finance/admin/assessments/_edit_form.html.erb +4 -0
- data/app/views/finance/admin/assessments/_filter_form.html.erb +9 -0
- data/app/views/finance/admin/assessments/_form.html.erb +2 -0
- data/app/views/finance/admin/assessments/_index_tbody.html.erb +2 -0
- data/app/views/finance/admin/assessments/_index_thead.html.erb +3 -0
- data/app/views/finance/admin/assessments/_index_tr.html.erb +19 -0
- data/app/views/finance/admin/assessments/_new_form.html.erb +4 -0
- data/app/views/finance/admin/assessments/_show_table.html.erb +4 -0
- data/app/views/finance/admin/assessments/index.html.erb +5 -0
- data/app/views/finance/admin/base/_nav.html.erb +3 -0
- data/app/views/finance/admin/budgets/_breadcrumb.html.erb +9 -0
- data/app/views/finance/admin/budgets/_edit_form.html.erb +4 -0
- data/app/views/finance/admin/budgets/_filter_form.html.erb +10 -0
- data/app/views/finance/admin/budgets/_filter_table.html.erb +11 -0
- data/app/views/finance/admin/budgets/_form.html.erb +7 -0
- data/app/views/finance/admin/budgets/_index_tbody.html.erb +13 -0
- data/app/views/finance/admin/budgets/_index_thead.html.erb +6 -0
- data/app/views/finance/admin/budgets/_item_form.html.erb +17 -0
- data/app/views/finance/admin/budgets/_items.html.erb +16 -0
- data/app/views/finance/admin/budgets/_new_form.html.erb +4 -0
- data/app/views/finance/admin/budgets/_show/_breadcrumb.html.erb +6 -0
- data/app/views/finance/admin/budgets/_show_table.html.erb +62 -0
- data/app/views/finance/admin/budgets/index.html.erb +5 -0
- data/app/views/finance/admin/budgets/next.turbo_stream.erb +1 -0
- data/app/views/finance/admin/budgets/show.htmlx.erb +35 -0
- data/app/views/finance/admin/budgets/trigger.js.erb +1 -0
- data/app/views/finance/admin/expense_members/_edit_form.html.erb +3 -0
- data/app/views/finance/admin/expense_members/_form.html.erb +5 -0
- data/app/views/finance/admin/expense_members/_index_tbody.html.erb +53 -0
- data/app/views/finance/admin/expense_members/_index_thead.html.erb +12 -0
- data/app/views/finance/admin/expense_members/index.html.erb +8 -0
- data/app/views/finance/admin/expenses/_breadcrumb.html.erb +9 -0
- data/app/views/finance/admin/expenses/_edit_form.html.erb +4 -0
- data/app/views/finance/admin/expenses/_filter_form.html.erb +10 -0
- data/app/views/finance/admin/expenses/_filter_table.html.erb +11 -0
- data/app/views/finance/admin/expenses/_form.html.erb +12 -0
- data/app/views/finance/admin/expenses/_index_tbody.html.erb +13 -0
- data/app/views/finance/admin/expenses/_index_thead.html.erb +6 -0
- data/app/views/finance/admin/expenses/_item_form.html.erb +18 -0
- data/app/views/finance/admin/expenses/_items.html.erb +20 -0
- data/app/views/finance/admin/expenses/_member_form.html.erb +16 -0
- data/app/views/finance/admin/expenses/_new_form.html.erb +4 -0
- data/app/views/finance/admin/expenses/index.html.erb +5 -0
- data/app/views/finance/admin/expenses/next.turbo_stream.erb +1 -0
- data/app/views/finance/admin/expenses/show.html.erb +121 -0
- data/app/views/finance/admin/expenses/trigger.turbo_stream.erb +1 -0
- data/app/views/finance/admin/financial_taxons/_edit_form.html.erb +4 -0
- data/app/views/finance/admin/financial_taxons/_filter_form.html.erb +10 -0
- data/app/views/finance/admin/financial_taxons/_form.html.erb +5 -0
- data/app/views/finance/admin/financial_taxons/_index_tbody.html.erb +36 -0
- data/app/views/finance/admin/financial_taxons/_index_thead.html.erb +5 -0
- data/app/views/finance/admin/financial_taxons/_index_tr.html.erb +13 -0
- data/app/views/finance/admin/financial_taxons/_new_form.html.erb +4 -0
- data/app/views/finance/admin/financial_taxons/index.html.erb +6 -0
- data/app/views/finance/admin/fund_incomes/_breadcrumb.html.erb +7 -0
- data/app/views/finance/admin/fund_incomes/_edit_form.html.erb +4 -0
- data/app/views/finance/admin/fund_incomes/_filter_form.html.erb +9 -0
- data/app/views/finance/admin/fund_incomes/_form.html.erb +4 -0
- data/app/views/finance/admin/fund_incomes/_index_tbody.html.erb +5 -0
- data/app/views/finance/admin/fund_incomes/_index_thead.html.erb +4 -0
- data/app/views/finance/admin/fund_incomes/_new_form.html.erb +4 -0
- data/app/views/finance/admin/fund_incomes/_show_table.html.erb +12 -0
- data/app/views/finance/admin/fund_incomes/index.html.erb +5 -0
- data/app/views/finance/admin/funds/_edit_form.html.erb +3 -0
- data/app/views/finance/admin/funds/_filter_form.html.erb +9 -0
- data/app/views/finance/admin/funds/_form.html.erb +5 -0
- data/app/views/finance/admin/funds/_index_tbody.html.erb +14 -0
- data/app/views/finance/admin/funds/_index_thead.html.erb +8 -0
- data/app/views/finance/admin/funds/_new_form.html.erb +3 -0
- data/app/views/finance/admin/funds/_show_table.html.erb +16 -0
- data/app/views/finance/admin/funds/index.html.erb +5 -0
- data/app/views/finance/admin/home/index.html.erb +6 -0
- data/app/views/finance/admin/stocks/_breadcrumb.html.erb +7 -0
- data/app/views/finance/admin/stocks/_edit_form.html.erb +4 -0
- data/app/views/finance/admin/stocks/_filter_form.html.erb +9 -0
- data/app/views/finance/admin/stocks/_form.html.erb +4 -0
- data/app/views/finance/admin/stocks/_index_tbody.html.erb +6 -0
- data/app/views/finance/admin/stocks/_index_thead.html.erb +7 -0
- data/app/views/finance/admin/stocks/_new_form.html.erb +4 -0
- data/app/views/finance/admin/stocks/_show_table.html.erb +16 -0
- data/app/views/finance/admin/stocks/index.html.erb +5 -0
- data/app/views/finance/me/budgets/_breadcrumb.html.erb +6 -0
- data/app/views/finance/me/budgets/_filter_form.html.erb +8 -0
- data/app/views/finance/me/budgets/_filter_table.html.erb +11 -0
- data/app/views/finance/me/budgets/_index_tbody.html.erb +23 -0
- data/app/views/finance/me/budgets/_index_thead.html.erb +4 -0
- data/app/views/finance/me/budgets/_items.html.erb +22 -0
- data/app/views/finance/me/budgets/_show/_breadcrumb.html.erb +6 -0
- data/app/views/finance/me/budgets/admin.html.erb +5 -0
- data/app/views/finance/me/budgets/financial_taxons.js.erb +7 -0
- data/app/views/finance/me/budgets/index.html.erb +5 -0
- data/app/views/finance/me/budgets/index.js +45 -0
- data/app/views/finance/me/budgets/submit.turbo_stream.erb +1 -0
- data/app/views/finance/me/budgets/transfer.turbo_stream.erb +1 -0
- data/app/views/finance/me/expense_members/_breadcrumb.html.erb +6 -0
- data/app/views/finance/me/expense_members/_button.html.erb +0 -0
- data/app/views/finance/me/expense_members/_filter_form.html.erb +10 -0
- data/app/views/finance/me/expense_members/_form.html.erb +9 -0
- data/app/views/finance/me/expense_members/_index_tbody.html.erb +8 -0
- data/app/views/finance/me/expense_members/_index_thead.html.erb +7 -0
- data/app/views/finance/me/expense_members/_show_items.html.erb +1 -0
- data/app/views/finance/me/expense_members/admin.html.erb +3 -0
- data/app/views/finance/me/expense_members/index.html.erb +6 -0
- data/app/views/finance/me/expense_members/items.js.erb +1 -0
- data/app/views/finance/me/expense_members/show.html.erb +62 -0
- data/app/views/finance/me/expenses/_breadcrumb.html.erb +7 -0
- data/app/views/finance/me/expenses/_edit_form.html.erb +3 -0
- data/app/views/finance/me/expenses/_filter_form.html.erb +8 -0
- data/app/views/finance/me/expenses/_filter_table.html.erb +11 -0
- data/app/views/finance/me/expenses/_index_tbody.html.erb +16 -0
- data/app/views/finance/me/expenses/_index_thead.html.erb +6 -0
- data/app/views/finance/me/expenses/_index_tr.html.erb +14 -0
- data/app/views/finance/me/expenses/_new_form.html.erb +4 -0
- data/app/views/finance/me/expenses/_show/_breadcrumb.html.erb +6 -0
- data/app/views/finance/me/expenses/_show_table.html.erb +124 -0
- data/app/views/finance/me/expenses/admin.html.erb +5 -0
- data/app/views/finance/me/expenses/confirm.html.erb +27 -0
- data/app/views/finance/me/expenses/financial_taxons.js.erb +44 -0
- data/app/views/finance/me/expenses/index.html.erb +5 -0
- data/app/views/finance/me/expenses/index.js +42 -0
- data/app/views/finance/me/expenses/show.html.erb +3 -0
- data/app/views/me/_finance_nav.html.erb +11 -0
- data/config/locales/en.attributes.yml +6 -0
- data/config/locales/en.controller.yml +21 -0
- data/config/locales/en.enum.yml +18 -0
- data/config/locales/zh.attributes.yml +65 -0
- data/config/locales/zh.controller.yml +57 -0
- data/config/locales/zh.enum.yml +38 -0
- data/config/routes.rb +63 -0
- data/lib/rails_finance/config.rb +11 -0
- data/lib/rails_finance/engine.rb +26 -0
- data/lib/rails_finance/version.rb +3 -0
- data/lib/rails_finance.rb +2 -0
- metadata +259 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5bec1a0c6a13c61d298cdf2ec81d555a68dc8b501b15afde21f46fe5e65d9823
|
4
|
+
data.tar.gz: fab60fb5ad5a07146eaff3bb27a365f8eff3b226c9a6090fe59310d75c0daa31
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 00d896b29e7740817f2dbfe6d075b303fd12715a2b034bb91544a0a03850651b8ddbe10d8d135d2e7a8361311b2b7897e4ef6f7cc2a7bd6bb4b3b6d7f50827d6
|
7
|
+
data.tar.gz: 6c2737fe4bd16e32d9e7c8bccf5e7d5aed32b7fe4f1eb5f7a77eb742758321e1ab4d06880f174337bbc11a38aca684837367bb9cf2244afa6ca38422fbbcd90b
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2018-Present Mingyuan Qin <mingyuan0715@foxmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# RailsFinance
|
2
|
+
|
3
|
+
[![测试](https://github.com/work-design/rails_finance/actions/workflows/test.yml/badge.svg)](https://github.com/work-design/rails_finance/actions/workflows/test.yml)
|
4
|
+
[![Docker构建](https://github.com/work-design/rails_finance/actions/workflows/cd.yml/badge.svg)](https://github.com/work-design/rails_finance/actions/workflows/cd.yml)
|
5
|
+
[![Gem](https://github.com/work-design/rails_finance/actions/workflows/gempush.yml/badge.svg)](https://github.com/work-design/rails_finance/actions/workflows/gempush.yml)
|
6
|
+
|
7
|
+
财务管理
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
How to use my plugin.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
## Contributing
|
17
|
+
Contribution directions go here.
|
18
|
+
|
19
|
+
## 协议
|
20
|
+
遵循 [MIT](https://opensource.org/licenses/MIT) 开源协议
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsDoc'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Finance
|
2
|
+
class Admin::AssessmentsController < Admin::BaseController
|
3
|
+
before_action :set_assessment, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
q_params = {}
|
7
|
+
q_params.merge! default_params
|
8
|
+
|
9
|
+
@assessments = Assessment.default_where(q_params).page(params[:page])
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@assessment = Assessment.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@assessment = Assessment.new(assessment_params)
|
18
|
+
|
19
|
+
unless @assessment.save
|
20
|
+
render :new, locals: { model: @assessment }, status: :unprocessable_entity
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def show
|
25
|
+
end
|
26
|
+
|
27
|
+
def edit
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
@assessment.assign_attributes(assessment_params)
|
32
|
+
|
33
|
+
unless @assessment.save
|
34
|
+
render :edit, locals: { model: @assessment }, status: :unprocessable_entity
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
@assessment.destroy
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def set_assessment
|
44
|
+
@assessment = Assessment.find(params[:id])
|
45
|
+
end
|
46
|
+
|
47
|
+
def assessment_params
|
48
|
+
p = params.fetch(:assessment, {}).permit(
|
49
|
+
:amount
|
50
|
+
)
|
51
|
+
p.merge! default_params
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Finance
|
2
|
+
class Admin::BudgetsController < Admin::BaseController
|
3
|
+
before_action :set_fund
|
4
|
+
before_action :set_budget, only: [:show, :edit, :update, :trigger, :destroy]
|
5
|
+
before_action :prepare_form
|
6
|
+
|
7
|
+
def index
|
8
|
+
q_params = {}
|
9
|
+
q_params.merge! default_params
|
10
|
+
q_params.merge! params.permit(:budget_id, :stock_id, :state, :id, :financial_type)
|
11
|
+
|
12
|
+
@budgets = Budget.default_where(q_params).page(params[:page])
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
@budget = Budget.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@budget = Budget.new(budget_params)
|
21
|
+
|
22
|
+
unless @budget.save
|
23
|
+
render :new, locals: { model: @budget }, status: :unprocessable_entity
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def show
|
28
|
+
@budget_members = @budget.budget_members
|
29
|
+
@budget_items = @budget.budget_items.where(member_id: nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
def edit
|
33
|
+
if @budget.expense_items.size == 0
|
34
|
+
@budget.expense_items.build
|
35
|
+
end
|
36
|
+
@taxon_options = FinancialTaxon.roots.map { |i| [i.name, i.id] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def update
|
40
|
+
@budget.assign_attributes budget_params
|
41
|
+
|
42
|
+
unless @budget.save
|
43
|
+
render :edit, locals: { model: @budget }, status: :unprocessable_entity
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def next
|
48
|
+
@budget.do_next(state: params[:state], auditor_id: current_member.id)
|
49
|
+
end
|
50
|
+
|
51
|
+
def trigger
|
52
|
+
@budget.do_trigger(state: params[:state], auditor_id: current_member.id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
@budget.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def set_fund
|
61
|
+
@fund = Fund.find params[:fund_id] if params[:fund_id]
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_budget
|
65
|
+
@budget = Budget.find params[:id]
|
66
|
+
end
|
67
|
+
|
68
|
+
def prepare_form
|
69
|
+
q_params = {}
|
70
|
+
q_params.merge! default_params
|
71
|
+
|
72
|
+
@financial_taxons = FinancialTaxon.default_where(q_params)
|
73
|
+
end
|
74
|
+
|
75
|
+
def budget_params
|
76
|
+
p = params.fetch(:budget, {}).permit(
|
77
|
+
:state
|
78
|
+
)
|
79
|
+
p.merge! default_form_params
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Finance
|
2
|
+
class Admin::ExpenseMembersController < Admin::BaseController
|
3
|
+
before_action :set_expense, only: [:index]
|
4
|
+
before_action :set_expense_member, only: [:show, :edit, :update, :to_advance_pay, :to_pay, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@expense_members = @expense.expense_members.page(params[:page])
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
def edit
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
@expense_member.assign_attribute(expense_member_params)
|
18
|
+
|
19
|
+
unless @expense_member.save
|
20
|
+
render :edit, locals: { model: @expense_member }, status: :unprocessable_entity
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_advance_pay
|
25
|
+
unless @expense_member.to_advance_payout
|
26
|
+
render :edit, locals: { model: @expense_member }, status: :unprocessable_entity
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_pay
|
31
|
+
unless @expense_member.to_payout
|
32
|
+
render :edit, locals: { model: @expense_member }, status: :unprocessable_entity
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@expense_member.destroy
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def set_expense
|
42
|
+
@expense = Expense.find params[:expense_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_expense_member
|
46
|
+
@expense_member = ExpenseMember.find(params[:id])
|
47
|
+
@expense = @expense_member.expense
|
48
|
+
end
|
49
|
+
|
50
|
+
def expense_member_params
|
51
|
+
params.fetch(:expense_member, {}).permit(
|
52
|
+
:state,
|
53
|
+
:payment_method_id,
|
54
|
+
:advance
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Finance
|
2
|
+
class Admin::ExpensesController < Admin::BaseController
|
3
|
+
before_action :set_fund
|
4
|
+
before_action :set_expense, only: [:show, :edit, :update, :trigger, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
q_params = {}
|
8
|
+
q_params.merge! default_params
|
9
|
+
q_params.merge! params.permit(:state, :id, :fund_id, :stock_id)
|
10
|
+
|
11
|
+
@expenses = Expense.default_where(q_params).page(params[:page])
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@expense = Expense.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@expense = Expense.new(expense_params)
|
20
|
+
|
21
|
+
unless @expense.save
|
22
|
+
render :new, locals: { model: @expense }, status: :unprocessable_entity
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def show
|
27
|
+
@expense_members = @expense.expense_members
|
28
|
+
@expense_items = @expense.expense_items.where(member_id: nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@expense.assign_attributes expense_params
|
36
|
+
|
37
|
+
unless @expense.save
|
38
|
+
render :edit, locals: { model: @expense }, status: :unprocessable_entity
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def next
|
43
|
+
@expense.do_next(state: params[:state], auditor_id: current_member.id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def trigger
|
47
|
+
@expense.do_trigger(state: params[:state], auditor_id: current_member.id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def destroy
|
51
|
+
@expense.destroy
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def set_fund
|
56
|
+
@fund = Fund.find params[:fund_id] if params[:fund_id]
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_expense
|
60
|
+
@expense = Expense.find(params[:id])
|
61
|
+
end
|
62
|
+
|
63
|
+
def expense_params
|
64
|
+
p = params.fetch(:expense, {}).permit(
|
65
|
+
:state
|
66
|
+
)
|
67
|
+
p.merge! default_form_params
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Finance
|
2
|
+
class Admin::FinancialTaxonsController < Admin::BaseController
|
3
|
+
before_action :set_financial_taxon, only: [:show, :edit, :update, :destroy]
|
4
|
+
before_action :prepare_form
|
5
|
+
|
6
|
+
def index
|
7
|
+
q_params = {}
|
8
|
+
q_params.merge! default_ancestors_params
|
9
|
+
q_params.merge! params.permit(:name)
|
10
|
+
|
11
|
+
@financial_taxons = FinancialTaxon.roots.default_where(q_params).page(params[:page])
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@financial_taxon = FinancialTaxon.new(default_form_params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@financial_taxon = FinancialTaxon.new(financial_taxon_params)
|
20
|
+
|
21
|
+
unless @financial_taxon.save
|
22
|
+
render :new, locals: { model: @financial_taxon }, status: :unprocessable_entity
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def show
|
27
|
+
end
|
28
|
+
|
29
|
+
def edit
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
@financial_taxon.assign_attributes(financial_taxon_params)
|
34
|
+
|
35
|
+
unless @financial_taxon.save
|
36
|
+
render :edit, locals: { model: @financial_taxon }, status: :unprocessable_entity
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
@financial_taxon.destroy
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def set_financial_taxon
|
46
|
+
@financial_taxon = FinancialTaxon.find(params[:id])
|
47
|
+
end
|
48
|
+
|
49
|
+
def prepare_form
|
50
|
+
@financial_taxon_root = FinancialTaxon.new(default_form_params)
|
51
|
+
end
|
52
|
+
|
53
|
+
def financial_taxon_params
|
54
|
+
p = params.fetch(:financial_taxon, {}).permit(
|
55
|
+
:name,
|
56
|
+
:position,
|
57
|
+
:verifier_id,
|
58
|
+
:parent_id,
|
59
|
+
:parent_ancestors,
|
60
|
+
:individual,
|
61
|
+
:take_stock
|
62
|
+
)
|
63
|
+
p.merge! default_form_params
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Finance
|
2
|
+
class Admin::FundIncomesController < Admin::BaseController
|
3
|
+
before_action :set_fund
|
4
|
+
before_action :set_fund_income, only: [:show, :edit, :update, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@fund_incomes = @fund.fund_incomes.page(params[:page])
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@fund_income = @fund.fund_incomes.build
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@fund_income = @fund.fund_incomes.build(fund_income_params)
|
16
|
+
|
17
|
+
unless @fund_income.save
|
18
|
+
render :new, locals: { model: @fund_income }, status: :unprocessable_entity
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
@fund_income.assign_attributes(fund_income_params)
|
30
|
+
|
31
|
+
unless @fund_income.save
|
32
|
+
render :edit, locals: { model: @fund_income }, status: :unprocessable_entity
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@fund_income.destroy
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def set_fund
|
42
|
+
@fund = Fund.find params[:fund_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_fund_income
|
46
|
+
@fund_income = FundIncome.find(params[:id])
|
47
|
+
end
|
48
|
+
|
49
|
+
def fund_income_params
|
50
|
+
params.fetch(:fund_income, {}).permit(
|
51
|
+
:amount,
|
52
|
+
:note,
|
53
|
+
:user_id,
|
54
|
+
:proof
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|