add inclc in receipt bill
This commit is contained in:
@@ -421,7 +421,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
total_tax_amount = 0
|
total_tax_amount = 0
|
||||||
tax_incl_exec = "execulsive"
|
tax_incl_exec = "exclusive"
|
||||||
#tax_profile - list by order_by
|
#tax_profile - list by order_by
|
||||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||||
customer = Customer.find(sale.customer_id)
|
customer = Customer.find(sale.customer_id)
|
||||||
@@ -431,29 +431,30 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
if tax.group_type.to_s == order_source.to_s
|
if tax.group_type.to_s == order_source.to_s
|
||||||
if tax_type
|
if tax_type
|
||||||
if tax_type.to_s == tax.name.to_s || tax_type == 'all'
|
if tax_type.to_s == tax.name.to_s || tax_type == 'all'
|
||||||
sale_tax = SaleTax.new(:sale => sale)
|
sale_tax = SaleTax.new(:sale => sale)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax.tax_rate = tax.rate
|
||||||
|
|
||||||
# substract , to give after discount
|
# substract , to give after discount
|
||||||
total_tax = total_taxable - total_discount
|
total_tax = total_taxable - total_discount
|
||||||
#include or execulive
|
#include or execulive
|
||||||
if tax.inclusive
|
if tax.inclusive
|
||||||
rate = tax.rate
|
tax_incl_exec = "inclusive"
|
||||||
divided_value = (100 + rate)/rate
|
rate = tax.rate
|
||||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
divided_value = (100 + rate)/rate
|
||||||
else
|
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
else
|
||||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||||
end
|
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||||
#new taxable amount is standard rule for step by step
|
|
||||||
if shop.calc_tax_order
|
|
||||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
|
||||||
end
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
|
||||||
sale_tax.save
|
|
||||||
end
|
end
|
||||||
|
#new taxable amount is standard rule for step by step
|
||||||
|
if shop.calc_tax_order
|
||||||
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
sale_tax.inclusive = tax.inclusive
|
||||||
|
sale_tax.save
|
||||||
|
end
|
||||||
else
|
else
|
||||||
# customer.tax_profiles.each do |cus_tax|
|
# customer.tax_profiles.each do |cus_tax|
|
||||||
# if cus_tax.to_i == tax.id
|
# if cus_tax.to_i == tax.id
|
||||||
@@ -465,6 +466,7 @@ class Sale < ApplicationRecord
|
|||||||
total_tax = total_taxable - total_discount
|
total_tax = total_taxable - total_discount
|
||||||
#include or execulive
|
#include or execulive
|
||||||
if tax.inclusive
|
if tax.inclusive
|
||||||
|
tax_incl_exec = "inclusive"
|
||||||
rate = tax.rate
|
rate = tax.rate
|
||||||
divided_value = (100 + rate)/rate
|
divided_value = (100 + rate)/rate
|
||||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||||
@@ -484,7 +486,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sale.tax_type =
|
sale.tax_type = tax_incl_exec
|
||||||
sale.total_tax = total_tax_amount
|
sale.total_tax = total_tax_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -499,6 +501,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
total_tax_amount = 0
|
total_tax_amount = 0
|
||||||
|
tax_incl_exec = "exclusive"
|
||||||
#tax_profile - list by order_by
|
#tax_profile - list by order_by
|
||||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||||
|
|
||||||
@@ -520,6 +523,7 @@ class Sale < ApplicationRecord
|
|||||||
total_tax = total_taxable - self.total_discount
|
total_tax = total_taxable - self.total_discount
|
||||||
#include or execulive
|
#include or execulive
|
||||||
if tax.inclusive
|
if tax.inclusive
|
||||||
|
tax_incl_exec = "inclusive"
|
||||||
rate = tax.rate
|
rate = tax.rate
|
||||||
divided_value = (100 + rate)/rate
|
divided_value = (100 + rate)/rate
|
||||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||||
@@ -539,7 +543,8 @@ class Sale < ApplicationRecord
|
|||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.total_tax = total_tax_amount
|
self.tax_type = tax_incl_exec
|
||||||
|
self.total_tax = total_tax_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
def product_get_unit_price(item_code)
|
def product_get_unit_price(item_code)
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
|
|
||||||
if sale_data.sale_taxes.length > 0
|
if sale_data.sale_taxes.length > 0
|
||||||
incl_tax = ""
|
incl_tax = ""
|
||||||
if sale_data.tax_type == "inculsive"
|
if sale_data.tax_type == "inclusive"
|
||||||
incl_tax = "Incl."
|
incl_tax = "Incl."
|
||||||
end
|
end
|
||||||
sale_data.sale_taxes.each do |st|
|
sale_data.sale_taxes.each do |st|
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
if sale_data.sale_taxes.length > 0
|
if sale_data.sale_taxes.length > 0
|
||||||
incl_tax = ""
|
incl_tax = ""
|
||||||
if sale_data.tax_type == "inculsive"
|
if sale_data.tax_type == "inclusive"
|
||||||
incl_tax = "Incl."
|
incl_tax = "Incl."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user