fixed first bill with discount

This commit is contained in:
Aung Myo
2018-05-11 11:54:53 +06:30
parent 5e0bdf1e36
commit 87913956f1

View File

@@ -98,9 +98,8 @@ class SaleItem < ApplicationRecord
discount_accounts = [] discount_accounts = []
Account.all.each do |a| Account.all.each do |a|
discount_account = {:name => a.title, :price => 0} discount_account = {:name => a.title, :price => 0}
# Check for actual sale items # Check for actual sale items
sale_items.where("status = 'Discount'").find_each do |si| sale_items.where("status = 'Discount'").each do |si|
if si.account_id == a.id if si.account_id == a.id
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1) discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
end end