Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into r-1804001-01

This commit is contained in:
Aung Myo
2018-04-20 17:04:18 +06:30
10 changed files with 101 additions and 88 deletions

View File

@@ -62,7 +62,7 @@ $(function() {
// console.log(data);
var delivery = data["delivery"];
var items = data["order_items"];
console.log(data)
var item_list = $('.summary-items');
item_list.empty();
@@ -113,7 +113,12 @@ $(function() {
$("#order_remark").text(data.reservation_remark);
}
$("#sr_number").text("No."+sr_no);
$("#contact_info").text();
if (data["receipt_no"]) {
$("#contact_info").text(data["receipt_no"]);
}else{
$("#contact_info").text(data["order_reservation_id"]);
}
}
}
}

View File

@@ -285,10 +285,10 @@ class Origami::DiscountsController < BaseOrigamiController
'Accept' => 'application/json; version=3'
}, :timeout => 10)
rescue HTTParty::Error
response = {"status": false, "message": "Can't open membership server " }
response = {"status": false, "message": "Http party error" }
rescue Net::OpenTimeout
response = {"status": false, "message": "Can't open membership server " }
response = {"status": false, "message": "Connection TIme out " }
rescue OpenURI::HTTPError
response = {"status": false, "message": "Can't open membership server " }

View File

@@ -2603,34 +2603,35 @@ end
end
def self.all_receipts
query = Sale.select("sales.*, sale_payments.created_at as receipt_close_time,
case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
SUM(sale_items.qty) as qty,
sales.cashier_name as cashier_name,
surveys.child as child,
surveys.adult as adult")
query = Sale.select("sale_payments.created_at as receipt_close_time,
case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
SUM(sale_items.qty) as qty,
sales.cashier_name as cashier_name,
surveys.child as child,
surveys.adult as adult")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join sale_taxes on sale_taxes.sale_id = sales.sale_id")
.joins("join sale_items on sale_items.sale_id = sales.sale_id")
.joins("join sale_audits on sale_audits.sale_id = sales.sale_id")
.joins("left join surveys on surveys.receipt_no = sales.receipt_no")
query = query.where("sale_status != 'new' && sale_payments.payment_amount > 0")
.group("sale_id")
query = query.where("sales.sale_status != 'new' && sale_payments.payment_amount > 0")
query = query.where("sales.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-02-05 13:59:59 +0630')
.group("sales.sale_id")
return query
end
@@ -2640,7 +2641,8 @@ def self.all_receipt_details
.joins("join sale_payments on sale_payments.sale_id = sale_items.sale_id")
.joins("join sales on sales.sale_id = sale_items.sale_id")
.group("sale_items.sale_item_id")
query = query.where("qty > 0 and sales.sale_status !='new'")
query = query.where("sale_itemsqty > 0 and sales.sale_status !='new'")
query = query.where("sale_items.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-02-05 13:59:59 +0630')
return query
end

View File

@@ -142,7 +142,7 @@ $(function() {
});
// QR Code Reader
$("#qr_code").on('sclick', function(e){
$("#qr_code").on('click', function(e){
var code = "";
setTimeout(function(){
code=getQRCode();

View File

@@ -358,7 +358,7 @@
}
// QR Code Reader
$("#qr_code").on('click', function(e){
$("#qr_code").on('click', function(e){
var code = "";
var customer_id = '';
var customer_name = '';
@@ -368,35 +368,34 @@
setTimeout(function(){
code=getQRCode();
setQRCode(code);
}, 100);
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
// $.alert({
// title: 'Alert!',
// content: data[0].message,
// type: 'red',
// typeAnimated: true,
// btnClass: 'btn-danger',
// });
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
}
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
// $.alert({
// title: 'Alert!',
// content: data[0].message,
// type: 'red',
// typeAnimated: true,
// btnClass: 'btn-danger',
// });
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
}
});
}
},100);
}
});
}
});
// Read qrcode from java

View File

@@ -4,7 +4,7 @@ if @order
:requested_time,:callback_url,:transaction_ref,:item_count,:total_customer,:payment_type,
:payment_status,:payment_ref,:total_amount,:total_tax,
:discount_amount,:grand_total,:status,:order_remark,
:reservation_remark)
:reservation_remark,:sale_id)
@delivery = Delivery.find_by_order_reservation_id(@order.order_reservation_id)
if @delivery
json.delivery do |json|
@@ -22,4 +22,9 @@ if @order
json.customer_name @customer.name
json.phone @customer.contact_no
if @order.sale_id
@receipt_no = Sale.find(@order.sale_id).receipt_no
json.receipt_no @receipt_no
end
end

View File

@@ -152,11 +152,12 @@
<div class="card-header custom-card-header" style="color:">
<table class="table">
<tr>
<td width ="70%" class="header-td align-left">
<td width ="30%" class="header-td align-left">
<b class="col-pink font-16"><span id="sr_number"></span> </b>
<span class="font-13"><span id="delivery_info"></span></span>
</td>
<td width ="30%" class="header-td font-16 align-right"><b><span id="contact_info">0065 4321</span></b></td>
<td class="header-td align-left"></td>
<td width ="50%" class="header-td font- align-right"><b><span id="contact_info"></span></b></td>
</tr>
</table>
</div>

View File

@@ -1134,33 +1134,34 @@ var customer_name = "<%= @customer.name %>";
var membership_type = '';
setTimeout(function(){
code=getQRCode();
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : code ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
$("#qr_code").val(code);
});
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : code ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
});
}
},100);
}
});
}
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
$("#qr_code").val(code);
return code2lab.readQRCode();
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {

View File

@@ -20,11 +20,11 @@ class ActionController::Base
end
else
#check for license file
if check_license
current_license(ENV["SX_PROVISION_URL"])
else
redirect_to activate_path
end
# if check_license
# current_license(ENV["SX_PROVISION_URL"])
# else
# redirect_to activate_path
# end
end
end

View File

@@ -1,9 +1,9 @@
namespace :consolidate do
desc "Receipt"
task :receipt => :environment do
Receipt.delete_all
# Receipt.delete_all
sales = Sale.all_receipts
puts sales.to_json
shop = Shop.find(1)
sales.each do |sale|
puts sale.to_json