customer sales report tax fixed

This commit is contained in:
yarzar_code
2020-09-11 14:14:56 +06:30
parent fcadb14ec6
commit 7bbfacca00
7 changed files with 33 additions and 14 deletions

View File

@@ -207,7 +207,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
# if !saleObj.nil? # if !saleObj.nil?
# InventoryJob.perform_now(self.id) # InventoryJob.perform_now(self.id)
# InventoryDefinition.calculate_product_count(saleObj) # InventoryDefinition.calculate_product_count(saleObj)

View File

@@ -34,7 +34,7 @@ class Reports::CustomerController < BaseReportController
membership_type = params[:membership_type] membership_type = params[:membership_type]
end end
@sale_data = Sale.get_shift_sales_by_customer(@shift_sale_range, @shift, from, to, membership_type, customer_filter) @sale_data = Sale.get_shift_sales_by_customer(@shift_sale_range, @shift, from, to, membership_type, customer_filter)
@sale_taxes = Sale.get_separate_tax(@shift_sale_range, @shift, from, to, nil) @sale_taxes = Sale.get_separate_tax_by_customer(@shift_sale_range, @shift, from, to, nil, customer_filter, membership_type)
@tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@from = from @from = from

View File

@@ -32,7 +32,7 @@ authorize_resource :class => false
payment_type = params[:payment_type] payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range, @shift, from, to, payment_type, customer_filter) @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range, @shift, from, to, payment_type, customer_filter)
@sale_taxes = Sale.get_separate_tax(@shift_sale_range, @shift, from, to, payment_type) @sale_taxes = Sale.get_separate_tax_by_customer(@shift_sale_range, @shift, from, to, payment_type, customer_filter)
@tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@from = from @from = from

View File

@@ -1225,7 +1225,7 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range, shift, from, to, paymen
if payment_type.blank? if payment_type.blank?
payment_type = '' payment_type = ''
else else
payment_type = " and sale_payments.payment_method = '#{payment_type}'" payment_type = "sale_payments.payment_method = '#{payment_type}'"
end end
query = Sale.includes(:sale_items).select("sales.*, sale_payments.*") query = Sale.includes(:sale_items).select("sales.*, sale_payments.*")
@@ -1235,7 +1235,9 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range, shift, from, to, paymen
.joins("LEFT JOIN dining_facilities ON dining_facilities.id = bookings.dining_facility_id") .joins("LEFT JOIN dining_facilities ON dining_facilities.id = bookings.dining_facility_id")
.completed.where.not(total_amount: 0) .completed.where.not(total_amount: 0)
.group("sales.sale_id") .group("sales.sale_id")
if payment_type != ''
query = query.where("#{payment_type} and sale_payments.payment_amount!=0")
end
if customer_filter.present? if customer_filter.present?
query = query.joins(sanitize_sql_array(["INNER JOIN customers ON customers.customer_id = sales.customer_id AND " + query = query.joins(sanitize_sql_array(["INNER JOIN customers ON customers.customer_id = sales.customer_id AND " +
"customers.name LIKE :filter", filter: "%#{customer_filter}%"])) "customers.name LIKE :filter", filter: "%#{customer_filter}%"]))
@@ -1440,6 +1442,31 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
end end
end end
def self.get_separate_tax_by_customer(shift_sale_range, shift, from, to, payment_type,customer_filter, membership_type=nil)
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.where("sale_status= 'completed'")
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
.group("sale_taxes.tax_name")
.order("sale_taxes.tax_name desc")
if payment_type.present?
query = query.joins("JOIN sale_payments ON sale_payments.sale_id = sale_taxes.sale_id AND sale_payments.payment_method = '#{payment_type}' and sale_payments.payment_amount!=0")
end
query = query.joins("INNER JOIN customers ON customers.customer_id = sales.customer_id
#{sanitize_sql_array(['AND customers.name LIKE :filter', filter: "%#{customer_filter}%"]) if customer_filter.present?}
#{sanitize_sql_array(['AND customers.membership_type = :type', type: membership_type]) if membership_type.present?}")
if shift.present?
query = query.where("sales.shift_sale_id in (?) ", shift.to_a)
elsif shift_sale_range.present?
query = query.where("sales.shift_sale_id in (?) ", shift_sale_range.to_a)
else
query = query.where("sales.receipt_date between ? and ? ", from,to)
end
end
def self.get_payment_method_by_shift(shift,from,to,payment_type) def self.get_payment_method_by_shift(shift,from,to,payment_type)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method) payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)

View File

@@ -165,13 +165,7 @@
$("#member_acc_no").on('click', function(e){ $("#member_acc_no").on('click', function(e){
localStorage.setItem("member_card",true); localStorage.setItem("member_card",true);
$("#sxModal").show(); $("#sxModal").show();
<<<<<<< HEAD
setTimeout(function(){
getCardNo();
},100);
=======
getCardNo(); getCardNo();
>>>>>>> r-1902001-01
}); });
// QR Code Reader // QR Code Reader

View File

@@ -31,7 +31,7 @@
<select name="membership_type" id="membership_type" class="form-control m-t-3" style="height: 32px;"> <select name="membership_type" id="membership_type" class="form-control m-t-3" style="height: 32px;">
<option value="0">--- All Group ---</option> <option value="0">--- All Group ---</option>
<% @membership_type.each do |mt| %> <% @membership_type.each do |mt| %>
<option class="<%=mt.name.downcase%>" value="<%=mt.value%>"><%=mt.name%></option> <option class="<%=mt.name.downcase%>" value="<%=mt.value%>" <%= 'selected' if mt.value == params[:membership_type]%>><%=mt.name%></option>
<%end %> <%end %>
</select> </select>
</div> </div>

View File

@@ -1,5 +1,3 @@
<% breadcrumb_add 'LookUp', settings_lookups_path, settings_lookups_path, t("views.btn.#{action_name}") %>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8"> <div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<%= simple_form_for([:settings,@settings_lookup]) do |f| %> <%= simple_form_for([:settings,@settings_lookup]) do |f| %>