add first bill

This commit is contained in:
Yan
2017-06-29 11:34:13 +06:30
parent d35aa23e34
commit 9991970203
13 changed files with 374 additions and 125 deletions

View File

@@ -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)