fixed conflict

This commit is contained in:
Nweni
2019-11-08 16:08:45 +06:30
19 changed files with 585 additions and 955 deletions

View File

@@ -34,7 +34,7 @@
<span class="hidden" id ="table_id" value="<%=@table%>"><%=@table%></span>
<span class="hidden" id="table_type" value="<%=@table%>"><%=@table%></span>
<%end%>
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
<p class="m-l-10">Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
@@ -44,24 +44,22 @@
</div>
</div>
<div id="order-detail-slimscroll" data-height="160">
<div class="card-text dining">
<span id="discount_itemsErr" style="color:red;"></span>
<table class="table table-default" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<div class="card-text dining">
<span id="discount_itemsErr" style="color:red;"></span>
<table class="table table-default" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
</tr>
</thead>
<tbody>
<% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %>
<%
sub_total += sale_item.qty*sale_item.unit_price
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
<% sub_total += sale_item.qty * sale_item.unit_price %>
<% if sale_item.price > 0 && sale_item.status.blank? %>
<tr class="item-row item" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left">
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
<span id="item-account-qty" class="hidden"><%=sale_item.qty%></span>
@@ -74,14 +72,26 @@
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
</td>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
</div>
<% elsif sale_item.price < 0 && sale_item.status == "Discount" %>
<tr class="item-row discount" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left">
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
<span id="item-account-qty" class="hidden"><%=sale_item.qty%></span>
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty.abs%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
@@ -130,18 +140,18 @@
<div class="card-block">
<div class="card-title">
<div class="form-horizontal">
<div class="col-md-12">
<div class="form-group">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
<div class="col-md-12">
<div class="form-group">
<input type="text" id="discount-amount" name="discount-amount" value="0" class="form-control" />
<span id="discount-amountErr" style="color:red;"></span>
</div>
<br>
<div class="form-group">
<div class="form-group">
<% @accounts.each do |acc| %>
<button id="account-<%= acc.id %>" class="accounts-type btn bg-default"><%= acc.title %></button>
<% end %>
</div>
</div>
</div>
</div>
</div>
@@ -217,11 +227,11 @@
<div class="col-md-4">
<div class="form-group">
<button id="net" class="btn bg-info fluid action-btn">Nett</button>
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
<button id="remove-item" class="btn bg-default fluid action-btn">Clear Discount</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -235,7 +245,7 @@
<div class="form-horizontal">
<div class="p-l-20">
<div class="row">
<div class="col-md-8 form-group">
<div class="col-md-8 form-group">
<div class="form-group">
<input type="text" id="promo-code" name="promo-code" value="" class="form-control" /></span>
</div>
@@ -243,11 +253,11 @@
<div class="col-md-4">
<button id="" class="btn bg-primary btn-block action-btn">Promo</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->
</div>
<!-- Column Three -->
@@ -259,7 +269,7 @@
<button id="remove-all" class="btn bg-primary btn-block action-btn">Remove All</button>
<button id="pay-discount" class="btn bg-primary btn-block action-btn">Enter</button>
<% if @member_discount%>
<!-- <hr />
<!-- <hr />
<button id="member-discount" class="btn btn-success btn-block action-btn
<%= @sale_data.customer.membership_id ? " " : "disabled"%>">Member Discount</button> -->
<%end %>
@@ -270,6 +280,9 @@
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
var totalAmount = <%= sub_total %>;
var totalDiscount = <%= @sale_data.total_discount %>
var precision = <%= precision %>;
$(document).ready(function(){
setHeaderBreadCrumb(_DISCOUNTS_);
/* check webview loaded*/
@@ -300,10 +313,10 @@ var cashier_type = "<%= @cashier_type %>";
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
$('#discount-amount').val(original_value + '' + input_value);
}
break;
case 'add':
@@ -313,10 +326,10 @@ var cashier_type = "<%= @cashier_type %>";
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#discount-amount').val("0.0");
$('#discount-amount').val("0.0");
break;
}
event.handled = true;
@@ -326,28 +339,12 @@ var cashier_type = "<%= @cashier_type %>";
});
// Select Sale Item
$('.item-row').on('click',function(){
$('#order-items-table').on('click', '.item-row', function(){
if($(this).hasClass('selected-item') == true){
$(this).removeClass('selected-item');
}
else {
if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){
$(this).addClass('selected-item');
}
}
});
// Select discount-item
$('#order-items-table tbody').on('click', '.discount-item-row',function(){
if($(this).hasClass('selected-item') == true){
$(this).removeClass('selected-item');
}
else {
if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){
$(this).addClass('selected-item');
}
$(this).addClass('selected-item');
}
});
@@ -374,7 +371,7 @@ var cashier_type = "<%= @cashier_type %>";
}
}
});
}
}
});
// Calculate Net Discount for Payment
@@ -384,7 +381,7 @@ var cashier_type = "<%= @cashier_type %>";
var discount_value = $('#discount-amount').val();
var sub_total = parseFloat($('#order-sub-total').text());
var ajax_url = "/origami/" + sale_id + "/discount";
if(discount_value!=""){
if(discount_value > 0){
if(parseFloat(discount_value) > sub_total){
@@ -393,7 +390,7 @@ var cashier_type = "<%= @cashier_type %>";
}else{
$("#discount-amountErr").html("");
// Selected Items
var sale_items = get_selected_sale_items();
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
@@ -401,9 +398,9 @@ var cashier_type = "<%= @cashier_type %>";
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(0, discount_value);
}
else {
calculate_item_discount(0, discount_value, sale_items, account_types);
}
else if(sale_items.length > 0){
calculate_item_discount(0, discount_value, sale_items, account_types);
}
// Remove Selection
selection_remove();
@@ -414,7 +411,7 @@ var cashier_type = "<%= @cashier_type %>";
}else{
$("#discount-amountErr").html("can't be blank");
}
});
// Calculate Percentage Discount for Payment
@@ -424,34 +421,46 @@ var cashier_type = "<%= @cashier_type %>";
var discount_value = $('#discount-amount').val();
var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(1, discount_value);
}
else {
calculate_item_discount(1, discount_value, sale_items, account_types);
if(discount_value!=""){
if(discount_value > 0){
$("#discount-amountErr").val("");
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(1, discount_value);
} else if(sale_items.length > 0){
calculate_item_discount(1, discount_value, sale_items, account_types);
}
}else{
$("#discount-amountErr").html("Discount must be greater than 0!");
}
}else{
$("#discount-amountErr").html("can't be blank");
}
// Remove Selection
selection_remove();
selection_remove();
});
// Remove selected discount items
$("#remove-item").on('click', function(e){
e.preventDefault();
var origin_sub_total = parseFloat($("#order-sub-total").text());
var total = 0;
// 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);
$('.item-row.new-discount').each(function(i){
var amount = parseFloat($(this).find('#item-total-price').text());
totalAmount += Math.abs(amount)
// total = total + Math.abs(amount);
$(this).remove();
});
$("#order-sub-total").text(origin_sub_total + total);
$("#order-sub-total").text(totalAmount);
$("#order-discount").text(totalDiscount.toFixed(<%= precision.to_i %>));
});
// Pay Discount for Payment
@@ -462,10 +471,10 @@ var cashier_type = "<%= @cashier_type %>";
}
$("#loading_wrapper").show();
var sale_id = $('#sale-id').text();
var discount_items = JSON.stringify(get_discount_item_rows());
var discount_items = JSON.stringify(get_new_discount_item_rows());
var overall_discount = $("#order-discount").text();
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/discount";
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/discount";
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
@@ -473,8 +482,8 @@ var cashier_type = "<%= @cashier_type %>";
type: "POST",
url: ajax_url,
data: params,
success:function(result){
$("#loading_wrapper").hide();
success:function(result){
$("#loading_wrapper").hide();
swal({
title: "Information!",
text: result.status,
@@ -489,7 +498,7 @@ var cashier_type = "<%= @cashier_type %>";
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
}
});
});
@@ -500,13 +509,7 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#sale-id').text();
var discount_items = [];
// Selected Items
var sale_items = get_selected_sale_items();
if(sale_items.length == 0){
//swal("Information!", "You have no selected item!");
swal ( "Oops" , "You have no selected item!" , "error" );
return;
}
var sale_items = get_selected_discount_items();
for(var i=0;i < sale_items.length;i++){
if(sale_items[i].price < 0){
@@ -514,7 +517,7 @@ var cashier_type = "<%= @cashier_type %>";
}
else {
swal ("Oops" , "You have no selected item!" , "error" );
return;
return;
}
}
@@ -539,7 +542,7 @@ var cashier_type = "<%= @cashier_type %>";
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
}
});
});
@@ -566,7 +569,7 @@ var cashier_type = "<%= @cashier_type %>";
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
}
});
});
@@ -575,8 +578,8 @@ var cashier_type = "<%= @cashier_type %>";
$("#member-discount").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/member_discount";
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/member_discount";
// Selected Account
//var account_types = JSON.stringify(get_selected_account_types());
@@ -618,96 +621,95 @@ var cashier_type = "<%= @cashier_type %>";
});
}
});
});//end member discount
});
/* Remove Selection */
function selection_remove(){
$(".item-row").removeClass("selected-item");
$(".discount_item_row").removeClass("selected-item");
$(".accounts-type").removeClass("selected-account");
}
/* Get Item rows but not discount*/
function get_item_rows(){
var sale_items = [];
$('.item-row').not('.discount-item-row').each(function(i){
var sale_items = [];
$('.item-row.item').not('.discount').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id').substr(0,16);
sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
sale_item.account_id = $(this).find('#item-account-type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
});
return sale_items;
}
/* Get discount Item rows */
function get_discount_item_rows(){
var sale_items = [];
$('.discount-item-row').each(function(i){
function get_new_discount_item_rows(){
var sale_items = [];
$('.item-row.new-discount').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id');
sale_item.name = $(this).find('#item-name-price').text();
sale_item.account_id = $(this).find('#item_account_type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
});
return sale_items;
}
/* Get discount Item rows */
// function get_selected_discount_items(){
// var sale_items = [];
// $('.discount-item-row').hasClass('.selected-item').each(function(i){
// var sale_item = {};
// sale_item.id = $(this).attr('id');
// sale_item.name = $(this).find('#item-name-price').text();
// sale_item.account_id = $(this).find('#item_account_type').text();
// sale_item.price = $(this).find('#item-total-price').text();
// sale_items.push(sale_item);
// });
// return sale_items;
// }
function get_selected_discount_items(){
var sale_items = [];
$('.item-row.discount.selected-item').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id');
sale_item.name = $(this).find('#item-name-price').text();
sale_item.account_id = $(this).find('#item_account_type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
return sale_items;
}
/* Get Selected Sale Item's ID and Price */
function get_selected_sale_items(){
var sale_items = [];
$('.item-row.selected-item').each(function(i){
var sale_items = [];
$('.item-row.item.selected-item').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id').substr(0,16);
sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
sale_item.account_id = $(this).find('#item-account-type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
});
return sale_items;
}
/* Get Selected Accounts ID and Price */
function get_selected_account_types(){
function get_selected_account_types(){
var account_types = [];
$('.selected-account').each(function(i){
var account= {};
account.id = $(this).attr('id').substr(8);
account.name = $(this).text();
account.name = $(this).text();
account_types.push(account);
});
});
return account_types;
}
/* Calculate Overall Discount*/
function calculate_overall_discount(type, amount){
var origin_sub_total = parseFloat($("#order-sub-total").text());
var origin_sub_total = parseFloat($("#order-sub-total").text()) + parseFloat($("#order-discount").text());
var dis_amount = 0;
var sub_total = 0;
var total_discount = 0;
// For Net Pay
if(type == 0){
total_discount = amount;
total_discount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
}
// For Percentage Pay
@@ -719,34 +721,37 @@ function calculate_overall_discount(type, amount){
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
});
}
else{
total_discount = (origin_sub_total * amount)/100;
total_discount = Math.round(totalAmount * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
}
}
sub_total = parseFloat(totalAmount) - parseFloat(total_discount)
$("#order-discount").text(parseFloat(total_discount).toFixed(<%= precision.to_i %>));
}
/* Calculate Items Discount*/
function calculate_item_discount(type, amount, sale_items, account_types){
var origin_sub_total = parseFloat($("#order-sub-total").text());
var origin_sub_total = parseFloat($("#order-sub-total").text());
var dis_amount = 0;
var sub_total = 0;
var total_discount = 0;
var arrItemName = "";
$("#discount_itemsErr").html("");
$("#discount-amountErr").html("");
// For Net Pay
if(origin_sub_total > 0){
if(type == 0){
dis_amount = (0 - amount);
dis_amount = -Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
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){
// 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);
@@ -755,20 +760,19 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// }
// else {
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
arrItemName += ", " + sale_items[i].name;
}else{
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = parseFloat(total_discount) + parseFloat(amount);
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
arrItemName += ", " + sale_items[i].name;
}else{
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = parseFloat(total_discount) + parseFloat(amount);
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
}else{
total_discount = parseFloat(total_discount) - parseFloat(amount);
$("#discount-amountErr").html("Discount is greater than sub total!");
}
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
}else{
total_discount = parseFloat(total_discount) - parseFloat(amount);
$("#discount-amountErr").html("Discount is greater than sub total!");
}
}
// }
}
}
@@ -782,11 +786,11 @@ function calculate_item_discount(type, amount, sale_items, account_types){
}else{
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" price");
}
}
// No Needs For Auto Selected
// if(account_types.length > 0){
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
@@ -802,10 +806,12 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// else {
// alert("No Items!");
// }
// }
// }
sub_total = parseFloat(origin_sub_total) - parseFloat(total_discount);
totalAmount = sub_total
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
}
// For Percentage Pay
@@ -817,7 +823,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
});
}
else{
// Check sale items exists
@@ -825,7 +831,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
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){
// 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);
@@ -835,9 +841,9 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
dis_amount = -Math.round(sale_items[i].price * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = total_discount + dis_amount;
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
@@ -848,18 +854,20 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
}
sub_total = parseFloat(origin_sub_total) + parseFloat(total_discount);
totalAmount = sub_total
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
}
}
// No Needs For Auto Selected
// Check account types exists
// if(account_types.length > 0){
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// console.log(account_types);
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// // Discount Items
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
@@ -870,15 +878,14 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// else {
// alert("No Items!");
// }
// }
// }
// }
}
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
}else{
$("#discount-amountErr").html("Discount is greater than sub total!");
}
}
function item_row_template(type, item, discount_amount, amount){
@@ -886,25 +893,25 @@ function item_row_template(type, item, discount_amount, amount){
if(type == 1){
dis_str = dis_str + "(" + amount + "%)"
}
var discount_item_row = "<tr class='discount-item-row' id='" + item.id + "'>" +
"<td style='width: 60%; text-align: left;'>" +
"<span id='item_account_type' class='hidden'>" +
var discount_item_row = "<tr class='item-row new-discount' id='" + item.id + "'>" +
"<td style='width: 60%; text-align: left;'>" +
"<span id='item_account_type' class='hidden'>" +
item.account_id +
"</span>" +
"<span id='item-name-price'>" +
"</span>" +
"<span id='item-name-price'>" +
item.name + dis_str +
"</span>" +
"</span>" +
"</td>" +
"<td style='width: 20%; text-align: right;'>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-qty'>1</span>" +
"</td>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-total-price'>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-total-price'>" +
discount_amount +
"</span>" +
"</span>" +
"</td>" +
"</tr>";
return discount_item_row;
return discount_item_row;
}
</script>

View File

@@ -98,8 +98,8 @@
<%if !@sale_data.nil? %>
<% @sale_data.each do |result| %>
<% grand_total +=result.grand_total.to_f %>
<% old_grand_total += result.grand_total_after_rounding() %>
<% grand_total += result.grand_total.to_f %>
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
@@ -124,50 +124,35 @@
</td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %>
<td><%= number_with_precision(result.total_amount, precision: precision.to_i, delimiter: delimiter) %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '0' %>
</td>
<!-- <%if result.customer.customer_type == "Takeaway"%>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<% num = 1 %>
<% if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% num += 1 %>
<% end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td><%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<%end%>
<% num = 1 %>
<% if !tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% num += 1 %>
<% end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<td><%= number_with_precision(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% if @lookup.value.to_i == 1 %>
<td>
<!-- ############### Need to Check SyncStatus ############# -->
@@ -185,54 +170,34 @@
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="3">&nbsp;</td>
<td><b><%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<!-- <% if !@sale_taxes.empty?
@sale_taxes.each do |tax| %>
<td>
<b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b>
</td>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><b>0</b></td>
<% end %>
<% end %> -->
<td><b><%= number_with_precision(total_sum, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(discount_amt, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
<% if !@sale_taxes.empty? %>
<% num = 1
if ttax_flag && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) %></td>
<% num += 1
end %>
<% end %>
<% @sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<td><%= number_with_precision(tax.st_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<%end%>
<% num = 1
if ttax_flag==false && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) %></td>
<% num += 1
end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= number_with_precision(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
<td></td>
</tr>
<tr>

View File

@@ -29,7 +29,7 @@
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></th>
<th><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> </th>
<% @tax_profiles.each do |tax| %>
<th><%= tax.name %></th>
<th><%= tax.name %></th>
<% end %>
<!-- <th>Other Amount</th> -->
<th><%= t("views.right_panel.detail.grand_total") %></th>
@@ -74,11 +74,11 @@
end
%>
<%if !@sale_data.nil? %>
<%if @sale_data %>
<% @sale_data.each do |result| %>
<% grand_total +=result.grand_total.to_f %>
<% old_grand_total += result.grand_total_after_rounding() %>
<% grand_total += result.grand_total.to_f %>
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
@@ -91,59 +91,45 @@
tax_flag = false
end
end %>
<tr>
<td>
<%if result.type %>
<%= result.type %> - <%= result.name %>
<% else %>
-
<% end %>
</td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %>
</td>
<% if !result.sale_taxes.empty? %>
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<tr>
<td>
<%if result.type %>
<%= result.type %> - <%= result.name %>
<% else %>
-
<% end %>
</td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= number_with_precision(result.total_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% if !result.sale_taxes.empty? %>
<% num = 1 %>
<% if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% num += 1 %>
<% end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<td><%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% num += 1
end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<td><%= number_with_precision(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="3">&nbsp;</td>
@@ -153,23 +139,17 @@
<% num = 1
if ttax_flag && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% num += 1
end %>
<% end %>
<% @sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<td><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<% num = 1
if ttax_flag==false && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<td><%= number_with_precision(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% num += 1
end %>
<% end %>
@@ -178,12 +158,9 @@
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td></td>
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= number_with_precision(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
@@ -209,4 +186,4 @@
</div>
</div>
</body>
</html>
</html>