calc tax by user taxes
This commit is contained in:
@@ -273,9 +273,12 @@ class Sale < ApplicationRecord
|
||||
total_tax_amount = 0
|
||||
#tax_profile - list by order_by
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
customer = Customer.find(sale.customer_id)
|
||||
|
||||
# #Creat new tax records
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax == tax.id
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
@@ -296,6 +299,8 @@ class Sale < ApplicationRecord
|
||||
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sale.total_tax = total_tax_amount
|
||||
end
|
||||
@@ -312,8 +317,11 @@ class Sale < ApplicationRecord
|
||||
#tax_profile - list by order_by
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
|
||||
# #Creat new tax records
|
||||
customer = Customer.find(self.customer_id)
|
||||
# #Create new tax records
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax == tax.id
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
@@ -335,9 +343,9 @@ class Sale < ApplicationRecord
|
||||
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
self.total_tax = total_tax_amount
|
||||
|
||||
end
|
||||
|
||||
def product_get_unit_price(item_code)
|
||||
@@ -382,7 +390,6 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.search(filter,from,to)
|
||||
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
else
|
||||
@@ -399,7 +406,6 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.search_credit_sales(customer,filter,from,to)
|
||||
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
else
|
||||
@@ -518,7 +524,6 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
|
||||
query = Sale.select("
|
||||
mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total,
|
||||
SUM(i.qty) as total_item," +
|
||||
@@ -536,13 +541,8 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
|
||||
|
||||
query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def self.get_by_shiftsales(from,to,shift)
|
||||
if !shift.blank?
|
||||
ShiftSale.where("id =?",shift.id)
|
||||
|
||||
@@ -99,9 +99,8 @@ customer_type = Lookup.create([{lookup_type:'customer_type', name: 'Dinein', val
|
||||
{lookup_type:'customer_type', name: 'Delivery', value: 'Delivery'}])
|
||||
|
||||
#WALK CUSTOMER - Default CUSTOMER (take key 1)
|
||||
customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"})
|
||||
customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111"})
|
||||
|
||||
customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000", customer_type:"Dinein", tax_profiles:"[2,1]"})
|
||||
customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111", customer_type:"Takeaway", tax_profiles:"[1]"})
|
||||
|
||||
#Default ZOne
|
||||
# zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"})
|
||||
|
||||
Reference in New Issue
Block a user