add first bill
This commit is contained in:
@@ -30,11 +30,13 @@ class SaleItem < ApplicationRecord
|
||||
# end
|
||||
end
|
||||
|
||||
# Get Prices for each accounts (eg: food, beverage)
|
||||
def self.calculate_price_by_accounts(sale_items)
|
||||
price_accounts = []
|
||||
Account.all.each do |a|
|
||||
account_price = {:name => a.title, :price => 0}
|
||||
|
||||
# Check for actual sale items
|
||||
sale_items.each do |si|
|
||||
if si.account_id == a.id
|
||||
account_price[:price] = account_price[:price] + si.price
|
||||
@@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord
|
||||
return price_accounts
|
||||
end
|
||||
|
||||
# Get discount Prices for each accounts (eg: food, beverage)
|
||||
def self.get_discount_price_by_accounts(sale_items)
|
||||
discount_accounts = []
|
||||
Account.all.each do |a|
|
||||
discount_account = {:name => a.title, :price => 0}
|
||||
|
||||
# Check for actual sale items
|
||||
sale_items.where("is_taxable = 0 AND remark = 'Discount'").find_each do |si|
|
||||
if si.account_id == a.id
|
||||
discount_account[:price] = (discount_account[:price] + si.price) * -1
|
||||
end
|
||||
end
|
||||
discount_accounts.push(discount_account)
|
||||
end
|
||||
|
||||
return discount_accounts
|
||||
end
|
||||
|
||||
# Calculate rebate_by_account
|
||||
def self.calculate_rebate_by_account(sale_items)
|
||||
rebateacc = Account.where("rebate=?",true)
|
||||
|
||||
Reference in New Issue
Block a user