diff --git a/Gemfile b/Gemfile index 6058e7cc..6b3740a7 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -# gem 'pg' + gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 7bf4f9a4..17b395eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,6 +122,7 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -256,6 +257,7 @@ DEPENDENCIES kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + pg prawn prawn-table puma (~> 3.0) diff --git a/app/assets/stylesheets/orgiami.scss b/app/assets/stylesheets/orgiami.scss index 70e1fe8b..327c5897 100644 --- a/app/assets/stylesheets/orgiami.scss +++ b/app/assets/stylesheets/orgiami.scss @@ -25,3 +25,7 @@ .long{ width:100% } + +.purple { + background-color:#7a62d3; +} 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/payments_controller.rb b/app/controllers/origami/payments_controller.rb index a09b81fe..f64e27e3 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -2,13 +2,16 @@ 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 3fd7ffea..31766599 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -14,7 +14,7 @@ class Origami::RequestBillsController < BaseOrigamiController 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" @@ -30,7 +30,7 @@ class Origami::RequestBillsController < BaseOrigamiController def show sale_id = params[:sale_id] if Sale.exists?(sale_id) - @sale_data = Sale.find_by_id(sale_id) + @sale_data = Sale.find_by_sale_id(sale_id) end end diff --git a/app/models/order.rb b/app/models/order.rb index e2548906..036f9006 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -230,7 +230,7 @@ class Order < ApplicationRecord .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") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") end @@ -243,7 +243,7 @@ class Order < ApplicationRecord .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") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name") end #Origami: Cashier : to view order type Room @@ -255,7 +255,7 @@ 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.order_id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) - .group("orders.order_id,order_items.order_items_id,dining_facilities.name") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no") end @@ -271,7 +271,7 @@ 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,order_items.order_items_id,dining_facilities.name") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id") end private diff --git a/app/models/sale.rb b/app/models/sale.rb index d9725e4b..bd7e5668 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1,6 +1,6 @@ class Sale < ApplicationRecord self.primary_key = "sale_id" - + #primary key - need to be unique generated for multiple shops before_create :generate_custom_id @@ -17,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 @@ -32,6 +33,7 @@ class Sale < ApplicationRecord booking.sale_id = sale_id end order = booking.booking_orders.take.order + puts "add sale order" link_order_sale(order.id) return status end @@ -68,8 +70,8 @@ class Sale < ApplicationRecord add_item(item) end - link_order_sale(order.id) - + link_order_sale(order.id) + end @@ -226,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 diff --git a/app/views/origami/card_payments/index.html.erb b/app/views/origami/card_payments/index.html.erb new file mode 100644 index 00000000..86ef10b0 --- /dev/null +++ b/app/views/origami/card_payments/index.html.erb @@ -0,0 +1 @@ +Hello Card Payment diff --git a/app/views/origami/credit_payments/index.html.erb b/app/views/origami/credit_payments/index.html.erb new file mode 100644 index 00000000..e4f97119 --- /dev/null +++ b/app/views/origami/credit_payments/index.html.erb @@ -0,0 +1 @@ +hello Credit diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index cc8d2041..4897407d 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -25,7 +25,7 @@ <% if @booking_orders %> <% @booking_orders.each do |booking_order| %> - <% if !booking_order.order_status = 'new'%> + <% if booking_order.order_status != "new" %>