discount amount error fixed

This commit is contained in:
Zoey
2019-04-24 11:00:23 +06:30
parent e44489ed6f
commit 050ebdd1f7

View File

@@ -180,10 +180,10 @@ class SaleItem < ApplicationRecord
def self.get_all_sale_items(sale_id)
sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
product_name,product_alt_name,account_id,status,remark,
(CASE WHEN (qty > 0 AND remark IS NULL) OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty,
(CASE WHEN (qty > 0 AND remark IS NULL) OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty,
unit_price,
taxable_price,
(CASE WHEN (price > 0 AND remark IS NULL) OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price,
(CASE WHEN (price > 0 AND remark IS NULL) OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price,
is_taxable")
.where("sale_id = ?",sale_id)
.order("product_name asc")