CB ECR Integration

This commit is contained in:
phyusin
2018-01-10 18:08:28 +06:30
parent 014a071637
commit 903dddd8cc
37 changed files with 807 additions and 92 deletions

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,132 @@ 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{
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/MPU";
});
}
}
//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 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,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,7 @@ class Origami::JcbController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
@receipt_no = sale_data.receipt_no
end
def create

View File

@@ -28,6 +28,7 @@ class Origami::MasterController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
@receipt_no = sale_data.receipt_no
end
def create

View File

@@ -28,6 +28,7 @@ class Origami::MpuController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
@receipt_no = sale_data.receipt_no
end
def create

View File

@@ -61,7 +61,7 @@ class Origami::PaymentsController < BaseOrigamiController
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)
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)
end
def create
@@ -119,6 +119,18 @@ class Origami::PaymentsController < BaseOrigamiController
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_res_date = card_sale_trans_ref_no.res_date.strftime("%Y-%m-%d").to_s
card_res_time = card_sale_trans_ref_no.res_time.strftime("%H:%M").to_s
card_no = card_sale_trans_ref_no.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => card_sale_trans_ref_no.batch_no, 'trace' => card_sale_trans_ref_no.trace, 'pan' => card_no, 'app' => card_sale_trans_ref_no.app, 'tid' => card_sale_trans_ref_no.terminal_id, 'app_code' => card_sale_trans_ref_no.app_code, 'ref_no' => card_sale_trans_ref_no.ref_no, 'mid' => card_sale_trans_ref_no.merchant_id})
end
puts "card_data"
puts card_data.to_json
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
@@ -126,7 +138,7 @@ class Origami::PaymentsController < BaseOrigamiController
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",current_balance)
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
@@ -240,6 +252,18 @@ class Origami::PaymentsController < BaseOrigamiController
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_res_date = card_sale_trans_ref_no.res_date.strftime("%Y-%m-%d").to_s
card_res_time = card_sale_trans_ref_no.res_time.strftime("%H:%M").to_s
card_no = card_sale_trans_ref_no.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => card_sale_trans_ref_no.batch_no, 'trace' => card_sale_trans_ref_no.trace, 'pan' => card_no, 'app' => card_sale_trans_ref_no.app, 'tid' => card_sale_trans_ref_no.terminal_id, 'app_code' => card_sale_trans_ref_no.app_code, 'ref_no' => card_sale_trans_ref_no.ref_no, 'mid' => card_sale_trans_ref_no.merchant_id})
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -248,7 +272,7 @@ class Origami::PaymentsController < BaseOrigamiController
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)
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
@@ -298,7 +322,7 @@ class Origami::PaymentsController < BaseOrigamiController
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, "FOC",nil)
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

@@ -27,6 +27,7 @@ class Origami::VisaController < BaseOrigamiController
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
@receipt_no = sale_data.receipt_no
end
def create

View File

@@ -95,7 +95,7 @@ class Origami::VoidController < BaseOrigamiController
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)
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)
#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 @@
class CardSaleTran < ApplicationRecord
end

View File

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

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

@@ -1125,6 +1125,16 @@ 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=?",sale_id)
.first()
return query
end
private
def generate_custom_id

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,26 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
end
#start card sale trans data
def card_sale_data(card_data)
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
if !card_data[0].nil?
if card_data[0]['app'] == 'CUP'
card_data[0]['app'] = 'UNIONPAY'
elsif card_data[0]['app'] == 'MASTERCARD'
card_data[0]['app'] = 'MASTER'
end
text "DATE/TIME: #{card_data[0]['res_date']} #{card_data[0]['res_time']} ", :size => @item_font_size, :align => :left
text "BATCH NUM: #{card_data[0]['batch_no']} TRACE#: #{card_data[0]['trace']}",:size => @item_font_size, :align => :left
text "RREF NUM: #{card_data[0]['ref_no']} APPR CODE: #{card_data[0]['app_code']} ",:size => @item_font_size, :align => :left
text "TID: #{card_data[0]['tid']} ",:size => @item_font_size, :align => :left
text "#{card_data[0]['app']} #{card_data[0]['pan']} ",:size => @item_font_size, :align => :left
end
end
end

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,16 @@
<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">
<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>
<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 +119,28 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
}
});
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 +190,7 @@ $(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 %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -176,24 +207,7 @@ $('#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";
});
}
}
});
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no);
}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,16 @@
<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">
<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>
<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 +119,27 @@
</div>
<script>
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
}
}
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 +187,7 @@
$('#master_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
@@ -173,24 +204,7 @@
// });
// }
//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";
});
}
}
});
pay_withBank("SALE", "master", amount, sale_id, receipt_no);
}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,16 @@
<div class="card" style="margin-top:10px;padding:20px;">
<div class="card-block">
<div class="rebate-form">
<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>
<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 +122,30 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
}
});
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 +189,11 @@
return false;
}
});
$('#mpu_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
@@ -176,25 +210,8 @@
// });
// }
//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";
});
}
}
});
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
@@ -203,5 +220,5 @@
}
}
})
</script>
</script>

View File

@@ -370,7 +370,7 @@
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);
$('#cash').text(parseFloat(amt).toFixed(2));
update_balance();
break;
}

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

@@ -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,16 @@
<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">
<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>
<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 +119,28 @@
</div>
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_visa %>") - parseFloat(localStorage.getItem("cash")));
}
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 +188,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 +207,7 @@
// });
// }
//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";
});
}
}
});
pay_withBank("SALE", "visa", amount, sale_id, receipt_no);
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );

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

@@ -210,6 +210,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,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,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