update promotion with tax
This commit is contained in:
@@ -200,6 +200,12 @@ Add Feature for Order and Reservation
|
|||||||
** '0' means can not use order reservation and '1' means can use order reservation **
|
** '0' means can not use order reservation and '1' means can use order reservation **
|
||||||
=> settings/lookups => { type:order_reservation, name: OrderReservation, value:'{0 or 1}' }
|
=> settings/lookups => { type:order_reservation, name: OrderReservation, value:'{0 or 1}' }
|
||||||
|
|
||||||
|
For Price 0 in receipt bill
|
||||||
|
2) settings/lookups => { type:show_price, name:Shoe Price, value:1 }
|
||||||
|
|
||||||
|
For Price 0 in receipt bill
|
||||||
|
2) settings/lookups => { type:order_by, name:Order By, value:name }
|
||||||
|
|
||||||
* ToDo list
|
* ToDo list
|
||||||
|
|
||||||
1. Migration
|
1. Migration
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ class Promotion < ApplicationRecord
|
|||||||
else
|
else
|
||||||
item = OrderItem.find_by_item_code(promo_product)
|
item = OrderItem.find_by_item_code(promo_product)
|
||||||
end
|
end
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion", item.price)
|
source = Order.find(item.order_id).source
|
||||||
|
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion", item.price,source)
|
||||||
|
|
||||||
puts "Charged - " + charge_qty.to_s
|
puts "Charged - " + charge_qty.to_s
|
||||||
puts "FOC - " + foc_qty.to_s
|
puts "FOC - " + foc_qty.to_s
|
||||||
@@ -150,10 +152,12 @@ class Promotion < ApplicationRecord
|
|||||||
promotion_qty = foc_qty
|
promotion_qty = foc_qty
|
||||||
end
|
end
|
||||||
item = OrderItem.find_by_item_instance_code(promo_product)
|
item = OrderItem.find_by_item_instance_code(promo_product)
|
||||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price)
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_existing_item(qty, item, sale_id, type, item_price)
|
|
||||||
|
def self.update_existing_item(qty, item, sale_id, type, item_price,source)
|
||||||
|
|
||||||
sale_item = SaleItem.new
|
sale_item = SaleItem.new
|
||||||
sale_item.product_code = item.item_code
|
sale_item.product_code = item.item_code
|
||||||
@@ -171,7 +175,7 @@ class Promotion < ApplicationRecord
|
|||||||
sale_item.sale_id = sale_id
|
sale_item.sale_id = sale_id
|
||||||
sale_item.save
|
sale_item.save
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,nil,source)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -181,40 +185,44 @@ class Promotion < ApplicationRecord
|
|||||||
if same
|
if same
|
||||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||||
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off)
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||||
else
|
else
|
||||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||||
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off)
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, sale_id)
|
def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||||
|
|
||||||
if same
|
if same
|
||||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||||
item = OrderItem.find_by_item_instance_code(orderitem[0]) # need to specify with menu item instance
|
item = OrderItem.find_by_item_instance_code(orderitem[0]) # need to specify with menu item instance
|
||||||
price = item.price.to_i - promo_product.net_price.to_i
|
price = item.price.to_i - promo_product.net_price.to_i
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
|
|
||||||
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||||
else
|
else
|
||||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||||
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||||
price = item.price - promo_product.net_price
|
price = item.price - promo_product.net_price
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, sale_id)
|
def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||||
|
|
||||||
if same
|
if same
|
||||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||||
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
||||||
# total = orderitem[1].to_i * item.price
|
# total = orderitem[1].to_i * item.price
|
||||||
total = item.price
|
total = item.price
|
||||||
price = calculate_discount(total, promo_product.percentage)
|
price = calculate_discount(total, promo_product.percentage)
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||||
else
|
else
|
||||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||||
# give total qty is 1
|
# give total qty is 1
|
||||||
@@ -224,7 +232,8 @@ class Promotion < ApplicationRecord
|
|||||||
# total = item.price * foc_qty
|
# total = item.price * foc_qty
|
||||||
total = item.price
|
total = item.price
|
||||||
price = calculate_discount(total, promo_product.percentage)
|
price = calculate_discount(total, promo_product.percentage)
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
source = Order.find(item.order_id).source
|
||||||
|
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -425,6 +425,7 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||||
customer = Customer.find(sale.customer_id)
|
customer = Customer.find(sale.customer_id)
|
||||||
# #Creat new tax records
|
# #Creat new tax records
|
||||||
|
|
||||||
if sale.payment_status != 'foc'
|
if sale.payment_status != 'foc'
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
# customer.tax_profiles.each do |cus_tax|
|
# customer.tax_profiles.each do |cus_tax|
|
||||||
|
|||||||
Reference in New Issue
Block a user