From f0ea6f3c56ddde42ac8e2dea883d7c255d247057 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 15 Jun 2017 19:07:33 +0630 Subject: [PATCH 01/13] finish reprint --- app/assets/javascripts/origami.js | 15 ++++++++++++ .../origami/payments_controller.rb | 24 +++++++++++++++++++ app/views/origami/home/index.html.erb | 2 +- config/routes.rb | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 87b74809..b2f94bc0 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -51,6 +51,7 @@ $(document).ready(function(){ var customer_id=$(this).find(".customer-id").text(); show_customer_details(customer_id); + $("#re-print").val(unique_id); var cashier=""; var receipt_date=""; @@ -199,6 +200,14 @@ $(document).ready(function(){ return false; }); + $('#re-print').click(function() { + var sale_id = $(".selected-item").find(".orders-id").text(); + + window.location.href = '/origami/'+ sale_id + "/reprint" + + return false; + }); + function show_customer_details(customer_id){ if(window.location.pathname.substring(0, 12) == "/origami/SAL"){ @@ -297,19 +306,25 @@ function control_button(order_status){ $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', false); $("#pay-bill").prop('disabled', false); + $("#re-print").prop('disabled', true); } else if(order_status=="new") { $("#customer").prop('disabled', false); $("#request_bills").prop('disabled', false); $("#discount").prop('disabled', true); $("#pay-bill").prop('disabled', true); + $("#re-print").prop('disabled', true); + }else if(order_status=="completed"){ + $("#re-print").prop('disabled', false); } else { $("#customer").prop('disabled', true); $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', true); $("#pay-bill").prop('disabled', true); + $("#re-print").prop('disabled', true); } + } /* For Receipt - Update Balance */ diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 01cedcbe..92c4fe3f 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -77,4 +77,28 @@ class Origami::PaymentsController < BaseOrigamiController end end end + + def reprint + + sale_id = params[:sale_id] + + saleObj = Sale.find(sale_id) + + unique_code = "ReceiptBillPdf" + customer= Customer.find(saleObj.customer_id) + + # get member information + member_info = Customer.get_member_account(customer) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # Calculate Food and Beverage Total + food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) + end + + end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 9f6cd7d6..66d65aea 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -383,6 +383,6 @@ - + diff --git a/config/routes.rb b/config/routes.rb index fc21337a..e1baa28d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,7 +83,7 @@ Rails.application.routes.draw do post "/:id/discount" => "discounts#create" get "/:id/request_bills" => "request_bills#print" - + get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' From 09a96372c8af46ddbbe1a0f8df00efdd2c4814d4 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 10:20:20 +0630 Subject: [PATCH 02/13] update void and complete sale --- .../crm/dining_queues_controller.rb | 5 +- .../transactions/manual_sales_controller.rb | 77 +++++++++++++++++++ .../transactions/sales_controller.rb | 34 +------- app/models/dining_queue.rb | 5 ++ .../{sales => manual_sales}/void.html.erb | 0 app/views/transactions/sales/show.html.erb | 66 +--------------- config/routes.rb | 6 +- 7 files changed, 93 insertions(+), 100 deletions(-) create mode 100644 app/controllers/transactions/manual_sales_controller.rb rename app/views/transactions/{sales => manual_sales}/void.html.erb (100%) diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 9e8cd06c..99a68fe3 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -15,6 +15,7 @@ class Crm::DiningQueuesController < BaseCrmController # GET /crm/dining_queues/new def new @dining_queue = DiningQueue.new + @queue_no = DiningQueue.generate_queue_no end # GET /crm/dining_queues/1/edit @@ -25,7 +26,9 @@ class Crm::DiningQueuesController < BaseCrmController # POST /crm/dining_queues.json def create @dining_queue = DiningQueue.new(dining_queue_params) - + +puts "ffffffffffff" +puts @queue_no respond_to do |format| if @dining_queue.save format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' } diff --git a/app/controllers/transactions/manual_sales_controller.rb b/app/controllers/transactions/manual_sales_controller.rb new file mode 100644 index 00000000..77dd4371 --- /dev/null +++ b/app/controllers/transactions/manual_sales_controller.rb @@ -0,0 +1,77 @@ +class Transactions::ManualSalesController < ApplicationController + + def void + @sale = params[:sale_id] + @reason = Lookup.where("lookup_type = 'void_reason'") + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sales } + end + end + + def manual_void_sale + sale_id = params[:sale_id] + reason = params[:reason] + sale = Sale.find(sale_id) + sale.sale_status = 'void' + sale.requested_by = current_login_employee.id + if sale.save + @sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason) + + if sale.sale_orders + + sale.sale_orders.each do |bo| + order =Order.find(bo.order_id) + order.status= 'void' + order.save + booking_order = BookingOrder.find_by_order_id(bo.order_id) + + if booking_order.booking_id + booking = Booking.find(booking_order.booking_id) + dining_facility = booking.dining_facility + dining_facility.status = 'available' + dining_facility.save + end + end + + end + end + respond_to do |format| + format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' } + end + + end + + def manual_complete_sale + sale_id = params[:sale_id] + sale = Sale.find(sale_id) + + sale.sale_status = 'completed' + sale.requested_by = current_login_employee.id + remark = "Complete for Sale ID #{sale_id} By #{current_login_employee.name}" + if sale.save + @sale = SaleAudit.record_audit_complete(sale_id, remark, current_login_employee.id) + + if sale.sale_orders + + sale.sale_orders.each do |bo| + # order =Order.find(bo.order_id) + # order.status= 'void' + # order.save + booking_order = BookingOrder.find_by_order_id(bo.order_id) + + if booking_order.booking_id + booking = Booking.find(booking_order.booking_id) + dining_facility = booking.dining_facility + dining_facility.status = 'available' + dining_facility.save + end + end + + end + + end + redirect_to transactions_sales_path + end + +end diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 8088e0a3..fed62a34 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -60,7 +60,7 @@ class Transactions::SalesController < ApplicationController else @membership = 0 end - #end customer amount + #end customer amount respond_to do |format| format.html # show.html.erb @@ -117,38 +117,6 @@ class Transactions::SalesController < ApplicationController end end - def void - @sale = params[:sale_id] - @reason = Lookup.where("lookup_type = 'void_reason'") - end - - def manual_void_sale - sale_id = params[:sale_id] - reason = params[:reason] - sale = Sale.find(sale_id) - sale.sale_status = 'void' - sale.requested_by = current_login_employee.id - if sale.save - @sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason) - end - respond_to do |format| - format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' } - end - end - - def manual_complete_sale - sale_id = params[:sale_id] - sale = Sale.find(sale_id) - sale.sale_status = 'completed' - sale.requested_by = current_login_employee.id - remark = remark = "Complete for Sale ID #{sale_id} By #{current_login_employee.name}" - if sale.save - sale = SaleAudit.record_audit_complete(sale_id, remark, current_login_employee.id) - end - redirect_to transactions_sales_path - end - - private # Use callbacks to share common setup or constraints between actions. def set_transactions_sale diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb index ea6a1381..09f8b6b5 100644 --- a/app/models/dining_queue.rb +++ b/app/models/dining_queue.rb @@ -1,2 +1,7 @@ class DiningQueue < ApplicationRecord + + def self.generate_queue_no + queue_no = DiningQueue.all.count + 1 + return queue_no + end end diff --git a/app/views/transactions/sales/void.html.erb b/app/views/transactions/manual_sales/void.html.erb similarity index 100% rename from app/views/transactions/sales/void.html.erb rename to app/views/transactions/manual_sales/void.html.erb diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index b61f2312..5f6365e5 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -160,67 +160,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <% if @membership == 0 %> - - - - <% else %> - <% @membership.each do |member| %> - - - - - - <% end %> - - <% end %> - - - - - -

Customer Details

Name<%= @customer.name %>
Email<%= @customer.email %>
Contact no<%= @customer.contact_no %>
Company<%= @customer.company rescue '-' %>
Date Of Birth<%= @customer.date_of_birth rescue '-' %>

Membership Details

"There is no membership data"
<%= member["accountable_type"] %><%= member["balance"] %>
+
@@ -238,9 +178,9 @@ Void Sale - + diff --git a/config/routes.rb b/config/routes.rb index e1baa28d..19b07979 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -199,9 +199,9 @@ Rails.application.routes.draw do resources :sales resources :orders - get "/sales/:sale_id/manual_complete_sale" =>"sales#manual_complete_sale", :as => "manual_complete_sale" - get "/sales/:sale_id/void" =>"sales#void", :as => "void" - post "sales/:sale_id/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale" + get "/sales/:sale_id/manual_complete_sale" =>"manual_sales#manual_complete_sale", :as => "manual_complete_sale" + get "/sales/:sale_id/void" =>"manual_sales#void", :as => "void" + post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale" end #--------- Reports Controller Sections ------------# From 4cf9ce79ecf05f40cb79817875caf469fefb3e26 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 10:51:50 +0630 Subject: [PATCH 03/13] update receipt print member info --- app/controllers/crm/dining_queues_controller.rb | 2 -- app/controllers/origami/payments_controller.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 15 ++++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 99a68fe3..8b9cc4fc 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -27,8 +27,6 @@ class Crm::DiningQueuesController < BaseCrmController def create @dining_queue = DiningQueue.new(dining_queue_params) -puts "ffffffffffff" -puts @queue_no respond_to do |format| if @dining_queue.save format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' } diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 92c4fe3f..ca497b81 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -89,7 +89,7 @@ class Origami::PaymentsController < BaseOrigamiController # get member information member_info = Customer.get_member_account(customer) - + # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 9d5742d6..3eebc8f3 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -207,17 +207,18 @@ class ReceiptBillPdf < Prawn::Document # show member information def member_info(member_info) move_down 7 - if member_info["data"] == true + if member_info["status"] == true member_info["data"].each do |res| - stroke_horizontal_rule + move_down 5 y_position = cursor - - bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "#{ res["accountable_type"] } : #{ res["balance"] }", :size => self.item_font_size,:align => :left + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ res["accountable_type"] }", :size => self.item_font_size,:align => :left end - - move_down 5 + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right + end + end end end From 58bc13e8b66e0d28b6d2d28361bf13b7b9cc04b5 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 11:14:47 +0630 Subject: [PATCH 04/13] add auto_print field to migration --- db/migrate/20170403151731_create_order_queue_stations.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20170403151731_create_order_queue_stations.rb b/db/migrate/20170403151731_create_order_queue_stations.rb index 6ad93bb1..6c327b8e 100644 --- a/db/migrate/20170403151731_create_order_queue_stations.rb +++ b/db/migrate/20170403151731_create_order_queue_stations.rb @@ -9,6 +9,7 @@ class CreateOrderQueueStations < ActiveRecord::Migration[5.1] t.integer :font_size, :null => false, :default => 10 t.boolean :cut_per_item, :null => false, :default => false t.boolean :use_alternate_name, :null => false, :default => false + t.boolean :auto_print, :null => false, :default => false t.string :created_by, :null => false t.timestamps end From bec59a1d7bf474edda22914366e3195615c6e3f4 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 13:23:05 +0630 Subject: [PATCH 05/13] update queue no print --- .../crm/dining_queues_controller.rb | 9 +++ app/models/printer/receipt_printer.rb | 10 ++++ app/pdf/queue_no_pdf.rb | 58 +++++++++++++++++++ app/pdf/receipt_bill_pdf.rb | 1 + app/views/crm/dining_queues/_form.html.erb | 15 ++++- 5 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 app/pdf/queue_no_pdf.rb diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 8b9cc4fc..41655d98 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -29,6 +29,15 @@ class Crm::DiningQueuesController < BaseCrmController respond_to do |format| if @dining_queue.save + + unique_code = "QueueNoPdf" + + # 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) + format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' } format.json { render :show, status: :created, location: @dining_queue } else diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index e8fb111a..92468b0e 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -74,6 +74,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print("tmp/receipt_bill.pdf") end + #Queue No Print + def print_queue_no(printer_settings,queue) + #Use CUPS service + #Generate PDF + #Print + pdf = QueueNoPdf.new(printer_settings,queue) + pdf.render_file "tmp/print_queue_no.pdf" + self.print("tmp/print_queue_no.pdf") + end + #Bill Receipt Print def print_crm_order(booking,order_items,setting) #Use CUPS service diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb new file mode 100644 index 00000000..704dbfdb --- /dev/null +++ b/app/pdf/queue_no_pdf.rb @@ -0,0 +1,58 @@ +class QueueNoPdf < Prawn::Document + 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 + def initialize(printer_settings, queue) + self.page_width = 210 + self.page_height = 2500 + self.margin = 5 + self.price_width = 35 + self.qty_width = 20 + self.total_width = 35 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.item_height = 15 + self.item_description_width = (self.page_width-20) / 2 + self.label_width = 100 + + super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + self.header_font_size = 10 + self.item_font_size = 8 + + header( "Beauty In the Pot", printer_settings.name) + + queue_no(queue) + stroke_horizontal_rule + + date_info(queue) + + end + + def header (printer_name, name) + text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center + text "#{name}", :size => self.header_font_size,:align => :center + # move_down self.item_height + move_down 5 + stroke_horizontal_rule + move_down 5 + end + + def queue_no (queue) + move_down 5 + text "#{queue.queue_no}", :size => 100,:align => :center + end + + def date_info(queue) + move_down 5 + + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "Date:", :size => self.item_font_size,:align => :left + end + bounding_box([self.label_width,y_position], :width => self.item_width) do + text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left + end + + move_down 5 + + end + +end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 3eebc8f3..2d67989d 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -206,6 +206,7 @@ class ReceiptBillPdf < Prawn::Document # show member information def member_info(member_info) + move_down 7 if member_info["status"] == true member_info["data"].each do |res| diff --git a/app/views/crm/dining_queues/_form.html.erb b/app/views/crm/dining_queues/_form.html.erb index a99f6b76..7f02ac15 100644 --- a/app/views/crm/dining_queues/_form.html.erb +++ b/app/views/crm/dining_queues/_form.html.erb @@ -1,16 +1,25 @@ <%= simple_form_for([:crm,@dining_queue]) do |f| %> <%= f.error_notification %> - +
<%= f.input :name %> <%= f.input :contact_no %> - <%= f.input :queue_no %> + <%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%>
- +
<%= f.button :submit %>
<% end %> + + From cd804a3d1868af06e2380b571102e189196fe1b2 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 13:28:28 +0630 Subject: [PATCH 06/13] update queue no print --- db/seeds.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index f6323d48..56591e2c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -151,6 +151,7 @@ order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderIte order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) +queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A"}) member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) @@ -163,10 +164,10 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} ]) -payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http//192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) puts " Finished System Default Set Up Data " From c40a2c78e7ef58974f74e6361d41bf31e680b658 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 13:44:39 +0630 Subject: [PATCH 07/13] oqs autoprint developing --- app/controllers/oqs/print_controller.rb | 12 +++---- .../order_queue_stations_controller.rb | 2 +- app/models/printer/order_queue_printer.rb | 33 ++++++++++++++----- .../order_queue_stations/_form.html.erb | 1 + .../order_queue_stations/index.html.erb | 2 ++ .../order_queue_stations/show.html.erb | 5 +++ 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index ecbc94e7..9fc2a2d7 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -6,13 +6,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # printer for each stations - printer_name = assigned_item.order_queue_station.printer_name + # order queue stations + oqs = assigned_item.order_queue_station # 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(printer_name,assigned_item.order_id, assigned_item.item_code ) + order_queue_printer.print_order_item(oqs,assigned_item.order_id, assigned_item.item_code ) # update print status for completed same order items assigned_items.each do |ai| @@ -28,13 +28,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # printer for each stations - printer_name = assigned_item.order_queue_station.printer_name + # order queue stations + oqs = assigned_item.order_queue_station # 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_summary(printer_name,assigned_item.order_id) + order_queue_printer.print_order_summary(oqs,assigned_item.order_id) # update print status for completed same order items assigned_items.each do |ai| diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index e8b9bbe0..408519d2 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -71,6 +71,6 @@ class Settings::OrderQueueStationsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_order_queue_station_params - params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) + params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 9b3f5205..57a819c9 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,25 +1,42 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(printer_name,order_id, item_code) + def print_order_item(oqs,order_id, item_code) #Use CUPS service #Generate PDF #Print order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) pdf = OrderItemPdf.new(order_item[0]) pdf.render_file "tmp/receipt.pdf" - self.print("tmp/receipt.pdf", printer_name) + if oqs.print_copy + self.print("tmp/receipt.pdf", oqs.printer_name)*2 + else + self.print("tmp/receipt.pdf", oqs.printer_name) + end end - def print_order_summary(printer_name,order_id) + def print_order_summary(oqs,order_id) #Use CUPS service #Generate PDF #Print order=print_query('order_summary',order_id) - filename = "tmp/order_summary_#{order_id}" + ".pdf" - pdf = OrderSummaryPdf.new(order) - pdf.render_file filename - - self.print(filename, printer_name) + # For Print Per Item + if oqs.cut_per_item + order.each do|odi| + pdf = OrderItemPdf.new(odi) + pdf.render_file "tmp/receipt.pdf" + if oqs.print_copy + self.print("tmp/receipt.pdf", oqs.printer_name)*2 + else + self.print("tmp/receipt.pdf", oqs.printer_name) + end + end + # For Print Order Summary + else + filename = "tmp/order_summary_#{order_id}" + ".pdf" + pdf = OrderSummaryPdf.new(order) + pdf.render_file filename + self.print(filename, printer_name) + end end # Query for OQS with status diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index db7ed5fd..bc76f044 100644 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -4,6 +4,7 @@
<%= f.input :station_name %> <%= f.input :is_active %> + <%= f.input :auto_print %> <%= f.input :printer_name %> <%= f.input :font_size %> <%= f.input :print_copy %> diff --git a/app/views/settings/order_queue_stations/index.html.erb b/app/views/settings/order_queue_stations/index.html.erb index 03da3c23..287fb10b 100644 --- a/app/views/settings/order_queue_stations/index.html.erb +++ b/app/views/settings/order_queue_stations/index.html.erb @@ -17,6 +17,7 @@ Station name Is active + Auto Print Print copy Printer name Cut per item @@ -31,6 +32,7 @@ <%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %> <%= settings_order_queue_station.is_active %> + <%= settings_order_queue_station.auto_print %> <%= settings_order_queue_station.print_copy %> <%= settings_order_queue_station.printer_name %> <%= settings_order_queue_station.cut_per_item %> diff --git a/app/views/settings/order_queue_stations/show.html.erb b/app/views/settings/order_queue_stations/show.html.erb index 1a80c2c0..e92ed0bb 100644 --- a/app/views/settings/order_queue_stations/show.html.erb +++ b/app/views/settings/order_queue_stations/show.html.erb @@ -18,6 +18,11 @@ <%= @settings_order_queue_station.is_active %>

+

+ Auto Print: + <%= @settings_order_queue_station.auto_print %> +

+

Processing items: <%= @settings_order_queue_station.processing_items %> From cb43afc40582101183c72d1f4f9517747b3ffd81 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 18:04:39 +0630 Subject: [PATCH 08/13] update bug sale --- app/assets/javascripts/origami.js | 28 ++++--- app/views/crm/customers/show.html.erb | 45 ++++------ app/views/transactions/orders/index.html.erb | 5 +- app/views/transactions/orders/show.html.erb | 11 ++- app/views/transactions/sales/index.html.erb | 4 +- app/views/transactions/sales/show.html.erb | 87 ++++++++++++++++---- 6 files changed, 116 insertions(+), 64 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index b39a4c6e..6149a2bc 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -227,20 +227,24 @@ $(document).ready(function(){ dataType: "json", success: function(data) { $("#customer_name").text(data["customer"].name); - $.each(data["response_data"]["data"], function (i) { - if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ - var balance = data["response_data"]["data"][i]["balance"]; - if (data["response_data"]["status"]==true) { - $('.rebate_amount').removeClass('hide'); - row = - '' + data["response_data"]["data"][i]["accountable_type"] +'' - +'' + balance + ''; + if (data["response_data"]["data"].length) { + $.each(data["response_data"]["data"], function (i) { + if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ + var balance = data["response_data"]["data"][i]["balance"]; + if (data["response_data"]["status"]==true) { + $('.rebate_amount').removeClass('hide'); + row = + '' + data["response_data"]["data"][i]["accountable_type"] +'' + +'' + balance + ''; - $(".rebate_amount").html(row); - } + $(".rebate_amount").html(row); + } - } - }); + } + }); + }else{ + $('.rebate_amount').addClass('hide'); + } } }); //End Ajax diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index d806ec34..04f3acf9 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,26 +1,8 @@

-
+
- - - - - -
-
-

Customer Profile

@@ -51,11 +33,8 @@
-
-
-
-
+

Membership Detail

@@ -78,8 +57,22 @@ + - + + + +

Order Details

@@ -114,9 +107,8 @@
-
-

Sale Details

+

Sale Details

@@ -146,7 +138,6 @@
-
diff --git a/app/views/transactions/orders/index.html.erb b/app/views/transactions/orders/index.html.erb index 29cd001c..80befdc1 100644 --- a/app/views/transactions/orders/index.html.erb +++ b/app/views/transactions/orders/index.html.erb @@ -34,7 +34,6 @@ Order status Order date Items Count - Action @@ -42,13 +41,13 @@ <% @orders.each do |order| %> - <%= order.order_id %> + <%= link_to order.order_id, transactions_order_path(order) %> <%= order.order_type %> <%= order.customer.name rescue '-' %> <%= order.status %> <%= order.date.strftime("%d-%m-%Y") %> <%= order.item_count %> - <%= link_to 'Show', transactions_order_path(order) %> + <% end %> diff --git a/app/views/transactions/orders/show.html.erb b/app/views/transactions/orders/show.html.erb index dc5bae88..e1127296 100644 --- a/app/views/transactions/orders/show.html.erb +++ b/app/views/transactions/orders/show.html.erb @@ -14,7 +14,7 @@
-
+
@@ -70,13 +70,16 @@ <% end %>
- - Back - +
+
diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb index b7e73219..2f437f3c 100644 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -36,7 +36,6 @@ Cashier Sales status Receipt Date - Action @@ -44,14 +43,13 @@ <% if @sales != 0 %> <% @sales.each do |sale| %> - <%= sale.sale_id %> + <%= link_to sale.sale_id, transactions_sale_path(sale) %> <%= sale.receipt_no %> <%= sale.grand_total rescue '-' %> <%= sale.total_tax %> <%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> <%= sale.receipt_date.strftime("%d-%m-%Y") %> - <%= link_to 'Show', transactions_sale_path(sale) %> <% end %> <% else %> diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 5f6365e5..5f4e8f6e 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -82,12 +82,13 @@ Discount <%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%> + <% @sale.sale_taxes.each do |r|%> - Tax - <%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%> + <%= r.tax_name %>(<%= r.tax_rate %>) + <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%> - + <% end %> Grand Total @@ -99,21 +100,24 @@ Pay Amount <%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%> - - - Change - <%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%> - + <% @sale_receivables.each do |r|%> Payment <%= r.payment_method rescue ' '%> <%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> - - + + <% end %> + + + + Change + <%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%> + + @@ -160,7 +164,61 @@
- +
+
+
+

Customer Profile

+
+ + + + + + + + + + + + + + + + + + + + + + + +
Name<%= @customer.name %>
Email<%= @customer.email %>
Contact no<%= @customer.contact_no %>
Company<%= @customer.company %>
Date Of Birth<%= @customer.date_of_birth %>
+
+
+
+
+

Membership Detail

+
+ + + <% if @membership == 0 %> + + + + <% else %> + <% @membership.each do |member| %> + + + + + <% end %> + + <% end %> + +
"There is no membership data"
<%= member["accountable_type"] %><%= member["balance"] %>
+
+
+
@@ -169,16 +227,15 @@
From 841f74b4066ba9ec1e547a6d7afc4732143e09c6 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 18:22:18 +0630 Subject: [PATCH 09/13] update footer in req bill --- app/pdf/receipt_bill_pdf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2d67989d..524ee7e5 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -229,7 +229,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule move_down 5 - text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center + text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center move_down 5 end From 0a496f227446325ffa7723438f3324279aed9a8c Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 18:55:14 +0630 Subject: [PATCH 10/13] update order for oqs --- app/jobs/order_queue_processor_job.rb | 4 ++-- app/models/order.rb | 2 +- app/models/order_queue_station.rb | 24 ++++++++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index e92faa36..5b3423dc 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -1,7 +1,7 @@ class OrderQueueProcessorJob < ApplicationJob queue_as :default - def perform(order_id) + def perform(order_id, table_id) # Do something later #Order ID order = Order.find(order_id) @@ -10,7 +10,7 @@ class OrderQueueProcessorJob < ApplicationJob #Execute orders and send to order stations if order oqs = OrderQueueStation.new - oqs.process_order(order) + oqs.process_order(order, table_id) end end diff --git a/app/models/order.rb b/app/models/order.rb index f3ae798c..2ea76a98 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -199,7 +199,7 @@ class Order < ApplicationRecord #Process order items and send to order queue def process_order_queue #Send to background job for processing - OrderQueueProcessorJob.perform_later(self.id) + OrderQueueProcessorJob.perform_later(self.id, self.table_id) end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b0619af2..062c2c65 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -8,26 +8,30 @@ class OrderQueueStation < ApplicationRecord scope :active, -> {where(is_active: true)} - def process_order (order) + def process_order (order, table_id) oqs_stations = OrderQueueStation.active + dining=DiningFacility.find_by_name(table_id) + oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) order_items = order.order_items #Assign OQS id to order Items oqs_stations.each do |oqs| #Get List of items - - pq_items = JSON.parse(oqs.processing_items) + pq_items = JSON.parse(oqs.processing_items) - #Loop through the processing items - pq_items.each do |pq_item| - #Processing through the looping items - order_items.each do |order_item| - if (pq_item == order_item.item_code) - #Same Order_items can appear in two location. - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + if oqs.id == oqpbz.order_queue_station_id + #Loop through the processing items + pq_items.each do |pq_item| + #Processing through the looping items + order_items.each do |order_item| + if (pq_item == order_item.item_code) + #Same Order_items can appear in two location. + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + end end end - end + end #Print OQS where printing is require From b029cabeba1df3ae66da93e91ce466ce0d8f18de Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 19:04:25 +0630 Subject: [PATCH 11/13] update show detail and order --- app/views/transactions/orders/show.html.erb | 9 +++++-- app/views/transactions/sales/show.html.erb | 27 +++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/views/transactions/orders/show.html.erb b/app/views/transactions/orders/show.html.erb index e1127296..903ed0f0 100644 --- a/app/views/transactions/orders/show.html.erb +++ b/app/views/transactions/orders/show.html.erb @@ -8,6 +8,11 @@
  • <%= @order.order_id %>
  • + + + Back + +
    @@ -75,11 +80,11 @@
    -
    +
    diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 5f4e8f6e..1e5cc41a 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -8,11 +8,24 @@
  • <%= @sale.sale_id %>
  • + + + Back + + + + + Void Sale + + + Complete Sale + +
    -
    +
    @@ -29,7 +42,7 @@ -
    +
    @@ -53,7 +66,7 @@ <%= @sale.receipt_no %> <%= @sale.cashier_name rescue '-' %> <%= @sale.sale_status %> - <%= @sale.requested_at.strftime("%d-%m-%Y") %> + <%= @sale.requested_at %> Sale item name @@ -85,7 +98,7 @@ <% @sale.sale_taxes.each do |r|%> - <%= r.tax_name %>(<%= r.tax_rate %>) + <%= r.tax_name %> <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%> <% end %> @@ -226,19 +239,19 @@
    - +
    -->
    From c7efcb85d39532b514a920748e0266d1928fb570 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Jun 2017 19:19:33 +0630 Subject: [PATCH 12/13] update sale --- app/views/transactions/orders/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/transactions/orders/show.html.erb b/app/views/transactions/orders/show.html.erb index 903ed0f0..f55cec28 100644 --- a/app/views/transactions/orders/show.html.erb +++ b/app/views/transactions/orders/show.html.erb @@ -51,7 +51,7 @@ Qty Unit Price Total Price - Option + Status Order By Created at @@ -67,7 +67,7 @@ <%= order.qty %> <%= order.price %> <%= order.qty * order.price %> - <%= order.options %> + <%= order.order_item_status %> <%= order.item_order_by %> <%= order.created_at.strftime("%d-%m-%Y") %> From 9f3acad10d29c6d461c86a8b5b344331a0080a81 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 19:26:21 +0630 Subject: [PATCH 13/13] update order for oqs --- app/controllers/api/orders_controller.rb | 2 +- app/models/order_queue_station.rb | 3 +-- db/seeds.rb | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 08847f6f..c383fafb 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -31,7 +31,7 @@ class Api::OrdersController < Api::ApiController @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.items = params[:order_items] @order.guest = params[:guest_info] - @order.table_id = params[:table_id] + @order.table_id = params[:table_id] # this is dining facilities's id @order.new_booking = true @order.employee_name = current_login_employee.name #Create Table Booking or Room Booking diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 062c2c65..d6e21c64 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -10,7 +10,7 @@ class OrderQueueStation < ApplicationRecord def process_order (order, table_id) oqs_stations = OrderQueueStation.active - dining=DiningFacility.find_by_name(table_id) + dining=DiningFacility.find(table_id) oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) order_items = order.order_items @@ -31,7 +31,6 @@ class OrderQueueStation < ApplicationRecord end end end - end #Print OQS where printing is require diff --git a/db/seeds.rb b/db/seeds.rb index 56591e2c..07e5746c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -147,8 +147,8 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111 admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"}) -order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) -order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) +# order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) +# order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A"})