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
validates_presence_of :name, :contact_no, :email,:card_no
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
validates :contact_no, uniqueness: true, numericality: 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 :paypar_account_no, uniqueness: true

View File

@@ -666,7 +666,13 @@ end
.joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
.where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
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}
sale_arr.push(out)
return sale_arr