diff --git a/app/assets/javascripts/origami/payment.js b/app/assets/javascripts/origami/payment.js new file mode 100644 index 00000000..e21a369e --- /dev/null +++ b/app/assets/javascripts/origami/payment.js @@ -0,0 +1,113 @@ +// $(document).on('touchstart click', '.keypad', function(event){ +// event.stopPropagation(); +// event.preventDefault(); +// if(event.handled !== true) { +// +// // Do your magic here. +// var input_value = $(this).attr("data-value"); +// switch (input_value) { +// +// case 'delete': +// process_delete_payment(); +// break; +// +// case 'foc': +// remove_input_action(); +// $(".foc").attr("data-action","true"); +// if(customerName.toString() != " "){ //if already chosen customer +// if($("#foc_reason_lists").attr("foc_reason") == ' '){ +// alert("Please! Choose or Add FOC reason"); +// foc_additional_form(); +// } +// else{ +// process_foc_payment(); +// } +// } +// else{ +// alert("Please! Choose or Save Customer"); +// foc_additional_form(); +// } +// break; +// +// case 'nett': +// remove_input_action(); +// $(".nett").attr("data-action","true"); +// if($(".credit_note_payment").hasClass("payment_selected")){ +// if(customerName == " "){ +// alert("Please! Choose or Save Customer"); +// showCustomer(); +// } +// else{ +// $("#accept_payment_btn").attr("data-payment","credit"); +// process_nett_payment(); +// } +// } +// else{ +// process_nett_payment(); +// } +// break; +// +// case 'edit': +// process_edit_invoice(); +// break; +// +// case 'cancel': +// remove_input_action(); +// var status = $("#label_amountdue").attr("data-status"); +// if (status != 'completed' && status != 'void'){ +// $(".cancel").attr("data-action","true"); +// var message = confirm("Are you sure to void? Please, add reason!"); +// if (message == true) { +// $(".additional_form").hide(); +// $("#void_sale_additional_form").show(); +// process_cancel_payment(); +// } +// } +// else{ +// $(".cancel").addClass("dim"); +// } +// break; +// +// case 'ent': +// amount_due = parseFloat($("#label_amountdue").attr("data-original")); +// other_amt = parseFloat($("#label_cash_amount").attr("data-value")); +// credit_amount = parseFloat($("#label_credit_note").text()); +// if ($(".credit_note_payment").hasClass("payment_selected") && credit_amount > 0){ +// if(customerName.toString() != " "){ +// if(credit_amount > (amount_due - other_amt)){ +// alert("You shouldn't exceed the amount due."); +// } +// else{ +// $("#accept_payment_btn").attr("data-payment","credit"); +// update_balance_due(); +// } +// } +// else{ +// alert("Please! Choose or Save Customer"); +// } +// } +// else{ +// update_balance_due(); +// } +// +// break; +// case 'clear': +// process_clear_payment(); +// break; +// +// default: +// +// var existing_value = $(".payment_selected span").text(); +// +// if (existing_value == "0" || existing_value == "0.00") { existing_value = ""; } +// existing_value = existing_value + input_value; +// $(".payment_selected span").text(existing_value); +// +// } +// +// +// event.handled = true; +// } else { +// return false; +// } +// }); diff --git a/app/assets/stylesheets/orgiami.scss b/app/assets/stylesheets/orgiami.scss index b0f802f1..70e1fe8b 100644 --- a/app/assets/stylesheets/orgiami.scss +++ b/app/assets/stylesheets/orgiami.scss @@ -7,3 +7,21 @@ // min-height: 75rem; // padding-top: 4.5rem; // } + +.cashier_number{ + height:76px; + line-height:80px; + text-align:center; + background:#54A5AF; + float:left; + margin:2px; + font-size:20px; + color:white; + cursor:pointer; +} +.cashier_number:hover{ + background:#A9F5F2; +} +.long{ + width:100% +} diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index d4940907..a98c8f3d 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -10,7 +10,7 @@ class Api::BillController < Api::ApiController if (params[:booking_id]) @sale = Sale.new @status = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name) - + elsif (params[:order_id]) @sale = Sale.new @status = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 18a5819c..480e9204 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,21 +4,23 @@ class Origami::HomeController < BaseOrigamiController @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() end + def show str = [] - + + if !params[:sale_id].nil? - @order_details = SaleItem.get_order_items_details(params[:sale_id]) - @order_details.each do |ord_detail| + @order_details = SaleItem.get_order_items_details(params[:sale_id]) + @order_details.each do |ord_detail| str.push(ord_detail) end - render :json => str.to_json + render :json => str.to_json else - @order_details = OrderItem.get_order_items_details(params[:order_id]) - @order_details.each do |ord_detail| + @order_details = OrderItem.get_order_items_details(params[:order_id]) + @order_details.each do |ord_detail| str.push(ord_detail) end - render :json => str.to_json + render :json => str.to_json end end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 447d1282..a09b81fe 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -1,6 +1,14 @@ class Origami::PaymentsController < BaseOrigamiController + + def index + end + def create end + + def show + + end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 59039da8..3fd7ffea 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,27 +1,37 @@ class Origami::RequestBillsController < BaseOrigamiController - def show + + def create @sale = Sale.new + booking_id = params[:id] check_booking = Booking.find_by_booking_id(booking_id) if check_booking.sale_id.nil? - #check if it doesn't exist - @status = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name) + #check if it doesn't exist + @status = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name) @sale_data = Sale.find_by_sale_id(check_booking.sale_id) @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) else @sale_data = Sale.find_by_sale_id(check_booking.sale_id) @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) - end + end unique_code="ReceiptBillPdf" + print_settings=PrintSetting.find_by_unique_code(unique_code) printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data) - end - + + + def show + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + @sale_data = Sale.find_by_id(sale_id) + end + end + end diff --git a/app/models/booking.rb b/app/models/booking.rb index 12d7e04b..01cf0f46 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -1,6 +1,7 @@ -class Booking < ApplicationRecord + +class Booking < ApplicationRecord self.primary_key = "booking_id" - + #primary key - need to be unique before_create :generate_custom_id diff --git a/app/models/order.rb b/app/models/order.rb index 57a239f8..3fabf91b 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -210,6 +210,18 @@ class Order < ApplicationRecord #Origami: Cashier : to view order type Table + def self.get_order_table + order_table = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, + order_items.id as order_items_id,dining_facilities.name as table_name") + .joins("left join booking_orders on booking_orders.order_id = orders.id + left join bookings on bookings.id = booking_orders.id + left join dining_facilities on dining_facilities.id = bookings.dining_facility_id + left join order_items on order_items.order_id = orders.id") + .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) + + .group("orders.id, order_items.id,dining_facilities.name") + + def self.get_booking_order_table booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") @@ -258,16 +270,9 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id left join sales on sales.sale_id = sale_orders.sale_id") .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) - .group("orders.order_id") - # Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") - # .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") - # .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - # .joins("left join orders on orders.order_id = booking_orders.order_id") - # .joins("left join sale_orders on sale_orders.order_id = orders.order_id") - # .joins("left join sales on sales.sale_id = sale_orders.sale_id") - # .where("booking_orders.order_id IS NOT NULL and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) - # .group("orders.order_id") + .group("orders.id,order_items.id,dining_facilities.name") + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 444a554a..d9725e4b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -31,7 +31,8 @@ class Sale < ApplicationRecord end booking.sale_id = sale_id end - + order = booking.booking_orders.take.order + link_order_sale(order.id) return status end end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 9bfd80ac..cc8d2041 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -22,25 +22,26 @@
| @@ -37,9 +37,8 @@ | <%=(sale_item.qty*sale_item.unit_price)%> | -