Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into crm

This commit is contained in:
Aung Myo
2017-07-03 10:29:07 +06:30
16 changed files with 194 additions and 171 deletions

View File

@@ -18,4 +18,5 @@
//= require cable
//= require jquery-ui
//= require bootstrap-datepicker
//= require bootstrap/modal
//= require bootstrap/modal

View File

@@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
//= require tether
//= require bootstrap
//= require jquery_ujs
//= require turbolinks

View File

@@ -28,6 +28,10 @@ class Api::BillController < Api::ApiController
@status = false
@error_message = "No Current Open Shift"
end
#@sale_data = Sale.find_by_sale_id(@sale_id)
#@sale_items = SaleItem.where("sale_id=?",@sale_id)
# Not Use for these printed bill cannot give customer
# @sale_data = Sale.find_by_sale_id(@sale_id)
# @sale_items = SaleItem.where("sale_id=?",@sale_id)
@@ -47,11 +51,12 @@ class Api::BillController < Api::ApiController
# # Calculate Price by accounts
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
#customer= Customer.find(@sale_data.customer_id)
# get member information
#member_info = Customer.get_member_account(customer)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
end

View File

@@ -115,18 +115,22 @@ class Crm::CustomersController < BaseCrmController
'Content-Type' => 'application/json',
'Accept' => 'application/json'
},
:timeout => 10
:timeout => 100
)
rescue Net::OpenTimeout
response = { status: false }
rescue OpenURI::HTTPError
response = { status: false}
rescue HTTParty::Error
response = {status: false, message: "Can't open embership server "}
rescue SocketError
response = { status: false}
end
rescue Net::OpenTimeout
response = { status: false , message: "Can't open embership server "}
rescue OpenURI::HTTPError
response = { status: false, message: "Can't open embership server "}
rescue SocketError
response = { status: false, message: "Can't open embership server "}
end
if response["status"] == true
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
@@ -141,14 +145,14 @@ class Crm::CustomersController < BaseCrmController
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. '}
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response[:message]}
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' }
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response[:message] }
end
end
else
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '}
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'}
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' }
end
@@ -252,7 +256,7 @@ end
)
rescue Net::OpenTimeout
response = { status: false }
rescue OpenURI::HTTPError
response = { status: false}

View File

@@ -77,7 +77,7 @@ class Settings::OrderQueueStationsController < ApplicationController
# params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by)
# =======
# Don't Know { zone_ids: [] }
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] })
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :auto_print, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] })
# >>>>>>> b093a993ba002c92659bbb34338c55c031c11d87
end
end

View File

@@ -27,16 +27,19 @@ class Customer < ApplicationRecord
'Content-Type' => 'application/json',
'Accept' => 'application/json'
},
:timeout => 10
:timeout => 100
)
rescue HTTParty::Error
response = {status: false, message: "Server Error"}
rescue Net::OpenTimeout
response = { status: false }
response = { status: false , message: "Server Time out"}
rescue OpenURI::HTTPError
response = { status: false}
response = { status: false, message: "Can't connect server"}
rescue SocketError
response = { status: false}
response = { status: false, message: "Can't connect server"}
end
return response;
@@ -60,13 +63,13 @@ class Customer < ApplicationRecord
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
response = { status: false , message: "Server Time out"}
rescue OpenURI::HTTPError
response = { status: false}
response = { status: false, message: "Can't connect server"}
rescue SocketError
response = { status: false}
response = { status: false, message: "Can't connect server"}
end
return response;

View File

@@ -281,8 +281,8 @@ class Sale < ApplicationRecord
# sale_tax.tax_payable_amount = total_taxable * tax.rate
# substract , to give after discount
total_taxable = total_taxable - total_discount
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
total_tax = total_taxable - total_discount
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount

View File

@@ -306,16 +306,22 @@ class SalePayment < ApplicationRecord
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
paypar = sObj.sale_payments
payparcost = 0
credit = 0
paypar.each do |pp|
if pp.payment_method == "paypar"
payparcost = payparcost + pp.payment_amount
elsif pp.payment_method == "creditnote"
credit = 1
end
end
# overall_dis = SaleItem.get_overall_discount(sObj.id)
overall_dis = sObj.total_discount
total_amount = rebate_prices - payparcost - overall_dis
if total_amount > 0
if credit == 1
total_amount = 0
end
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
@@ -331,15 +337,15 @@ class SalePayment < ApplicationRecord
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10)
}, :timeout => 100)
rescue Net::OpenTimeout
response = { status: false }
response = { status: false , message: "Server Time out"}
rescue OpenURI::HTTPError
response = { status: false}
response = { status: false, message: "Can't connect server"}
rescue SocketError
response = { status: false}
response = { status: false, message: "Can't connect server"}
end
return response
# puts response.to_json

View File

@@ -32,7 +32,7 @@
<script>
$('#close_cashier').on('click',function(){
var amount = $('#closing_balance_amount').val();
var shift_id = "<%= @shift.id %>"
var shift_id = "<%= @shift.id rescue ""%>"
$.ajax({type: "POST",
url: "<%= origami_close_shift_path %>",
data: "closing_balance="+ amount + "&shift_id="+ shift_id,