check tax profile

This commit is contained in:
phyusin
2018-07-26 11:10:54 +06:30
parent fd654a9554
commit fd44a57689
2 changed files with 40 additions and 9 deletions

View File

@@ -12,12 +12,23 @@ class Origami::RequestBillsController < ApplicationController
sale_order=SaleOrder.new
if !ShiftSale.current_shift.nil?
tax_profiles = TaxProfile.unscoped.where("group_type='cashier'").pluck(:id)
customers = Customer.find('CUS-000000000002')
tax_data = TaxProfile.unscoped.where("group_type='cashier'").pluck(:id)
customer = Customer.find('CUS-000000000001')
puts "data => "
puts tax_profiles.to_json
puts customers.tax_profiles.to_json
puts tax_data
puts customer.tax_profiles
arr_data = []
tax_data.each do |value1|
puts JSON.stringify(customer.tax_profiles)
if customer.include? value1
arr_data << value1
end
end
puts "unique => "
puts arr_data
# tax_profiles = TaxProfile.unscoped.where("id in ?",arr_data)
# puts tax_profiles.to_json
# order_id = params[:id] # order_id
# bk_order = BookingOrder.find_by_order_id(order_id)
# order = Order.find(order_id)
@@ -93,6 +104,11 @@ class Origami::RequestBillsController < ApplicationController
@error_message = "No Current Open Shift for This Employee"
end
def difference(other)
h = other.each_with_object(Hash.new(0)) { |e,h| h[e] += 1 }
reject { |e| h[e] > 0 && h[e] -= 1 }
end
# Not Use for these printed bill cannot give customer
# unique_code = "ReceiptBillPdf"
# #shop detail

View File

@@ -512,13 +512,23 @@ class Sale < ApplicationRecord
total_tax_amount = 0
tax_incl_exec = "exclusive"
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
# tax_profiles = TaxProfile.all.order("order_by asc")
if order_source.to_s == "emenu"
order_source = "cashier"
end
tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id)
customer = Customer.find(self.customer_id).tax_profiles
arr_tax = []
arr_tax = customer - tax_data
if !arr_tax.empty?
tax_profiles = TaxProfile.unscoped.where("id in ?",arr_tax)
else
tax_profiles = TaxProfile.unscoped.where("group_type=?",order_source)
end
#Create new tax records
tax_profiles.each do |tax|
if tax.group_type.to_s == order_source.to_s
@@ -552,8 +562,8 @@ class Sale < ApplicationRecord
# end
end
end
self.tax_type = tax_incl_exec
self.total_tax = total_tax_amount
self.tax_type = tax_incl_exec
self.total_tax = total_tax_amount
end
def product_get_unit_price(item_code)
@@ -2774,6 +2784,11 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
return query
end
def difference(other)
h = other.each_with_object(Hash.new(0)) { |e,h| h[e] += 1 }
reject { |e| h[e] > 0 && h[e] -= 1 }
end
private
def generate_custom_id