venue_management/app/models/venue_management_bill.rb

28 lines
1.3 KiB
Ruby

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