Edit bills feature

This commit is contained in:
BoHung Chiu 2020-09-08 16:32:08 +08:00
parent f655b68697
commit 84bdf0c9f1
7 changed files with 52 additions and 7 deletions

View File

@ -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

View File

@ -29,7 +29,28 @@
<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(\' \'))})()"} %>
<% 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');})()"} %>
<div id="bill_other_field" class="tab-content language-area <%=@venue_management_bill.bill_typeB == 'other' ? '' : 'hidden'%>">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>" id="bill_other_<%=locale%>">
<!-- Bill other -->
<div class="add-input address-input">
<%= 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 %>
</div>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= (i == 0 ? 'active' : '') %> last" href="#bill_other_<%=locale%>" data-toggle="tab"><%=t(locale)%></a>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="control-group">

View File

@ -32,7 +32,11 @@
</div>
</td>
<td><%= bill.accounting_month.strftime("%Y-%m") %></td>
<td><%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %></td>
<td><%= "#{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 %>
</td>
<td><%= "#{t("vm_bill.#{bill.caculation_basis_type}")}: #{bill.caculation_basis}" %></td>
<td><%= bill.reason %></td>
<td><%= bill.amount %></td>

View File

@ -26,7 +26,11 @@
<td class="venue_managementive-title-value"><%= @venue_management_bill.accounting_month.strftime("%Y-%m") %></td>
<tr>
<th class="venue_managementive-title-field"><%= t('vm_bill.bill_type') %></th>
<td class="venue_managementive-title-value"><%= "#{t("vm_bill.#{@venue_management_bill.bill_typeA}")}/#{t("vm_bill.#{@venue_management_bill.bill_typeB}")}" %></td>
<td class="venue_managementive-title-value"><%= "#{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 %>
</td>
</tr>
<tr>
<th class="venue_managementive-title-field"><%= t('vm_bill.caculation_basis') %></th>

View File

@ -350,9 +350,17 @@
<tbody data-level="1" data-list="plugin_datas">
<% @bills.each do |bill| %>
<tr>
<td><%= bill.contractor.display_contractors rescue "" %></td>
<td>
<% 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' %>
</td>
<td><%= bill.accounting_month.strftime("%Y-%m") %></td>
<td><%= "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" %></td>
<td><%= "#{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 %>
</td>
<td><%= bill.caculation_basis %></td>
<td><%= bill.reason %></td>
<td><%= bill.amount %></td>

View File

@ -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

View File

@ -208,9 +208,11 @@ zh_tw:
house_tax: 房屋稅
land_tax: 地價稅
other: 其他
bill_other: 其他項目
penalty: 罰款
revenue: 營業額
degree: 度數
prejudgment_interest: 遲延利息
vm_contract:
renewal_permission: 是否得續約
renewal_deadline: 續約申請期限