dis ui calc fix and update for shift

This commit is contained in:
Yan
2017-07-09 11:04:43 +06:30
parent c73cfa4c2d
commit 0031300947
6 changed files with 59 additions and 38 deletions

View File

@@ -283,7 +283,7 @@ $(document).ready(function(){
$("#net").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var discount_value = $('#discount-amount').val();
var discount_value = parseFloat($('#discount-amount').val());
var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items
@@ -330,10 +330,15 @@ $(document).ready(function(){
// Remove selected discount items
$("#remove-item").on('click', function(e){
e.preventDefault();
var origin_sub_total = parseFloat($("#order-sub-total").text());
var total = 0;
$('.discount-item-row.selected-item').each(function(i){
var amount = parseFloat($(this).find('#item-total-price').text());
total = total + Math.abs(amount);
$(this).remove();
});
$("#order-sub-total").text(origin_sub_total + total);
});
// Pay Discount for Payment
@@ -628,21 +633,21 @@ function calculate_item_discount(type, amount, sale_items, account_types){
dis_amount = (0 - amount);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
if(account_types.length > 0){
for(var j=0; j < account_types.length; j++){
if(sale_items[i].account_id == account_types[j].id){
// Discount Items
var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + amount;
}
}
}
else {
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + amount;
}
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// else {
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + amount;
// }
}
}
@@ -690,23 +695,23 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// Check sale items exists
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
if(account_types.length > 0){
for(var j=0; j < account_types.length; j++){
if(sale_items[i].account_id == account_types[j].id){
// Discount Items
dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + dis_amount;
}
}
}
else {
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + dis_amount;
}
// }
}
sub_total = origin_sub_total + total_discount;
}