diff --git a/app/assets/stylesheets/foodcourt.scss b/app/assets/stylesheets/foodcourt.scss
index 2a203037..1736face 100644
--- a/app/assets/stylesheets/foodcourt.scss
+++ b/app/assets/stylesheets/foodcourt.scss
@@ -380,6 +380,12 @@ select.form-control {
font-weight: bolder;
}
+.btn_qrpay {
+ padding: 40px !important;
+ font-size: 20px !important;
+ font-weight: bolder;
+}
+
/* End Payment Page */
/* Logout Icon */
diff --git a/app/controllers/foodcourt/qrpay_controller.rb b/app/controllers/foodcourt/qrpay_controller.rb
index e9c88d27..cc8cf505 100644
--- a/app/controllers/foodcourt/qrpay_controller.rb
+++ b/app/controllers/foodcourt/qrpay_controller.rb
@@ -5,6 +5,196 @@ class Foodcourt::QrpayController < BaseFoodcourtController
skip_before_action :authenticate, only: [:create]
skip_before_action :verify_authenticity_token, only: [:create]
+ def precreate
+ @cash_exist = PaymentMethodSetting.cash_exist
+ @credit_exist = PaymentMethodSetting.credit_exist
+ display_type = Lookup.find_by_lookup_type("display_type")
+ if !display_type.nil? && display_type.value.to_i == 2
+ @display_type = display_type.value
+ else
+ @display_type = nil
+ end
+ path = request.fullpath
+ sale_id = params[:sale_id]
+ @trans_flag = true
+
+ @cashier_type = params[:cashier_type] || session[:cashier_type] || "cashier"
+ Rails.logger.info "Precreate action called with params: #{@cashier_type}"
+
+ # if params[:type] == "transaction"
+ # @trans_flag = false
+ # @cashier_type = "cashier"
+ # else
+ # @cashier_type = params[:type]
+ # end
+
+ if path.include? ("credit_payment")
+ @sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
+ end
+
+ @member_discount = MembershipSetting.find_by_discount(1)
+ @membership_rebate_balance=0
+
+ if Sale.exists?(sale_id)
+ begin
+ @cash = 0.0
+ @kbz_pay_amount = 0.0
+ @other = 0.0
+ @ppamount = 0.0
+ @visacount= 0.0
+ @jcbcount= 0.0
+ @mastercount = 0.0
+ @unionpaycount = 0.0
+ @alipaycount = 0.0
+ @junctionpaycount = 0.0
+ @credit = 0.0
+ @paymalcount = 0.0
+ @dingacount = 0.0
+ @giftvouchercount = 0.0
+ @sale_data = Sale.find_by_sale_id(sale_id)
+ @balance = 0
+ @accountable_type = ''
+ @table_no = ''
+ @dining = ''
+ @other_payment = 0.0
+ @pdf_view = nil
+ @lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
+ if !@lookup_pdf.nil?
+ @pdf_view = @lookup_pdf.value
+ end
+
+ amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
+ @kbz_pay_amount += amount.to_f
+
+ # @shop = shop_detail #show shop info
+
+ @customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
+ saleObj = Sale.find(sale_id)
+
+ #total customer with individual total amount
+ @individual_total = Array.new
+ if !saleObj.equal_persons.nil?
+ per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
+ @individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
+ end
+
+ if current_shop.is_rounding_adj
+ a = saleObj.grand_total % 25 # Modulus
+ b = saleObj.grand_total / 25 # Division
+ #not calculate rounding if modulus is 0 and division is even
+ #calculate rounding if modulus is zero or not zero and division are not even
+ if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
+ new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
+ @rounding_adj = new_total-saleObj.grand_total
+ saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
+ @sale_data.grand_total = new_total
+ @sale_data.old_grand_total = saleObj.grand_total
+ @sale_data.rounding_adjustment = @rounding_adj
+ else
+ @rounding_adj = @sale_data.rounding_adjustment
+ end
+ else
+ @rounding_adj = @sale_data.rounding_adjustment
+ end
+ #end rounding adjustment
+
+ # get printer info
+ @print_settings = PrintSetting.get_precision_delimiter()
+
+ #get customer amount
+ @customer = Customer.find(@sale_data.customer_id)
+ # accounts = @customer.tax_profiles
+ accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
+ @account_arr =[]
+ @tax_arr =[]
+ accounts.each do |acc|
+ account = TaxProfile.find(acc.id)
+ # @account_arr.push(account)
+ @tax_arr.push(account.name)
+ end
+ sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
+ if !sale_taxes.empty?
+ sale_taxes.each do |sale_tax|
+ @account_arr.push(sale_tax)
+ end
+ end
+ rebate = MembershipSetting.find_by_rebate(1)
+ # get member information
+ if @customer.membership_id != nil && rebate
+ response = Customer.get_member_account(@customer)
+ if response["status"]==true
+ response["account_data"].each do |res|
+ if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
+ @balance = @balance.to_f + res["balance"].to_f
+ # @accountable_type = res["accountable_type"]
+ @accountable_type = "Rebate Balance"
+ end
+ end
+ end
+ end
+
+ #end customer amount
+
+ #paymal payment
+
+ @sale_data.bookings.each do |sbk|
+ if sbk.dining_facility_id.to_i >0
+ df = DiningFacility.find(sbk.dining_facility_id)
+ @table_no = df.type + ' ' + df.name
+ @checkin_time = sbk.checkin_at
+ @dining = df
+ break
+ else
+ @table_no = nil
+ @checkin_time = nil
+ @dining = nil
+ end
+ end
+
+ if path.include? ("credit_payment")
+ @sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
+ else
+ @sale_payment_data = SalePayment.get_sale_payments(@sale_data)
+ end
+ @sale_payment_data.each do |spay|
+ if spay.payment_method == "cash"
+ @cash += spay.payment_amount
+ end
+ if spay.payment_method !="creditnote"
+ @other_payment += spay.payment_amount
+ end
+
+ if spay.payment_method == "mpu"
+ @other += spay.payment_amount
+ elsif spay.payment_method == "paypar"
+ @ppamount += spay.payment_amount
+ elsif spay.payment_method == "visa"
+ @visacount += spay.payment_amount
+ elsif spay.payment_method == "jcb"
+ @jcbcount += spay.payment_amount
+ elsif spay.payment_method == "master"
+ @mastercount += spay.payment_amount
+ elsif spay.payment_method == "unionpay"
+ @unionpaycount += spay.payment_amount
+ elsif spay.payment_method == "JunctionPay"
+ @junctionpaycount += spay.payment_amount
+ elsif spay.payment_method == "creditnote"
+ @credit += spay.payment_amount
+ elsif spay.payment_method == "paymal"
+ @paymalcount += spay.payment_amount
+ elsif spay.payment_method == "alipay"
+ @alipaycount += spay.payment_amount
+ elsif spay.payment_method == "dinga"
+ @dingacount += spay.payment_amount
+ elsif spay.payment_method == "giftvoucher"
+ @giftvouchercount += spay.payment_amount
+ end
+ end
+
+ end
+ end
+ end
+
def init
@cash_exist = PaymentMethodSetting.cash_exist
@credit_exist = PaymentMethodSetting.credit_exist
diff --git a/app/views/foodcourt/orders/_read_modal.html.erb b/app/views/foodcourt/orders/_read_modal.html.erb
index e773d48b..efee4b58 100644
--- a/app/views/foodcourt/orders/_read_modal.html.erb
+++ b/app/views/foodcourt/orders/_read_modal.html.erb
@@ -226,10 +226,10 @@
<% mmqr = PaymentMethodSetting.find_by(payment_method: 'MMQR') %>
<% if mmqr.present? && mmqr.is_active %>
@@ -282,43 +282,85 @@ document.addEventListener('DOMContentLoaded', function () {
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
document.getElementById('fullpage-loading').style.display = 'flex';
- setTimeout(function() {
- document.getElementById('fullpage-loading').style.display = 'none';
- }, 5000);
- initDynamicQrPay();
+ setTimeout(function() {
+ document.getElementById('fullpage-loading').style.display = 'none';
+ }, 5000);
+ precreateDynamicQrPay();
+ // initDynamicQrPay();
+ });
+
+ function precreateDynamicQrPay() {
+ const paymentMethod = 'MMQR';
+ const $serverMode = $('#server_mode');
+ const $createOrderBtn = $('#create_order');
+ const $createPayOrderBtn = $('#create_pay_order');
+
+ const params = {
+ order_source: "food_court",
+ order_type: "dine_in",
+ customer_id: $("#customer_id").text(),
+ guest_info: "",
+ table_id: $("#table_id").text(),
+ order_items: JSON.stringify(get_order_item_rows()),
+ create_type: "create_pay",
+ };
+
+ $.ajax({
+ url: '/foodcourt/addorders/create',
+ method: 'POST',
+ contentType: 'application/json',
+ headers: {
+ 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
+ },
+ data: JSON.stringify(params),
+ success: function(result) {
+ const booking_id = result.booking_id;
+ window.location.href = `/foodcourt/${result.sale_id}/qrpay/precreate`;
+ if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
+ // customer_display_view(null, "reload");
+ }
+ },
+ error: function(xhr) {
+ $('#oqs_loading_wrapper').hide();
+ $createOrderBtn.prop('disabled', false);
+ $createPayOrderBtn.prop('disabled', false);
+
+ const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
+ swal("Error", errorMsg, "error");
+ }
});
}
- function initDynamicQrPay() {
- const paymentMethod = 'MMQR';
- const $serverMode = $('#server_mode');
- const $createOrderBtn = $('#create_order');
- const $createPayOrderBtn = $('#create_pay_order');
+ // function initDynamicQrPay() {
+ // const paymentMethod = 'MMQR';
+ // const $serverMode = $('#server_mode');
+ // const $createOrderBtn = $('#create_order');
+ // const $createPayOrderBtn = $('#create_pay_order');
- $.ajax({
- url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
- method: 'GET',
- success: function(result) {
- console.log(result);
- if(! result.status) {
- alert('Something went wrong');
- return;
- }
+ // $.ajax({
+ // url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
+ // method: 'GET',
+ // success: function(result) {
+ // console.log(result);
+ // if(! result.status) {
+ // alert('Something went wrong');
+ // return;
+ // }
- window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
- if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
- // customer_display_view(null, "reload");
- }
- },
- error: function(xhr) {
- $('#oqs_loading_wrapper').hide();
- $createOrderBtn.prop('disabled', false);
- $createPayOrderBtn.prop('disabled', false);
+ // window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
+ // if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
+ // // customer_display_view(null, "reload");
+ // }
+ // },
+ // error: function(xhr) {
+ // $('#oqs_loading_wrapper').hide();
+ // $createOrderBtn.prop('disabled', false);
+ // $createPayOrderBtn.prop('disabled', false);
- const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
- swal("Error", errorMsg, "error");
- }
- });
- }
+ // const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
+ // swal("Error", errorMsg, "error");
+ // }
+ // });
+ // }
});
diff --git a/app/views/foodcourt/qrpay/precreate.html.erb b/app/views/foodcourt/qrpay/precreate.html.erb
new file mode 100644
index 00000000..d087e94f
--- /dev/null
+++ b/app/views/foodcourt/qrpay/precreate.html.erb
@@ -0,0 +1,1356 @@
+
+
+
+<% if !@print_settings.nil? %>
+ <% if @print_settings.precision.to_i > 0
+ precision = @print_settings.precision
+ else
+ precision = 0
+ end
+ #check delimiter
+ if @print_settings.delimiter
+ delimiter = ","
+ else
+ delimiter = ""
+ end
+ %>
+<% end %>
+
+
+
+
+ <% if @error %>
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+ | # |
+ Items |
+ QTY |
+ Price |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ " id="server_mode">
+
+
+
+
+
+
+ <%= link_to '/foodcourt/app_orders', class: 'btn btn-block btn-default waves-effect', :id => 'foodcourt_back', style: "padding-top: 0;" do%>
+
reply
+ BACK
+ <% end %>
+
+ <% if @sale_payment.nil? %>
+
+ <% if current_login_employee.role == "cashier" %>
+
Void
+
Edit
+ <% else %>
+
+
+ <% end %>
+
+
+ <%end %>
+
+
">
+
+
+
+
+
+
+
+
+
+
+ <% if !@customer_lists.nil? %>
+ <% @customer_lists.each do |cus| %>
+ <% if cus.customer_id != @customer.id %>
+
+
+
+ <% end %>
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <% if !@tax_arr.empty? %>
+ <% if @tax_arr.count > 1 %>
+
+
+
+
+
+ <% @tax_arr.each_with_index do |tax, tax_index| %>
+ <% if (tax_index+1)%2 == 0 %>
+
+ <% end %>
+
+
+
+ <% end %>
+ <% else %>
+
+
+ <% @tax_arr.each do |tax| %>
+
+
+
+ <% end %>
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+<%= render "layouts/read_modal" %>
+
+
\ No newline at end of file
diff --git a/app/views/layouts/_read_modal.html.erb b/app/views/layouts/_read_modal.html.erb
index 3aa29dab..7e74c141 100644
--- a/app/views/layouts/_read_modal.html.erb
+++ b/app/views/layouts/_read_modal.html.erb
@@ -292,10 +292,11 @@ document.addEventListener('DOMContentLoaded', function () {
setTimeout(function() {
document.getElementById('fullpage-loading').style.display = 'none';
}, 5000);
- initDynamicQrPay();
+ precreateDynamicQrPay();
+ // initDynamicQrPay();
});
- function initDynamicQrPay() {
+ function precreateDynamicQrPay() {
const paymentMethod = 'MMQR';
const $serverMode = $('#server_mode');
const $createOrderBtn = $('#create_order');
@@ -321,7 +322,7 @@ document.addEventListener('DOMContentLoaded', function () {
data: JSON.stringify(params),
success: function(result) {
const booking_id = result.booking_id;
- window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
+ window.location.href = `/foodcourt/${result.sale_id}/qrpay/precreate`;
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
// customer_display_view(null, "reload");
}
@@ -336,5 +337,47 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
}
+
+ // function initDynamicQrPay() {
+ // const paymentMethod = 'MMQR';
+ // const $serverMode = $('#server_mode');
+ // const $createOrderBtn = $('#create_order');
+ // const $createPayOrderBtn = $('#create_pay_order');
+
+ // const params = {
+ // order_source: "food_court",
+ // order_type: "dine_in",
+ // customer_id: $("#customer_id").text(),
+ // guest_info: "",
+ // table_id: $("#table_id").text(),
+ // order_items: JSON.stringify(get_order_item_rows()),
+ // create_type: "create_pay",
+ // };
+
+ // $.ajax({
+ // url: '/foodcourt/addorders/create',
+ // method: 'POST',
+ // contentType: 'application/json',
+ // headers: {
+ // 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
+ // },
+ // data: JSON.stringify(params),
+ // success: function(result) {
+ // const booking_id = result.booking_id;
+ // window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
+ // if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
+ // // customer_display_view(null, "reload");
+ // }
+ // },
+ // error: function(xhr) {
+ // $('#oqs_loading_wrapper').hide();
+ // $createOrderBtn.prop('disabled', false);
+ // $createPayOrderBtn.prop('disabled', false);
+
+ // const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
+ // swal("Error", errorMsg, "error");
+ // }
+ // });
+ // }
});
diff --git a/config/routes.rb b/config/routes.rb
index 96b6ee3c..4243d558 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -746,6 +746,7 @@ scope "(:locale)", locale: /en|mm/ do
get '/:sale_id/reprint' => 'payments#reprint', :defaults => {:format => 'json'}
get '/food_court/:order_id/cancel_order' => 'orders#cancel_order', :as => 'cancel_order'
+ get '/:sale_id/qrpay/precreate' => 'qrpay#precreate'
get '/:sale_id/qrpay/init' => 'qrpay#init'
post 'qrpay/cancel' => 'qrpay#cancel'
get 'qrpay/test-payment' => 'qrpay#test_payment'