diff --git a/app/controllers/admin/venue_management_bills_controller.rb b/app/controllers/admin/venue_management_bills_controller.rb
new file mode 100644
index 0000000..4c40b8a
--- /dev/null
+++ b/app/controllers/admin/venue_management_bills_controller.rb
@@ -0,0 +1,69 @@
+class Admin::VenueManagementBillsController < Admin::VenueAdminController
+ include Admin::VenueManagementsHelper
+ before_action ->(module_app = @app_title) { set_variables module_app }
+ before_action :set_venue_management_bill, only: [:edit, :update, :destroy]
+
+ def initialize
+ super
+ @app_title = 'venue_management'
+ end
+
+ def index
+ @table_fields = [
+ 'venue_management.title',
+ "contractor",
+ "accounting_month",
+ "bill_type",
+ "caculation_basis",
+ "reason",
+ "amount",
+ "pay_date",
+ "pay_method",
+ "note"
+ ]
+ @bills = VenueManagementBill.all.page(params[:page]).per(10)
+ @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
+ end
+
+ def new
+ @venue_management = VenueManagementMain.find(params[:id])
+ @venue_management_bill = VenueManagementBill.new(venue_management_main_id: params[:id])
+ end
+
+ def create
+ @venue_management_bill = VenueManagementBill.new(venue_management_bill_params)
+ @venue_management_bill.save
+
+ redirect_to params['referer_url']
+ end
+
+ def edit
+ @venue_management = VenueManagementMain.find(@venue_management_bill.venue_management_main_id)
+ end
+
+ def update
+ @venue_management_bill.update_attributes(venue_management_bill_params)
+
+ redirect_to venue_management_bills_admin_venue_management_path(@venue_management_bill.venue_management_main_id)
+ end
+
+ def destroy
+ @venue_management_main_id = @venue_management_bill.venue_management_main_id
+ @venue_management_bill.destroy
+
+ redirect_to venue_management_bills_admin_venue_management_path(@venue_management_main_id)
+ end
+
+ private
+
+ def set_venue_management_bill
+ @venue_management_bill = VenueManagementBill.find(params[:id])
+ end
+
+ def venue_management_bill_params
+ params.require(:venue_management_bill).permit!
+ end
+ def venue_management_bill_params
+ params.require(:venue_management_bill).permit!
+ end
+end
diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb
index 7560d95..6a7ccc9 100644
--- a/app/controllers/admin/venue_managements_controller.rb
+++ b/app/controllers/admin/venue_managements_controller.rb
@@ -4,7 +4,7 @@ class Admin::VenueManagementsController < Admin::VenueAdminController
require 'axlsx'
helper Admin::VenueManagementsFieldHelper
before_action ->(module_app = @app_title) { set_variables module_app }
- before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings, :venue_management_memorabilias, :venue_management_contracts]
+ before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings, :venue_management_memorabilias, :venue_management_bills, :venue_management_contracts]
def initialize
super
@@ -29,6 +29,7 @@ class Admin::VenueManagementsController < Admin::VenueAdminController
'venue_management.contract_history',
'venue_management.inviting_history',
'venue_management.memorabilia',
+ 'venue_management.bills',
'venue_management.export'
]
@filter_fields["vm_inviting.type"] = @module_app.tags.map{|t| {:title => t.name,:id => t.id} }
@@ -329,7 +330,21 @@ class Admin::VenueManagementsController < Admin::VenueAdminController
@memorabilias = @venue_management.venue_management_memorabilias.page(params[:page]).per(10)
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
end
-
+ def venue_management_bills
+ @table_fields = [
+ "contractor",
+ "accounting_month",
+ "bill_type",
+ "caculation_basis",
+ "reason",
+ "amount",
+ "pay_date",
+ "pay_method",
+ "note"
+ ]
+ @bills = @venue_management.venue_management_bills.page(params[:page]).per(10)
+ @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
+ end
def venue_management_contracts
@table_fields = [
'vm_contract.case_no',
diff --git a/app/controllers/venue_managements_controller.rb b/app/controllers/venue_managements_controller.rb
index c789ea8..b47d422 100644
--- a/app/controllers/venue_managements_controller.rb
+++ b/app/controllers/venue_managements_controller.rb
@@ -100,6 +100,14 @@ class VenueManagementsController < ApplicationController
'params' => params
}
end
+ def show_bill
+ params = OrbitHelper.params
+ venue_management_bill = VenueManagementBill.find(params[:uid]) rescue nil
+ {
+ 'venue_management_bill' => venue_management_bill,
+ 'params' => params
+ }
+ end
def show
params = OrbitHelper.params
diff --git a/app/helpers/admin/venue_management_bills_helper.rb b/app/helpers/admin/venue_management_bills_helper.rb
new file mode 100644
index 0000000..3230c47
--- /dev/null
+++ b/app/helpers/admin/venue_management_bills_helper.rb
@@ -0,0 +1,9 @@
+module Admin::VenueManagementBillsHelper
+ def self.thead(field)
+ if field.include?(".")
+ return ("
"+I18n.t(field)+" | ").html_safe
+ else
+ return (""+I18n.t("vm_bill.#{field}")+" | ").html_safe
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/models/venue_management_bill.rb b/app/models/venue_management_bill.rb
new file mode 100644
index 0000000..cec136d
--- /dev/null
+++ b/app/models/venue_management_bill.rb
@@ -0,0 +1,27 @@
+require 'orbit_form_helper'
+class VenueManagementBill
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include Mongoid::Enum
+ BILLTYPE = {'venue_fee'=>["usage_fee", "royalties", "admin_fee", "land_rent"],'utility_bill'=>['electricity','water'],'tax'=>['house_tax','land_tax'],'other'=>['penalty','other']}
+ CACULATIONBASISTYPE = ['revenue','degree']
+ field :accounting_month, type: Date, default: Time.now
+ field :bill_typeA, type: String, default: ""
+ field :bill_typeB, type: String, default: ""
+ field :caculation_basis_type, type: String, default: ""
+ field :caculation_basis, type: Integer, default: ""
+ field :reason, type: String, default: "", localize: true
+ field :amount, type: Integer, default: 0
+ field :deadline, type: Date, default: Time.now
+ field :received_date, type: Date, default: Time.now
+ field :pay_method, type: String, default: "", localize: true
+ field :note, type: String, default: "", localize: true
+ belongs_to :venue_management_main
+ include VenueLinkFile
+ def contractor
+ return self.venue_management_main.venue_management_contracts.where(:contract_start_date.lte=>self.accounting_month,:contract_end_date.gte=>self.accounting_month).first
+ end
+ def pay_date
+ return "#{self.deadline}/#{self.received_date}"
+ end
+end
diff --git a/app/models/venue_management_main.rb b/app/models/venue_management_main.rb
index ff8ace9..6d3a261 100644
--- a/app/models/venue_management_main.rb
+++ b/app/models/venue_management_main.rb
@@ -36,6 +36,7 @@ class VenueManagementMain
has_many :venue_management_invitings, :autosave => true, :dependent => :destroy
has_many :venue_management_memorabilias, :autosave => true, :dependent => :destroy
+ has_many :venue_management_bills, :autosave => true, :dependent => :destroy
has_many :venue_management_contracts, :autosave => true, :dependent => :destroy
has_many :venue_management_item_contents, :autosave => true, :dependent => :destroy
has_many :venue_management_signups, :autosave => true, :dependent => :destroy
diff --git a/app/views/admin/venue_management_bills/_form.html.erb b/app/views/admin/venue_management_bills/_form.html.erb
new file mode 100644
index 0000000..667a81b
--- /dev/null
+++ b/app/views/admin/venue_management_bills/_form.html.erb
@@ -0,0 +1,105 @@
+<% content_for :page_specific_css do %>
+ <%= stylesheet_link_tag "lib/main-forms" %>
+ <%= stylesheet_link_tag "lib/fileupload" %>
+ <%= stylesheet_link_tag "lib/main-list" %>
+<% end %>
+<% content_for :page_specific_javascript do %>
+ <%= javascript_include_tag "lib/bootstrap-fileupload" %>
+ <%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
+ <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
+ <%= javascript_include_tag "lib/file-type" %>
+ <%= javascript_include_tag "lib/module-area" %>
+<% end %>
+
+
+
+
+
+ <%= get_referer_url[:venue_managemention] rescue "" %>
+ <%= f.submit t('submit'), class: 'btn btn-primary' %>
+
+ <%= link_to t('cancel'), venue_management_memorabilias_admin_venue_management_path(id: @venue_management.id), :class=>"btn" %>
+
diff --git a/app/views/admin/venue_management_bills/_index.html.erb b/app/views/admin/venue_management_bills/_index.html.erb
new file mode 100644
index 0000000..c82c904
--- /dev/null
+++ b/app/views/admin/venue_management_bills/_index.html.erb
@@ -0,0 +1,60 @@
+
+<% if 'venue_management_memorabilias' == params[:action] %>
+ <%= @venue_management.title %>
+<% end %>
+
+
+
+
+
+ <% @bills.each do |bill| %>
+
+ <% if 'venue_management_bills' != params[:action] %>
+ <%= bill.venue_management_main.title %> |
+ <% end %>
+
+ <% contractors = bill.contractor.display_contractors rescue "" %>
+ <% contractors = t(:empty) if contractors.blank? %>
+ <%= link_to contractors, (@venue_management_page_url.blank? ? "#" : "/#{I18n.locale}"+@venue_management_page_url+"/#{contractors.to_s.strip}-#{bill.id}?method=show_bill"), :target => '_self' %>
+
+
+ <% if can_edit_or_delete?(bill) %>
+ - <%= link_to t(:edit), edit_admin_venue_management_bill_path(bill.id) %>
+ - <%= t(:delete_) %>
+ <% end %>
+
+
+ |
+ <%= bill.accounting_month.strftime("%Y-%m") %> |
+ <%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %> |
+ <%= "#{t("vm_bill.#{bill.caculation_basis_type}")}: #{bill.caculation_basis}" %> |
+ <%= bill.reason %> |
+ <%= bill.amount %> |
+ <%= bill.pay_date %> |
+ <%= bill.pay_method %> |
+ <%= bill.note %> |
+
+ <% end %>
+
+
+
+<%=
+ content_tag :div, class: "bottomnav clearfix" do
+ content_tag :div, paginate(@bills), class: "pagination pagination-centered"
+ end
+%>
+<% if @venue_management.present? %>
+
+
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_venue_management_bill_path(id: @venue_management.id), class: "btn btn-primary" %>
+
+
+
+<% end %>
diff --git a/app/views/admin/venue_management_bills/edit.html.erb b/app/views/admin/venue_management_bills/edit.html.erb
new file mode 100644
index 0000000..74880dc
--- /dev/null
+++ b/app/views/admin/venue_management_bills/edit.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @venue_management_bill, url: admin_venue_management_bill_path(@venue_management_bill), html: {class: "form-horizontal main-forms"} do |f| %>
+
+<% end %>
diff --git a/app/views/admin/venue_management_bills/index.html.erb b/app/views/admin/venue_management_bills/index.html.erb
new file mode 100644
index 0000000..be82942
--- /dev/null
+++ b/app/views/admin/venue_management_bills/index.html.erb
@@ -0,0 +1,4 @@
+
+ <%= render 'index' %>
+
+<%= render 'layouts/delete_modal', delete_options: @delete_options %>
diff --git a/app/views/admin/venue_management_bills/new.html.erb b/app/views/admin/venue_management_bills/new.html.erb
new file mode 100644
index 0000000..fa9a857
--- /dev/null
+++ b/app/views/admin/venue_management_bills/new.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @venue_management_bill, url: admin_venue_management_bills_path, html: {class: "form-horizontal main-forms"} do |f| %>
+
+<% end %>
diff --git a/app/views/admin/venue_managements/_index.html.erb b/app/views/admin/venue_managements/_index.html.erb
index f118d53..fb654a9 100644
--- a/app/views/admin/venue_managements/_index.html.erb
+++ b/app/views/admin/venue_managements/_index.html.erb
@@ -49,6 +49,9 @@
<%= link_to venue_management.venue_management_memorabilias.count, venue_management_memorabilias_admin_venue_management_path(venue_management.id) %>
|
+
+ <%= link_to venue_management.venue_management_bills.count, venue_management_bills_admin_venue_management_path(venue_management.id) %>
+ |
<%= t('venue_management.export') %> |
<% end %>
diff --git a/app/views/admin/venue_managements/venue_management_bills.html.erb b/app/views/admin/venue_managements/venue_management_bills.html.erb
new file mode 100644
index 0000000..ceec95f
--- /dev/null
+++ b/app/views/admin/venue_managements/venue_management_bills.html.erb
@@ -0,0 +1,5 @@
+
+ <%= render 'admin/venue_management_bills/index' %>
+
+
+<%= render 'layouts/delete_modal', delete_options: @delete_options %>
diff --git a/app/views/venue_managements/show_bill.html.erb b/app/views/venue_managements/show_bill.html.erb
new file mode 100644
index 0000000..a1bc134
--- /dev/null
+++ b/app/views/venue_managements/show_bill.html.erb
@@ -0,0 +1,79 @@
+<% # encoding: utf-8 %>
+<% @@session = session %>
+<%= yield %>
+<%
+ data = action_data
+ @venue_management_bill = data["venue_management_bill"]
+ @params = data['params']
+%>
+
+
+
+
+ <%= t('venue_management.title') %> |
+ <%= @venue_management_bill.venue_management_main.title %> |
+
+
+ <%= t('vm_bill.contractor') %> |
+
+ <% contractors = @venue_management_bill.contractor.display_contractors rescue "" %>
+ <% contractors = t(:empty) if contractors.blank? %>
+ <%= contractors %>
+ |
+
+
+ <%= t('vm_bill.accounting_month') %> |
+ <%= @venue_management_bill.accounting_month.strftime("%Y-%m") %> |
+
+ <%= t('vm_bill.bill_type') %> |
+ <%= "#{t("vm_bill.#{@venue_management_bill.bill_typeA}")}/#{t("vm_bill.#{@venue_management_bill.bill_typeB}")}" %> |
+
+
+ <%= t('vm_bill.caculation_basis') %> |
+ <%= "#{t("vm_bill.#{@venue_management_bill.caculation_basis_type}")}: #{@venue_management_bill.caculation_basis}" %> |
+
+
+ <%= t('vm_bill.reason') %> |
+ <%= @venue_management_bill.reason %> |
+
+
+ <%= t('vm_bill.amount') %> |
+ <%= @venue_management_bill.amount %> |
+
+
+ <%= t('vm_bill.pay_date') %> |
+ <%= @venue_management_bill.pay_date %> |
+
+
+ <%= t('vm_bill.pay_method') %> |
+ <%= @venue_management_bill.pay_method %> |
+
+
+ <%= t('vm_bill.note') %> |
+ <%= @venue_management_bill.note %> |
+
+ <% if !@venue_management_bill.venue_management_files.blank? %>
+
+ <%= t(:file_) %> |
+
+ <% @venue_management_bill.venue_management_files.map do |file| %>
+ <%= link_to (file.title.blank? ? File.basename(file.file.path) : file.title) , file.file.url, {:target => '_blank', :title => file.description} if file.file.file %>
+ <% end %>
+ |
+
+ <% end %>
+ <% if !@venue_management_bill.venue_management_links.blank? %>
+
+ <%= t(:link) %> |
+
+ <% @venue_management_bill.venue_management_links.map do |link| %>
+ <%= link_to (link.title.blank? ? link.url : link.title), link.url, :target => '_blank' %>
+ <% end %>
+ |
+
+ <% end %>
+
+
+
+
+<%= link_to t(:close), 'javascript:window.close();', :class => 'btn btn-primary' %>
diff --git a/app/views/venue_managements/show_data.html.erb b/app/views/venue_managements/show_data.html.erb
index 4c9f4f4..3a8bb29 100644
--- a/app/views/venue_managements/show_data.html.erb
+++ b/app/views/venue_managements/show_data.html.erb
@@ -202,6 +202,7 @@
<%=t('venue_management.contract_history')%>
<%=t('venue_management.inviting_history')%>
<%=t('venue_management.memorabilia')%>
+ <%=t('venue_management.bills')%>
@@ -319,5 +320,50 @@
+
+
+
+
+
+ <%
+ @table_fields = [
+ "contractor",
+ "accounting_month",
+ "bill_type",
+ "caculation_basis",
+ "reason",
+ "amount",
+ "pay_date",
+ "pay_method",
+ "note"
+ ]
+ @bills = @venue_management.venue_management_bills.to_a
+ %>
+
+
+
+ <% @table_fields.each do |th| %>
+ <%=Admin::VenueManagementBillsHelper.thead(th)%>
+ <% end %>
+
+
+
+ <% @bills.each do |bill| %>
+
+ <%= bill.contractor.display_contractors rescue "" %> |
+ <%= bill.accounting_month.strftime("%Y-%m") %> |
+ <%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %> |
+ <%= bill.caculation_basis %> |
+ <%= bill.reason %> |
+ <%= bill.amount %> |
+ <%= bill.pay_date %> |
+ <%= bill.pay_method %> |
+ <%= bill.note %> |
+
+ <% end %>
+
+
+
+
<%= link_to t(:close), 'javascript:window.close();', :class => 'btn btn-primary' %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fab3131..93b9c28 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -11,6 +11,7 @@ en:
venue_management_signup_field: VenueManagement Signup Field
venue_management_signup: Signup Analyze
venue_management_memorabilias: Memorabilia
+ venue_management_bills: Bills
venue_management_invitings: Inviting History
venue_management_contracts: Contract History
module_name:
@@ -91,6 +92,7 @@ en:
contract_history: Contract history
inviting_history: Inviting history
memorabilia: Memorabilia
+ bills: Bills
signup: Inviting Contractor
export: Export #匯出
set_venue_management_items: Items #項目
@@ -100,6 +102,7 @@ en:
set_venue_management_contracts: Contract History
set_venue_management_invitings: Inviting History
set_venue_management_memorabilias: Memorabilia
+ set_venue_management_bills: Bills
set_venue_management_agreements: Personal Data Usage Agreements #個資宣告設定
venue_management_agreements_content: Content of Personal Data Usage Agreements #個資宣告內容
to_require: Should Be Filled? #是否必填
@@ -181,6 +184,33 @@ en:
case_no: 'Case No.'
event_date: Event Date
details: Details
+ vm_bill:
+ contractor: Contractor
+ accounting_month: Accounting month
+ bill_type: Bill type
+ caculation_basis: Caculation basis
+ reason: Reason
+ amount: Amount
+ deadline: Deadline
+ received_date: Received date
+ pay_date: Deadline / Received date
+ pay_method: Method
+ note: Note
+ venue_fee: Venue fee
+ usage_fee: Usage fee
+ royalties: Royalties
+ admin_fee: Admin fee
+ land_rent: Land rent
+ utility_bill: Utility bill
+ electricity: Electricity
+ water: Water
+ tax: Tax
+ house_tax: House tax
+ land_tax: Land tax
+ other: Other
+ penalty: Penalty
+ revenue: Revenue
+ degree: Degree
vm_contract:
renewal_permission: Renewal permission
renewal_deadline: Renewal deadline
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 5098ab2..2b4bd9d 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -11,6 +11,7 @@ zh_tw:
venue_management_signup_field: 報名欄位
venue_management_signup: 報名統計
venue_management_memorabilias: 大事記
+ venue_management_bills: 費用管理
venue_management_invitings: 招商公告
venue_management_contracts: 履約記錄
module_name:
@@ -91,6 +92,7 @@ zh_tw:
contract_history: 履約紀錄
inviting_history: 招商公告
memorabilia: 大事記
+ bills: 費用管理
signup: 招商
export: 匯出
set_venue_management_items: 項目
@@ -100,6 +102,7 @@ zh_tw:
set_venue_management_contracts: 履約記錄
set_venue_management_invitings: 招商公告
set_venue_management_memorabilias: 大事記
+ set_venue_management_bills: 費用管理
set_venue_management_agreements: 個資宣告設定
venue_management_agreements_content: 個資宣告內容
to_require: 是否必填
@@ -181,6 +184,33 @@ zh_tw:
case_no: 相關案號
event_date: 事件日期
details: 事件內容
+ vm_bill:
+ contractor: 廠商
+ accounting_month: 列帳年月
+ bill_type: 收入別
+ caculation_basis: 計算基礎
+ reason: 說明
+ amount: 金額
+ deadline: 繳交期限
+ received_date: 繳交日期
+ pay_date: 繳交期限 / 繳交日期
+ pay_method: 繳交方式
+ note: 備註
+ venue_fee: 場地收入
+ usage_fee: 使用費
+ royalties: 權利金
+ admin_fee: 管理費(清潔費)
+ land_rent: 土地租金
+ utility_bill: 水電費
+ electricity: 電費
+ water: 水費
+ tax: 稅
+ house_tax: 房屋稅
+ land_tax: 地價稅
+ other: 其他
+ penalty: 罰款
+ revenue: 營業額
+ degree: 度數
vm_contract:
renewal_permission: 是否得續約
renewal_deadline: 續約申請期限
diff --git a/config/routes.rb b/config/routes.rb
index ae11a7a..e3e8bc7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -14,6 +14,7 @@ Rails.application.routes.draw do
get 'venue_management_submission_field'
get 'venue_management_invitings'
get 'venue_management_memorabilias'
+ get 'venue_management_bills'
get 'venue_management_contracts'
get 'print_pdf'
end
@@ -28,6 +29,7 @@ Rails.application.routes.draw do
resources :venue_management_item_contents
resources :venue_management_invitings
resources :venue_management_memorabilias
+ resources :venue_management_bills
resources :venue_management_contracts do
collection do
post 'fetch_inviting'
diff --git a/lib/venue_management/engine.rb b/lib/venue_management/engine.rb
index e9ce873..4ce154f 100644
--- a/lib/venue_management/engine.rb
+++ b/lib/venue_management/engine.rb
@@ -60,6 +60,11 @@ module VenueManagement
:priority => 8,
:active_for_action => { 'admin/venue_managements' => 'venue_management_memorabilias' },
:available_for => 'managers'
+ context_link 'venue_management.set_venue_management_bills',
+ :link_path => 'admin_venue_management_bills_path',
+ :priority => 8,
+ :active_for_action => { 'admin/venue_managements' => 'venue_management_bills' },
+ :available_for => 'managers'
context_link 'venue_management.set_venue_management_contracts',
:link_path => 'admin_venue_management_contracts_path',
:priority => 9,