merge with crm

This commit is contained in:
Yan
2017-07-01 20:11:52 +06:30
28 changed files with 467 additions and 98 deletions

View File

@@ -94,7 +94,6 @@ class Sale < ApplicationRecord
link_order_sale(order.id)
end
self.save!
#compute sales summary
@@ -410,8 +409,8 @@ class Sale < ApplicationRecord
else
## up to 100
value = 100 - get_last_no.to_f
num += value
puts 'up to 100'
num += value
puts 'up to 100'
end
end
end
@@ -444,6 +443,7 @@ class Sale < ApplicationRecord
to_date = sale_date.end_of_day.utc - diff
total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj")
@@ -451,6 +451,7 @@ class Sale < ApplicationRecord
total_sale.each do |sale|
grand_total = sale.grand_total
old_grand_total = sale.old_grand_total
total_discount = sale.total_discount
void_amount = sale.void_amount
total = {:sale_date => pay.sale_date,
@@ -464,6 +465,7 @@ class Sale < ApplicationRecord
:foc_amount => pay.foc_amount,
:total_discount => total_discount,
:grand_total => grand_total,
:old_grand_total => old_grand_total,
:void_amount => void_amount,
:rounding_adj => sale.rounding_adj}
daily_total.push(total)