This commit is contained in:
Myat Zin Wai Maw
2019-09-10 13:12:41 +06:30
parent 258aba669b
commit ac24499319
6 changed files with 35 additions and 33 deletions

View File

@@ -461,7 +461,7 @@ class Sale < ApplicationRecord
end
#compute - invoice total
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil,type=nil)
shop = Shop.first
sale = Sale.find(sale_id)
sales_items = sale_itemss
@@ -473,20 +473,23 @@ class Sale < ApplicationRecord
sales_items.each do |item|
#compute each item and added to total
subtotal_price = subtotal_price + item.price
subtotal_price = subtotal_price + item.price
# check for item is taxable and calculate
if item.is_taxable
total_taxable = total_taxable + item.taxable_price
end
end
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
sale.total_amount = subtotal_price
sale.total_discount = total_discount
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
sale.grand_total_round
if type =="foc"
sale.grand_total = 0
else
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
sale.grand_total_round
end
if discount_type == "member_discount"
sale.discount_type = discount_type
end
@@ -2955,13 +2958,10 @@ end
#not to show decimal in grand total
def grand_total_round
shop =Shop.first
print_settings = PrintSetting.get_precision_delimiter()
if !print_settings.nil?
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
puts self.grand_total
puts "Hello grand_total_round"
end
print_settings = PrintSetting.get_precision_delimiter()
if !print_settings.nil?
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
end
end
private