update edit with remark

This commit is contained in:
Aung Myo
2018-02-26 16:56:57 +06:30
parent 07e208a457
commit b38e98a22a
10 changed files with 123 additions and 61 deletions

View File

@@ -28,7 +28,7 @@ class SaleItem < ApplicationRecord
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
# Original Item to add remark
item.remark = type
item.status = type
item.save
sale_item = SaleItem.new
@@ -37,7 +37,7 @@ class SaleItem < ApplicationRecord
sale_item.product_name = item.product_name + " (#{type.upcase})"
sale_item.product_alt_name = item.product_alt_name
sale_item.account_id = item.account_id
sale_item.remark = type
sale_item.status = type
if type == "foc" || type == "promotion" || type == "void"
sale_item.qty = qty * (-1)
else
@@ -99,7 +99,7 @@ class SaleItem < ApplicationRecord
discount_account = {:name => a.title, :price => 0}
# Check for actual sale items
sale_items.where("remark = 'Discount'").find_each do |si|
sale_items.where("status = 'Discount'").find_each do |si|
if si.account_id == a.id
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
end