diff --git a/README.md b/README.md index dfebed49..4ba6d51f 100755 --- a/README.md +++ b/README.md @@ -200,6 +200,12 @@ Add Feature for Order and 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}' } +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 1. Migration diff --git a/app/models/promotion.rb b/app/models/promotion.rb index 028847f3..f1e19d98 100755 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -136,7 +136,9 @@ class Promotion < ApplicationRecord else item = OrderItem.find_by_item_code(promo_product) 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 "FOC - " + foc_qty.to_s @@ -150,10 +152,12 @@ class Promotion < ApplicationRecord promotion_qty = foc_qty end 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 - 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.product_code = item.item_code @@ -171,50 +175,54 @@ class Promotion < ApplicationRecord sale_item.sale_id = sale_id sale_item.save 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 def self.give_promotion_nett_off(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 - + if same foc_qty = orderitem[1].to_i / foc_min_qty 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 foc_qty = find_second_item_qty(sale_id, 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 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 - if same 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 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 foc_qty = find_second_item_qty(sale_id, promo_product.item_code) item = OrderItem.find_by_item_instance_code(promo_product.item_code) 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 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 - if same foc_qty = orderitem[1].to_i / foc_min_qty item = OrderItem.find_by_item_instance_code(orderitem[0]) # 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) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) # give total qty is 1 @@ -224,7 +232,8 @@ class Promotion < ApplicationRecord # 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) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source) end end diff --git a/app/models/sale.rb b/app/models/sale.rb index e072d435..7ceecebd 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -425,6 +425,7 @@ class Sale < ApplicationRecord tax_profiles = TaxProfile.all.order("order_by asc") customer = Customer.find(sale.customer_id) # #Creat new tax records + if sale.payment_status != 'foc' tax_profiles.each do |tax| # customer.tax_profiles.each do |cus_tax|