fixed confiixed for print

This commit is contained in:
Aung Myo
2018-01-12 15:19:22 +06:30
58 changed files with 1520 additions and 230 deletions

View File

@@ -49,6 +49,10 @@ Order Item & Order Summary Slim
5) app/models/printer/order_queue_printer.rb
6) app/models/printer/receipt_printer.rb
For Bank Integration setting
1) rake db:migrate for card_sale_trans, card_settle_trans
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }
* ToDo list
1. Cloud Sync

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -194,4 +194,135 @@ function deleteReceiptNoInFirstBillData(receipt_no) {
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
}
}
/* end check first bill or not funs: */
/* end check first bill or not funs: */
//start CB ECR integration
//set CB com port data
function setCommPorts(comPortLists) {
var sale_id = "<%= @sale_id %>";
$('#com_port_name').html("");
var jsonPortLists = $.parseJSON(comPortLists);
// alert(jsonPortLists);
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
$.each(jsonPortLists,function(key,value){
$('#com_port_name').append("<option value='"+value+"'>"+value+"</option>");
});
}
else{
swal({
title: 'Oops',
text: 'Payment device has been disconnected! Please plug it in.',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
/** pay with CB bank **/
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no) {
$("#loading_wrapper").show();
var com_port = $("#com_port_name").val();
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port);
}
//add req data to card_sale_trans table
function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port) {
var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port};
$.ajax({
type: "POST",
url: "/origami/bank_integration/sale_trans",
data: {type:"request", data: jobj},
dataType: "json",
success: function(data) {
if (data.status == "success"){
card_sale_trans_id = data.card_sale_trans_id;
resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port);
}
}
});
}
//add res data to card_sale_trans table
function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port) {
var resMsg = "";
var card_payment_type="";
if($("#loading_wrapper").is(":visible")){
if(payment_type=="mpu" || payment_type=="visa" || payment_type=="master" || payment_type=="jcb" || payment_type=="unionpay"){
card_payment_type = "CARD";
}
else if(payment_type == "alipay"){
card_payment_type = "EWALLET";
}
bnk_bill_amount = parseFloat(bnk_bill_amount);
resMsg = code2lab.reqBankPayment(cmd_type,card_payment_type,bnk_bill_amount,receipt_no,com_port);
}
if(resMsg.includes("STATUS")){
var jobj = $.parseJSON(resMsg);
$.ajax({
type: "POST",
url: "/origami/bank_integration/sale_trans",
data: {type:"response", card_sale_trans_id: card_sale_trans_id, data: jobj},
dataType: "json",
success: function(data) {
if(data.status == "success"){
resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port);
}
}
});
}else{
$("#loading_wrapper").hide();
swal ( "Oops" , resMsg.toString() , "error" );
}
}
function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port) {
$("#loading_wrapper").hide();
var jobj = $.parseJSON(resMsg);
if(jobj.STATUS == "Approved"){
$.ajax({type: "POST",
url: "/origami/payment/"+payment_type,
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
}else{
if(payment_type!="master"){
payment_type = payment_type.toUpperCase();
}
swal({
title: 'Oops',
text: "Transaction is " + (jobj.STATUS).toLowerCase(),
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment/"+payment_type;
});
}
}
//end CB ECR integration

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the app/controllers/origami/BankIntegration controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the origami/BankIntegration controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the origami/unionpay controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -7,8 +7,7 @@ class Api::AuthenticateController < Api::ApiController
if emp_id && password
@employee = Employee.login(emp_id, password)
if @employee
if @employee && @employee.role == "waiter"
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
else
render json: JSON.generate({:status => false, :error_message => "Bad Emp_ID or Password."})

View File

@@ -113,6 +113,9 @@ class HomeController < ApplicationController
@top_items = Sale.top_items(today)
@total_foc_items = Sale.total_foc_items(today)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
end
def destroy

View File

@@ -0,0 +1,98 @@
class Origami::BankIntegrationController < ApplicationController #BaseOrigamiController
def settle_trans
if(params[:type] == 'request')
card_settle_trans = CardSettleTran.new()
card_settle_trans.req_date = Time.now.strftime("%Y-%m-%d")
card_settle_trans.req_time = Time.now.utc
card_settle_trans.req_cmd = params[:data][:cmd_type]
card_settle_trans.req_type = params[:data][:payment_type]
card_settle_trans.save()
card_settle_trans_id = card_settle_trans.id
response = {status: 'success', card_settle_trans_id: card_settle_trans_id}
else
card_settle_trans = CardSettleTran.find(params[:card_settle_trans_id])
card_settle_trans.res_date = Time.now.strftime("%Y-%m-%d")
card_settle_trans.res_time = Time.now.utc
card_settle_trans.res_cmd = params[:data][:CMD]
card_settle_trans.res_type = params[:data][:TYPE]
card_settle_trans.status = params[:data][:STATUS]
card_settle_trans.sale_cnt = params[:data][:SALECNT]
card_settle_trans.sale_amt = params[:data][:SALEAMT].to_f
card_settle_trans.void_cnt = params[:data][:VOIDCNT]
card_settle_trans.void_amt = params[:data][:VOIDAMT].to_f
card_settle_trans.refund_cnt = params[:data][:REFUNDCNT]
card_settle_trans.refund_amt = params[:data][:REFUNDAMT].to_f
card_settle_trans.print_text_part1_type = params[:data][:PRINTTEXTPART1TYPE]
card_settle_trans.print_text_part1_value = params[:data][:PRINTTEXTPART1VALUE]
card_settle_trans.print_text_part2_type = params[:data][:PRINTTEXTPART2TYPE]
card_settle_trans.print_text_part2_value = params[:data][:PRINTTEXTPART2VALUE]
card_settle_trans.print_text_part3_type = params[:data][:PRINTTEXTPART3TYPE]
card_settle_trans.print_text_part3_value = params[:data][:PRINTTEXTPART3VALUE]
card_settle_trans.print_text_part4_type = params[:data][:PRINTTEXTPART4TYPE]
card_settle_trans.print_text_part4_value = params[:data][:PRINTTEXTPART4VALUE]
card_settle_trans.save()
response = {status: 'success'}
end
render json: response
end
def sale_trans
if(params[:type] == 'request')
card_sale_trans = CardSaleTran.new()
card_sale_trans.sale_id = params[:data][:sale_id]
card_sale_trans.req_date = Time.now.strftime("%Y-%m-%d")
card_sale_trans.req_time = Time.now.utc
card_sale_trans.req_amt = params[:data][:amt]
card_sale_trans.req_inv_no = params[:data][:inv_no]
card_sale_trans.req_cmd = params[:data][:cmd_type]
card_sale_trans.req_type = params[:data][:payment_type]
card_sale_trans.save()
card_sale_trans_id = card_sale_trans.id
response = {status: 'success', card_sale_trans_id: card_sale_trans_id}
else
card_sale_trans = CardSaleTran.find(params[:card_sale_trans_id])
card_sale_trans.res_date = params[:data][:DATE]
card_sale_trans.res_time = params[:data][:TIME]
card_sale_trans.res_amt = params[:data][:AMT].to_f / 100
card_sale_trans.res_inv_no = params[:data][:ECRREF]
card_sale_trans.res_cmd = params[:data][:CMD]
card_sale_trans.res_type = params[:data][:TYPE]
card_sale_trans.status = params[:data][:STATUS]
card_sale_trans.resp = params[:data][:RESP]
card_sale_trans.trace = params[:data][:TRACE]
card_sale_trans.app_code = params[:data][:APPCODE]
card_sale_trans.pan = params[:data][:PAN]
card_sale_trans.exp_date = params[:data][:EXPDATE]
card_sale_trans.tips = params[:data][:TIPS]
card_sale_trans.entry_mode = params[:data][:ENTRYMODE]
card_sale_trans.terminal_id = params[:data][:TERMINALID]
card_sale_trans.merchant_id = params[:data][:MERCHANTID]
card_sale_trans.card_holder = params[:data][:CARDHOLDERNAME]
card_sale_trans.batch_no = params[:data][:BATCHNO]
card_sale_trans.ref_no = params[:data][:REFNUM]
card_sale_trans.app = params[:data][:APP]
card_sale_trans.emv_app_id = params[:data][:AID]
card_sale_trans.emv_cyptrogram = params[:data][:TC]
card_sale_trans.curr_code = params[:data][:CURRCODE]
card_sale_trans.fx_rate = params[:data][:FXRATE]
card_sale_trans.foreign_amt = params[:data][:FOREIGNAMT]
card_sale_trans.dcc_msg = params[:data][:DCCMSG]
card_sale_trans.tender = params[:data][:TENDER]
card_sale_trans.print_text_part1_type = params[:data][:PRINTTEXTPART1TYPE]
card_sale_trans.print_text_part1_value = params[:data][:PRINTTEXTPART1VALUE]
card_sale_trans.print_text_part2_type = params[:data][:PRINTTEXTPART2TYPE]
card_sale_trans.print_text_part2_value = params[:data][:PRINTTEXTPART2VALUE]
card_sale_trans.print_text_part3_type = params[:data][:PRINTTEXTPART3TYPE]
card_sale_trans.print_text_part3_value = params[:data][:PRINTTEXTPART3VALUE]
card_sale_trans.print_text_part4_type = params[:data][:PRINTTEXTPART4TYPE]
card_sale_trans.print_text_part4_value = params[:data][:PRINTTEXTPART4VALUE]
card_sale_trans.save()
response = {status: 'success'}
end
render json: response
end
end

View File

@@ -29,6 +29,13 @@ class Origami::JcbController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create

View File

@@ -28,6 +28,13 @@ class Origami::MasterController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create

View File

@@ -28,6 +28,13 @@ class Origami::MpuController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create

View File

@@ -22,29 +22,47 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# Print for First Bill to Customer
# unique_code = "ReceiptBillPdf"
# #shop detail
# shop_details = Shop::ShopDetail
# # customer= Customer.where('customer_id=' +.customer_id)
# customer= Customer.find(sale_data.customer_id)
# # get member information
# rebate = MembershipSetting.find_by_rebate(1)
# if customer.membership_id != nil && rebate
# member_info = Customer.get_member_account(customer)
# end
# # get printer info
# print_settings=PrintSetting.find_by_unique_code(unique_code)
unique_code = "ReceiptBillPdf"
#shop detail
shop_details = Shop::ShopDetail
# customer= Customer.where('customer_id=' +.customer_id)
customer = Customer.find(sale_data.customer_id)
# # find order id by sale id
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# rounding adjustment
if shop_details.is_rounding_adj
a = sale_data.grand_total % 25 # Modulus
b = sale_data.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(sale_data.grand_total)
rounding_adj = new_total-sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
end
end
#end rounding adjustment
# # Calculate price_by_accounts
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
# discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# printer = Printer::ReceiptPrinter.new(print_settings)
# find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
# printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt")
end
def create
@@ -91,22 +109,38 @@ class Origami::PaymentsController < BaseOrigamiController
# For Print
# unique_code = "ReceiptBillPdf"
# customer= Customer.find(saleObj.customer_id)
# # get member information
# rebate = MembershipSetting.find_by_rebate(1)
# if customer.membership_id != nil && rebate
# member_info = Customer.get_member_account(customer)
# rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
# end
# # get printer info
# print_settings=PrintSetting.find_by_unique_code(unique_code)
# # Calculate Food and Beverage Total
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
# discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
if customer.membership_id != nil && rebate && credit_data.nil?
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
end
end
@@ -122,6 +156,7 @@ class Origami::PaymentsController < BaseOrigamiController
@visacount= 0.0
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@credit = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0.00
@@ -183,6 +218,8 @@ class Origami::PaymentsController < BaseOrigamiController
@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 == "creditnote"
@credit += spay.payment_amount
end
@@ -208,26 +245,40 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# unique_code = "ReceiptBillPdf"
# customer= Customer.find(saleObj.customer_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# #shop detail
# shop_details = Shop::ShopDetail
# # get member information
# rebate = MembershipSetting.find_by_rebate(1)
# if customer.membership_id != nil && rebate
# member_info = Customer.get_member_account(customer)
# rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
# end
# # get printer info
# print_settings=PrintSetting.find_by_unique_code(unique_code)
#shop detail
shop_details = Shop::ShopDetail
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
# # Calculate price_by_accounts
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
# discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
end
def foc
@@ -278,6 +329,8 @@ class Origami::PaymentsController < BaseOrigamiController
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
end
end

View File

@@ -45,6 +45,15 @@ class Origami::ShiftsController < BaseOrigamiController
cashier_terminal.is_currently_login = 0
cashier_terminal.save
#add shift_sale_id to card_settle_trans
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
card_settle_trans.each do |data|
card_sett_trans = CardSettleTran.find(data.id)
card_sett_trans.shift_sale_id = @shift.id
card_sett_trans.save()
end
# unique_code = "CloseCashierPdf"
# shop_details = Shop.find(1)

View File

@@ -0,0 +1,61 @@
class Origami::UnionpayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit unionpay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@unionpaycount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
puts "unionpaycount"
puts @unionpaycount
@can_unionpay = total - @unionpaycount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
# rounding adjustment
if shop_details.is_rounding_adj
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)
end
saleObj = Sale.find(sale_id)
#end rounding adjustment
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
end
end
end

View File

@@ -27,6 +27,13 @@ class Origami::VisaController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create

View File

@@ -61,40 +61,41 @@ class Origami::VoidController < BaseOrigamiController
# For Print
# member_info = nil
# rebate_amount = nil
member_info = nil
rebate_amount = nil
# # For Cashier by Zone
# bookings = Booking.where("sale_id='#{sale_id}'")
# if bookings.count > 1
# # for Multiple Booking
# table = DiningFacility.find(bookings[0].dining_facility_id)
# else
# table = DiningFacility.find(bookings[0].dining_facility_id)
# end
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings[0].dining_facility_id)
end
# cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
# cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# unique_code = "ReceiptBillPdf"
# customer= Customer.find(sale.customer_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
# #shop detail
# shop_details = Shop.find(1)
# # get member information
# rebate = MembershipSetting.find_by_rebate(1)
# if customer.membership_id != nil && rebate
# member_info = Customer.get_member_account(customer)
# rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
# end
# # get printer info
# print_settings=PrintSetting.find_by_unique_code(unique_code)
# # Calculate Food and Beverage Total
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
# discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID")
#end print

View File

@@ -0,0 +1,2 @@
module App::Controllers::Origami::BankIntegrationHelper
end

View File

@@ -0,0 +1,2 @@
module Origami::BankIntegrationHelper
end

View File

@@ -0,0 +1,2 @@
module Origami::UnionpayHelper
end

View File

@@ -96,6 +96,7 @@ class Ability
can :read, Order
can :update, Order
can :menage, Booking
can :manage, OrderQueueStation
can :read, Sale
can :update, Sale
can :get_customer, Customer
@@ -104,11 +105,11 @@ class Ability
can :index, :other_charge
can :create, :other_charge
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :member_discount, :discount
# can :index, :discount
# can :create, :discount
# can :remove_discount_items, :discount
# can :remove_all_discount, :discount
# can :member_discount, :discount
can :first_bill, :payment
can :show, :payment

View File

@@ -0,0 +1,2 @@
class CardSaleTran < ApplicationRecord
end

View File

@@ -0,0 +1,2 @@
class CardSettleTran < ApplicationRecord
end

View File

@@ -146,9 +146,10 @@ class Customer < ApplicationRecord
if sale.customer.membership_id
response = self.rebat(Sale.find(sale.sale_id))
#record an payment in sale-audit
if !response.nil?
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} "
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
end
if response["status"] == true
status = sale.update_attributes(rebate_status: "true")
end
@@ -159,8 +160,9 @@ class Customer < ApplicationRecord
def self.rebat(sObj)
rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items)
generic_customer_id = sObj.customer.membership_id
if generic_customer_id.present?
if generic_customer_id.present?
paypar = sObj.sale_payments
payparcost = 0
credit = 0
@@ -171,6 +173,7 @@ class Customer < ApplicationRecord
end
if pp.payment_method == "creditnote"
credit = 1
sObj.update_attributes(rebate_status: nil)
end
end
# overall_dis = SaleItem.get_overall_discount(sObj.id)
@@ -287,6 +290,7 @@ class Customer < ApplicationRecord
end
end
else
puts "no Response"
response = { "status": "no_member", "message": "Not membership"}
end
end

View File

@@ -37,6 +37,25 @@ class MenuCategory < ApplicationRecord
end
end
def valid_time
menu_category = MenuCategory.find(self.id)
menu = Menu.find(menu_category.menu_id)
from = menu.valid_time_from.strftime("%H:%M:%S")
to = menu.valid_time_to.strftime("%H:%M:%S")
current = Time.now.utc.getlocal.strftime("%H:%M:%S")
from = from.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
to = to.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
current = current.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
if current.between?(from, to)
return true
else
return nil
end
end
private
# def generate_menu_category_code

View File

@@ -65,12 +65,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance)
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
#Use CUPS service
#Generate PDF
#Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance)
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
# print as print copies in printer setting
count = printer_settings.print_copies

View File

@@ -654,7 +654,7 @@ def self.get_item_query()
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
"i.remark as status_type,"+
" i.unit_price as unit_price,i.product_name as product_name, mc.name as" +
" i.unit_price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
" menu_category_name,mc.id as menu_category_id ")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
@@ -1125,6 +1125,15 @@ end
.sum("a.qty")
end
#card sale trans data
def self.getCardSaleTrans(sale_id)
query = Sale.select("cst.res_date,cst.res_time,cst.trace,cst.pan,cst.batch_no,cst.exp_date,cst.app,cst.res_type,cst.ref_no,cst.terminal_id,cst.merchant_id,cst.app_code")
.joins("JOIN card_sale_trans as cst on cst.sale_id = sales.sale_id")
.where("sales.sale_id=? and status = 'Approved'",sale_id)
return query
end
private
def generate_custom_id

View File

@@ -360,7 +360,7 @@ class CloseCashierPdf < Prawn::Document
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account

View File

@@ -1,7 +1,7 @@
class ReceiptBillPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance)
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
@@ -65,6 +65,12 @@ class ReceiptBillPdf < Prawn::Document
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
@@ -503,5 +509,28 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
end
#start card sale trans data
def card_sale_data(card_data)
if card_data != nil && !card_data.empty?
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
card_data.each do |data|
if data['app'] == 'CUP'
data['app'] = 'UNIONPAY'
elsif data['app'] == 'MASTERCARD'
data['app'] = 'MASTER'
end
text "DATE/TIME: #{data['res_date']} #{data['res_time']} ", :size => @item_font_size, :align => :left
text "BATCH NUM: #{data['batch_no']} TRACE#: #{data['trace']}",:size => @item_font_size, :align => :left
text "RREF NUM: #{data['ref_no']} APPR CODE: #{data['app_code']} ",:size => @item_font_size, :align => :left
text "TID: #{data['tid']} ",:size => @item_font_size, :align => :left
text "#{data['app']} #{data['pan']} ",:size => @item_font_size, :align => :left
end
end
end
end

View File

@@ -2,7 +2,18 @@
<div class="block-header">
<h2><%= t :dashboard %></h2>
</div>
<% 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
%>
<!-- Widgets -->
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
@@ -125,19 +136,19 @@
</tr>
<tr>
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
<td align="right"><%= @summ_sale.total_amount %></td>
<td align="right"><%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr>
<tr>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
<td align="right"><%= @summ_sale.total_discount %></td>
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr>
<tr>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
<td align="right"><%= @summ_sale.total_tax %></td>
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
</tr>
<tr>
<td><%= t("views.right_panel.detail.grand_total") %> : </td>
<td align="right"><%= @summ_sale.grand_total %></td>
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
</tr>
</table>
<table class="table">

View File

@@ -8,6 +8,7 @@
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
@@ -28,21 +29,10 @@
</a>
</li>
<% end%>
<% end%>
<% end%>
<% end %>
<%end %>
<!-- <li class="nav-item menu_category">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 1 <b class="caret"></b></a>
<ul class="dropdown-menu multi-level">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
<li class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li> -->
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
</li>

View File

@@ -390,7 +390,7 @@
<% if @status_sale == 'sale' %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect">Customer</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' active="<%= can? :edit, :sale_edit %>">Edit</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect">Discount</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" active="<%= can? :index, :discount %>">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
@@ -416,7 +416,7 @@
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" id="payment_method" >
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
<option value="Cash">Cash</option>
<option value="Credit">Credit</option>
<% @payment_methods.each do |pay| %>
@@ -549,6 +549,8 @@
// Discount for Payment
$('#discount').click(function () {
if ($(this).attr('active')=== "true") {
var sale = $('#sale_id').val();
if (sale != "") {
var sale_id = sale
@@ -562,7 +564,9 @@
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
swal("Opps","You are not authorized for void","warning")
}
return false;
});
});

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -17,6 +20,17 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -106,11 +120,31 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
}
});
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'JCB is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
});
// number key pad
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
@@ -160,6 +194,8 @@ $(document).on('click', '.cashier_number', function(event){
$('#jcb_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -176,24 +212,28 @@ $('#jcb_pay').on('click',function(){
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
},function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
if(bank_integration == '1'){
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no);
}else{
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -17,6 +20,18 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -106,10 +121,30 @@
</div>
<script>
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
}
}
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'MASTER is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
@@ -157,6 +192,8 @@
$('#master_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -173,24 +210,28 @@
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
},function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
if(bank_integration == '1'){
pay_withBank("SALE", "master", amount, sale_id, receipt_no);
}else{
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
}
});
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -18,6 +21,17 @@
<div class="card" style="margin-top:10px;padding:20px;">
<div class="card-block">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -109,11 +123,32 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
}
});
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'MPU is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
@@ -157,9 +192,12 @@
return false;
}
});
$('#mpu_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -176,25 +214,29 @@
// });
// }
//end member discount
//Mpu Payment
$.ajax({type: "POST",
url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
if(bank_integration == '1'){
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
}else{
$.ajax({type: "POST",
url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
@@ -203,5 +245,5 @@
}
}
})
</script>
</script>

View File

@@ -34,11 +34,12 @@
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
if(payment_type) {
$(".others-payment").hide();
$("."+payment_type).show();
}
if(payment_type) {
$(".others-payment").hide();
$(payment_type).each(function(i){
$("."+payment_type[i]).show();
});
}
/* end check first bill or not*/
$('.others-payment').on('click',function(){

View File

@@ -182,13 +182,13 @@
<% if @visacount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">Visa</div>
<div class="col-md-3">VISA</div>
<div class="col-md-4 visa is_card" id="visacount"><%= @visacount %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">Visa</div>
<div class="col-md-3">VISA</div>
<div class="col-md-4" id="visacount">0.0</div>
</div>
<% end %>
@@ -210,17 +210,31 @@
<% if @mastercount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">Master</div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4 master is_card" id="mastercount"><%= @mastercount %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">Master</div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4" id="mastercount">0.0</div>
</div>
<% end %>
<!-- <br> -->
<!-- UNIONPAY -->
<% if @unionpaycount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4 master is_card" id="unionpaycount"><%= @unionpaycount %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4" id="unionpaycount">0.0</div>
</div>
<% end %>
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total rescue 0 %></span></strong></div>
@@ -296,16 +310,20 @@
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if(payment_type=="Cash"){
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
// console.log(jQuery.inArray("Credit", payment_type))
// console.log(payment_type)
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
} else{
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("MPU", payment_type)) > 0 || parseInt(jQuery.inArray("VISA", payment_type)) > 0 || parseInt(jQuery.inArray("JCB", payment_type)) > 0 || parseInt(jQuery.inArray("Master", payment_type)) > 0 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) > 0 || parseInt(jQuery.inArray("Redeem", payment_type)) > 0){
$("#card_payment").show();
} else{
$("#card_payment").hide();
$("#credit_payment").hide();
}else if(payment_type=="Credit"){
$("#card_payment").hide();
$("#others_payment").hide();
}else if(payment_type=="MPU"||payment_type=="VISA"||payment_type=="JCB"||payment_type=="Master"){
$("#credit_payment").hide();
}
}
/* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
@@ -361,17 +379,18 @@
update_balance();
break;
case 'nett':
var credit1 = $('#credit').text();
var card1 = $('#others').text();
var paypar1 = $('#ppamount').text();
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(amt);
update_balance();
var credit1 = $('#credit').text();
var card1 = $('#others').text();
var paypar1 = $('#ppamount').text();
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var unionpay1 = $('#unionpaycount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(parseFloat(amt).toFixed(2));
update_balance();
break;
}
event.handled = true;
@@ -412,6 +431,9 @@
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Credit Payment","warning");
}else{
@@ -515,8 +537,9 @@
var visa = $('#visacount').text();
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var unionpay = $('#unionpaycount').text();
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master)
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
var result = parseFloat(amount_due) - parseFloat(total);
$('#balance').text(result.toFixed(2));
}

View File

@@ -390,7 +390,7 @@
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" id="payment_method" >
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
<option value="Cash">Cash</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">

View File

@@ -1,4 +1,8 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class='row clearfix'>
<div class='col-md-10'>
<h1><%= t :close_cashier %></h1>
@@ -27,6 +31,27 @@
<div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
<button type="button" class="btn bg-blue btn-block green" id='close_cashier'> <%= t("views.btn.close_cashier") %> </button>
<button type="button" class="btn bg-blue btn-block green" id="card_settlement"> <%= t("views.btn.card_settle") %> </button>
</div>
</div>
<div class="modal fade" id="cardSettleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="cardSettleModal">Select Device: </h4>
</div>
<div class="modal-body">
<select class="form-control show-tick sel_com_port" id="sel_com_port" >
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect" id="card_settle">OK</button>
</div>
</div>
</div>
</div>
</div>
@@ -42,8 +67,175 @@
window.location.href = '/';
}
});
})
});
$('#back').on('click',function(){
window.location.href = '/origami';
})
});
/** start CB Card Settle process **/
$("#card_settlement").on('click', function(){
if(typeof code2lab != 'undefined'){
$('#cardSettleModal').modal({ keyboard: false, backdrop: false });
code2lab.getCommPorts();
}else{
swal({
title: 'Oops',
text: 'Settlement can not print out in browser!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/close';
});
}
});
//CB Bank payment settlement ECR integration
function setCommPorts(comPortLists) {
// alert(comPortLists);
$('#sel_com_port').html("");
var jsonPortLists = $.parseJSON(comPortLists);
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
$.each(jsonPortLists,function(key,value){
$('#sel_com_port').append("<option value='"+value+"'>"+value+"</option>");
});
}
else{
swal({
title: 'Oops',
text: 'Payment can not pay in browser!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/close';
});
}
}
$("#card_settle").on('click', function () {
$("#loading_wrapper").show();
$('#cardSettleModal').modal('hide');
reqCBBankMPUSettlement();
});
//add req data to card_settle_trans table
function reqCardSettleTrans(cmd_type,payment_type,com_port) {
var jobj = {"cmd_type" : cmd_type, "payment_type" : payment_type};
$.ajax({
type: "POST",
url: "/origami/bank_integration/settle_trans",
data: {type:"request", data: jobj},
dataType: "json",
success: function(data) {
if (data.status == "success"){
resCardSettleTrans(data.card_settle_trans_id,cmd_type,payment_type,com_port);
}
}
});
}
//add res data to card_settle_trans table
function resCardSettleTrans(card_settle_trans_id,cmd_type,payment_type,com_port) {
var resMsg = "";
if($("#loading_wrapper").is(':visible')){
resMsg = code2lab.reqBankPayment(cmd_type, payment_type, 1, "", com_port);
}
if(resMsg.includes("STATUS")){
var jobj = $.parseJSON(resMsg);
$.ajax({
type: "POST",
url: "/origami/bank_integration/settle_trans",
data: {type:"response", card_settle_trans_id: card_settle_trans_id, data: jobj},
dataType: "json",
success: function(data) {
if(data.status == "success"){
if(payment_type == "MPU"){
reqCBBankVMJSettlement();
}
else if(payment_type == "VMJ"){
reqCBBankJCBSettlement();
}
else if(payment_type == "JCB"){
reqCBBankCUPSettlement();
}
else if(payment_type == "CUP"){
$("#loading_wrapper").hide();
// reqCBBankAlipaySettlement();
}
// else if(payment_type == "Alipay"){
// reqCBBankIPPSettlement();
// $('#loading').hide();
// }
}
}
});
}
else{
$("#loading_wrapper").hide();
swal ( "Oops" , resMsg.toString() , "error" );
}
}
//settle for MPU / MPU-UPI
function reqCBBankMPUSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "MPU";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for VMJ (VISA, MASTER)
function reqCBBankVMJSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "VMJ"; //VISA,Master and JCB
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for JCB
function reqCBBankJCBSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "JCB";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for International Union Pay (CUP)
function reqCBBankCUPSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "CUP";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for Alipay
function reqCBBankAlipaySettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "Alipay";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
//settle for insert/direct swipe (now does not using this state - future one)
function reqCBBankIPPSettlement() {
var com_port = $('#sel_com_port').val();
var cmd_type = "SETTLEMENT";
var payment_type = "IPP";
$("#loading_wrapper").show();
reqCardSettleTrans(cmd_type,payment_type,com_port);
}
/** end CB Card Settle process **/
</script>

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

View File

@@ -0,0 +1,247 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
<li class="breadcrumb-item active"><%= t("views.btn.unionpay") %></li>
<span class="float-right">
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
</span>
</ol>
</div> -->
<h5>UNIONPAY Payment</h5>
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-5">
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_unionpay = @can_unionpay +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_unionpay %>" data-member-value="">
</div>
<hr>
</div>
<% if @unionpaycount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Recent Visa paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@unionpaycount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="">
<div class=" m-t-10 p-l-20">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class="col-md-4 cashier_number " data-value="1" data-type="num">1</div>
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number green border-left" data-type="nett" >Nett</div>
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom m-l-5">
<div class="pay purple left" id="unionpay_pay">Pay</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn bg-default m-t-10 btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
</div>
</div>
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_unionpay %>") - parseFloat(localStorage.getItem("cash")));
}
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}
else{
swal({
title: 'Oops',
text: 'UNIONPAY is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$('#unionpay_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
var bank_integration = "<%= @bank_integration %>";
if(bank_integration == '1'){
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no);
}
else{
$.ajax({type: "POST",
url: "<%= origami_payment_unionpay_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
}
})
</script>

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
@@ -17,6 +20,18 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -106,10 +121,33 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_visa %>") - parseFloat(localStorage.getItem("cash")));
}
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}
else{
swal({
title: 'Oops',
text: 'VISA is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
@@ -157,6 +195,7 @@
$('#visa_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
console.log(amount);
console.log($("#validamount").attr("value"));
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
@@ -175,24 +214,30 @@
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_visa_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
var bank_integration = "<%= @bank_integration %>";
if(bank_integration == '1'){
pay_withBank("SALE", "visa", amount, sale_id, receipt_no);
}
else{
$.ajax({type: "POST",
url: "<%= origami_payment_visa_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
}
}
}
});
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );

View File

@@ -77,11 +77,14 @@
<% total_tax = 0 %>
<% @sale_data.each do |sale| %>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
@@ -127,9 +130,13 @@
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type != "Discount" && sale.status_type != "foc"
<% if sale.status_type!="Discount" && sale.status_type!="foc"
sub_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
sub_qty += sale.total_item
end %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>

View File

@@ -130,6 +130,8 @@ en:
exp_to_excel: "EXPORT TO EXCEL"
check_in: "Check In"
card_settle: "CARD SETTLE"
pagination:
first: "&laquo; First"
last: "Last &raquo;"

View File

@@ -123,7 +123,8 @@ mm:
new_inventory_product: "ကုန်လှောင်ရုံရောက်ပစ္စည်းအသစ်များ"
generate_report: "အစီရင်ခံစာများရှာဖွေရန်"
exp_to_excel: "Excel သို့ ပို့ပြီးဆက်လက်လုပ်ဆောင်ရန်"
card_settle: "ကဒ် စာရင်းရှင်းတမ်း"
pagination:
first: "&laquo; ပထမ"
last: "အဆံုး &raquo;"

View File

@@ -156,6 +156,7 @@ scope "(:locale)", locale: /en|mm/ do
post 'payment/jcb' => "jcb#create"
post 'payment/master' => "master#create"
post 'payment/visa' => "visa#create"
post 'payment/unionpay' => "unionpay#create"
post 'payment/paypar' => 'paypar_payments#create'
post 'payment/credit' => 'credit_payments#create'
post 'payment/voucher' => 'voucher_payments#create'
@@ -166,6 +167,7 @@ scope "(:locale)", locale: /en|mm/ do
get 'sale/:sale_id/payment/others_payment/VISA' => "visa#index"
get 'sale/:sale_id/payment/others_payment/Master' => "master#index"
get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index"
get 'sale/:sale_id/payment/others_payment/UNIONPAY' => "unionpay#index"
get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index"
get 'sale/:sale_id/payment/others_payment/Voucher' => "voucher#index"
@@ -210,6 +212,10 @@ scope "(:locale)", locale: /en|mm/ do
#check_in
post '/check_in' => "check_in_process#check_in_process"
#CB ECR Trans
post "bank_integration/settle_trans", to: "bank_integration#settle_trans", as:"settle_trans"
post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans"
end
#--------- Waiter/Ordering Station ------------#

View File

@@ -0,0 +1,34 @@
class CreateCardSettleTrans < ActiveRecord::Migration[5.1]
def change
create_table :card_settle_trans do |t|
t.integer :shift_sale_id
t.date :req_date
t.time :req_time
t.string :req_cmd
t.string :req_type
t.date :res_date
t.time :res_time
t.string :res_cmd
t.string :res_type
t.string :status, :limit=>50
t.integer :sale_cnt
t.float :sale_amt, :limit=>50
t.integer :void_cnt
t.float :void_amt, :limit=>50
t.integer :refund_cnt
t.float :refund_amt, :limit=>50
t.string :print_text_part1_type
t.string :print_text_part1_value
t.string :print_text_part2_type
t.string :print_text_part2_value
t.string :print_text_part3_type
t.string :print_text_part3_value
t.string :print_text_part4_type
t.string :print_text_part4_value
end
end
def down
drop_table :card_settle_trans
end
end

View File

@@ -0,0 +1,52 @@
class CreateCardSaleTrans < ActiveRecord::Migration[5.1]
def change
create_table :card_sale_trans do |t|
t.string :sale_id
t.date :req_date
t.time :req_time
t.float :req_amt, :limit=>50
t.string :req_inv_no
t.string :req_cmd
t.string :req_type
t.date :res_date
t.time :res_time
t.float :res_amt, :limit=>50
t.string :res_inv_no
t.string :res_cmd
t.string :res_type
t.string :status, :limit=>50
t.string :resp
t.string :trace
t.string :app_code
t.string :pan
t.string :exp_date
t.string :tips
t.string :entry_mode
t.string :terminal_id
t.string :merchant_id
t.string :card_holder
t.string :batch_no
t.string :ref_no
t.string :app
t.string :emv_app_id
t.string :emv_cyptrogram
t.string :curr_code
t.string :fx_rate
t.float :foreign_amt, :limit=>50
t.string :dcc_msg
t.string :tender
t.string :print_text_part1_type
t.string :print_text_part1_value
t.string :print_text_part2_type
t.string :print_text_part2_value
t.string :print_text_part3_type
t.string :print_text_part3_value
t.string :print_text_part4_type
t.string :print_text_part4_value
end
end
def down
drop_table :card_sale_trans
end
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe App::Controllers::Origami::BankIntegrationController, type: :controller do
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Origami::BankIntegrationController, type: :controller do
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Origami::UnionpayController, type: :controller do
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the App::Controllers::Origami::BankIntegrationHelper. For example:
#
# describe App::Controllers::Origami::BankIntegrationHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe App::Controllers::Origami::BankIntegrationHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Origami::BankIntegrationHelper. For example:
#
# describe Origami::BankIntegrationHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Origami::BankIntegrationHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Origami::UnionpayHelper. For example:
#
# describe Origami::UnionpayHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Origami::UnionpayHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CardSaleTran, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CardSettleTran, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end