From c660097d28d097bb4b5835072c9252d7e5637270 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 12 Dec 2017 18:51:13 +0630 Subject: [PATCH 01/10] no print for cloud --- app/assets/javascripts/OQS.js | 47 ++++--- .../crm/dining_queues_controller.rb | 10 +- app/controllers/crm/home_controller.rb | 8 +- app/controllers/oqs/edit_controller.rb | 14 +- app/controllers/oqs/print_controller.rb | 84 ++++++------ .../origami/payments_controller.rb | 124 +++++++++--------- app/controllers/origami/shifts_controller.rb | 30 ++--- app/controllers/origami/void_controller.rb | 58 ++++---- app/models/order_queue_station.rb | 64 ++++----- app/models/printer/receipt_printer.rb | 4 +- app/views/oqs/home/index.html.erb | 5 +- app/views/origami/home/show.html.erb | 34 ++--- app/views/origami/rooms/show.html.erb | 2 +- app/views/origami/sales/show.html.erb | 12 +- 14 files changed, 242 insertions(+), 254 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 64e207ab..572d94b3 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -217,30 +217,29 @@ $(document).on('turbolinks:load', function() { }); // Print Order Item - $(document).on('click', '#print_order_item', function(event){ - var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text(); - var options = $('.selected-item').children('.card-block').find('.item-options').text(); - var params = { 'options':options }; + // $(document).on('click', '#print_order_item', function(event){ + // var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text(); + // var options = $('.selected-item').children('.card-block').find('.item-options').text(); + // var params = { 'options':options }; - $.ajax({ - type: 'GET', - url: '/oqs/print/print/'+assigned_item_id, - success: function(data){ } - }); - }); + // $.ajax({ + // type: 'GET', + // url: '/oqs/print/print/'+assigned_item_id, + // success: function(data){ } + // }); + // }); - // Print Order Summary - // $('#print_order_summary').on('click',function(){ - $(document).on('click', '#print_order_summary', function(event){ - var orderNo = $('.selected-item').attr('data-order-no'); - var table_name=$('.selected-item').children().children().children('.order-zone').text().trim(); - var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); - var params = { 'table_name':table_name }; - $.ajax({ - type: 'GET', - url: '/oqs/print/print_order_summary/'+assigned_item_id, - data: params, - success: function(data){ } - }); - }); + // Print Order Summary + // $(document).on('click', '#print_order_summary', function(event){ + // var orderNo = $('.selected-item').attr('data-order-no'); + // var table_name=$('.selected-item').children().children().children('.order-zone').text().trim(); + // var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + // var params = { 'table_name':table_name }; + // $.ajax({ + // type: 'GET', + // url: '/oqs/print/print_order_summary/'+assigned_item_id, + // data: params, + // success: function(data){ } + // }); + // }); }); diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 20e58088..8184c660 100755 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -45,13 +45,13 @@ class Crm::DiningQueuesController < BaseCrmController respond_to do |format| if @dining_queue.save - unique_code = "QueueNoPdf" + # unique_code = "QueueNoPdf" - # get printer info - print_settings = PrintSetting.find_by_unique_code(unique_code) + # # get printer info + # print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_queue_no(print_settings,@dining_queue) + # printer = Printer::ReceiptPrinter.new(print_settings) + # printer.print_queue_no(print_settings,@dining_queue) format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' } format.json { render :show, status: :created, location: @dining_queue } diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index 012f2bc6..13b4ede3 100755 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -33,13 +33,13 @@ class Crm::HomeController < BaseCrmController end - unique_code="CrmOrderPdf" + # unique_code="CrmOrderPdf" - print_settings = PrintSetting.find_by_unique_code(unique_code) + # print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::ReceiptPrinter.new(print_settings) + # printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_crm_order(@booking,order_items,print_settings) + # printer.print_crm_order(@booking,order_items,print_settings) end diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index 8ec0725e..368255e5 100755 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -17,14 +17,14 @@ class Oqs::EditController < BaseOqsController order_item.save # print - assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code) - # order queue stations - oqs = assigned_item.order_queue_station + # assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code) + # # order queue stations + # oqs = assigned_item.order_queue_station - unique_code="OrderItemPdf" + # unique_code="OrderItemPdf" - print_settings=PrintSetting.find_by_unique_code(unique_code) - order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" ) + # print_settings=PrintSetting.find_by_unique_code(unique_code) + # order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) + # order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" ) end end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 0ff94403..cc5556e9 100755 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -1,61 +1,61 @@ class Oqs::PrintController < ApplicationController # Print Order Item def print - unique_code="OrderItemPdf" - assigned_item_id = params[:id] - options = params[:options] - assigned_item = AssignedOrderItem.find(assigned_item_id) - assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); + # unique_code="OrderItemPdf" + # assigned_item_id = params[:id] + # options = params[:options] + # assigned_item = AssignedOrderItem.find(assigned_item_id) + # assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # order queue stations - oqs = assigned_item.order_queue_station - order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first() + # # order queue stations + # oqs = assigned_item.order_queue_station + # order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first() - # Check Printed - print_status = assigned_item.print_status == true ? " (Re-Print)" : "" + # # Check Printed + # print_status = assigned_item.print_status == true ? " (Re-Print)" : "" - # print when complete click - print_settings = PrintSetting.find_by_unique_code(unique_code) - order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options ) + # # print when complete click + # print_settings = PrintSetting.find_by_unique_code(unique_code) + # order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) + # order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options ) - # update print status for completed same order items - assigned_items.each do |ai| - ai.print_status=true - ai.save - end + # # update print status for completed same order items + # assigned_items.each do |ai| + # ai.print_status=true + # ai.save + # end end # Print Order Details with booking id def print_order_summary - unique_code="OrderSummaryPdf" - assigned_item_id = params[:id] - table_name = params[:table_name] - assigned_item = AssignedOrderItem.find(assigned_item_id) - assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); + # unique_code="OrderSummaryPdf" + # assigned_item_id = params[:id] + # table_name = params[:table_name] + # assigned_item = AssignedOrderItem.find(assigned_item_id) + # assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # order queue stations - oqs = assigned_item.order_queue_station + # # order queue stations + # oqs = assigned_item.order_queue_station - # Check Printed - print_status = assigned_item.print_status == true ? " (Re-Print)" : "" + # # Check Printed + # print_status = assigned_item.print_status == true ? " (Re-Print)" : "" - # get dining - # dining = DiningFacility.find_by_name(table_name); - # booking = Booking.find_by_dining_facility_id(dining.id) + # # get dining + # # dining = DiningFacility.find_by_name(table_name); + # # booking = Booking.find_by_dining_facility_id(dining.id) - # Get Booking ID - booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0] + # # Get Booking ID + # booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0] - # print when complete click - print_settings = PrintSetting.find_by_unique_code(unique_code) - order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status) + # # print when complete click + # print_settings = PrintSetting.find_by_unique_code(unique_code) + # order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) + # order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status) - # update print status for completed same order items - assigned_items.each do |ai| - ai.print_status = true - ai.save - end + # # update print status for completed same order items + # assigned_items.each do |ai| + # ai.print_status = true + # ai.save + # end end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 5b0db19f..d9ea5ec3 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -22,29 +22,29 @@ 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) + # # 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) - # find order id by sale id - # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + # # 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) + # # 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 = 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") + # 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 @@ -83,24 +83,24 @@ class Origami::PaymentsController < BaseOrigamiController cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) # For Print - unique_code = "ReceiptBillPdf" - customer= Customer.find(saleObj.customer_id) + # 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 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 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") end end @@ -202,26 +202,26 @@ 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) + # end + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) - # 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) + # # 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") + # 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") end def foc @@ -251,20 +251,20 @@ class Origami::PaymentsController < BaseOrigamiController # Re-call Sale Data saleObj = Sale.find(sale_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 + # #shop detail + # shop_details = Shop::ShopDetail - # 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 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, "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") end end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 851be7e5..a1169ab1 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -46,24 +46,24 @@ class Origami::ShiftsController < BaseOrigamiController cashier_terminal.save - unique_code = "CloseCashierPdf" - shop_details = Shop.find(1) - #get tax - shift_obj = ShiftSale.where('id =?',@shift.id) - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') - #other payment details for mpu or visa like card - @other_payment = ShiftSale.get_by_shift_other_payment(@shift) + # unique_code = "CloseCashierPdf" + # shop_details = Shop.find(1) + # #get tax + # shift_obj = ShiftSale.where('id =?',@shift.id) + # @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') + # #other payment details for mpu or visa like card + # @other_payment = ShiftSale.get_by_shift_other_payment(@shift) - # Calculate price_by_accounts - @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') - @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') - @total_member_discount = ShiftSale.get_total_member_discount(@shift) - # get printer info - print_settings = PrintSetting.find_by_unique_code(unique_code) + # # Calculate price_by_accounts + # @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') + # @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') + # @total_member_discount = ShiftSale.get_total_member_discount(@shift) + # # get printer info + # print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::CashierStationPrinter.new(print_settings) + # printer = Printer::CashierStationPrinter.new(print_settings) - printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount) + # printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount) end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 27faea25..5a0aa3b8 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -55,40 +55,40 @@ 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") + # 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/models/order_queue_station.rb b/app/models/order_queue_station.rb index c8a3a552..8b1d6d7d 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -78,22 +78,13 @@ class OrderQueueStation < ApplicationRecord end end - if oqs.auto_print - if oqs_order_items.length > 0 - print_slip(oqs, order, oqs_order_items) - is_auto_printed = true - end - end - end - # if oqs.id == oqpbz.order_queue_station_id - # # Auto Printing - # if oqs.auto_print - # if oqs_order_items.length > 0 - # print_slip(oqs, order, oqs_order_items) - # is_auto_printed = true - # end - # end - # end + # if oqs.auto_print + # if oqs_order_items.length > 0 + # print_slip(oqs, order, oqs_order_items) + # is_auto_printed = true + # end + # end + end end # end end @@ -101,33 +92,32 @@ class OrderQueueStation < ApplicationRecord private #Print order_items in 1 slip def print_slip(oqs, order, order_items) - unique_code="OrderSummaryPdf" + # unique_code="OrderSummaryPdf" - print_settings=PrintSetting.find_by_unique_code(unique_code) - order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") + # print_settings=PrintSetting.find_by_unique_code(unique_code) + # order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) + # order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") - AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai| - # update print status for order items - ai.print_status=true - ai.save - end - + # AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai| + # # update print status for order items + # ai.print_status=true + # ai.save + # end end #Print order_item in 1 slip per item def print_slip_item(oqs, assigned_item) - unique_code="OrderItemPdf" - order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first() - # print when complete click - print_settings=PrintSetting.find_by_unique_code(unique_code) - order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" ) + # unique_code="OrderItemPdf" + # order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first() + # # print when complete click + # print_settings=PrintSetting.find_by_unique_code(unique_code) + # order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) + # order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" ) - # update print status for completed same order items - assigned_order_item.each do |ai| - ai.print_status=true - ai.save - end + # # update print status for completed same order items + # assigned_order_item.each do |ai| + # ai.print_status=true + # ai.save + # end end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 40a60201..f628c7f2 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -94,7 +94,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker # stock check def print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker_name, shop_details) pdf = StockResultPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details) - pdf.render_file "tmp/print_stock_check_result.pdf" + pdf.render_file "tmp/print_stock_check_result.pdf" self.print("tmp/print_stock_check_result.pdf") end @@ -114,7 +114,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker #Generate PDF #Print pdf = CrmOrderPdf.new(booking,order_items,setting) - pdf.render_file "tmp/print_crm_order.pdf" + pdf.render_file "tmp/print_crm_order.pdf" self.print("tmp/print_crm_order.pdf") end end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 7f7f2d24..ea118e9c 100755 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -168,9 +168,8 @@
reply Back - - +
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 0b98ac76..27c9e2c4 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -389,7 +389,7 @@ - + <% end %> @@ -472,12 +472,12 @@ }); - $('#re-print').click(function () { - var sale_id = $('#sale_id').val(); - window.location.href = '/origami/' + sale_id + "/reprint" + // $('#re-print').click(function () { + // var sale_id = $('#sale_id').val(); + // window.location.href = '/origami/' + sale_id + "/reprint" - return false; - }); + // return false; + // }); // Add Other Charges $('#other-charges').click(function () { @@ -519,18 +519,18 @@ }); // Print for first bill - $("#first_bill").on('click', function () { - var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + // $("#first_bill").on('click', function () { + // var sale_id = $('#sale_id').val(); + // var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; - $.ajax({ - type: "GET", - url: ajax_url, - success: function (result) { - location.reload(); - } - }); - }); + // $.ajax({ + // type: "GET", + // url: ajax_url, + // success: function (result) { + // location.reload(); + // } + // }); + // }); // $('#pay').on('click', function () { // var sale_id = $('#sale_id').val(); diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 05f14c04..d50f9ae5 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -369,7 +369,7 @@ - + <% end %> diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index 7c008977..49395586 100755 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -201,7 +201,7 @@ <% if @sale.sale_status != 'void' %> <% end %> - + @@ -271,10 +271,10 @@ $('#back').on('click',function(){ }); }); -$('#re-print').click(function() { - var sale_id = $('#sale_id').val(); - window.location.href = '/origami/'+ sale_id + "/reprint" +// $('#re-print').click(function() { +// var sale_id = $('#sale_id').val(); +// window.location.href = '/origami/'+ sale_id + "/reprint" - return false; - }); +// return false; +// }); From fef4d4caa19d182740f66ecc1f22174c117da69e Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 12 Dec 2017 18:51:56 +0630 Subject: [PATCH 02/10] no print for cloud --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4f0ac524..8489e37c 100755 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,7 @@ pickle-email-*.html .rbenv-version config/deploy/config/* config/puma.rb -config/shops.json +#config/shops.json !/log/.keep !/tmp/.keep .ruby-version From 9def0756b336ac1aab11d1e47c7330189be8a3e5 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 14 Dec 2017 10:25:31 +0630 Subject: [PATCH 03/10] add cipher type --- config/secrets.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/secrets.yml b/config/secrets.yml index 23c287ba..d81ab339 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -28,6 +28,7 @@ production: secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 sx_provision_url: provision.zsai.ws/api #192.168.1.94:3002 server_mode: cloud + cipher_type: AES-256-CBC sx_key: Wh@t1$C2L aes_key: <%= ENV['AES_KEY'] %> aes_iv: <%= ENV['AES_IV'] %> From b9296c68f3d93199cb9ebe48b3b3c564327106c2 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 14 Dec 2017 12:18:09 +0630 Subject: [PATCH 04/10] nothing --- config/secrets.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/secrets.yml b/config/secrets.yml index d81ab339..bcb6d0a6 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,7 +12,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: 192.168.1.147:3002/api #connect.smartsales.asia/api #provision.zsai.ws/api + sx_provision_url: connect.smartsales.asia/api #provision.zsai.ws/api server_mode: cloud cipher_type: AES-256-CBC sx_key: Wh@t1$C2L @@ -26,7 +26,7 @@ test: # instead read values from the environment. production: secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 - sx_provision_url: provision.zsai.ws/api #192.168.1.94:3002 + sx_provision_url: provision.zsai.ws/api #192.168.1.147:3002/api server_mode: cloud cipher_type: AES-256-CBC sx_key: Wh@t1$C2L From a735f66c3314f6cf3703c19e5dd30115be1b97a4 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 14 Dec 2017 12:18:23 +0630 Subject: [PATCH 05/10] nothing --- config/shops.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 config/shops.json diff --git a/config/shops.json b/config/shops.json new file mode 100644 index 00000000..e218eb9e --- /dev/null +++ b/config/shops.json @@ -0,0 +1,11 @@ +{ + "data": [ + { + "lookup": "osaka1-7.zsai.ws", + "value": { + "key": "wwF9Zx9q/LfxSDqSNHYXvfu1eGsBqFEFXoXqGWrEirA=\n", + "iv": "GIAdRW/8tlyDRTI4w5D3ZA==\n" + } + } + ] +} From 14d102f4fe46e82ad75eb1c4653c15ae50779b7a Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 14 Dec 2017 12:20:07 +0630 Subject: [PATCH 06/10] shops json --- config/shops.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/shops.json b/config/shops.json index e218eb9e..f48d28c5 100644 --- a/config/shops.json +++ b/config/shops.json @@ -4,7 +4,7 @@ "lookup": "osaka1-7.zsai.ws", "value": { "key": "wwF9Zx9q/LfxSDqSNHYXvfu1eGsBqFEFXoXqGWrEirA=\n", - "iv": "GIAdRW/8tlyDRTI4w5D3ZA==\n" + "iv": "l1rUEZFcPNHrTHWgaODkYQ==\n" } } ] From 3fb3fdfe3fd430a05d1c69ed6e37e06938351997 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 14 Dec 2017 13:46:48 +0630 Subject: [PATCH 07/10] update secrets --- config/secrets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/secrets.yml b/config/secrets.yml index bcb6d0a6..a53c9f76 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -26,7 +26,7 @@ test: # instead read values from the environment. production: secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 - sx_provision_url: provision.zsai.ws/api #192.168.1.147:3002/api + sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api server_mode: cloud cipher_type: AES-256-CBC sx_key: Wh@t1$C2L From bac1309f1fb0e6be864fba2bf019691313898945 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 9 Jan 2018 16:56:34 +0630 Subject: [PATCH 08/10] remove frt bill --- app/assets/javascripts/origami.js | 2 +- .../origami/payments_controller.rb | 48 ------------------- app/views/origami/home/show.html.erb | 10 ++-- 3 files changed, 6 insertions(+), 54 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 33252efa..3afb23c1 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -163,7 +163,7 @@ function checkReceiptNoInFirstBillData(receipt_no,payment) { } } if (payment) { - return json_data[0]["payment"]; + return status; //json_data[0]["payment"]; }else{ return status; } diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index ebc10789..9d86c8ff 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -22,7 +22,6 @@ class Origami::PaymentsController < BaseOrigamiController cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) # Print for First Bill to Customer -<<<<<<< HEAD # unique_code = "ReceiptBillPdf" # #shop detail # shop_details = Shop::ShopDetail @@ -46,48 +45,6 @@ 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") -======= - unique_code = "ReceiptBillPdf" - #shop detail - shop_details = Shop::ShopDetail - # customer= Customer.where('customer_id=' +.customer_id) - customer = Customer.find(sale_data.customer_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 - - # 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) - - # 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) ->>>>>>> master end def create @@ -319,13 +276,8 @@ class Origami::PaymentsController < BaseOrigamiController # 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) -<<<<<<< HEAD # 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) ->>>>>>> master end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a19f6b46..03897e1b 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -447,11 +447,11 @@ receipt_no = ($("#receipt_no").html()).trim(); } // console.log(checkReceiptNoInFirstBillData(receipt_no)); - if(checkReceiptNoInFirstBillData(receipt_no,"")){ - $("#pay").show(); - }else{ - $("#pay").hide(); - } + // if(checkReceiptNoInFirstBillData(receipt_no,"")){ + // $("#pay").show(); + // }else{ + // $("#pay").hide(); + // } /* end check first bill or not*/ $('.invoicedetails').on('click', function () { From 0b517807f9eb3328106f1c180b09a7ef99dcda12 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 12 Jan 2018 15:46:40 +0630 Subject: [PATCH 09/10] update check server mode --- .../origami/payments_controller.rb | 3 ++- app/views/origami/home/show.html.erb | 24 +++++++++---------- app/views/origami/payments/show.html.erb | 3 +-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 304b9396..1123351f 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -20,7 +20,8 @@ class Origami::PaymentsController < BaseOrigamiController cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) - +puts ENV["SERVER_MODE"] +puts "DDDDDDDDDDDDDDDDD" # Print for First Bill to Customer unique_code = "ReceiptBillPdf" #shop detail diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a5e43a58..12491edf 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -396,7 +396,7 @@ - + @@ -571,18 +571,18 @@ }); }); // Print for first bill - // $("#first_bill").on('click', function () { - // var sale_id = $('#sale_id').val(); - // var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + $("#first_bill").on('click', function () { + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; - // $.ajax({ - // type: "GET", - // url: ajax_url, - // success: function (result) { - // location.reload(); - // } - // }); - // }); + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + location.reload(); + } + }); + }); // $('#pay').on('click', function () { // var sale_id = $('#sale_id').val(); diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 5e99509f..314c9b68 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -311,8 +311,7 @@ } payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment") - // console.log(jQuery.inArray("Credit", payment_type)) - // console.log(payment_type) + if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){ $("#credit_payment").hide(); } else{ From f214be884749823b4addc4783e5d6ad60f8057b7 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 12 Jan 2018 16:41:28 +0630 Subject: [PATCH 10/10] update cloud for print and first bill --- .../origami/payments_controller.rb | 236 +++++++++--------- app/controllers/origami/void_controller.rb | 39 +-- app/views/origami/home/show.html.erb | 21 +- .../origami/others_payments/index.html.erb | 18 +- app/views/origami/payments/show.html.erb | 14 +- app/views/origami/rooms/show.html.erb | 19 +- 6 files changed, 183 insertions(+), 164 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 1123351f..fecdbfc3 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -20,50 +20,52 @@ class Origami::PaymentsController < BaseOrigamiController cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) -puts ENV["SERVER_MODE"] -puts "DDDDDDDDDDDDDDDDD" - # 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) - # 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) + Rails.logger.debug ENV["SERVER_MODE"] + + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # 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) + + # 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 + + # 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 - #end rounding adjustment + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) - # 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 + # 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) end - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) - - # 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) - end def create @@ -108,40 +110,42 @@ puts "DDDDDDDDDDDDDDDDD" cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) # For Print - # unique_code = "ReceiptBillPdf" - # customer= Customer.find(saleObj.customer_id) + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + unique_code = "ReceiptBillPdf" + customer= Customer.find(saleObj.customer_id) - # 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}) + # 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 - 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) + + #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",current_balance,card_data) + 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 end @@ -246,40 +250,42 @@ puts "DDDDDDDDDDDDDDDDD" 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) + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + 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) - 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}) + #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 - end - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) - # 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) + #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 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 end def foc @@ -316,22 +322,22 @@ puts "DDDDDDDDDDDDDDDDD" # Re-call Sale Data saleObj = Sale.find(sale_id) - # unique_code = "ReceiptBillPdf" - # customer= Customer.find(saleObj.customer_id) - - # #shop detail - # shop_details = Shop::ShopDetail + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + unique_code = "ReceiptBillPdf" + customer= Customer.find(saleObj.customer_id) + + #shop detail + shop_details = Shop::ShopDetail - # # 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 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, "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) + 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 end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 1283fb2e..a0c4a23b 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -76,26 +76,27 @@ class Origami::VoidController < 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(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) + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + 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) + + 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) 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) - #end print diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 12491edf..db9dbbb6 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -395,9 +395,10 @@ - - - + + <% if ENV["SERVER_MODE"] != "cloud" %> + + <% end %> <% end %> @@ -407,6 +408,7 @@ <% else %> <% end %> + "> +">