crong job and close cashier
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -59,6 +59,7 @@ gem 'jbuilder', '~> 2.5'
|
||||
gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
gem 'sidekiq'
|
||||
gem 'whenever', :require => false
|
||||
|
||||
# XML parser
|
||||
#gem 'nokogiri', '~> 1.6'
|
||||
|
||||
@@ -51,6 +51,7 @@ GEM
|
||||
builder (3.2.3)
|
||||
byebug (9.0.6)
|
||||
cancancan (1.17.0)
|
||||
chronic (0.10.2)
|
||||
coffee-rails (4.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0)
|
||||
@@ -237,6 +238,8 @@ GEM
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
whenever (0.9.7)
|
||||
chronic (>= 0.6.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -282,6 +285,7 @@ DEPENDENCIES
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (>= 3.3.0)
|
||||
whenever
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.1
|
||||
|
||||
@@ -123,7 +123,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
# @crm_customers.destroy
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '}
|
||||
else
|
||||
@@ -207,7 +208,12 @@ end
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
|
||||
|
||||
else
|
||||
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: response["error"] }
|
||||
end
|
||||
|
||||
|
||||
@@ -73,6 +73,48 @@ class Customer < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.update_membership
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
|
||||
|
||||
@customers.each do |customer|
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body =>
|
||||
{ name: customer.name,phone: customer.contact_no,
|
||||
email: customer.email,dob: customer.date_of_birth,
|
||||
address: customer.address,nrc:customer.nrc_no,
|
||||
card_no:customer.card_no,member_group_id: customer.membership_type,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
})
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
puts response.to_json
|
||||
|
||||
if response["status"] == true
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
|
||||
@@ -168,7 +168,10 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
move_down 5
|
||||
|
||||
end
|
||||
|
||||
|
||||
7
config/schedule.rb
Normal file
7
config/schedule.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
set :environment, "development"
|
||||
env :PATH, ENV['PATH']
|
||||
set :output, 'log/whenever.log'
|
||||
|
||||
every 30.minutes do
|
||||
runner "Customer.update_membership"
|
||||
end
|
||||
Reference in New Issue
Block a user