conflict remove
This commit is contained in:
@@ -92,7 +92,7 @@ class Sale < ApplicationRecord
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
self.shift_sale_id = shift_id.id
|
||||
self.shift_sale_id = current_shift.id
|
||||
else
|
||||
self.cashier_id = current_shift.employee_id
|
||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||
@@ -227,7 +227,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.product_name = item.item_name
|
||||
sale_item.product_alt_name = item.alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.remark = item.remark
|
||||
sale_item.status = item.remark
|
||||
|
||||
sale_item.qty = item.qty
|
||||
sale_item.unit_price = item.price
|
||||
@@ -255,7 +255,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.product_name = instance.item_instance_name
|
||||
sale_item.product_alt_name = menu_item.alt_name
|
||||
sale_item.account_id = menu_item.account_id
|
||||
sale_item.remark = nil
|
||||
sale_item.status = nil
|
||||
|
||||
sale_item.qty = item["quantity"]
|
||||
sale_item.unit_price = item["price"]
|
||||
@@ -381,7 +381,7 @@ class Sale < ApplicationRecord
|
||||
rounding_adjustment = 0
|
||||
|
||||
sales_items.each do |item|
|
||||
if item.remark != 'void' && item.remark != 'foc'
|
||||
if item.status != 'void' && item.status != 'foc'
|
||||
#compute each item and added to total
|
||||
subtotal_price = subtotal_price + item.price
|
||||
|
||||
@@ -417,35 +417,36 @@ class Sale < ApplicationRecord
|
||||
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.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
if sale.payment_status != 'foc'
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
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
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
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
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sale.total_tax = total_tax_amount
|
||||
end
|
||||
|
||||
@@ -757,7 +758,7 @@ end
|
||||
def self.get_item_query()
|
||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
||||
"i.remark as status_type,"+
|
||||
"i.status as status_type,"+
|
||||
" i.unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id ")
|
||||
|
||||
@@ -776,7 +777,7 @@ end
|
||||
def self.get_other_charges()
|
||||
query = Sale.select("i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
||||
"i.remark as status_type,"+
|
||||
"i.status as status_type,"+
|
||||
" i.unit_price as unit_price,i.product_name as product_name")
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
query = query.where("i.item_instance_code IS NULL AND i.product_code = 'Other Charges'")
|
||||
|
||||
Reference in New Issue
Block a user