quick service tax

This commit is contained in:
Myat Zin Wai Maw
2019-12-20 14:12:57 +06:30
parent 40871c30fb
commit e3207ed1d5
4 changed files with 50 additions and 8 deletions

View File

@@ -1097,16 +1097,28 @@ $(function() {
var total_price = 0; var total_price = 0;
var total_qty = 0; var total_qty = 0;
var taxable_amount = 0; var taxable_amount = 0;
var exclusive_total =0;
var inclusive_total =0;
var inclusive_tax =$('#inclusive_tax').val();
var exclusive_tax =$('#exclusive_tax').val();
var item_row = $('.summary-items tbody tr'); var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){ $(item_row).each(function(i){
var unit_price = parseFloat($(item_row[i]).attr('data-price')); var unit_price = parseFloat($(item_row[i]).attr('data-price'));
var qty = parseFloat($(item_row[i]).children('#item_qty').text()); var qty = parseFloat($(item_row[i]).children('#item_qty').text());
total_qty += qty; total_qty += qty;
total_price += qty*unit_price; total_price += qty*unit_price;
}); });
if (inclusive_tax >0){
inclusive_total = total_price / inclusive_tax;
}
if (exclusive_tax >0){
exclusive_total = total_price * exclusive_tax;
}
total_price = total_price + exclusive_total + inclusive_total;
var fixed_total_price = parseFloat(total_price).toFixed(2); var fixed_total_price = parseFloat(total_price).toFixed(2);
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2); var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
$('#total_tax').empty();
$('#total_tax').append(exclusive_total + inclusive_total);
$('#sub_total').empty(); $('#sub_total').empty();
$('#sub_total').append(fixed_total_price); $('#sub_total').append(fixed_total_price);

View File

@@ -81,7 +81,8 @@ class Crm::CustomersController < BaseCrmController
@membership_types = Lookup.collection_of("member_group_type") @membership_types = Lookup.collection_of("member_group_type")
# @taxes = TaxProfile.where(:group_type => 'cashier') # @taxes = TaxProfile.all
# @taxes =TaxProfile.unscoped.select("id,(SELECT name from lookups where lookup_type='tax_profiles') as name")
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC") .order("group_type ASC,order_by ASC")

View File

@@ -32,8 +32,8 @@ class Origami::QuickServiceController < ApplicationController
#checked quick_service only #checked quick_service only
@quick_service_only = false @quick_service_only = false
lookup_dine_in = Lookup.collection_of('quickservice_add_order') lookup_dine_in = Lookup.collection_of('quickservice_add_order')
puts 'lookup_dine_in!!!!' # puts 'lookup_dine_in!!!!'
puts lookup_dine_in # puts lookup_dine_in
if !lookup_dine_in.empty? if !lookup_dine_in.empty?
lookup_dine_in.each do |dine_in| lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "quickserviceaddorder" if dine_in[0].downcase == "quickserviceaddorder"
@@ -43,7 +43,23 @@ class Origami::QuickServiceController < ApplicationController
end end
end end
end end
divided_value =0
exclusive =0
tax_profiles = TaxProfile.where(group_type: "quick_service")
if !tax_profiles.empty?
tax_profiles.each do |tax|
#include or execulive
if tax.inclusive
tax_incl_exec = "inclusive"
rate = tax.rate
divided_value += (100 + rate)/rate
else
exclusive +=tax.rate / 100
end
end
end
@inclusive_tax =divided_value
@exclusive_tax =exclusive
render "origami/addorders/detail" render "origami/addorders/detail"
end end

View File

@@ -10,6 +10,8 @@
</div> </div>
<input type="hidden" name="type" id="role" value="<%= current_user.role%>"> <input type="hidden" name="type" id="role" value="<%= current_user.role%>">
<input type="hidden" name="cashier_type" id="cashier_type" value="<%= type%>"> <input type="hidden" name="cashier_type" id="cashier_type" value="<%= type%>">
<input type="hidden" name="inclusive_tax" id="inclusive_tax" value="<%= @inclusive_tax%>">
<input type="hidden" name="exclusive_tax" id="exclusive_tax" value="<%= @exclusive_tax%>">
<input type="hidden" name="link_type" id="link_type" value="<%= @cashier_type %>"> <input type="hidden" name="link_type" id="link_type" value="<%= @cashier_type %>">
<input type="hidden" name="display_type" id="display_type" value="<%= @display_type%>"> <input type="hidden" name="display_type" id="display_type" value="<%= @display_type%>">
<div class="row m-t--20"> <div class="row m-t--20">
@@ -259,8 +261,17 @@
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;"> <div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
<table class="table" id="order-charges-table" border="0"> <table class="table" id="order-charges-table" border="0">
<tr> <%if @cashier_type=='quick_service' %>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td> <tr>
<td colspan="3" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Tax:</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="total_tax">0.00</strong></td>
</tr>
<tr>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total + tax:</strong></td>
<% else %>
<tr>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
<% end %>
<td style="padding:2px;" width="15%"><strong id="total_qty">0</strong></td> <td style="padding:2px;" width="15%"><strong id="total_qty">0</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td> <td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
@@ -794,6 +805,8 @@
$(document).on('click', '#clear_all', function(event){ $(document).on('click', '#clear_all', function(event){
$(".summary-items tbody").empty(); $(".summary-items tbody").empty();
$('#sub_total').text("0.00"); $('#sub_total').text("0.00");
$('#total_qty').text("0");
$('#total_tax').text("0");
$(".create").attr("disabled","disabled"); $(".create").attr("disabled","disabled");
customer_display_view(null,"reload"); customer_display_view(null,"reload");
}); });