merge with august spring
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
class Commission < ApplicationRecord
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
self.primary_key = 'commission_id'
|
||||
|
||||
# primary key - need to be unique
|
||||
before_create :generate_custom_id
|
||||
|
||||
belongs_to :menu_item, foreign_key: 'product_code'
|
||||
has_many :commissioners
|
||||
has_many :product_commissions
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Commissioner < ApplicationRecord
|
||||
belongs_to :employee, foreign_key: 'emp_id'
|
||||
belongs_to :commission, foreign_key: 'commission_type'
|
||||
belongs_to :commission, foreign_key: 'commission_id'
|
||||
has_many :in_juties
|
||||
has_many :product_commissions
|
||||
scope :active, -> { where(is_active: true) }
|
||||
|
||||
@@ -5,7 +5,5 @@ class ProductCommission < ApplicationRecord
|
||||
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
|
||||
|
||||
@@ -69,7 +69,7 @@ class Promotion < ApplicationRecord
|
||||
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE4
|
||||
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -138,8 +138,8 @@ class Promotion < ApplicationRecord
|
||||
sale_item.remark = type
|
||||
sale_item.qty = foc_qty * (-1)
|
||||
|
||||
sale_item.unit_price = item_price * (-1)
|
||||
sale_item.taxable_price = item_price * (-1)
|
||||
sale_item.unit_price = item_price # * (-1)
|
||||
sale_item.taxable_price = item_price # * (-1)
|
||||
sale_item.price = foc_qty * item_price * (-1)
|
||||
|
||||
sale_item.is_taxable = false
|
||||
@@ -170,8 +170,8 @@ class Promotion < ApplicationRecord
|
||||
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
item = OrderItem.find_by_item_code(orderitem[0])
|
||||
price = item.price - promo_product.net_price
|
||||
item = OrderItem.find_by_item_code(orderitem[0]) # need to specify with menu item instance
|
||||
price = item.price.to_i - promo_product.net_price.to_i
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
|
||||
else
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
@@ -187,13 +187,15 @@ class Promotion < ApplicationRecord
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
item = OrderItem.find_by_item_code(orderitem[0])
|
||||
total = orderitem[1].to_i * item.price
|
||||
# total = orderitem[1].to_i * item.price
|
||||
total = item.price
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
||||
else
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
item = OrderItem.find_by_item_code(promo_product.item_code)
|
||||
total = item.price * foc_qty
|
||||
# total = item.price * foc_qty
|
||||
total = item.price
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user