update customer validation messages

This commit is contained in:
Aung Myo
2017-07-28 18:08:11 +06:30
parent 98c04f21d8
commit 78d383f5ec
3 changed files with 15 additions and 8 deletions

View File

@@ -7,8 +7,8 @@ class Customer < ApplicationRecord
has_many :sales has_many :sales
validates_presence_of :name, :contact_no, :email,:card_no validates_presence_of :name, :contact_no, :email,:card_no
validates :contact_no, uniqueness: true validates :contact_no, uniqueness: true, numericality: true
validates :email, uniqueness: true validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
validates :card_no, uniqueness: true validates :card_no, uniqueness: true
validates :paypar_account_no, uniqueness: true validates :paypar_account_no, uniqueness: true

View File

@@ -667,6 +667,12 @@ end
.where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
OR sh.shift_closed_at between ? and ? )", from ,to, from, to) OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
if shift.present?
query = query.where("sales.sale_status = 'void' and s.shift_sale_id in (?)",shift.to_a)
else
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
end
out = {:items => account} out = {:items => account}
sale_arr.push(out) sale_arr.push(out)
return sale_arr return sale_arr

View File

@@ -6,7 +6,7 @@
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>"> <div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%> <%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %> <% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]" <% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '') str.gsub!('["', '')
str.gsub!('"]', '') %> str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span> <span class="help-block" style="margin-top:-6px"><%= str %></span>
@@ -35,8 +35,9 @@
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>"> <div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %> <%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %> <% flash.each do |test, msg| %>
<% str="[\"#{msg['name']}\"]" <%
str="[\"#{msg['name']}\"]"
str.gsub!('["', '') str.gsub!('["', '')
str.gsub!('"]', '') %> str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span> <span class="help-block" style="margin-top:-6px"><%= str %></span>
@@ -80,7 +81,7 @@
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%> <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %> <% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]" <% str="[\"#{msg['email']}\"]"
str.gsub!('["', '') str.gsub!('["', '')
str.gsub!('"]', '') %> str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span> <span class="help-block" style="margin-top:-6px"><%= str %></span>