precision

This commit is contained in:
Myat Zin Wai Maw
2019-09-05 18:12:17 +06:30
parent 1ced4a3d6d
commit 258aba669b
5 changed files with 58 additions and 12 deletions

View File

@@ -452,6 +452,7 @@ class Sale < ApplicationRecord
self.total_amount = subtotal_price
self.total_discount = total_discount
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
self.grand_total_round
#compute rounding adjustment
adjust_rounding
@@ -461,6 +462,7 @@ class Sale < ApplicationRecord
#compute - invoice total
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
shop = Shop.first
sale = Sale.find(sale_id)
sales_items = sale_itemss
@@ -484,6 +486,7 @@ class Sale < ApplicationRecord
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 discount_type == "member_discount"
sale.discount_type = discount_type
end
@@ -519,6 +522,7 @@ class Sale < ApplicationRecord
self.total_amount = subtotal_price
self.total_discount = total_discount
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
self.grand_total_round
#compute rounding adjustment
adjust_rounding
@@ -2948,6 +2952,17 @@ end
# End hourly sale item report
#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
end
private
def generate_custom_id