update customer tax calc
This commit is contained in:
@@ -37,14 +37,14 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||||
#@products = Product.order("name").page(params[:page]).per(5)
|
#@products = Product.order("name").page(params[:page]).per(5)
|
||||||
else
|
else
|
||||||
@crm_customers = Customer.search(filter)
|
@crm_customers = Customer.search(filter)
|
||||||
|
|
||||||
end
|
end
|
||||||
#@crm_customers = Customer.all
|
#@crm_customers = Customer.all
|
||||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||||
@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
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# #Creat new tax records
|
# #Creat new tax records
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
customer.tax_profiles.each do |cus_tax|
|
customer.tax_profiles.each do |cus_tax|
|
||||||
if cus_tax == tax.id
|
if cus_tax.to_i == tax.id
|
||||||
sale_tax = SaleTax.new(:sale => sale)
|
sale_tax = SaleTax.new(:sale => sale)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax.tax_rate = tax.rate
|
||||||
@@ -318,10 +318,11 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||||
|
|
||||||
customer = Customer.find(self.customer_id)
|
customer = Customer.find(self.customer_id)
|
||||||
|
|
||||||
# #Create new tax records
|
# #Create new tax records
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
customer.tax_profiles.each do |cus_tax|
|
customer.tax_profiles.each do |cus_tax|
|
||||||
if cus_tax == tax.id
|
if cus_tax.to_i == tax.id
|
||||||
sale_tax = SaleTax.new(:sale => self)
|
sale_tax = SaleTax.new(:sale => self)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax.tax_rate = tax.rate
|
||||||
|
|||||||
@@ -82,17 +82,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Date Of Birth</label>
|
<label>Date Of Birth</label>
|
||||||
<%= 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">
|
<div class="form-group">
|
||||||
<label>Select Customer Type</label>
|
<label>Select Customer Type</label>
|
||||||
@@ -103,10 +93,21 @@
|
|||||||
<%end %>
|
<%end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
|
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
|
||||||
</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">
|
<div class="form-group">
|
||||||
<label>Paypar Account No:</label>
|
<label>Paypar Account No:</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
|||||||
@@ -81,23 +81,7 @@
|
|||||||
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
|
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
|
||||||
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
|
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
<%= 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['name']}\"]"
|
|
||||||
str.gsub!('["', '')
|
|
||||||
str.gsub!('"]', '') %>
|
|
||||||
<span class="help-block" style="margin-top:-10px"><%= 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>
|
||||||
@@ -176,6 +160,37 @@
|
|||||||
<%= 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">
|
||||||
|
<label>Select Customer Type</label>
|
||||||
|
<select class="selectpicker form-control col-md-12" id="customer_type" 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 <%= (flash["errors"]) ? "has-error" : "" %>">
|
||||||
|
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
|
||||||
|
<% flash.each do |name, msg| %>
|
||||||
|
<% str="[\"#{msg['name']}\"]"
|
||||||
|
str.gsub!('["', '')
|
||||||
|
str.gsub!('"]', '') %>
|
||||||
|
<span class="help-block" style="margin-top:-10px"><%= 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>Select Member Group</label>
|
<label>Select Member Group</label>
|
||||||
<select class="selectpicker form-control col-md-12" name="member_group_id">
|
<select class="selectpicker form-control col-md-12" name="member_group_id">
|
||||||
@@ -292,6 +307,11 @@
|
|||||||
data: {},
|
data: {},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
var parse_taxes = JSON.parse(data.tax_profiles);
|
||||||
|
$.each(parse_taxes, function(i, value){
|
||||||
|
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
|
||||||
|
});
|
||||||
|
|
||||||
$('#customer_id').val(data.id);
|
$('#customer_id').val(data.id);
|
||||||
$('#customer_name').val(data.name);
|
$('#customer_name').val(data.name);
|
||||||
$('#customer_company').val(data.company);
|
$('#customer_company').val(data.company);
|
||||||
@@ -301,7 +321,8 @@
|
|||||||
$('#customer_membership_type').val(data.membership_type);
|
$('#customer_membership_type').val(data.membership_type);
|
||||||
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
|
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
|
||||||
$('.membership_authentication_code').val(data.membership_authentication_code);
|
$('.membership_authentication_code').val(data.membership_authentication_code);
|
||||||
|
$('#customer_card_no').val(data.card_no);
|
||||||
|
$('#customer_type').val(data.customer_type);
|
||||||
$('#customer_salutation').val(data.salutation);
|
$('#customer_salutation').val(data.salutation);
|
||||||
$('#customer_nrc_no').val(data.nrc_no);
|
$('#customer_nrc_no').val(data.nrc_no);
|
||||||
$('#paypar_account_no').val(data.paypar_account_no);
|
$('#paypar_account_no').val(data.paypar_account_no);
|
||||||
|
|||||||
Reference in New Issue
Block a user