merge with old_town_aston req

This commit is contained in:
phyusin
2018-03-12 12:10:52 +06:30
parent 6e9ecd342b
commit 92401ab4f9
6 changed files with 99 additions and 27 deletions

View File

@@ -228,6 +228,23 @@ class Origami::PaymentsController < BaseOrigamiController
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f }) @individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
end end
# rounding adjustment
# if @shop.is_rounding_adj
# a = saleObj.grand_total % 25 # Modulus
# b = saleObj.grand_total / 25 # Division
# #not calculate rounding if modulus is 0 and division is even
# #calculate rounding if modulus is zero or not zero and division are not even
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
# @rounding_adj = new_total-saleObj.grand_total
# else
# @rounding_adj = @sale_data.rounding_adjustment
# end
# else
# @rounding_adj = @sale_data.rounding_adjustment
# end
#end rounding adjustment
# rounding adjustment # rounding adjustment
if @shop.is_rounding_adj if @shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
@@ -237,6 +254,7 @@ class Origami::PaymentsController < BaseOrigamiController
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total) new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@rounding_adj = new_total-saleObj.grand_total @rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
else else
@rounding_adj = @sale_data.rounding_adjustment @rounding_adj = @sale_data.rounding_adjustment
end end

View File

@@ -46,6 +46,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale.grand_total) new_total = Sale.get_rounding_adjustment(sale.grand_total)
sale.rounding_adjustment = new_total-sale.grand_total sale.rounding_adjustment = new_total-sale.grand_total
sale.update_attributes(grand_total: new_total,old_grand_total: sale.grand_total,rounding_adjustment:sale.rounding_adjustment)
end end
end end
#end rounding adjustment #end rounding adjustment

View File

@@ -913,15 +913,15 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
query = Sale.all query = Sale.all
if shift.present? if shift.present?
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sales.payment_status= 'paid' and sale_payments.payment_amount != 0", shift.to_a) query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.group("sales.sale_id") .group("sales.sale_id")
elsif shift_sale_range.present? elsif shift_sale_range.present?
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.payment_status= 'paid' and sales.shift_sale_id in (?)",shift_sale_range.to_a) query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.group("sales.sale_id") .group("sales.sale_id")
else else
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sales.payment_status= 'paid' and sale_payments.payment_amount != 0",from,to) query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.group("sales.sale_id") .group("sales.sale_id")
end end
@@ -1112,7 +1112,7 @@ end
" i.price as unit_price,mi.name as product_name") " i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
.where("(i.qty > 0 and i.price > 0) and receipt_date between '#{from}' and '#{to}'"+ .where("(i.qty > 0 and i.price > 0) and receipt_date between '#{from}' and '#{to}'"+
"and payment_status='paid' and sale_status= 'completed'") "and sale_status= 'completed'")
.group('mi.name') .group('mi.name')
.order("SUM(i.qty) DESC").limit(20) .order("SUM(i.qty) DESC").limit(20)
else else
@@ -1120,7 +1120,7 @@ end
" i.price as unit_price,mi.name as product_name") " i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+ .where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
"and payment_status='paid' and sale_status= 'completed'") "and sale_status= 'completed'")
.group('mi.name') .group('mi.name')
.order("SUM(i.qty) DESC").limit(20) .order("SUM(i.qty) DESC").limit(20)
end end
@@ -1132,7 +1132,7 @@ end
" i.price as unit_price,mi.name as product_name") " i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
.where("(i.qty > 0 and i.price > 0) and receipt_date between '#{from}' and '#{to}'"+ .where("(i.qty > 0 and i.price > 0) and receipt_date between '#{from}' and '#{to}'"+
"and payment_status='paid' and sale_status= 'completed'") "and sale_status= 'completed'")
.group('mi.name') .group('mi.name')
.order("SUM(i.qty) ASC").limit(20) .order("SUM(i.qty) ASC").limit(20)
else else
@@ -1140,7 +1140,7 @@ end
" i.price as unit_price,mi.name as product_name") " i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+ .where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
"and payment_status='paid' and sale_status= 'completed'") "and sale_status= 'completed'")
.group('mi.name') .group('mi.name')
.order("SUM(i.qty) ASC").limit(20) .order("SUM(i.qty) ASC").limit(20)
end end
@@ -1149,12 +1149,12 @@ end
def self.hourly_sales(today,from,to) def self.hourly_sales(today,from,to)
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
query= Sale.select("grand_total") query= Sale.select("grand_total")
.where('payment_status="paid" and sale_status = "completed" and receipt_date between ? and ?',from,to) .where('sale_status = "completed" and receipt_date between ? and ?',from,to)
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
.order('receipt_date') .order('receipt_date')
else else
query= Sale.select("grand_total") query= Sale.select("grand_total")
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
.order('receipt_date') .order('receipt_date')
end end

3
app/views/origami/split_bill/index.html.erb Executable file → Normal file
View File

@@ -387,7 +387,8 @@
$('#order_item_split').on('click',function () { $('#order_item_split').on('click',function () {
var cnt_order_item = "<%= @order_items.count %>"; var cnt_order_item = "<%= @order_items.count %>";
var order_items = get_selected_order_items();// Selected Order Items var order_items = get_selected_order_items();// Selected Order Items
var cnt_items = parseInt(cnt_order_item) - parseInt(order_items.length);
var cnt_items = parseInt(cnt_order_item - 1) - parseInt(order_items.length);
if (order_items.length > 0){ if (order_items.length > 0){
// if(cnt_items > 0){ // if(cnt_items > 0){
swal({ swal({

74
app/views/origami/table_invoices/show.html.erb Executable file → Normal file
View File

@@ -157,8 +157,56 @@
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %> <button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button> <button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button> <button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
<button type="button" id="void" class="btn bg-danger btn-block" active="<%= can? :overall_void, :void %>" > Void </button> <button type="button" data-toggle="modal" data-target="#voidModal" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
</div>
</div>
</div>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect " id="void" active="true">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="focModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="focModalLabel">Please Enter Reason for FOC</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="foc_remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect " id="foc" active="true">FOC</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -177,17 +225,18 @@ $(document).ready(function(){
$('#pay').on('click',function() { $('#pay').on('click',function() {
var sale_id = '<%= @sale.id %>'; var sale_id = '<%= @sale.id %>';
var url = '<%= @calculate_rouding_adj_path %>'; // var url = '<%= @calculate_rouding_adj_path %>';
$.ajax({ // $.ajax({
type: "GET", // type: "GET",
url: url, // url: url,
success:function(result){ // success:function(result){
// location.reload(); // // console.log(result);
} // }
}); // });
window.location.href = '/origami/sale/'+ sale_id + "/cashier/payment"; window.location.href = '/origami/sale/'+ sale_id + "/cashier/payment";
}); });
$('#back').on('click',function(){ $('#back').on('click',function(){
var lookup_split_bill = '<%= @split_bill %>'; var lookup_split_bill = '<%= @split_bill %>';
if(lookup_split_bill == '1'){ if(lookup_split_bill == '1'){
@@ -211,10 +260,12 @@ $('#void').on('click',function () {
}, function (isConfirm) { }, function (isConfirm) {
if (isConfirm) { if (isConfirm) {
var sale_id = $('#sale_id').val(); var sale_id = $('#sale_id').val();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void'; var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: ajax_url, url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () { success: function () {
window.location.href = '/origami'; window.location.href = '/origami';
} }
@@ -227,13 +278,14 @@ $('#void').on('click',function () {
}); });
$('#foc').click(function() { $('#foc').click(function() {
var remark = $("#foc_remark").val();
var cash = $('#grand_total').text(); var cash = $('#grand_total').text();
var sub_total = $('#sub_total').text(); var sub_total = $('#sub_total').text();
var sale_id = ''; var sale_id = '';
if($('.receipt_block > div').hasClass('selected-item')){ if($('.receipt_block > div').hasClass('selected-item')){
sale_id = $('.receipt_block > div.selected-item').parent().attr('data-id'); sale_id = $('.receipt_block > div.selected-item').parent().attr('data-id');
} }
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total }; var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total,'remark':remark,'type':'cashier' };
// console.log(sale_id); // console.log(sale_id);
if(sale_id != ''){ if(sale_id != ''){
if ($(this).attr('active')=== "true") { if ($(this).attr('active')=== "true") {

View File

@@ -20,11 +20,11 @@ class ActionController::Base
end end
else else
# check for license file # check for license file
# if check_license if check_license
# current_license(ENV["SX_PROVISION_URL"]) current_license(ENV["SX_PROVISION_URL"])
# else else
# redirect_to activate_path redirect_to activate_path
# end end
end end
end end