This commit is contained in:
Nweni
2017-06-29 18:59:17 +06:30
parent 11c3be8f4a
commit 8046bc7745
9 changed files with 119 additions and 69 deletions

View File

@@ -25,7 +25,7 @@ class Sale < ApplicationRecord
SALE_STATUS_OUTSTANDING = "outstanding"
SALE_STATUS_COMPLETED = "completed"
def generate_invoice_from_booking(booking_id, requested_by, cashier)
def generate_invoice_from_booking(booking_id, requested_by, cashier)
booking = Booking.find(booking_id)
status = false
Rails.logger.debug "Booking -> " + booking.id.to_s
@@ -66,7 +66,7 @@ class Sale < ApplicationRecord
#Default Tax - Values
self.tax_type = "exclusive"
# set cashier
# set cashier
if cashier != nil
self.cashier_id = cashier[0].id
self.cashier_name = cashier[0].name
@@ -270,8 +270,6 @@ class Sale < ApplicationRecord
end
private
def product_get_unit_price(item_code)
menu_item_hash =MenuItem.search_by_item_code(item_code)
if (menu_instance_code)
@@ -409,6 +407,36 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
end
def get_cash_amount
cash = 0.0
self.sale_payments.each do |pay|
if pay.payment_method == 'cash'
cash = pay.payment_amount
end
end
return cash
end
def get_credit_amount
credit = 0.0
self.sale_payments.each do |pay|
if pay.payment_method == 'creditnote'
credit = pay.payment_amount
end
end
return credit
end
def get_other_amount
other = 0.0
self.sale_payments.each do |pay|
if pay.payment_method != 'cash' && pay.payment_method != 'creditnote'
other += pay.payment_amount
end
end
return other
end
private
def generate_custom_id