order quries update

This commit is contained in:
Yan
2017-06-12 20:14:20 +06:30
10 changed files with 66 additions and 46 deletions

View File

@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
gem 'mysql2', '>= 0.3.18', '< 0.5'
#Use PosgreSQL
# gem 'pg'
gem 'pg'
# redis server for cable
# gem 'redis', '~> 3.0'

View File

@@ -110,6 +110,7 @@ GEM
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
pdf-core (0.7.0)
pg (0.20.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -246,6 +247,7 @@ DEPENDENCIES
kaminari (~> 0.16.3)
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
pg
prawn
prawn-table
puma (~> 3.0)

View File

@@ -190,11 +190,17 @@ $(document).ready(function(){
function show_customer_details(customer_id){
$('.customer_detail').removeClass('hide');
if(window.location.pathname.substring(0, 12) == "/origami/SAL"){
var url = customer_id+"/get_customer/"
}else{
var url = "origami/"+customer_id+"/get_customer/"
}
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: "origami/"+customer_id+"/get_customer/",
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
@@ -203,10 +209,10 @@ $(document).ready(function(){
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
console.log(balance);
if (balance) {
$("#customer_amount").text(balance);
if (balance == "0.0") {
$("#customer_amount").text('0.0');
}else{
$("#customer_amount").text('00');
$("#customer_amount").text(balance);
}

View File

@@ -8,9 +8,15 @@ class Api::BillController < Api::ApiController
#create Bill by Booking ID
if (params[:booking_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
booking = Booking.find(params[:booking_id])
if booking
if booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
else
@status = true
end
end
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)

View File

@@ -5,7 +5,7 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers.json
def index
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
@@ -31,7 +31,7 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1.json
def show
@orders = Order.where("customer_id=?", params[:id])
if @orders
@order_items = []
@orders.each do |bo|
@@ -57,13 +57,13 @@ class Crm::CustomersController < BaseCrmController
def create
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customers.save
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
dob = customer_params[:date_of_birth]
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -72,7 +72,9 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
dob: dob,
member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
@@ -81,18 +83,18 @@ class Crm::CustomersController < BaseCrmController
)
if response["status"] == true
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
end
end
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
@@ -103,7 +105,7 @@ class Crm::CustomersController < BaseCrmController
else
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
@@ -123,8 +125,8 @@ end
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
id = customer_params[:membership_id]
dob = customer_params[:date_of_birth]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -133,7 +135,7 @@ end
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
dob: dob,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',

View File

@@ -28,8 +28,8 @@ class Origami::CustomersController < BaseOrigamiController
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
puts "Errrrrrrrrrrrrrrrrr"
puts @crm_customer.new_record?
# puts "Errrrrrrrrrrrrrrrrr"
# puts @crm_customer.valid?
respond_to do |format|

View File

@@ -24,8 +24,8 @@ class Origami::PaymentsController < BaseOrigamiController
if spay.payment_method == "cash"
@cash = spay.payment_amount
end
if spay.payment_method == "mpu"
@other = spay.payment_amount
if spay.payment_method == "mpu" || spay.payment_method == "paypar"
@other += spay.payment_amount
end
end
end

View File

@@ -243,21 +243,9 @@ class Order < ApplicationRecord
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
end
#Origami: Cashier : to view booking order Table
# def self.get_booking_order_table
# booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,
# bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
# .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
# .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
# .joins("left join orders on orders.order_id = booking_orders.order_id")
# .joins("left join sales on sales.sale_id = bookings.sale_id")
# .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
# .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id")
# end
#Origami: Cashier : to view order type Room
def self.get_booking_order_rooms
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
@@ -270,7 +258,7 @@ class Order < ApplicationRecord
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id")
end
#Origami: Cashier : to view order type Room

View File

@@ -60,7 +60,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
return false, "No outstanding Amount"
end
@@ -217,7 +217,7 @@ class SalePayment < ApplicationRecord
self.sale.sale_status = "completed"
self.sale.save!
table_update_status(sObj)
rebat()
rebat(sObj)
end
end
@@ -233,8 +233,24 @@ class SalePayment < ApplicationRecord
end
end
def rebat
def rebat(sObj)
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
generic_customer_id = sObj.customer.membership_id
total_amount = food_prices
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id,
receipt_no: receipt_no}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
})
puts response.to_json
end
private

View File

@@ -157,7 +157,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})