merge all 03062017

This commit is contained in:
Yan
2017-06-03 12:50:08 +06:30
38 changed files with 754 additions and 22 deletions

7
app/models/account.rb Normal file
View File

@@ -0,0 +1,7 @@
class Account < ApplicationRecord
validates_presence_of :title, :account_type
has_many :menu_items
# belongs_to :lookup , :class_name => "Lookup" ,:foreign_key => :tax_type
end

5
app/models/crm.rb Normal file
View File

@@ -0,0 +1,5 @@
module Crm
def self.table_name_prefix
'crm_'
end
end

View File

@@ -1,4 +1,6 @@
class Lookup < ApplicationRecord
has_many :accounts
def available_types
{'Employee Roles' => 'employee_roles',

View File

@@ -1,8 +1,10 @@
class MenuItem < ApplicationRecord
belongs_to :account
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
validates_presence_of :item_code, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
default_scope { order('item_code asc') }

View File

@@ -16,6 +16,7 @@ class Order < ApplicationRecord
# option_values : [],
# sub_order_items : [],
# }
def generate
booking = nil
@@ -235,13 +236,15 @@ class Order < ApplicationRecord
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
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.is_active=?",true)
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.id")
end
end

View File

@@ -188,7 +188,8 @@ class Sale < ApplicationRecord
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
sale_tax.tax_payable_amount = total_taxable * tax.rate
# sale_tax.tax_payable_amount = total_taxable * tax.rate
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
#new taxable amount
total_taxable = total_taxable + sale_tax.tax_payable_amount