diff --git a/app/controllers/admin/venue_management_bills_controller.rb b/app/controllers/admin/venue_management_bills_controller.rb index a23e29d..f2788cb 100644 --- a/app/controllers/admin/venue_management_bills_controller.rb +++ b/app/controllers/admin/venue_management_bills_controller.rb @@ -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 = "
" + @filter_fields['vm_bill.bill_type'] = bill_type_select_str + @filter_fields['vm_bill.accounting_month'] = ('') + 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 diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index 727a234..afa5df9 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -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 = "" + @filter_fields['vm_bill.bill_type'] = bill_type_select_str + @filter_fields['vm_bill.accounting_month'] = ('') + 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 = [ diff --git a/app/models/venue_management_bill.rb b/app/models/venue_management_bill.rb index 6f2ffa8..7c8711f 100644 --- a/app/models/venue_management_bill.rb +++ b/app/models/venue_management_bill.rb @@ -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| diff --git a/app/views/admin/venue_management_bills/_form.html.erb b/app/views/admin/venue_management_bills/_form.html.erb index 5317342..52079d0 100644 --- a/app/views/admin/venue_management_bills/_form.html.erb +++ b/app/views/admin/venue_management_bills/_form.html.erb @@ -37,13 +37,13 @@