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