add receipt no report and bug fixing

This commit is contained in:
Yan
2017-06-12 12:04:12 +06:30
parent b6bba9ecd4
commit ca2dc181d6
5 changed files with 29 additions and 16 deletions

View File

@@ -0,0 +1,9 @@
class Reports::ReceiptNoController < BaseReportController
def index
@hi = "hi"
end
def show
end
end

View File

@@ -241,7 +241,7 @@ class Order < ApplicationRecord
.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 sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='complete'")
.where("sales.sale_status='completed'")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
end
@@ -254,7 +254,7 @@ class Order < ApplicationRecord
.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 sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
.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
@@ -268,7 +268,7 @@ class Order < ApplicationRecord
.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("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
.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

View File

@@ -35,22 +35,22 @@ class SaleItem < ApplicationRecord
beverage_prices=0
sale_items.each do |si|
food_price = get_food_price(si.sale_item_id)
beverage_price = get_beverage_price(si.sale_item_id)
food_prices += food_price
beverage_prices += beverage_price
food_price = self.get_food_price(si.sale_item_id)
beverage_price = self.get_beverage_price(si.sale_item_id)
puts food_price
# food_prices = food_prices + food_price.price
# beverage_prices = beverage_prices + beverage_price.price
end
return food_prices, beverage_prices
end
def get_food_price(sale_item_id)
def self.get_food_price(sale_item_id)
food_price=SaleItem.select("sale_items.price")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=? and menu_items.account_id=0", sale_item_id)
end
def get_beverage_price(sale_item_id)
def self.get_beverage_price(sale_item_id)
beverage_price=SaleItem.select("sale_items.price")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id)

View File

@@ -0,0 +1,3 @@
<div class="row">
<%= @hi %>
</div>

View File

@@ -197,12 +197,13 @@ Rails.application.routes.draw do
#--------- Reports Controller Sections ------------#
namespace :reports do
resources :sales, :only => [:index, :show]
resources :orders, :only => [:index, :show]
resources :customers, :only => [:index, :show]
resources :products, :only => [:index, :show]
resources :inventory, :only => [:index, :show]
resources :employees, :only => [:index, :show]
resources :receipt_no, :only => [:index, :show]
# resources :sales, :only => [:index, :show]
# resources :orders, :only => [:index, :show]
# resources :customers, :only => [:index, :show]
# resources :products, :only => [:index, :show]
# resources :inventory, :only => [:index, :show]
# resources :employees, :only => [:index, :show]
end
#mount_compendium at: '/report' #, controller: 'reports'