change tax profile overide
This commit is contained in:
@@ -462,4 +462,9 @@ iframe {
|
||||
/* section class for webview */
|
||||
.section-margin {
|
||||
margin-top: -50px;
|
||||
}
|
||||
|
||||
.tax-btn-box {
|
||||
width: 230px;
|
||||
height: 80px;
|
||||
}
|
||||
@@ -96,6 +96,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
member_info = nil
|
||||
type = params[:type]
|
||||
tax_type = params[:tax_type]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
@@ -298,11 +300,18 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
@account_arr.push(account.name)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
@@ -571,4 +580,15 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
render :json => result.to_json
|
||||
# render :json => {status: true}
|
||||
end
|
||||
|
||||
#changable tax for sale
|
||||
def change_tax
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:cashier_type]
|
||||
tax_type = params[:tax_type]
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount,nil,order_source,tax_type)
|
||||
|
||||
render json: JSON.generate({:status => true})
|
||||
end
|
||||
end
|
||||
@@ -71,6 +71,7 @@ class Ability
|
||||
can :rounding_adj, :payment
|
||||
can :foc, :payment
|
||||
can :print, :payment
|
||||
can :change_tax, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
@@ -154,6 +155,7 @@ class Ability
|
||||
can :rounding_adj, :payment
|
||||
can :foc, :payment
|
||||
can :print, :payment
|
||||
can :change_tax, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
@@ -249,6 +251,7 @@ class Ability
|
||||
can :rounding_adj, :payment
|
||||
can :print, :payment
|
||||
can :foc, :payment
|
||||
can :change_tax, :payment
|
||||
|
||||
can :manage, Commission
|
||||
can :manage, Commissioner
|
||||
|
||||
@@ -317,10 +317,10 @@ class Order < ApplicationRecord
|
||||
#Send to background job for processing
|
||||
# OrderBroadcastJob.perform_later(table,type)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
|
||||
end
|
||||
|
||||
@@ -131,7 +131,6 @@ class Sale < ApplicationRecord
|
||||
if order_source.nil?
|
||||
order_source = order.source
|
||||
end
|
||||
puts "compute source"
|
||||
compute(order_source)
|
||||
|
||||
#Update the order items that is billed
|
||||
@@ -346,7 +345,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil)
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
|
||||
sale = Sale.find(sale_id)
|
||||
sales_items = sale_itemss
|
||||
|
||||
@@ -365,7 +364,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
compute_tax(sale, total_taxable, total_discount, order_source)
|
||||
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
|
||||
|
||||
sale.total_amount = subtotal_price
|
||||
sale.total_discount = total_discount
|
||||
@@ -412,7 +411,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
# Tax Re-Calculte
|
||||
def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil)
|
||||
def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
||||
shop = Shop.first();
|
||||
|
||||
#if tax is not apply create new record
|
||||
@@ -429,60 +428,59 @@ class Sale < ApplicationRecord
|
||||
|
||||
if sale.payment_status != 'foc'
|
||||
tax_profiles.each do |tax|
|
||||
# customer.tax_profiles.each do |cus_tax|
|
||||
# if cus_tax.to_i == tax.id
|
||||
if tax.group_type.to_s == order_source.to_s
|
||||
if customer.customer_type.downcase == 'takeaway'
|
||||
if tax.name.downcase == 'commercial tax'
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
if tax_type
|
||||
if tax_type.to_s == tax.name.to_s || tax_type == 'all'
|
||||
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
|
||||
# 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
|
||||
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
|
||||
end
|
||||
else
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
# 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
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
# 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
|
||||
# end
|
||||
# end
|
||||
end
|
||||
end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -510,11 +508,9 @@ class Sale < ApplicationRecord
|
||||
|
||||
#Create new tax records
|
||||
tax_profiles.each do |tax|
|
||||
# customer.tax_profiles.each do |cus_tax|
|
||||
# if cus_tax.to_i == tax.id
|
||||
if tax.group_type.to_s == order_source.to_s
|
||||
if customer.customer_type.downcase == 'takeaway'
|
||||
if tax.name.downcase == 'commercial tax'
|
||||
# customer.tax_profiles.each do |cus_tax|
|
||||
# if cus_tax.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
@@ -538,35 +534,9 @@ class Sale < ApplicationRecord
|
||||
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
end
|
||||
else
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - self.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
|
||||
end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
self.total_tax = total_tax_amount
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
`<div class="container-fluid">
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
@@ -99,52 +99,21 @@
|
||||
<tr>
|
||||
<td class="charges-name">
|
||||
<strong>
|
||||
Tax
|
||||
<!-- (<% @i = 0
|
||||
@account_arr.each do |ct| %>
|
||||
<%=ct%>
|
||||
<% if @account_arr.count != @i+1%>
|
||||
+ <% @i =+1 %>
|
||||
<%end%>
|
||||
<%end %>) -->
|
||||
<div class="row m-l-15">
|
||||
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
|
||||
<div class="form-check">
|
||||
<input type="radio" class="form-check-input" id="tax_type_0" name="tax_type" checked="checked">
|
||||
<label class="form-check-label" for="tax_type_0">
|
||||
Service Charges + Commercial Tax
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
|
||||
<div class="form-check">
|
||||
<input type="radio" class="form-check-input" id="tax_type_1" name="tax_type">
|
||||
<label class="form-check-label" for="tax_type_1">Service Charges</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
|
||||
<div class="form-check">
|
||||
<input type="radio" class="form-check-input" id="tax_type_2" name="tax_type">
|
||||
<label class="form-check-label" for="tax_type_2">
|
||||
Commercial Tax
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
|
||||
<div class="form-check">
|
||||
<input type="radio" class="form-check-input" id="tax_type_3" name="tax_type">
|
||||
<label class="form-check-label" for="tax_type_3">
|
||||
No Tax
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</strong>
|
||||
<% if !@account_arr.empty? %>
|
||||
Tax
|
||||
(<% @i = 0
|
||||
@account_arr.each do |ct| %>
|
||||
<%=ct.tax_name%>
|
||||
<% if @account_arr.count != @i+1%>
|
||||
+ <% @i =+1 %>
|
||||
<%end%>
|
||||
<%end %>)
|
||||
<% else %>
|
||||
No Tax
|
||||
<% end %></strong><br>
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
</td>
|
||||
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
@@ -574,6 +543,61 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- change tax modal -->
|
||||
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-md" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title" id="change_taxModalLabel">TAX</h1>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<% if !@tax_arr.empty? %>
|
||||
<% if @tax_arr.count > 1 %>
|
||||
<div class="row text-center">
|
||||
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
|
||||
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="all">
|
||||
<% @i = 0
|
||||
@tax_arr.each do |tax| %>
|
||||
<%= tax %>
|
||||
<% if @tax_arr.count != @i+1%>
|
||||
+ <% @i =+1 %><br>
|
||||
<%end%>
|
||||
<% end %>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<% @tax_arr.each_with_index do |tax, tax_index| %>
|
||||
<% if (tax_index+1)%2 == 0 %>
|
||||
<div class="row clearfix"></div>
|
||||
<% end %>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
|
||||
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>">
|
||||
<%= tax %>
|
||||
</button>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="row clearfix"></div>
|
||||
<div class="row text-center">
|
||||
<% @tax_arr.each do |tax| %>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
|
||||
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>"><%= tax %></button>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
|
||||
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="no_tax">No Tax</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sxModal">
|
||||
<div id="sxModal-Content">
|
||||
<h3>Card Tap</h3>
|
||||
@@ -719,6 +743,8 @@ var customer_name = "<%= @customer.name %>";
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
|
||||
var tax_type = $("input:radio[name=tax_type]:checked").val();
|
||||
|
||||
if (credit <= 0) {
|
||||
calculate_member_discount(sale_id);
|
||||
}
|
||||
@@ -727,7 +753,7 @@ var customer_name = "<%= @customer.name %>";
|
||||
$('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_payment_cash_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type,
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
|
||||
success:function(result){
|
||||
/* start delete receipt no in first bill*/
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
@@ -1384,4 +1410,41 @@ var customer_name = "<%= @customer.name %>";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Start function for tax changable */
|
||||
$(".change_tax").on("click",function(){
|
||||
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
|
||||
});
|
||||
|
||||
$("button[name=tax_type]").on("click", function(){
|
||||
var type = $(this).attr("data-value");
|
||||
var cashier_type = '<%= @cashier_type %>';
|
||||
var sale_id = $('#sale_id').text();
|
||||
console.log(type);
|
||||
swal({
|
||||
title: "Alert",
|
||||
text: "Are you sure want to change tax?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Yes, change it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/payment/"+cashier_type+"/change_tax",
|
||||
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
|
||||
success:function(data){
|
||||
if(data.status){
|
||||
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment';
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
/* End function for tax changable */
|
||||
</script>
|
||||
|
||||
@@ -199,6 +199,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'payment/junctionpay' => 'junctionpay#create'
|
||||
post 'payment/dinga' => 'dinga#create'
|
||||
|
||||
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
|
||||
|
||||
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/MPU' => "mpu#index"
|
||||
|
||||
Reference in New Issue
Block a user