update addorder and wrong tax

This commit is contained in:
Aung Myo
2017-11-23 17:34:31 +06:30
parent 8f0b44ca7b
commit d78ba65675
4 changed files with 35 additions and 28 deletions

View File

@@ -373,7 +373,7 @@ $(function() {
$('.add_to_order').removeAttr('data-attributes');
$('.add_to_order').removeAttr('data-options');
$('.change_qty').val(1);
$('.keypress_qty').val(1);
change_qty_plus_minus("count","plus","minus");
@@ -460,7 +460,7 @@ $(function() {
$(".options-list").append(row);
}
$('#count').val(1);
// $('#count').val(1);
$('#item_instances').text(instances);
$('#title_name').text(data.attr('data-name'));
$('#item_code').text(data.attr('data-item-code'));
@@ -825,12 +825,16 @@ $(function() {
// Get Selected Class
function change_qty_plus_minus(id,plus,minus) {
var count = parseInt($('#'+id).val())
var countEl = document.getElementById(id);
$('#'+plus).on("click", function(){
var count = parseInt($('#'+id).val());
var countEl = document.getElementById(id);
count++;
countEl.value = count;
countEl.value = count;
if (id == "count") {
@@ -856,9 +860,13 @@ $(function() {
});
$('#'+minus).on("click", function(){
var count = parseInt($('#'+id).val());
var countEl = document.getElementById(id);
if (count > 1) {
count--;
countEl.value = count;
countEl.value = count;
if (id=="count") {
price = $("#unit_price").text();
@@ -883,15 +891,15 @@ $(function() {
})
}
$('.keypress_qty').keyup(function(e){
$(".keypress_qty").on('keyup change', function (){
// $('.keypress_qty').keyup(function(e){
id = $(this).attr('id');
value = $(this).val();
if ($.isNumeric(value)) {
$('.change_qty').attr('value',value);
if (id=="count") {
$('.change_qty').attr('value',value);
price = $("#unit_price").text();
$("#total_price").text(value*price);
}else{

View File

@@ -41,9 +41,9 @@ class Transactions::ShiftSalesController < ApplicationController
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)

View File

@@ -777,35 +777,34 @@ end
def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
if payment_type.blank?
payment_type = ''
else
if payment_type == 'card'
payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar'"
else
payment_type = " and sale_payments.payment_method = '#{payment_type}'"
end
end
# wrong amount tax for service and commercial tax
# if payment_type.blank?
# payment_type = ''
# else
# if payment_type == 'card'
# payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar'"
# else
# payment_type = " and sale_payments.payment_method = '#{payment_type}'"
# end
# end
if shift.present?
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift.to_a)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
elsif shift_sale_range.present?
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift_sale_range.to_a)
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift_sale_range.to_a)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
else
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.receipt_date between ? and ? #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", from,to)
.where("sales.receipt_date between ? and ? and sale_status= 'completed'", from,to)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
end

View File

@@ -3,7 +3,7 @@
<% if period_type != false %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_period") %><%= t("views.right_panel.detail.select_period") %></label>
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<option value="0">Today</option>