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 sale_order=SaleOrder.new
if !ShiftSale.current_shift.nil? if !ShiftSale.current_shift.nil?
tax_profiles = TaxProfile.unscoped.where("group_type='cashier'").pluck(:id) tax_data = TaxProfile.unscoped.where("group_type='cashier'").pluck(:id)
customers = Customer.find('CUS-000000000002') customer = Customer.find('CUS-000000000001')
puts "data => " puts "data => "
puts tax_profiles.to_json puts tax_data
puts customers.tax_profiles.to_json 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 # order_id = params[:id] # order_id
# bk_order = BookingOrder.find_by_order_id(order_id) # bk_order = BookingOrder.find_by_order_id(order_id)
# order = Order.find(order_id) # order = Order.find(order_id)
@@ -93,6 +104,11 @@ class Origami::RequestBillsController < ApplicationController
@error_message = "No Current Open Shift for This Employee" @error_message = "No Current Open Shift for This Employee"
end 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 # Not Use for these printed bill cannot give customer
# unique_code = "ReceiptBillPdf" # unique_code = "ReceiptBillPdf"
# #shop detail # #shop detail

View File

@@ -512,13 +512,23 @@ class Sale < ApplicationRecord
total_tax_amount = 0 total_tax_amount = 0
tax_incl_exec = "exclusive" 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(self.customer_id)
if order_source.to_s == "emenu" if order_source.to_s == "emenu"
order_source = "cashier" order_source = "cashier"
end 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 #Create new tax records
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
@@ -2774,6 +2784,11 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
return query return query
end 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 private
def generate_custom_id def generate_custom_id