Add filters to bill page
Add add_and_subtract field to bill form
This commit is contained in:
parent
f4d4fdce94
commit
70fa993e01
|
@ -1,13 +1,28 @@
|
|||
class Admin::VenueManagementBillsController < Admin::VenueAdminController
|
||||
include Admin::VenueManagementsHelper
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include VenueAdminHelper
|
||||
include ActionView::Context
|
||||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
before_action :set_venue_management_bill, only: [:edit, :update, :destroy]
|
||||
|
||||
def objectify_options(options)
|
||||
@default_options = {}
|
||||
@default_options.merge(options)
|
||||
end
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'venue_management'
|
||||
end
|
||||
|
||||
def filter_fields(categories)
|
||||
{
|
||||
:category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}}
|
||||
}
|
||||
end
|
||||
def text_field(object_name , options = {})
|
||||
text_field_tag(object_name, options[:value], options)
|
||||
end
|
||||
def index
|
||||
@table_fields = [
|
||||
'venue_management.title',
|
||||
|
@ -21,8 +36,59 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController
|
|||
"pay_method",
|
||||
"note"
|
||||
]
|
||||
@bills = VenueManagementBill.all.page(params[:page]).per(10)
|
||||
@bills = nil
|
||||
@categories = @module_app.categories.enabled
|
||||
@filter_fields = filter_fields(@categories)
|
||||
@tags = @module_app.tags
|
||||
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
||||
bill_type_select_str = "<div class=\"controls\"><form>"
|
||||
value_bill_typeA = params[:filters]["bill_typeA"] rescue "0"
|
||||
value_bill_typeB = params[:filters]["bill_typeB"] rescue "0"
|
||||
bill_type_select_str += (select_tag "filters[bill_typeA]", options_for_select(VenueManagementBill::BILLTYPE.keys.map { |k| [ I18n.t("vm_bill.#{k}"), k ] },value_bill_typeA) ,{:onchange=>"var $this=this;(function(){var obj=#{VenueManagementBill::BILLTYPE.map{|k,v| [k,v.map{|vv| [vv,I18n.t("vm_bill.#{vv}")]}.to_h]}.to_h.to_s.gsub('=>',':')};$($this).siblings('select').html($.map(obj[$this.value],function(v,k){return \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).join(\' \'))})()"})
|
||||
bill_typeB = (params[:filters]["bill_typeA"].blank? rescue true) ? VenueManagementBill::BILLTYPE.values.first : VenueManagementBill::BILLTYPE[params[:filters]["bill_typeA"]]
|
||||
bill_type_select_str += (select_tag "filters[bill_typeB]", options_for_select(bill_typeB.map { |v| [ I18n.t("vm_bill.#{v}"), v ] },value_bill_typeB) , {:onchange=> "var $this=this;(function(){if($this.value == 'other') $('#bill_other_field').removeClass('hidden');else $('#bill_other_field').addClass('hidden');})()"})
|
||||
bill_type_select_str += submit_tag(I18n.t('venue_management.search'))
|
||||
bill_type_select_str += "</form></div>"
|
||||
@filter_fields['vm_bill.bill_type'] = bill_type_select_str
|
||||
@filter_fields['vm_bill.accounting_month'] = ('<form><div class="controls"><div style="float: left;">'+
|
||||
(org_datetime_picker("filters[accounting_month_start]", {:no_label => true, :format=>"yyyy/MM", :new_record=>false, :value=>(DateTime.parse(params[:filters]["accounting_month_start"]) rescue nil)})) +
|
||||
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
|
||||
(org_datetime_picker("filters[accounting_month_end]", {:no_label => true, :format=>"yyyy/MM", :new_record=>false, :value=>(DateTime.parse(params[:filters]["accounting_month_end"]) rescue nil)})) +
|
||||
submit_tag(I18n.t('venue_management.search')) +
|
||||
'</div></div></form>')
|
||||
filter_tags = params[:filters]["type"].to_a rescue []
|
||||
@main_ids = nil
|
||||
if !filter_tags.blank?
|
||||
@main_ids = VenueManagementInviting.with_tags(filter_tags).pluck(:venue_management_main_id)
|
||||
if !filters("category").blank?
|
||||
@main_ids = VenueManagementMain.where(:id.in=>@main_ids).with_categories(filters("category")).pluck(:id)
|
||||
end
|
||||
elsif !filters("category").blank?
|
||||
@main_ids = VenueManagementMain.all.with_categories(filters("category")).pluck(:id)
|
||||
end
|
||||
if ( !params[:filters]["bill_typeA"].blank? rescue false)
|
||||
@bills = VenueManagementBill.where(:bill_typeA=>params[:filters]["bill_typeA"],:bill_typeB=>params[:filters]["bill_typeB"]).page(params[:page]).per(10)
|
||||
end
|
||||
accounting_month_start = DateTime.parse(params[:filters]["accounting_month_start"]) rescue 0
|
||||
accounting_month_end = DateTime.parse(params[:filters]["accounting_month_end"]) rescue 0
|
||||
if @bills.nil?
|
||||
@bills = VenueManagementBill.where(:accounting_month.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
||||
else
|
||||
if accounting_month_start != 0 && accounting_month_end != 0
|
||||
@bills = @bills.where(:accounting_month.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
||||
elsif accounting_month_start != 0
|
||||
@bills = @bills.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10)
|
||||
elsif accounting_month_end != 0
|
||||
@bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
||||
end
|
||||
end
|
||||
if !@main_ids.nil?
|
||||
@bills = @bills.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10)
|
||||
end
|
||||
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
||||
if request.xhr?
|
||||
render '_index'
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
# encoding: utf-8
|
||||
class Admin::VenueManagementsController < Admin::VenueAdminController
|
||||
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include VenueAdminHelper
|
||||
include ActionView::Context
|
||||
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_bills, :venue_management_contracts]
|
||||
|
||||
def objectify_options(options)
|
||||
@default_options = {}
|
||||
@default_options.merge(options)
|
||||
end
|
||||
def text_field(object_name , options = {})
|
||||
text_field_tag(object_name, options[:value], options)
|
||||
end
|
||||
def initialize
|
||||
super
|
||||
@app_title = "venue_management"
|
||||
|
@ -52,7 +62,7 @@ class Admin::VenueManagementsController < Admin::VenueAdminController
|
|||
@venue_managements = VenueManagementMain.all.order_by(sort).with_categories(filters("category"))
|
||||
@venue_managements = search_data(@venue_managements,[:title])
|
||||
@venue_management_inviting_ids = @venue_managements.map{|v| v.venue_management_invitings.desc(:id).first.id rescue ""}
|
||||
@venue_management_ids = VenueManagementInviting.where(:id.in=>@venue_management_inviting_ids).with_tags(filter_tags).map{|v| v.venue_management_main_id}
|
||||
@venue_management_ids = VenueManagementInviting.where(:id.in=>@venue_management_inviting_ids).with_tags(filter_tags).pluck(:venue_management_main_id)
|
||||
@venue_managements = VenueManagementMain.where(:id.in=>@venue_management_ids).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
|
@ -344,6 +354,54 @@ class Admin::VenueManagementsController < Admin::VenueAdminController
|
|||
]
|
||||
@bills = @venue_management.venue_management_bills.page(params[:page]).per(10)
|
||||
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
||||
@categories = @module_app.categories.enabled
|
||||
@filter_fields = filter_fields(@categories)
|
||||
@tags = @module_app.tags
|
||||
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
||||
value_bill_typeA = params[:filters]["bill_typeA"] rescue "0"
|
||||
value_bill_typeB = params[:filters]["bill_typeB"] rescue "0"
|
||||
bill_type_select_str = "<div class=\"controls\"><form>"
|
||||
bill_type_select_str += (select_tag "filters[bill_typeA]", options_for_select(VenueManagementBill::BILLTYPE.keys.map { |k| [ I18n.t("vm_bill.#{k}"), k ] },value_bill_typeA) ,{:onchange=>"var $this=this;(function(){var obj=#{VenueManagementBill::BILLTYPE.map{|k,v| [k,v.map{|vv| [vv,I18n.t("vm_bill.#{vv}")]}.to_h]}.to_h.to_s.gsub('=>',':')};$($this).siblings('select').html($.map(obj[$this.value],function(v,k){return \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).join(\' \'))})()"})
|
||||
bill_typeB = (params[:filters]["bill_typeA"].blank? rescue true) ? VenueManagementBill::BILLTYPE.values.first : VenueManagementBill::BILLTYPE[params[:filters]["bill_typeA"]]
|
||||
bill_type_select_str += (select_tag "filters[bill_typeB]", options_for_select(bill_typeB.map { |v| [ I18n.t("vm_bill.#{v}"), v ] },value_bill_typeB) , {:onchange=> "var $this=this;(function(){if($this.value == 'other') $('#bill_other_field').removeClass('hidden');else $('#bill_other_field').addClass('hidden');})()"})
|
||||
bill_type_select_str += submit_tag(I18n.t('venue_management.search'))
|
||||
bill_type_select_str += "</form></div>"
|
||||
@filter_fields['vm_bill.bill_type'] = bill_type_select_str
|
||||
@filter_fields['vm_bill.accounting_month'] = ('<form><div class="controls"><div style="float: left;">'+
|
||||
(org_datetime_picker("filters[accounting_month_start]", {:no_label => true, :format=>"yyyy/MM", :new_record=>false, :value=>(DateTime.parse(params[:filters]["accounting_month_start"]) rescue nil)})) +
|
||||
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
|
||||
(org_datetime_picker("filters[accounting_month_end]", {:no_label => true, :format=>"yyyy/MM", :new_record=>false, :value=>(DateTime.parse(params[:filters]["accounting_month_end"]) rescue nil)})) +
|
||||
submit_tag(I18n.t('venue_management.search')) +
|
||||
'</div></div></form>')
|
||||
filter_tags = params[:filters]["type"].to_a rescue []
|
||||
@main_ids = nil
|
||||
if !filter_tags.blank?
|
||||
@main_ids = VenueManagementInviting.with_tags(filter_tags).pluck(:venue_management_main_id)
|
||||
if !filters("category").blank?
|
||||
@main_ids = VenueManagementMain.where(:id.in=>@main_ids).with_categories(filters("category")).pluck(:id)
|
||||
end
|
||||
elsif !filters("category").blank?
|
||||
@main_ids = VenueManagementMain.all.with_categories(filters("category")).pluck(:id)
|
||||
end
|
||||
if ( !params[:filters]["bill_typeA"].blank? rescue false)
|
||||
@bills = @bills.where(:bill_typeA=>params[:filters]["bill_typeA"],:bill_typeB=>params[:filters]["bill_typeB"]).page(params[:page]).per(10)
|
||||
end
|
||||
accounting_month_start = DateTime.parse(params[:filters]["accounting_month_start"]) rescue 0
|
||||
accounting_month_end = DateTime.parse(params[:filters]["accounting_month_end"]) rescue 0
|
||||
if accounting_month_start != 0 && accounting_month_end != 0
|
||||
@bills = @bills.where(:accounting_month.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
||||
elsif accounting_month_start != 0
|
||||
@bills = @bills.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10)
|
||||
elsif accounting_month_end != 0
|
||||
@bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
||||
end
|
||||
if !@main_ids.nil?
|
||||
@bills = @bills.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10)
|
||||
end
|
||||
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
||||
if request.xhr?
|
||||
render 'admin/venue_management_bills/_index'
|
||||
end
|
||||
end
|
||||
def venue_management_contracts
|
||||
@table_fields = [
|
||||
|
|
|
@ -5,7 +5,7 @@ class VenueManagementBill
|
|||
include Mongoid::Enum
|
||||
BILLTYPE = {'venue_fee'=>["usage_fee", "royalties", "admin_fee", "land_rent"],'utility_bill'=>['electricity','water'],'tax'=>['house_tax','land_tax'],'prejudgment_interest'=>["usage_fee", "royalties", "admin_fee", "land_rent",'electricity','water','house_tax','land_tax','other'],'other'=>['penalty','other']}
|
||||
CACULATIONBASISTYPE = {'revenue'=>{'revenue'=>{},'level_0'=>{'fields'=>['field_value','percent']},'level_1'=>{'fields'=>['field_value','percent']},'level_2'=>{'fields'=>['field_value','percent']},'level_3'=>{'fields'=>['field_value','percent']},'level_4'=>{'fields'=>['field_value','percent']},'level_5'=>{'fields'=>['field_value','percent']}},
|
||||
'degree'=>{'current_degree'=>{'float'=>'left'},'consumption'=>{'float'=>'left','clear'=>true,'no_margin'=>true},'level_0'=>{'fields'=>['field_value','dollar/degree']},'level_1'=>{'fields'=>['field_value','dollar/degree']},'level_2'=>{'fields'=>['field_value','dollar/degree']},'level_3'=>{'fields'=>['field_value','dollar/degree']}},
|
||||
'degree'=>{'current_degree'=>{'float'=>'left'},'consumption'=>{'float'=>'left','clear'=>true,'no_margin'=>true},'level_0'=>{'fields'=>['field_value','dollar/degree']},'level_1'=>{'fields'=>['field_value','dollar/degree']},'level_2'=>{'fields'=>['field_value','dollar/degree']},'level_3'=>{'fields'=>['field_value','dollar/degree']},'add_and_subtract'=>{'unit'=>'add_and_subtract_hint'}},
|
||||
'actual_bill'=>{'bill_amount'=>{}},
|
||||
'fixed'=>{'amount'=>{}},
|
||||
'taxable_present_value'=>{'present_value'=>{},'taxable_area'=>{'unit'=>'㎡'},'taxable_tax'=>{}},
|
||||
|
@ -34,6 +34,7 @@ class VenueManagementBill
|
|||
f=field_values.shift(1)
|
||||
field_values.push(f[0])
|
||||
result += inner_product(field_values,dollardegrees)
|
||||
result += add_and_subtract
|
||||
if(result < 0)
|
||||
result = 0",
|
||||
"actual_bill"=>"
|
||||
|
@ -59,6 +60,7 @@ class VenueManagementBill
|
|||
}
|
||||
CACULATIONBASIS = {'revenue'=>"revenue",
|
||||
"degree"=>"consumption",
|
||||
"actual_bill" => "bill_amount",
|
||||
"fixed"=>"amount",
|
||||
"taxable_present_value"=>"present_value",
|
||||
"announced_land_values"=>"land_values",
|
||||
|
@ -94,6 +96,7 @@ class VenueManagementBill
|
|||
field :taxable_area
|
||||
field :land_values
|
||||
field :taxable_tax
|
||||
field :add_and_subtract
|
||||
belongs_to :venue_management_main
|
||||
include VenueLinkFile
|
||||
# after_initialize do |record|
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t('vm_bill.accounting_month') %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :accounting_month, :no_label => true, :format=>"yyyy/MM", :new_record => new_record %>
|
||||
<%= f.org_datetime_picker :accounting_month, :no_label => true, :format=>"yyyy/MM", :new_record => new_record %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t('vm_bill.bill_type') %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :bill_typeA, @venue_management_bill.class::BILLTYPE.keys.map { |k| [ I18n.t("vm_bill.#{k}"), k ] },{},{:onchange=>"var $this=this;console.log($this.value);(function(){var obj=#{@venue_management_bill.class::BILLTYPE.map{|k,v| [k,v.map{|vv| [vv,I18n.t("vm_bill.#{vv}")]}.to_h]}.to_h.to_s.gsub('=>',':')};$($this).siblings('select').html($.map(obj[$this.value],function(v,k){return \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).join(\' \'))})()"} %>
|
||||
<%= f.select :bill_typeA, @venue_management_bill.class::BILLTYPE.keys.map { |k| [ I18n.t("vm_bill.#{k}"), k ] },{},{:onchange=>"var $this=this;(function(){var obj=#{@venue_management_bill.class::BILLTYPE.map{|k,v| [k,v.map{|vv| [vv,I18n.t("vm_bill.#{vv}")]}.to_h]}.to_h.to_s.gsub('=>',':')};$($this).siblings('select').html($.map(obj[$this.value],function(v,k){return \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).join(\' \'))})()"} %>
|
||||
<% bill_typeB = new_record ? @venue_management_bill.class::BILLTYPE.values.first : @venue_management_bill.class::BILLTYPE[@venue_management_bill.bill_typeA] %>
|
||||
<%= f.select :bill_typeB, bill_typeB.map { |v| [ I18n.t("vm_bill.#{v}"), v ] }, {}, {:onchange=> "var $this=this;(function(){if($this.value == 'other') $('#bill_other_field').removeClass('hidden');else $('#bill_other_field').addClass('hidden');})()"} %>
|
||||
<div id="bill_other_field" class="tab-content language-area <%=@venue_management_bill.bill_typeB == 'other' ? '' : 'hidden'%>">
|
||||
|
@ -94,7 +94,11 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<span class="unit">
|
||||
<%= (v['unit'].to_s rescue "") %>
|
||||
<% if ( t("vm_bill")[v['unit'].to_sym].nil? rescue true) %>
|
||||
<%= (v['unit'].to_s rescue "") %>
|
||||
<% else %>
|
||||
<%= (t("vm_bill.#{v['unit'].to_s}") rescue "") %>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -195,7 +199,13 @@
|
|||
end
|
||||
end
|
||||
end
|
||||
html += ("<span class=\"unit\"> "+v['unit'].to_s+ "</span>" rescue "")
|
||||
html += "<span class=\"unit\"> "
|
||||
if ( t("vm_bill")[v['unit'].to_sym].nil? rescue true)
|
||||
html += (v['unit'].to_s rescue "")
|
||||
else
|
||||
html += (t("vm_bill.#{v['unit'].to_s}") rescue "")
|
||||
end
|
||||
html += "</span>"
|
||||
html += "</div></div>"
|
||||
if(v['clear'] rescue false)
|
||||
html += "<div style=\"clear: both;\"></div>"
|
||||
|
@ -235,7 +245,6 @@
|
|||
return index;
|
||||
}
|
||||
})
|
||||
console.log(index);
|
||||
return index;
|
||||
}
|
||||
function update_result(){
|
||||
|
@ -289,7 +298,7 @@
|
|||
")
|
||||
}.select{|s| s.present?}.join(" ")+
|
||||
'default:'+
|
||||
'console.log("error");
|
||||
'
|
||||
break;}').html_safe
|
||||
%>
|
||||
eval.call(this,formula);
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<% 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 %>
|
||||
<script>
|
||||
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
|
||||
</script>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<%= render_filter @filter_fields, "index_table" %>
|
||||
<span id="index_table">
|
||||
<%= render 'index' %>
|
||||
</span>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<%= render_filter @filter_fields, "index_table" %>
|
||||
<span id="index_table">
|
||||
<%= render 'admin/venue_management_bills/index' %>
|
||||
</span>
|
||||
|
|
|
@ -22,6 +22,7 @@ en:
|
|||
verification_failed: Verification Failed #驗證碼錯誤
|
||||
|
||||
venue_management:
|
||||
search: Search
|
||||
reminder: Reminder
|
||||
print_pdf: Print
|
||||
send_email_reminder: Send email reminder
|
||||
|
@ -190,6 +191,8 @@ en:
|
|||
event_date: Event Date
|
||||
details: Details
|
||||
vm_bill:
|
||||
add_and_subtract_hint: Please add a minus sign before the number if it's minus!
|
||||
add_and_subtract: Add and subtract
|
||||
contractor: Contractor
|
||||
accounting_month: Accounting month
|
||||
bill_type: Bill type
|
||||
|
|
|
@ -22,6 +22,7 @@ zh_tw:
|
|||
verification_failed: 驗證碼錯誤
|
||||
|
||||
venue_management:
|
||||
search: 查詢
|
||||
reminder: 提醒
|
||||
print_pdf: 列印
|
||||
send_email_reminder: 寄送Email提醒
|
||||
|
@ -190,6 +191,8 @@ zh_tw:
|
|||
event_date: 事件日期
|
||||
details: 事件內容
|
||||
vm_bill:
|
||||
add_and_subtract_hint: 若為扣除金額請於數字前方填寫減號 ( - )
|
||||
add_and_subtract: 加減金額
|
||||
contractor: 廠商
|
||||
accounting_month: 列帳年月
|
||||
bill_type: 費用別
|
||||
|
|
Loading…
Reference in New Issue