add customer tax

This commit is contained in:
Yan
2017-08-08 18:02:05 +06:30
parent f46d786859
commit 1685713ff5
5 changed files with 52 additions and 30 deletions

View File

@@ -17,6 +17,8 @@ class Crm::CustomersController < BaseCrmController
@crm_customer = Customer.new @crm_customer = Customer.new
@count_customer = Customer.count_customer @count_customer = Customer.count_customer
@taxes = TaxProfile.all.order("order_by asc")
# if flash["errors"] # if flash["errors"]
# @crm_customer.valid? # @crm_customer.valid?
# end # end
@@ -72,6 +74,9 @@ class Crm::CustomersController < BaseCrmController
respond_to do |format| respond_to do |format|
if @crm_customers.save if @crm_customers.save
# update tax profile
customer = Customer.find(@crm_customers.customer_id)
customer.update_attributes(tax_profiles: params[:customer][:tax_profiles].to_json)
name = customer_params[:name] name = customer_params[:name]
phone = customer_params[:contact_no] phone = customer_params[:contact_no]
email = customer_params[:email] email = customer_params[:email]
@@ -346,7 +351,7 @@ end
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def customer_params def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email, params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no) :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
end end
end end

View File

@@ -3,24 +3,6 @@
<span class="patch_method"></span> <span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end %>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Salutation :</label><br> <label>Salutation :</label><br>
<label>Mr</label> <label>Mr</label>
@@ -102,6 +84,38 @@
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> <%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div> </div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end %>
</div>
<div class="form-group">
<label>Select Customer Type</label>
<select class="selectpicker form-control col-md-12" name="customer[customer_type]" style="height: 40px" >
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label> <label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" > <select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" >
@@ -111,7 +125,6 @@
<%= member.name %></option> <%= member.name %></option>
<%end %> <%end %>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -138,6 +151,11 @@
},100); },100);
} }
}); });
// $("#customer_card_no").click(function(){
// var ab=$("#customer_tax_profiles").val();
// console.log(JSON.stringify(ab));
// });
}); });

View File

@@ -76,7 +76,7 @@
</div> </div>
</div> </div>
<%= render 'new_form', crm_customer: @crm_customer %> <%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<br> <br>

View File

@@ -16,7 +16,7 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
t.string :membership_id t.string :membership_id
t.string :membership_type t.string :membership_type
t.string :membership_authentication_code t.string :membership_authentication_code
t.string :customer_type, default => "Dinein" t.string :customer_type, :default => "Dinein"
t.json :tax_profiles t.json :tax_profiles
end end
end end

View File

@@ -94,10 +94,9 @@ float_value = Lookup.create([{lookup_type:'float_value', name: '500', value: '50
{lookup_type:'float_value', name: '10000', value: '10000'}]) {lookup_type:'float_value', name: '10000', value: '10000'}])
# customer type # customer type
customer_type = Lookup.create([{lookup_type:'float_value', name: '500', value: '500'}, customer_type = Lookup.create([{lookup_type:'customer_type', name: 'Dinein', value: 'Dinein'},
{lookup_type:'float_value', name: '1000', value: '1000'}, {lookup_type:'customer_type', name: 'Takeaway', value: 'Takeaway'},
{lookup_type:'float_value', name: '5000', value: '5000'}, {lookup_type:'customer_type', name: 'Delivery', value: 'Delivery'}])
{lookup_type:'float_value', name: '10000', value: '10000'}])
#WALK CUSTOMER - Default CUSTOMER (take key 1) #WALK CUSTOMER - Default CUSTOMER (take key 1)
customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"})