update order and request bill
This commit is contained in:
@@ -8,7 +8,53 @@ class Booking < ApplicationRecord
|
||||
belongs_to :sale, :optional => true
|
||||
has_many :booking_orders
|
||||
has_many :orders, :through => :booking_orders
|
||||
has_many :order_items, :through => :orders
|
||||
has_many :order_items, :through => :orders do
|
||||
def to_sale_items
|
||||
sale_items = []
|
||||
proxy_association.load_target.select(&:order_items_id).each do |order_item|
|
||||
menu_category = order_item.menu_category || OpenStruct.new(name: 'Product', code: '') #get menu category for menu items
|
||||
|
||||
sale_items << SaleItem.new({
|
||||
menu_category_name: menu_category.name,
|
||||
menu_category_code: menu_category.code,
|
||||
product_name: order_item.item_name,
|
||||
product_code: order_item.item_code,
|
||||
product_alt_name: order_item.alt_name,
|
||||
account_id: order_item.account_id,
|
||||
is_taxable: order_item.taxable,
|
||||
item_instance_code: order_item.item_instance_code,
|
||||
qty: order_item.qty,
|
||||
unit_price: order_item.price,
|
||||
price: order_item.qty * order_item.price,
|
||||
taxable_price: order_item.qty * order_item.price,
|
||||
status: order_item.remark
|
||||
})
|
||||
|
||||
if order_item.set_menu_items
|
||||
JSON.parse(order_item.set_menu_items).each do |item|
|
||||
instance = MenuItemInstance.find_by_item_instance_code(item["item_instance_code"])
|
||||
menu_item = instance.menu_item
|
||||
menu_category = menu_item.menu_category #get menu category for menu items
|
||||
sale_items << SaleItem.new({
|
||||
menu_category_name: menu_category.name,
|
||||
menu_category_code: menu_category.code,
|
||||
product_name: instance.item_instance_name,
|
||||
product_code: menu_item.item_code,
|
||||
product_alt_name: menu_item.alt_name,
|
||||
account_id: menu_item.account_id,
|
||||
is_taxable: menu_item.taxable,
|
||||
item_instance_code: item["item_instance_code"],
|
||||
qty: item["quantity"],
|
||||
unit_price: item["price"],
|
||||
price: item["quantity"].to_f * item["price"].to_f,
|
||||
taxable_price: item["quantity"].to_f * item["price"].to_f
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
sale_items
|
||||
end
|
||||
end
|
||||
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
class CashierTerminal < ApplicationRecord
|
||||
has_many :cashier_terminal_by_zones
|
||||
has_many :zones, through: :cashier_terminal_by_zones
|
||||
has_many :cashier_terminal_by_zones
|
||||
has_many :zones, through: :cashier_terminal_by_zones
|
||||
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) }, class_name: "ShiftSale"
|
||||
|
||||
scope :available, -> {where(is_currently_login: false)}
|
||||
scope :is_active, -> {where(is_active: true)}
|
||||
scope :available, -> {where(is_currently_login: false)}
|
||||
scope :is_active, -> {where(is_active: true)}
|
||||
|
||||
# validations
|
||||
validates_presence_of :name, :printer_name
|
||||
|
||||
@@ -4,7 +4,7 @@ class DiningCharge < ApplicationRecord
|
||||
|
||||
def self.amount_calculate(dining_charges_obj, checkin , checkout)
|
||||
# note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block
|
||||
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
||||
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
||||
block_count = 0
|
||||
price = 0
|
||||
minutes = DiningCharge.time_diff(checkout, checkin)
|
||||
@@ -13,18 +13,17 @@ class DiningCharge < ApplicationRecord
|
||||
if dining_minutes <= free_time
|
||||
price = 0
|
||||
else
|
||||
charge_type = dining_charges_obj.charge_type
|
||||
charge_type = dining_charges_obj.charge_type
|
||||
if charge_type == 'hr'
|
||||
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||
elsif charge_type == 'day'
|
||||
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'day')
|
||||
end
|
||||
end
|
||||
return block_count, price
|
||||
return block_count, price
|
||||
else
|
||||
puts "<<<<<<<< NO"
|
||||
return 0, 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# dining charges calculate
|
||||
@@ -37,7 +36,7 @@ class DiningCharge < ApplicationRecord
|
||||
rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M'))
|
||||
if result.to_i < 1
|
||||
# for dining minute is under charge_block
|
||||
if dining_minutes > rounding_time
|
||||
if dining_minutes > rounding_time
|
||||
rounding_block = dining_minutes / rounding_time
|
||||
|
||||
solid_price = rounding_block * chargesObj.time_rounding_block_price
|
||||
@@ -46,7 +45,7 @@ class DiningCharge < ApplicationRecord
|
||||
else
|
||||
return 1, result.to_i,chargesObj.unit_price
|
||||
end
|
||||
elsif result.to_i >= 1
|
||||
elsif result.to_i >= 1
|
||||
|
||||
solid_price = result * chargesObj.unit_price
|
||||
|
||||
@@ -64,7 +63,7 @@ class DiningCharge < ApplicationRecord
|
||||
else
|
||||
solid_price += (roundingblock * chargesObj.time_rounding_block_price)
|
||||
|
||||
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price, extra_minutes)
|
||||
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price, extra_minutes)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -74,7 +73,7 @@ class DiningCharge < ApplicationRecord
|
||||
# rounding_block_remain = roundingblock / 1
|
||||
free_time = DiningCharge.convert_to_minutes(chargesObj.minimum_free_time.utc.strftime('%H:%M'))
|
||||
rounding_block_remain = extra_minutes - free_time
|
||||
|
||||
|
||||
if chargesObj.time_rounding == "down"
|
||||
return solid_price
|
||||
else
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
class DiningFacility < ApplicationRecord
|
||||
belongs_to :zone
|
||||
has_many :dining_charges
|
||||
has_many :in_juties
|
||||
has_one :dining_charge
|
||||
has_one :cashier_terminal_by_zone, foreign_key: "zone_id", primary_key: "zone_id"
|
||||
has_one :cashier_terminal, through: :cashier_terminal_by_zone
|
||||
|
||||
has_many :bookings
|
||||
has_many :current_bookings, -> { left_joins(:sale).assign.within_time_limit.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
|
||||
has_one :current_checkin_booking, -> { assign.within_time_limit.where(checkout_at: nil) }, class_name: "Booking"
|
||||
has_one :current_checkout_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(checkout_at: nil).merge(Sale.where(sale_status: ['new', nil])) }, class_name: "Booking"
|
||||
has_one :current_checkin_booking, -> { left_joins(:sale).assign.within_time_limit.merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
||||
has_one :current_checkout_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(checkout_at: nil).merge(Sale.where(sale_status: 'new')) }, class_name: "Booking"
|
||||
has_one :current_reserved_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
||||
|
||||
TABLE_TYPE = "Table"
|
||||
|
||||
@@ -2,6 +2,7 @@ class Employee < ApplicationRecord
|
||||
has_secure_password
|
||||
has_many :commissioners
|
||||
has_many :shit_sales
|
||||
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale"
|
||||
belongs_to :order_queue_station
|
||||
|
||||
validates_presence_of :name, :role
|
||||
|
||||
@@ -40,8 +40,8 @@ class MenuItem < ApplicationRecord
|
||||
account_id: account_id,
|
||||
item_code: item_code,
|
||||
item_instance_code: item_instance_code,
|
||||
name: item_name.to_s + (' - ' + item_instance_name.to_s) || '',
|
||||
alt_name: item_alt_name || '',
|
||||
name: "#{item_name}#{' - ' + item_instance_name if item_instance_name.present?}",
|
||||
alt_name: "#{item_alt_name}",
|
||||
price: price,
|
||||
promotion_price: promotion_price,
|
||||
is_on_promotion: is_on_promotion,
|
||||
|
||||
@@ -145,7 +145,6 @@ class Order < ApplicationRecord
|
||||
end
|
||||
sub_order_items = sub_order_items.to_json
|
||||
new_order_items << OrderItem.new({
|
||||
order_id: id,
|
||||
item_code: menu_item[:item_code],
|
||||
item_instance_code: order_item[:item_instance_code],
|
||||
item_name: menu_item[:name],
|
||||
@@ -160,17 +159,7 @@ class Order < ApplicationRecord
|
||||
})
|
||||
end
|
||||
|
||||
ids = OrderItem.generate_ids(new_order_items.length)
|
||||
new_order_items.each_with_index do |order_item, index|
|
||||
order_item.order_items_id = ids[index]
|
||||
end
|
||||
|
||||
OrderItem.import new_order_items, validate: false
|
||||
|
||||
new_order_items.each do |order_item|
|
||||
order_item.run_callbacks(:save) { true }
|
||||
end
|
||||
|
||||
self.order_items << new_order_items
|
||||
self.item_count = self.order_items.count
|
||||
self.save!
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ class OrderItem < ApplicationRecord
|
||||
|
||||
#Associations
|
||||
belongs_to :order, autosave: true
|
||||
has_one :menu_item, foreign_key: "item_code", primary_key: "item_code"
|
||||
has_one :menu_category, through: :menu_item
|
||||
# belongs_to :order, counter_cache: true
|
||||
|
||||
#Validation
|
||||
|
||||
@@ -15,7 +15,6 @@ class OrderQueueStation < ApplicationRecord
|
||||
validates_presence_of :station_name, :printer_name
|
||||
|
||||
def process_order(order, table_id, order_source = nil, pdf_status = nil ,change_to=nil, current_user=nil)
|
||||
|
||||
oqs_stations = OrderQueueStation.active
|
||||
order_items = order.order_items
|
||||
|
||||
@@ -47,14 +46,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
if pdf_status.nil?
|
||||
ids = AssignedOrderItem.generate_ids(assigned_order_items.length)
|
||||
assigned_order_items.each_with_index do |assigned_order_item, index|
|
||||
assigned_order_item.assigned_order_item_id = ids[index]
|
||||
end
|
||||
|
||||
AssignedOrderItem.import assigned_order_items, validate: false
|
||||
end
|
||||
assigned_order_items.each(&:save)
|
||||
end
|
||||
|
||||
def pay_process_order_queue (order_id, table_id)
|
||||
|
||||
@@ -14,8 +14,8 @@ class Product < ApplicationRecord
|
||||
account_id: account_id,
|
||||
item_code: item_code,
|
||||
item_instance_code: item_code,
|
||||
name: item_name || '',
|
||||
alt_name: item_name || '',
|
||||
name: "#{item_name}",
|
||||
alt_name: "#{item_name}",
|
||||
price: price,
|
||||
promotion_price: 0,
|
||||
is_on_promotion: 0,
|
||||
|
||||
@@ -5,10 +5,11 @@ class Sale < ApplicationRecord
|
||||
#primary key - need to be unique generated for multiple shops
|
||||
before_create :generate_custom_id
|
||||
before_create :generate_receipt_no
|
||||
|
||||
belongs_to :cashier, foreign_key: "cashier_id", class_name: "Employee"
|
||||
belongs_to :customer, :optional => true
|
||||
belongs_to :shift_sale
|
||||
has_one :survey, foreign_key: "receipt_no"
|
||||
has_one :survey, foreign_key: "receipt_no"
|
||||
has_many :sale_audits
|
||||
has_many :sale_items
|
||||
has_many :sale_discount_items
|
||||
@@ -20,6 +21,7 @@ class Sale < ApplicationRecord
|
||||
has_many :orders, through: :sale_orders
|
||||
has_many :order_items, through: :sale_orders
|
||||
has_many :bookings
|
||||
has_one :booking
|
||||
has_many :product_commissions
|
||||
|
||||
before_validation :round_to_precision
|
||||
@@ -79,188 +81,109 @@ class Sale < ApplicationRecord
|
||||
Rails.logger.debug '........ Sale data sync completed .......'
|
||||
end
|
||||
end
|
||||
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
||||
if booking
|
||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
||||
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
||||
#get all order attached to this booking and combine into 1 invoice
|
||||
|
||||
unless sale = booking.sale
|
||||
sale = booking.build_sale(
|
||||
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, in_duties_count = 0)
|
||||
Sale.transaction do
|
||||
if booking
|
||||
current = Time.now
|
||||
#get all order attached to this booking and combine into 1 invoice
|
||||
sale = booking.sale || booking.build_sale(
|
||||
{
|
||||
tax_type: "execulive" # Default Tax - Values
|
||||
}
|
||||
)
|
||||
end
|
||||
booking.booking_orders.each do |order|
|
||||
sale.generate_invoice_from_order(order.order_id, booking, requested_by, cashier, order_source)
|
||||
# saleObj = Sale.find(sale_id)
|
||||
# order = booking.booking_orders.take.order
|
||||
# link_order_sale(order.order_id)
|
||||
end
|
||||
# InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
|
||||
|
||||
# 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)
|
||||
if charges.charge_type =='hr'
|
||||
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
||||
if cashier.role == 'cashier'
|
||||
sale.cashier = cashier
|
||||
sale.shift_sale = cashier.current_shift
|
||||
elsif booking.dining_facility_id
|
||||
sale.shift_sale = booking.dining_facility.cashier_terminal.current_shift
|
||||
sale.cashier = booking.dining_facility.cashier_terminal.current_shift.employee
|
||||
else
|
||||
dining_time = booking.checkin_at.strftime('%B %d, %H:%M %p').to_s + " - " + booking.checkout_at.strftime('%B %d, %H:%M %p').to_s
|
||||
sale.cashier = Employee.where(role: 'cashier').where.not(token_session: [nil, '']).first
|
||||
sale.shift_sale = sale.cashier.current_shift
|
||||
end
|
||||
later_time = booking.checkout_at
|
||||
early_time = booking.checkin_at
|
||||
distance_in_minutes = ((later_time - early_time)/60.0).round
|
||||
basic_pay_amount = 0
|
||||
name = ""
|
||||
if current_checkin_induties_count != "0"
|
||||
basic_pay = Commission.where('commission_type=?','Basic Pay')
|
||||
basic_pay.each do |pay|
|
||||
basic_pay_amount = pay.amount
|
||||
name = pay.name
|
||||
end
|
||||
induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i
|
||||
sale.create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount)
|
||||
end
|
||||
sale.create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source)
|
||||
end
|
||||
|
||||
return sale
|
||||
end
|
||||
end
|
||||
sale.cashier_name = sale.cashier.name
|
||||
sale.requested_by = requested_by.name
|
||||
sale.requested_at = current
|
||||
|
||||
def generate_invoice_from_order(order_id, booking, requested_by, cashier = nil, order_source = nil)
|
||||
taxable = true
|
||||
sale.sale_items << booking.order_items.to_sale_items
|
||||
|
||||
order = Order.find(order_id)
|
||||
if dining_charge = booking.dining_facility.dining_charge
|
||||
block_count, dining_price = DiningCharge.amount_calculate(dining_charge, booking.checkin_at, booking.checkout_at)
|
||||
format = "%I:%M %p" if dining_charge.charge_type == "hr"
|
||||
format ||= "%B %d, %I:%M %p"
|
||||
dining_time = "#{booking.checkin_at.strftime(format)} - #{booking.checkout_at.strftime(format)}"
|
||||
|
||||
# current cashier login
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
# shift with terminal zone
|
||||
sale.sale_items.build({
|
||||
menu_category_name: "Dining Charge",
|
||||
menu_category_code: "DiningCharge",
|
||||
product_name: "#{booking.dining_facility.name} ( #{dining_time} )",
|
||||
product_code: dining_charge.item_code,
|
||||
product_alt_name: '-',
|
||||
account_id: 0,
|
||||
is_taxable: dining_charge.taxable,
|
||||
qty: block_count,
|
||||
unit_price: dining_charge.unit_price,
|
||||
price: dining_price,
|
||||
taxable_price: dining_price,
|
||||
})
|
||||
|
||||
# set cashier
|
||||
if order_source.present? && order_source.downcase == "emenu"
|
||||
if !booking.dining_facility_id.nil?
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||
#for multiple zone with terminal
|
||||
if shift.nil?
|
||||
multiple_zone = CashierTerminalByZone.where("zone_id = #{table.zone_id}")
|
||||
multiple_zone.each do |zone|
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first
|
||||
if !shift.nil? then
|
||||
break
|
||||
end
|
||||
if in_duties_count.to_i > 0
|
||||
basic_pay = Commission.find_by(commission_type: 'Basic Pay')
|
||||
in_duties_pay_amount = (in_duties_count.to_i * ((booking.checkout_at - booking.checkin_at) / 1.hours) * basic_pay_amount).to_i
|
||||
|
||||
sale.sale_items.build({
|
||||
menu_category_name: "Induty Charge",
|
||||
menu_category_code: "IndutyCharge",
|
||||
product_name: "#{basic_pay.name} ( #{dining_time} )",
|
||||
product_code: "",
|
||||
product_alt_name: '-',
|
||||
account_id: 0,
|
||||
is_taxable: dining_charge.taxable,
|
||||
qty: in_duties_count,
|
||||
unit_price: basic_pay.amount,
|
||||
price: in_duties_pay_amount,
|
||||
taxable_price: in_duties_pay_amount,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(cashier.id)
|
||||
end
|
||||
# set cashier
|
||||
if shift != nil #if current login employee open shift
|
||||
self.cashier_id = cashier.id
|
||||
self.cashier_name = cashier.name
|
||||
self.shift_sale_id = shift.id
|
||||
else
|
||||
if open_cashier.count>0 # if we have two open cashier
|
||||
# table and terminal in multiple shift
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
if shift_id
|
||||
self.shift_sale_id = shift_id.id
|
||||
else
|
||||
self.shift_sale_id = current_shift.id
|
||||
end
|
||||
else
|
||||
self.cashier_id = current_shift.employee_id
|
||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||
self.shift_sale_id = current_shift.id
|
||||
|
||||
sale.orders << booking.orders
|
||||
sale.customer_id = booking.orders[0].customer_id
|
||||
|
||||
sale.compute(booking.orders[0].source)
|
||||
|
||||
booking.orders.update_all(status: "billed")
|
||||
booking.order_items.update_all(order_item_status: "billed")
|
||||
|
||||
booking.checkout_at = current unless booking.checkout_at && booking.checkout_at > current
|
||||
booking.checkout_by = requested_by.name
|
||||
|
||||
booking.save
|
||||
return sale
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# set waiter
|
||||
self.requested_by = requested_by.name
|
||||
|
||||
self.requested_at = DateTime.now.utc.getlocal
|
||||
|
||||
Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}"
|
||||
if order
|
||||
self.customer_id = order.customer_id
|
||||
Rails.logger.debug "Order -> #{order.id} | Items Count -> #{order.order_items.count}"
|
||||
|
||||
order.order_items.each do |item|
|
||||
self.add_item(item)
|
||||
if !item.set_menu_items.nil?
|
||||
self.add_sub_item(item.set_menu_items)
|
||||
end
|
||||
end
|
||||
self.orders << order
|
||||
end
|
||||
|
||||
#compute sales summary
|
||||
if order_source.nil?
|
||||
order_source = order.source
|
||||
end
|
||||
self.compute(order_source)
|
||||
|
||||
#Update the order items that is billed
|
||||
order.update_items_status_to_billed(nil)
|
||||
order.status = "billed"
|
||||
order.save
|
||||
|
||||
if !booking.checkout_at.nil?
|
||||
if booking.checkout_at.utc < Time.now.utc
|
||||
booking.checkout_at = Time.now.utc.getlocal
|
||||
end
|
||||
else
|
||||
booking.checkout_at = Time.now.utc.getlocal
|
||||
end
|
||||
|
||||
booking.checkout_by = requested_by.name
|
||||
booking.save
|
||||
|
||||
# InventoryJob.perform_now(self.id)
|
||||
# saleObj = Sale.find(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#fOR Quick Service pay and create
|
||||
def self.request_bill(order,current_user,current_login_employee)
|
||||
def self.request_bill(order, current_user, current_login_employee)
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = order.order_id # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
booking = order.booking
|
||||
|
||||
if @sale_data = check_booking.sale
|
||||
# Create Sale if it doesn't exist
|
||||
# puts "current_login_employee"
|
||||
# puts current_login_employee.name
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(check_booking,current_login_employee,current_user,order.source)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
sale_data = Sale.generate_invoice_from_booking(check_booking, current_login_employee, current_user, order.source)
|
||||
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift.id
|
||||
# @sale_data.save
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale_data)
|
||||
@status = true
|
||||
return @status, @sale_data
|
||||
Promotion.promo_activate(sale_data)
|
||||
return true, sale_data
|
||||
else
|
||||
@status = false
|
||||
@message = "No Current Open Shift for This Employee"
|
||||
return false, "No Current Open Shift for This Employee"
|
||||
end
|
||||
end
|
||||
#This is when spilt bill is request - then we cannot link order to invoice
|
||||
|
||||
@@ -280,6 +280,11 @@ class SaleItem < ApplicationRecord
|
||||
|
||||
# Loader Service SFTP End
|
||||
|
||||
protected
|
||||
def self.generate_ids(count = 1)
|
||||
SeedGenerator.generate_ids(self.name, "SLI", count)
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_item_id.nil?
|
||||
|
||||
Reference in New Issue
Block a user