diff --git a/app/assets/javascripts/app/controllers/origami/bank_integration.coffee b/app/assets/javascripts/app/controllers/origami/bank_integration.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/app/controllers/origami/bank_integration.coffee @@ -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/ diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 33252efa..5bdbe861 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -194,4 +194,132 @@ function deleteReceiptNoInFirstBillData(receipt_no) { localStorage.setItem("receipt_lists",JSON.stringify(json_data)); } } -/* end check first bill or not funs: */ \ No newline at end of file +/* 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(""); + }); + } + 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 \ No newline at end of file diff --git a/app/assets/javascripts/origami/bank_integration.coffee b/app/assets/javascripts/origami/bank_integration.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/bank_integration.coffee @@ -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/ diff --git a/app/assets/stylesheets/app/controllers/origami/bank_integration.scss b/app/assets/stylesheets/app/controllers/origami/bank_integration.scss new file mode 100644 index 00000000..784f21f7 --- /dev/null +++ b/app/assets/stylesheets/app/controllers/origami/bank_integration.scss @@ -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/ diff --git a/app/assets/stylesheets/origami/bank_integration.scss b/app/assets/stylesheets/origami/bank_integration.scss new file mode 100644 index 00000000..5f839960 --- /dev/null +++ b/app/assets/stylesheets/origami/bank_integration.scss @@ -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/ diff --git a/app/controllers/origami/bank_integration_controller.rb b/app/controllers/origami/bank_integration_controller.rb new file mode 100644 index 00000000..a5e5d59f --- /dev/null +++ b/app/controllers/origami/bank_integration_controller.rb @@ -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 diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index a3b93efd..be4cc94c 100755 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -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 diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 8eb2e02b..068095ca 100755 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -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 diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 6bd0778f..d1cb3c81 100755 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -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 diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 0bc77fc3..88577ac4 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -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 diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 851be7e5..1c75d3bd 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -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) diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index 3e2e56a3..a664e327 100755 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -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 diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 0ac9df9f..fe2ddca8 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -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 diff --git a/app/helpers/app/controllers/origami/bank_integration_helper.rb b/app/helpers/app/controllers/origami/bank_integration_helper.rb new file mode 100644 index 00000000..845cf827 --- /dev/null +++ b/app/helpers/app/controllers/origami/bank_integration_helper.rb @@ -0,0 +1,2 @@ +module App::Controllers::Origami::BankIntegrationHelper +end diff --git a/app/helpers/origami/bank_integration_helper.rb b/app/helpers/origami/bank_integration_helper.rb new file mode 100644 index 00000000..dd301d75 --- /dev/null +++ b/app/helpers/origami/bank_integration_helper.rb @@ -0,0 +1,2 @@ +module Origami::BankIntegrationHelper +end diff --git a/app/models/card_sale_tran.rb b/app/models/card_sale_tran.rb new file mode 100644 index 00000000..7c496b56 --- /dev/null +++ b/app/models/card_sale_tran.rb @@ -0,0 +1,2 @@ +class CardSaleTran < ApplicationRecord +end diff --git a/app/models/card_settle_tran.rb b/app/models/card_settle_tran.rb new file mode 100644 index 00000000..29670946 --- /dev/null +++ b/app/models/card_settle_tran.rb @@ -0,0 +1,2 @@ +class CardSettleTran < ApplicationRecord +end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index adcb187e..49502b3f 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -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 diff --git a/app/models/sale.rb b/app/models/sale.rb index 69aa930a..35338665 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index ae02b22d..ab33d6e4 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -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 diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index c7cc79f9..1d855ad2 100755 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -1,4 +1,7 @@