diff --git a/app/models/venue_management_bill.rb b/app/models/venue_management_bill.rb index cec136d..3414b9e 100644 --- a/app/models/venue_management_bill.rb +++ b/app/models/venue_management_bill.rb @@ -3,13 +3,14 @@ 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']} + 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','degree'] field :accounting_month, type: Date, default: Time.now field :bill_typeA, type: String, default: "" field :bill_typeB, type: String, default: "" + field :bill_other, type: String, default: "", localize: true field :caculation_basis_type, type: String, default: "" - field :caculation_basis, type: Integer, default: "" + field :caculation_basis, type: String, default: "" field :reason, type: String, default: "", localize: true field :amount, type: Integer, default: 0 field :deadline, type: Date, default: Time.now @@ -18,6 +19,9 @@ class VenueManagementBill field :note, type: String, default: "", localize: true belongs_to :venue_management_main include VenueLinkFile + def case_no + return (self.contractor.case_no rescue "") + end 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 diff --git a/app/views/admin/venue_management_bills/_form.html.erb b/app/views/admin/venue_management_bills/_form.html.erb index 667a81b..26ec334 100644 --- a/app/views/admin/venue_management_bills/_form.html.erb +++ b/app/views/admin/venue_management_bills/_form.html.erb @@ -29,7 +29,28 @@
<%= 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 \'\'}).join(\' \'))})()"} %> <% bill_typeB = @venue_management_bill.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 ] } %> + <%= 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');})()"} %> +
+
+
+ <% @site_in_use_locales.each_with_index do |locale, i| %> +
" id="bill_other_<%=locale%>"> + +
+ <%= f.fields_for :bill_other_translations do |f| %> + <%= f.text_field locale , class: "input-block-level", :value => (@venue_management_bill.bill_other_translations[locale] rescue nil), :placeholder=> t('vm_bill.bill_other') %> + <% end %> +
+
+ <% end %> +
+
+ <% @site_in_use_locales.each_with_index do |locale, i| %> + <%=t(locale)%> + <% end %> +
+
+
diff --git a/app/views/admin/venue_management_bills/_index.html.erb b/app/views/admin/venue_management_bills/_index.html.erb index c82c904..cc9f061 100644 --- a/app/views/admin/venue_management_bills/_index.html.erb +++ b/app/views/admin/venue_management_bills/_index.html.erb @@ -32,7 +32,11 @@
<%= bill.accounting_month.strftime("%Y-%m") %> - <%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %> + <%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %> + <% if bill.bill_typeB == 'other' && bill.bill_other.present? %> + -<%=bill.bill_other%> + <% end %> + <%= "#{t("vm_bill.#{bill.caculation_basis_type}")}: #{bill.caculation_basis}" %> <%= bill.reason %> <%= bill.amount %> diff --git a/app/views/venue_managements/show_bill.html.erb b/app/views/venue_managements/show_bill.html.erb index a1bc134..4780cad 100644 --- a/app/views/venue_managements/show_bill.html.erb +++ b/app/views/venue_managements/show_bill.html.erb @@ -26,7 +26,11 @@ <%= @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.#{@venue_management_bill.bill_typeA}")}/#{t("vm_bill.#{@venue_management_bill.bill_typeB}")}" %> + <% if @venue_management_bill.bill_typeB == 'other' && @venue_management_bill.bill_other.present? %> + -<%=@venue_management_bill.bill_other%> + <% end %> + <%= t('vm_bill.caculation_basis') %> diff --git a/app/views/venue_managements/show_data.html.erb b/app/views/venue_managements/show_data.html.erb index 3a8bb29..8c3342a 100644 --- a/app/views/venue_managements/show_data.html.erb +++ b/app/views/venue_managements/show_data.html.erb @@ -350,9 +350,17 @@ <% @bills.each do |bill| %> - <%= bill.contractor.display_contractors rescue "" %> + + <% contractors = bill.contractor.display_contractors rescue "" %> + <% contractors = t(:empty) if contractors.blank? %> + <%= link_to contractors, "/#{I18n.locale}"+@params[:url]+"/#{contractors.to_s.strip}-#{bill.id}?method=show_bill", :target => '_blank' %> + <%= bill.accounting_month.strftime("%Y-%m") %> - <%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %> + <%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %> + <% if bill.bill_typeB == 'other' && bill.bill_other.present? %> + -<%=bill.bill_other%> + <% end %> + <%= bill.caculation_basis %> <%= bill.reason %> <%= bill.amount %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 93b9c28..72525b8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -208,9 +208,11 @@ en: house_tax: House tax land_tax: Land tax other: Other + bill_other: Other item penalty: Penalty revenue: Revenue degree: Degree + prejudgment_interest: Prejudgment interest 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 2b4bd9d..b905746 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -208,9 +208,11 @@ zh_tw: house_tax: 房屋稅 land_tax: 地價稅 other: 其他 + bill_other: 其他項目 penalty: 罰款 revenue: 營業額 degree: 度數 + prejudgment_interest: 遲延利息 vm_contract: renewal_permission: 是否得續約 renewal_deadline: 續約申請期限