diff --git a/Gemfile b/Gemfile index 0b7c3f11..6b3740a7 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,8 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' -gem 'pg' +#Use PosgreSQL + gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' @@ -90,3 +91,5 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'httparty', '~> 0.15.5' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 5dce67dc..17b395eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/amatsuda/kaminari.git - revision: c3c853a944cd2bff072ae05e48c563b2c9a29597 + revision: bc52ae73d41386d344b5d1b18e689e5a988f1a03 branch: master specs: kaminari (1.0.1) @@ -92,7 +92,9 @@ GEM railties (>= 3.2, < 5.2) globalid (0.4.0) activesupport (>= 4.2.0) - i18n (0.8.1) + httparty (0.15.5) + multi_xml (>= 0.5.2) + i18n (0.8.4) jbuilder (2.6.4) activesupport (>= 3.0.0) multi_json (>= 1.2) @@ -114,6 +116,7 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) + multi_xml (0.6.0) mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) @@ -125,7 +128,7 @@ GEM ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - puma (3.8.2) + puma (3.9.1) rack (2.0.3) rack-cors (0.4.1) rack-protection (2.0.0) @@ -248,6 +251,7 @@ DEPENDENCIES factory_girl_rails (~> 4.0) faker font-awesome-rails + httparty (~> 0.15.5) jbuilder (~> 2.5) jquery-rails kaminari! diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 80a09b47..7df365ec 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -80,4 +80,14 @@ $(document).ready(function(){ success: function(data){ } }); }); + + $('#print_order_summary').on('click',function(){ + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var params = { 'id':assigned_item_id }; + $.ajax({ + type: 'GET', + url: '/oqs/print/print_order_summary/'+assigned_item_id, + success: function(data){ } + }); + }); }); 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..afefe4c7 100644 --- a/app/assets/stylesheets/orgiami.scss +++ b/app/assets/stylesheets/orgiami.scss @@ -7,3 +7,33 @@ // 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% +} + +.purple { + background-color:#7a62d3; +} + +.red { + background-color:#ff0000; +} + +.green{ + background-color: #009900 +} 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/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 443a754b..df9b1542 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -28,7 +28,7 @@ class Api::OrdersController < Api::ApiController @order = Order.new @order.source = params[:order_source] @order.order_type = params[:order_type] - @order.customer_id = params[:customer_id] + @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] diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 4e97faec..896d9d14 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -4,7 +4,7 @@ class Crm::CustomersController < ApplicationController # GET /crm/customers # GET /crm/customers.json def index - @crm_customers = Crm::Customer.all + @crm_customers = Customer.all end # GET /crm/customers/1 @@ -14,7 +14,8 @@ class Crm::CustomersController < ApplicationController # GET /crm/customers/new def new - @crm_customer = Crm::Customer.new + @crm_customer = Customer.new + @membership = Customer.get_member_group end # GET /crm/customers/1/edit @@ -24,7 +25,7 @@ class Crm::CustomersController < ApplicationController # POST /crm/customers # POST /crm/customers.json def create - @crm_customer = Crm::Customer.new(crm_customer_params) + @crm_customer = Customer.new(crm_customer_params) respond_to do |format| if @crm_customer.save @@ -64,7 +65,7 @@ class Crm::CustomersController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_crm_customer - @crm_customer = Crm::Customer.find(params[:id]) + @crm_customer = Customer.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 1292a5e6..2b676f21 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -35,15 +35,15 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with status def queue_items_query(status) - AssignedOrderItem.select("assigned_order_items.id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") - .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") + .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id left join dining_facilities as df on df.zone_id = oqpz.zone_id left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id - left join orders as od ON od.id = assigned_order_items.order_id + left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code - left join customers as cus ON cus.id = od.customer_id") + left join customers as cus ON cus.customer_id = od.customer_id") .where("assigned_order_items.delivery_status = #{status}") - .group("assigned_order_items.id") + .group("assigned_order_items.assigned_order_item_id") .order("odt.item_name DESC") end end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 368a513d..8a12e439 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -2,7 +2,7 @@ class Oqs::PrintController < ApplicationController def print unique_code="OrderItemPdf" assigned_item_id=params[:id] - assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) + assigned_order_item=AssignedOrderItem.select("order_id, item_code").where("assigned_order_item_id='" + assigned_item_id + "'") print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) @@ -13,4 +13,19 @@ class Oqs::PrintController < ApplicationController assigned_item.print_status=true assigned_item.save end + + def print_order_summary + unique_code="OrderSummaryPdf" + assigned_item_id=params[:id] + assigned_order_item=AssignedOrderItem.select("order_id").where('assigned_order_item_id='+assigned_item_id) + + 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,assigned_order_item[0].order_id) + + # update print status when complete click + assigned_item=AssignedOrderItem.find(assigned_item_id) + assigned_item.print_status=true + assigned_item.save + end end diff --git a/app/controllers/origami/card_payments_controller.rb b/app/controllers/origami/card_payments_controller.rb new file mode 100644 index 00000000..2df4b266 --- /dev/null +++ b/app/controllers/origami/card_payments_controller.rb @@ -0,0 +1,10 @@ +class Origami::CardPaymentsController < BaseOrigamiController + + + def index + end + + def create + end + +end diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb new file mode 100644 index 00000000..a348951e --- /dev/null +++ b/app/controllers/origami/credit_payments_controller.rb @@ -0,0 +1,10 @@ +class Origami::CreditPaymentsController < BaseOrigamiController + + + def index + end + + def create + end + +end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index cbca1424..480e9204 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,15 +1,26 @@ class Origami::HomeController < BaseOrigamiController def index - @order_table = Order.get_order_table() - @order_rooms = Order.get_order_rooms() + @booking_orders = Order.get_booking_order_table() + @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() end + def show str = [] - @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 + + + if !params[:sale_id].nil? + @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 + else + @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 + end end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 447d1282..f64e27e3 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -1,6 +1,17 @@ class Origami::PaymentsController < BaseOrigamiController + + def index end + def create + #payment type + #sale status + #point - get [ food amount ] end + + def show + + end + end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 9f971289..31766599 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,22 +1,37 @@ class Origami::RequestBillsController < BaseOrigamiController - def show + + def create @sale = Sale.new - check_order = Order.find_by_id(params[:id]) - if check_order - @order_details = OrderItem.get_order_items_details(check_order.id) - @order_details = OrderItem.get_order_items_details(check_order.id) - @status, @sale_id = @sale.generate_invoice_from_order(check_order.id, nil,current_login_employee.name) - @sale_data = Sale.find_by_id(@sale_id) - @sale_items = SaleItem.where("sale_id=?",@sale_id) - end + + 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) + @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 + 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) + 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_sale_id(sale_id) + end + end + end diff --git a/app/models/login_form.rb b/app/forms/login_form.rb similarity index 100% rename from app/models/login_form.rb rename to app/forms/login_form.rb diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index e9a8c13f..10081ad5 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -1,11 +1,11 @@ class OrderQueueProcessorJob < ApplicationJob - queue_as :default + queue_as :oqs def perform(order_id) # Do something later #Order ID order = Order.find(order_id) - + #Loop through the order stations and process the items #Execute orders and send to order stations if order diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index c2d2e8b0..3ac84077 100644 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -1,4 +1,9 @@ class AssignedOrderItem < ApplicationRecord + before_create :generate_custom_id + + #primary key - need to be unique + self.primary_key = "assigned_order_item_id" + belongs_to :order belongs_to :order_queue_station @@ -11,4 +16,9 @@ class AssignedOrderItem < ApplicationRecord assigned_order_item.delivery_status = false assigned_order_item.save end + + private + def generate_custom_id + self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI") + end end diff --git a/app/models/booking.rb b/app/models/booking.rb index c34ecf42..01cf0f46 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -1,9 +1,17 @@ + class Booking < ApplicationRecord + self.primary_key = "booking_id" + #primary key - need to be unique - + before_create :generate_custom_id + belongs_to :dining_facility, :optional => true belongs_to :sale, :optional => true has_many :booking_orders + has_many :orders, :through => :booking_orders - + private + def generate_custom_id + self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") + end end diff --git a/app/models/booking_order.rb b/app/models/booking_order.rb index c9f748f0..ddf5ed18 100644 --- a/app/models/booking_order.rb +++ b/app/models/booking_order.rb @@ -1,5 +1,5 @@ class BookingOrder < ApplicationRecord - #primary key - need to be unique + #primary key - need to be unique belongs_to :booking belongs_to :order diff --git a/app/models/cashier_login_log.rb b/app/models/cashier_login_log.rb index d64860ce..353e9c90 100644 --- a/app/models/cashier_login_log.rb +++ b/app/models/cashier_login_log.rb @@ -1,4 +1,11 @@ class CashierLoginLog < ApplicationRecord + before_create :generate_custom_id + belongs_to :cashier_station belongs_to :employee + + private + def generate_custom_id + self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO") + end end diff --git a/app/models/crm.rb b/app/models/crm.rb deleted file mode 100644 index 3407e215..00000000 --- a/app/models/crm.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Crm - def self.table_name_prefix - 'crm_' - end -end diff --git a/app/models/customer.rb b/app/models/customer.rb index 42247791..4bdc290a 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,4 +1,7 @@ class Customer < ApplicationRecord + self.primary_key = "customer_id" + + before_create :generate_custom_id has_many :orders has_many :sales @@ -8,4 +11,9 @@ class Customer < ApplicationRecord def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end + + private + def generate_custom_id + self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS") + end end diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 9ff40ae2..89967e2e 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -1,5 +1,5 @@ class MenuItem < ApplicationRecord - + belongs_to :menu_category, :optional => true has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true diff --git a/app/models/order.rb b/app/models/order.rb index f571faa9..036f9006 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,6 +1,8 @@ class Order < ApplicationRecord - #primary key - need to be unique + self.primary_key = "order_id" + #primary key - need to be unique + before_create :generate_custom_id before_create :set_order_date belongs_to :customer @@ -40,7 +42,7 @@ class Order < ApplicationRecord self.adding_line_items #Add Order Table and Room relation afrer order creation - BookingOrder.create({:booking_id => booking.id, :order => self}) + BookingOrder.create({:booking_id => booking.booking_id, :order => self}) #Send order to queue one it done! process_order_queue @@ -182,14 +184,6 @@ class Order < ApplicationRecord return new_items_list end - private - def validate_api_inputs - - end - - def set_order_date - self.date = Time.now.utc - end #Update Items Count and Quantity changes whenever there is changes def update_products_and_quantity_count @@ -198,7 +192,7 @@ class Order < ApplicationRecord # Count number of different items self.item_count = self.order_items.item_count self.quantity_count = quantity_count - # Counter number of quantity + # Counter number of quantityf end #Process order items and send to order queue @@ -215,6 +209,7 @@ class Order < ApplicationRecord end #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") @@ -223,33 +218,70 @@ class Order < ApplicationRecord 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.order_id, order_items.order_items_id,dining_facilities.name") + end - .group("orders.id") + 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") + .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.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") end + + #Origami: Cashier : to view order type Room + def self.get_booking_order_rooms + booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as room_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.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name") + end + #Origami: Cashier : to view order type Room def self.get_order_rooms - order_rooms = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, + order_rooms = Order.select("orders.order_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 room_name") - .joins("left join booking_orders on booking_orders.order_id = orders.id - left join bookings on bookings.id = booking_orders.id + .joins("left join booking_orders on booking_orders.order_id = orders.order_id + left join bookings on bookings.booking_id = booking_orders.order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id - left join order_items on order_items.order_id = orders.id") + left join order_items on order_items.order_id = orders.order_id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) - .group("orders.id,order_items.id,dining_facilities.name") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no") + end + #Origami: Cashier : to view orders def self.get_orders from = Time.now.beginning_of_day.utc to = Time.now.end_of_day.utc - orders = 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_or_room_name") - .joins("left join booking_orders on booking_orders.order_id = orders.id - left join bookings on bookings.id = booking_orders.id + orders = Order.select("orders.order_id as order_id,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.order_id = orders.order_id + left join bookings on bookings.booking_id = booking_orders.order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id - left join order_items on order_items.order_id = orders.id") - + left join order_items on order_items.order_id = orders.order_id + 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.id") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id") end + + private + + def generate_custom_id + self.order_id = SeedGenerator.generate_id(self.class.name, "ODR") + end + + def set_order_date + self.date = Time.now.utc + end + end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 1633c1c4..a85d1113 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -1,5 +1,8 @@ class OrderItem < ApplicationRecord + self.primary_key = "order_items_id" + #primary key - need to be unique + before_create :generate_custom_id #Associations belongs_to :order, autosave: true @@ -36,10 +39,23 @@ class OrderItem < ApplicationRecord end #Origami : Cashier : to show order items details - def self.get_order_items_details(order_id) - order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") - .joins("left join orders on orders.id = order_items.order_id") - .where("order_items.order_id=?",order_id) - + + def self.get_order_items_details(booking_id) + booking_orders = BookingOrder.where("booking_id=?",booking_id) + if booking_orders + booking_orders.each do |book_order| + order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") + .joins("left join orders on orders.order_id = order_items.order_id") + .where("order_items.order_id=?",book_order.order) + return order_details + end + else + return false + end + end + + private + def generate_custom_id + self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI") end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 6a8a4b78..5a0eaf25 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -10,12 +10,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker self.print("tmp/receipt.pdf") end - def print_order_summary(printer_settings,booking_id) + def print_order_summary(printer_settings,order_id) #Use CUPS service #Generate PDF #Print - order=print_query('booking',booking_id) - filename = "tmp/order_summary_#{booking_id}" + ".pdf" + order=print_query('order_summary',order_id) + filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(order,printer_settings) pdf.render_file filename @@ -25,21 +25,23 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, code) if type == 'order_item' - OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") - .joins("left join orders ON orders.id = order_items.order_id + OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id - left join bookings AS b ON b.id = bo.booking_id + left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.id = orders.customer_id") - .where("order_items.item_code=" + code) + left join customers as cus ON cus.customer_id = orders.customer_id") + .where("order_items.item_code='" + code + "'") .group("order_items.item_code") else - OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining") - .joins("left join orders ON orders.id = order_items.order_id + OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id - left join bookings AS b ON b.id = bo.booking_id - left join dining_facilities AS df ON df.id = b.dining_facility_id") - .where("booking.id=" + code) + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id") + .where("orders.order_id='" + code.to_s + "'") + .group("order_items.item_code") end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index d25dc8c3..86d43190 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -64,12 +64,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print(filename) end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale) + def print_receipt_bill(printer_settings,sale_items,sale,sale_data) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale) - pdf.render_file "tmp/receipt_bill_#{sale.id}.pdf" - self.print("tmp/receipt_bill_#{sale.id}.pdf") + pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale,sale_data) + pdf.render_file "tmp/receipt_bill.pdf" + self.print("tmp/receipt_bill.pdf") end end diff --git a/app/models/room_booking.rb b/app/models/room_booking.rb index fb7c0dac..7efa52cb 100644 --- a/app/models/room_booking.rb +++ b/app/models/room_booking.rb @@ -1,3 +1,4 @@ class RoomBooking < Booking - + has_many :orders + end diff --git a/app/models/sale.rb b/app/models/sale.rb index ca3bd631..bd7e5668 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1,6 +1,9 @@ -#primary key - need to be unique generated for multiple shops - class Sale < ApplicationRecord + self.primary_key = "sale_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + #before_create :generate_receipt_no belongs_to :cashier, :optional => true belongs_to :customer, :optional => true @@ -14,6 +17,7 @@ class Sale < ApplicationRecord scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } def generate_invoice_from_booking(booking_id, requested_by) + puts "get invoice from booking" booking = Booking.find(booking_id) status = false Rails.logger.debug "Booking -> " + booking.id.to_s @@ -22,18 +26,20 @@ class Sale < ApplicationRecord #get all order attached to this booking and combine into 1 invoice booking.booking_orders.each do |order| if booking.sale_id - status, sale_id = generate_invoice_from_order(order.order_id, nil, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) else - status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by) end booking.sale_id = sale_id end - + order = booking.booking_orders.take.order + puts "add sale order" + link_order_sale(order.id) return status end end - def generate_invoice_from_order (order_id, sale_id, requested_by) + def generate_invoice_from_order (order_id, sale_id, booking, requested_by) taxable = true #if sale_id is exsit and validate #add order to that invoice @@ -75,6 +81,11 @@ class Sale < ApplicationRecord #Update the order items that is billed order.update_items_status_to_billed(nil) + order.status = "billed" + order.save + + booking.sale_id = self.id + booking.save return true, self.id end @@ -217,9 +228,14 @@ class Sale < ApplicationRecord def link_order_sale(order_id) #create if it doesn't exist - if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?) + saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take + + if saleOrder.nil? SaleOrder.create(:sale_id => self.id, :order_id => order_id) end + # if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?) + # SaleOrder.create(:sale_id => self.id, :order_id => order_id) + # end #dosomrting here #puts Time.now.format(":short") end @@ -242,4 +258,8 @@ class Sale < ApplicationRecord end end + private + def generate_custom_id + self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") + end end diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index cce6982d..c99d2dfc 100644 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -1,6 +1,9 @@ class SaleAudit < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_audit_id" + #primary key - need to be unique generated for SaleAudit + before_create :generate_custom_id + belongs_to :sale def record_audit_void(sale_id, void_by, approved_by, reason) @@ -50,4 +53,9 @@ class SaleAudit < ApplicationRecord sale_audit.remark = remark sale_audit.save! end + + private + def generate_custom_id + self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + end end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index c92ed48f..52ab480b 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -1,9 +1,33 @@ class SaleItem < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_item_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale #compute items - discount, tax, price_change def compute_item end + + + def self.get_order_items_details(sale_id) + sale_orders = SaleOrder.where("sale_id=?",sale_id) + if sale_orders + sale_orders.each do |sale_order| + order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") + .joins("left join sales on sales.id = sale_items.sale_id") + .where("sale_items.sale_id=?",sale_order.sale_id) + return order_details + end + else + return false + end + end + + private + def generate_custom_id + self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") + + end end diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index 23fd39bd..15da1386 100644 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -1,6 +1,14 @@ class SaleOrder < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_order_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale belongs_to :order + + private + def generate_custom_id + self.sale_order_id = SeedGenerator.generate_id(self.class.name, "SOI") + end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 2f7b72ea..15fe4c74 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1,5 +1,8 @@ class SalePayment < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_payment_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale @@ -156,4 +159,8 @@ class SalePayment < ApplicationRecord end + private + def generate_custom_id + self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") + end end diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index 6e0a2d47..79de9134 100644 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -1,5 +1,12 @@ class SaleTax < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_tax_id" + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale + + private + def generate_custom_id + self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI") + end end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 4351e74b..5e7864b6 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -15,7 +15,10 @@ class SeedGenerator < ApplicationRecord seed.save end - return prefix + "-" + seed.current.to_s + padding_len = 15 - prefix.length + + return prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0') + end def self.new_receipt_no diff --git a/app/models/test.rb b/app/models/test.rb deleted file mode 100644 index fe0afa77..00000000 --- a/app/models/test.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Test < ApplicationRecord -end diff --git a/app/models/transactions.rb b/app/models/transactions.rb deleted file mode 100644 index 9cffb0d1..00000000 --- a/app/models/transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Transactions - def self.table_name_prefix - 'transactions_' - end -end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 356327b4..3044c578 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -11,21 +11,61 @@ class OrderItemPdf < Prawn::Document stroke_horizontal_rule move_down 5 - cashier_info(order_item.order_by,order_item.order_at, order_item.customer) + #order_info + order_info(order_item.order_by,order_item.order_at, order_item.customer) + # order items + order_items(order_item) end - def cashier_info(order_by, order_at, customer) - move_down 5 + # Write Order Information to PDF + def order_info(order_by, order_at, customer) y_position = cursor - bounding_box([0,y_position], :width =>200, :height => 20) do - text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y %m %d")}", :size => 7,:align => :left + bounding_box([0,y_position], :width => 200, :height => 15) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left end stroke_horizontal_rule + move_down 20 + end + + # Write Order items to PDF + def order_items(order_item) + y_position = cursor + + bounding_box([0,y_position], :width => 180, :height => 15) do + text "Item", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 15) do + text "Qty", :size => 7,:align => :right + end + + stroke_horizontal_rule move_down 5 + + #Add Order Item + add_order_items(order_item) + end + + # Add order items under order info + def add_order_items(order_item) + y_position = cursor + + move_down 5 + + bounding_box([0,y_position], :width => 180, :height => 20) do + text "#{order_item.item_name}", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 20) do + text "#{order_item.qty}", :size => 7,:align => :right + end + + move_down 5 + end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 8b79b40e..8a7a1ad9 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -7,11 +7,68 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - font_size 9 - text "#{"table_name"}", :size => 15 + text "#{order[0].dining}", :size => 15 stroke_horizontal_rule move_down 5 + #order_info + order_info(order[0].order_by,order[0].order_at, order[0].customer) + + # order items + order_items(order) + + end + + # Write Order Information to PDF + def order_info(order_by, order_at, customer) + y_position = cursor + + bounding_box([0,y_position], :width => 200, :height => 15) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left + end + + stroke_horizontal_rule + + move_down 20 + end + + # Write Order items to PDF + def order_items(order_item) + y_position = cursor + + bounding_box([0,y_position], :width => 180, :height => 15) do + text "Item", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 15) do + text "Qty", :size => 7,:align => :right + end + + stroke_horizontal_rule + move_down 5 + + #Add Order Item + add_order_items(order_item) + end + + # Add order items under order info + def add_order_items(order_item) + y_position = cursor + + move_down 5 + + order_item.each do|odi| + bounding_box([0,y_position], :width => 180, :height => 20) do + text "#{odi.item_name}", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 20) do + text "#{odi.qty}", :size => 7,:align => :right + end + end + + move_down 5 + end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index e9ad042c..ffce7da2 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,11 +1,11 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width - def initialize(printer_settings, sale_items,sale) + def initialize(printer_settings, sale_items,sale, sale_data) self.p_width = 200 self.page_height = 1450 self.margin = 10 # self.price_width = self.p_width / 2 - self.price_width=90 + self.price_width=80 self.item_width = self.p_width - self.price_width self.item_height = self.item_height self.qty_column_width = self.p_width / 2 @@ -14,7 +14,7 @@ class ReceiptBillPdf < Prawn::Document @item_width = self.p_width.to_i / 2 @qty_width = @item_width.to_i / 3 - @double = @qty_width * 2 + @double = @qty_width * 1.3 @half_qty = @qty_width / 2 #setting page margin and width super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height]) @@ -23,8 +23,9 @@ class ReceiptBillPdf < Prawn::Document header( printer_settings.printer_name, printer_settings.name) stroke_horizontal_rule - cashier_info(sale.receipt_no,sale.customer.name, sale.receipt_date) + cashier_info(sale.receipt_no,sale.customer, sale.receipt_date) line_items(sale_items) + all_total(sale_data) end @@ -89,7 +90,6 @@ class ReceiptBillPdf < Prawn::Document text_box "Items", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size text_box "Price", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right text_box "Qty", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right - text_box "Discount", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right text_box "Total", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right } @@ -98,13 +98,80 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule add_line_item_row(sale_items) - stroke_horizontal_rule + end def add_line_item_row(sale_items) - y_position = cursor - move_down 5 + y_position = cursor + move_down 5 + sub_total = 0.0 + sale_items.each do |item| + + sub_total += item.qty*item.unit_price + qty = item.qty + total_price = item.qty*item.unit_price + price = item.unit_price + product_name = item.product_name + + + y_position = cursor + + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "#{product_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size + text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + + } + move_down 3 + end + stroke_horizontal_rule + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Sub Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "#{sub_total}" , :size => self.item_font_size,:align => :right + end + end + + def all_total(sale_data) + + move_down 5 + y_position =cursor + + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Discount", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right + end + + move_down 5 + y_position =cursor + + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Total Tax", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right + end + + move_down 5 + y_position = cursor + move_down 5 + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Grand Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right + end + move_down 5 + # stroke_horizontal_rule + end end diff --git a/app/views/api/bookings/show.json.jbuilder b/app/views/api/bookings/show.json.jbuilder index c4edb79f..cbd1575a 100644 --- a/app/views/api/bookings/show.json.jbuilder +++ b/app/views/api/bookings/show.json.jbuilder @@ -1,5 +1,5 @@ if (@booking) - json.id @booking.id + json.id @booking.booking_id json.status @booking.booking_status json.checkin_at @booking.checkin_at json.checkin_by @booking.checkin_by @@ -12,7 +12,8 @@ if (@booking) end @total_amount = 0.00 @total_tax = 0.00 - + + @booking_orders = BookingOrder.where("booking_id = #{@booking.booking_id}").all; if @booking.booking_orders order_items = [] @booking.booking_orders.each do |bo| diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb index c5adac88..7c37a2fe 100644 --- a/app/views/crm/customers/_form.html.erb +++ b/app/views/crm/customers/_form.html.erb @@ -1,4 +1,5 @@ -<%= simple_form_for(@crm_customer) do |f| %> + +<%= simple_form_for([:crm,@crm_customer]) do |f| %> <%= f.error_notification %>
<%= qid.customer_name %>
-<%= qid.id %>
+<%= qid.assigned_order_item_id %>
<%= qid.customer_name %>
-<%= qid.id %>
+<%= qid.assigned_order_item_id %>
<% @@ -193,7 +193,7 @@<%=order_table.total_price%>
-<%=order_room.total_price%>
-<%=order.total_price%>
-| @@ -36,9 +38,8 @@ | <%=(sale_item.qty*sale_item.unit_price)%> | -