fixed from trello bug
This commit is contained in:
@@ -19,7 +19,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
@newsaleitem.qty = saleitemObj.qty * -1
|
@newsaleitem.qty = saleitemObj.qty * -1
|
||||||
@newsaleitem.price = saleitemObj.price * -1
|
@newsaleitem.price = saleitemObj.price * -1
|
||||||
@newsaleitem.is_taxable = 1
|
@newsaleitem.is_taxable = 1
|
||||||
@newsaleitem.product_name = saleitemObj.product_name + ' - void'
|
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
|
|
||||||
# re-calc tax
|
# re-calc tax
|
||||||
@@ -39,7 +39,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
@newsaleitem.qty = saleitemObj.qty * -1
|
@newsaleitem.qty = saleitemObj.qty * -1
|
||||||
@newsaleitem.price = saleitemObj.price * -1
|
@newsaleitem.price = saleitemObj.price * -1
|
||||||
@newsaleitem.is_taxable = 1
|
@newsaleitem.is_taxable = 1
|
||||||
@newsaleitem.product_name = saleitemObj.product_name + ' foc'
|
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
|
|
||||||
# re-calc tax
|
# re-calc tax
|
||||||
@@ -81,7 +81,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
# saleitemObj.remark = 'edit'
|
# saleitemObj.remark = 'edit'
|
||||||
|
|
||||||
unless saleitemObj.product_name.include? 'updated'
|
unless saleitemObj.product_name.include? 'updated'
|
||||||
saleitemObj.product_name = saleitemObj.product_name + ' - updated'
|
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
|
||||||
end
|
end
|
||||||
|
|
||||||
saleitemObj.save
|
saleitemObj.save
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ class Ability
|
|||||||
can :create, :payment
|
can :create, :payment
|
||||||
can :reprint, :payment
|
can :reprint, :payment
|
||||||
can :rounding_adj, :payment
|
can :rounding_adj, :payment
|
||||||
can :foc, :payment
|
can :foc, :payment
|
||||||
|
|
||||||
|
|
||||||
can :move_dining, :movetable
|
can :move_dining, :movetable
|
||||||
can :moving, :movetable
|
can :moving, :movetable
|
||||||
@@ -68,6 +67,8 @@ class Ability
|
|||||||
can :item_void_cancel, :sale_edit
|
can :item_void_cancel, :sale_edit
|
||||||
can :cancel_all_void, :sale_edit
|
can :cancel_all_void, :sale_edit
|
||||||
can :apply_void, :sale_edit
|
can :apply_void, :sale_edit
|
||||||
|
can :item_foc, :sale_edit
|
||||||
|
can :item_edit, :sale_edit
|
||||||
|
|
||||||
can :overall_void, :void
|
can :overall_void, :void
|
||||||
|
|
||||||
@@ -118,10 +119,12 @@ class Ability
|
|||||||
|
|
||||||
can :edit, :sale_edit
|
can :edit, :sale_edit
|
||||||
can :item_void, :sale_edit
|
can :item_void, :sale_edit
|
||||||
|
can :item_foc, :sale_edit
|
||||||
can :item_edit, :sale_edit
|
can :item_edit, :sale_edit
|
||||||
can :item_void_cancel, :sale_edit
|
can :item_void_cancel, :sale_edit
|
||||||
can :cancel_all_void, :sale_edit
|
can :cancel_all_void, :sale_edit
|
||||||
can :apply_void, :sale_edit
|
can :apply_void, :sale_edit
|
||||||
|
|
||||||
can :overall_void, :void
|
can :overall_void, :void
|
||||||
|
|
||||||
can :first_bill, :payment
|
can :first_bill, :payment
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ class DiningCharge < ApplicationRecord
|
|||||||
else
|
else
|
||||||
charge_type = dining_charges_obj.charge_type
|
charge_type = dining_charges_obj.charge_type
|
||||||
if charge_type == 'hr'
|
if charge_type == 'hr'
|
||||||
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||||
elsif charge_type == 'day'
|
elsif charge_type == 'day'
|
||||||
price = charges(dining_charges_obj, dining_minutes, 'day')
|
block_count, price = charges(dining_charges_obj, dining_minutes, 'day')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return price
|
return block_count, price
|
||||||
else
|
else
|
||||||
puts "<<<<<<<< NO"
|
puts "<<<<<<<< NO"
|
||||||
end
|
end
|
||||||
@@ -28,26 +28,28 @@ class DiningCharge < ApplicationRecord
|
|||||||
|
|
||||||
def self.charges(chargesObj, dining_minutes, type)
|
def self.charges(chargesObj, dining_minutes, type)
|
||||||
solid_price = 0
|
solid_price = 0
|
||||||
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M'))
|
charge_block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M'))
|
||||||
|
|
||||||
result = dining_minutes / block
|
result = dining_minutes / charge_block
|
||||||
if result.to_i < 1
|
if result.to_i < 1
|
||||||
return chargesObj.unit_price
|
return result.to_i,chargesObj.unit_price
|
||||||
elsif result.to_i >= 1
|
elsif result.to_i >= 1
|
||||||
solid_price = result * chargesObj.unit_price
|
solid_price = result * chargesObj.unit_price
|
||||||
remain_value = dining_minutes % block
|
|
||||||
|
remain_value = dining_minutes % charge_block
|
||||||
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M'))
|
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M'))
|
||||||
roundingblock = remain_value / rounding_block
|
roundingblock = remain_value / rounding_block
|
||||||
if roundingblock.to_i < 1
|
if roundingblock.to_i < 1
|
||||||
return DiningCharge.check_rounding(chargesObj, solid_price)
|
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price)
|
||||||
else
|
else
|
||||||
solid_price += roundingblock * chargesObj.time_rounding_block_price
|
solid_price += roundingblock * chargesObj.time_rounding_block_price
|
||||||
remain_rounding = dining_minutes % block
|
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price)
|
||||||
if remain_rounding.to_i < 1
|
# remain_rounding = dining_minutes % charge_block
|
||||||
return DiningCharge.check_rounding(chargesObj, solid_price)
|
# if remain_rounding.to_i < 1
|
||||||
else
|
# return DiningCharge.check_rounding(chargesObj, solid_price)
|
||||||
return solid_price
|
# else
|
||||||
end
|
# return solid_price
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -217,6 +217,9 @@ class Promotion < ApplicationRecord
|
|||||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
||||||
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
|
||||||
|
foc_qty = (foc_qty - foc_qty) + 1
|
||||||
|
|
||||||
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||||
# total = item.price * foc_qty
|
# total = item.price * foc_qty
|
||||||
total = item.price
|
total = item.price
|
||||||
|
|||||||
@@ -46,6 +46,14 @@ class Sale < ApplicationRecord
|
|||||||
order = booking.booking_orders.take.order
|
order = booking.booking_orders.take.order
|
||||||
link_order_sale(order.id)
|
link_order_sale(order.id)
|
||||||
|
|
||||||
|
# dining charges
|
||||||
|
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
||||||
|
if !charges.nil?
|
||||||
|
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
||||||
|
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
||||||
|
create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time)
|
||||||
|
end
|
||||||
|
|
||||||
return status, sale_id
|
return status, sale_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -108,15 +116,7 @@ class Sale < ApplicationRecord
|
|||||||
booking.sale_id = self.id
|
booking.sale_id = self.id
|
||||||
booking.checkout_at = Time.now.utc.getlocal
|
booking.checkout_at = Time.now.utc.getlocal
|
||||||
booking.checkout_by = requested_by.name
|
booking.checkout_by = requested_by.name
|
||||||
booking.save
|
booking.save
|
||||||
|
|
||||||
# dining charges
|
|
||||||
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
|
||||||
if !charges.nil?
|
|
||||||
diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
|
||||||
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
|
||||||
create_saleitem_diningcharges(charges, diningprice, booking.dining_facility.name, dining_time)
|
|
||||||
end
|
|
||||||
|
|
||||||
InventoryJob.perform_now(self.id)
|
InventoryJob.perform_now(self.id)
|
||||||
|
|
||||||
@@ -174,13 +174,13 @@ class Sale < ApplicationRecord
|
|||||||
self.sale_items << sale_item
|
self.sale_items << sale_item
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_saleitem_diningcharges(chargeObj, diningprice, dining_name, dining_time)
|
def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time)
|
||||||
sale_item = SaleItem.new
|
sale_item = SaleItem.new
|
||||||
sale_item.product_code = chargeObj.item_code
|
sale_item.product_code = chargeObj.item_code
|
||||||
sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )"
|
sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )"
|
||||||
sale_item.account_id = 0
|
sale_item.account_id = 0
|
||||||
sale_item.product_alt_name = "-"
|
sale_item.product_alt_name = "-"
|
||||||
sale_item.qty = 1
|
sale_item.qty = block_count
|
||||||
sale_item.unit_price = chargeObj.unit_price
|
sale_item.unit_price = chargeObj.unit_price
|
||||||
sale_item.taxable_price = diningprice
|
sale_item.taxable_price = diningprice
|
||||||
sale_item.is_taxable = chargeObj.taxable
|
sale_item.is_taxable = chargeObj.taxable
|
||||||
|
|||||||
Reference in New Issue
Block a user