diff --git a/README.md b/README.md index 3412e2ed..5be96143 100755 --- a/README.md +++ b/README.md @@ -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 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 3afb23c1..18368f25 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -194,4 +194,135 @@ 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{ + 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 \ 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/javascripts/origami/unionpay.coffee b/app/assets/javascripts/origami/unionpay.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/unionpay.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/assets/stylesheets/origami/unionpay.scss b/app/assets/stylesheets/origami/unionpay.scss new file mode 100644 index 00000000..6daa3524 --- /dev/null +++ b/app/assets/stylesheets/origami/unionpay.scss @@ -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/ diff --git a/app/controllers/api/authenticate_controller.rb b/app/controllers/api/authenticate_controller.rb index fcd00f1b..8fbfda5b 100755 --- a/app/controllers/api/authenticate_controller.rb +++ b/app/controllers/api/authenticate_controller.rb @@ -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."}) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1ee30bab..25fb0d70 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -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 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..9c872325 100755 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -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 diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 8eb2e02b..0ad47913 100755 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -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 diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 6bd0778f..51bcabb1 100755 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -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 diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 9d86c8ff..304b9396 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -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 diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index a1169ab1..a6a2044d 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/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb new file mode 100644 index 00000000..a3f7e6ed --- /dev/null +++ b/app/controllers/origami/unionpay_controller.rb @@ -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 diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index 3e2e56a3..af4d31f0 100755 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -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 diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index b7efec25..1283fb2e 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -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 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/helpers/origami/unionpay_helper.rb b/app/helpers/origami/unionpay_helper.rb new file mode 100644 index 00000000..3911575e --- /dev/null +++ b/app/helpers/origami/unionpay_helper.rb @@ -0,0 +1,2 @@ +module Origami::UnionpayHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 02b2618f..560e0192 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 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/customer.rb b/app/models/customer.rb index c228e3e6..949093ea 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -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 diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 9930d3cd..1f45b3ff 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -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 diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index aecd13da..ed4fad91 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..e0918d5f 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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 diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index d84b0366..35248b97 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -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 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index ae02b22d..16b1fd58 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,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 diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 3ed5e068..eb1bdecd 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -2,7 +2,18 @@

<%= t :dashboard %>

- + <% 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 + %>
@@ -125,19 +136,19 @@ <%= t("views.right_panel.detail.total") %> <%= t :sale %> : - <%= @summ_sale.total_amount %> + <%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : - <%= @summ_sale.total_discount %> + <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : - <%= @summ_sale.total_tax %> + <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%> <%= t("views.right_panel.detail.grand_total") %> : - <%= @summ_sale.grand_total %> + <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index bebf18cc..ab813ec6 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -8,6 +8,7 @@
diff --git a/config/locales/en.yml b/config/locales/en.yml index f47f9aaf..19b49b9a 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -130,6 +130,8 @@ en: exp_to_excel: "EXPORT TO EXCEL" check_in: "Check In" + card_settle: "CARD SETTLE" + pagination: first: "« First" last: "Last »" diff --git a/config/locales/mm.yml b/config/locales/mm.yml index 29121da8..e7d81712 100755 --- a/config/locales/mm.yml +++ b/config/locales/mm.yml @@ -123,7 +123,8 @@ mm: new_inventory_product: "ကုန်လှောင်ရုံရောက်ပစ္စည်းအသစ်များ" generate_report: "အစီရင်ခံစာများရှာဖွေရန်" exp_to_excel: "Excel သို့ ပို့ပြီးဆက်လက်လုပ်ဆောင်ရန်" - + + card_settle: "ကဒ် စာရင်းရှင်းတမ်း" pagination: first: "« ပထမ" last: "အဆံုး »" diff --git a/config/routes.rb b/config/routes.rb index 9ffeb352..a31dcb5c 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 ------------# diff --git a/db/migrate/20180108070325_create_card_settle_trans.rb b/db/migrate/20180108070325_create_card_settle_trans.rb new file mode 100644 index 00000000..d587ac41 --- /dev/null +++ b/db/migrate/20180108070325_create_card_settle_trans.rb @@ -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 diff --git a/db/migrate/20180109085256_create_card_sale_trans.rb b/db/migrate/20180109085256_create_card_sale_trans.rb new file mode 100644 index 00000000..45702cb9 --- /dev/null +++ b/db/migrate/20180109085256_create_card_sale_trans.rb @@ -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 diff --git a/spec/controllers/app/controllers/origami/bank_integration_controller_spec.rb b/spec/controllers/app/controllers/origami/bank_integration_controller_spec.rb new file mode 100644 index 00000000..d6ff99e0 --- /dev/null +++ b/spec/controllers/app/controllers/origami/bank_integration_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe App::Controllers::Origami::BankIntegrationController, type: :controller do + +end diff --git a/spec/controllers/origami/bank_integration_controller_spec.rb b/spec/controllers/origami/bank_integration_controller_spec.rb new file mode 100644 index 00000000..f82341e8 --- /dev/null +++ b/spec/controllers/origami/bank_integration_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Origami::BankIntegrationController, type: :controller do + +end diff --git a/spec/controllers/origami/unionpay_controller_spec.rb b/spec/controllers/origami/unionpay_controller_spec.rb new file mode 100644 index 00000000..059b5577 --- /dev/null +++ b/spec/controllers/origami/unionpay_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Origami::UnionpayController, type: :controller do + +end diff --git a/spec/helpers/app/controllers/origami/bank_integration_helper_spec.rb b/spec/helpers/app/controllers/origami/bank_integration_helper_spec.rb new file mode 100644 index 00000000..05d25720 --- /dev/null +++ b/spec/helpers/app/controllers/origami/bank_integration_helper_spec.rb @@ -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 diff --git a/spec/helpers/origami/bank_integration_helper_spec.rb b/spec/helpers/origami/bank_integration_helper_spec.rb new file mode 100644 index 00000000..d3f5fe11 --- /dev/null +++ b/spec/helpers/origami/bank_integration_helper_spec.rb @@ -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 diff --git a/spec/helpers/origami/unionpay_helper_spec.rb b/spec/helpers/origami/unionpay_helper_spec.rb new file mode 100644 index 00000000..5fce324c --- /dev/null +++ b/spec/helpers/origami/unionpay_helper_spec.rb @@ -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 diff --git a/spec/models/card_sale_tran_spec.rb b/spec/models/card_sale_tran_spec.rb new file mode 100644 index 00000000..ea612cf3 --- /dev/null +++ b/spec/models/card_sale_tran_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CardSaleTran, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/card_settle_tran_spec.rb b/spec/models/card_settle_tran_spec.rb new file mode 100644 index 00000000..68f1463f --- /dev/null +++ b/spec/models/card_settle_tran_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CardSettleTran, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end