commission in sale edit
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
class Commission < ApplicationRecord
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
has_many :commissioners
|
||||
has_many :product_commissions
|
||||
end
|
||||
|
||||
@@ -2,5 +2,6 @@ class Commissioner < ApplicationRecord
|
||||
belongs_to :employee, foreign_key: 'emp_id'
|
||||
belongs_to :commission, foreign_key: 'commission_type'
|
||||
has_many :in_juties
|
||||
has_many :product_commissions
|
||||
scope :active, -> { where(is_active: true) }
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ class MenuItem < ApplicationRecord
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
has_many :commissions
|
||||
has_many :product_commissions
|
||||
|
||||
# belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
# has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
class ProductCommission < ApplicationRecord
|
||||
belongs_to :commission, foreign_key: 'commission_id'
|
||||
belongs_to :commissioner, foreign_key: 'commissioner_id'
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
belongs_to :sale_item, foreign_key: 'sale_item_id'
|
||||
belongs_to :sale, foreign_key: 'sale_id'
|
||||
|
||||
def self.check_product_commission(sale_item_id)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@ class Sale < ApplicationRecord
|
||||
has_many :sale_payments
|
||||
has_many :sale_orders
|
||||
has_many :bookings
|
||||
has_many :product_commissions
|
||||
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
|
||||
@@ -5,6 +5,7 @@ class SaleItem < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
|
||||
belongs_to :sale
|
||||
has_many :product_commissions
|
||||
|
||||
#compute items - discount, tax, price_change
|
||||
def compute_item
|
||||
@@ -80,7 +81,7 @@ class SaleItem < ApplicationRecord
|
||||
account_price[:amount] = account_price[:amount] + si.price
|
||||
price = price + si.price
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
rebate_arr.push(account_price)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user