update cash in and out for quick service

This commit is contained in:
Aung Myo
2018-05-16 18:01:47 +06:30
parent 29434f2df9
commit ca360c75d6
8 changed files with 76 additions and 17 deletions

View File

@@ -8,31 +8,32 @@ class Origami::CashInsController < BaseOrigamiController
amount = params[:amount] amount = params[:amount]
payment_method = params[:payment_method] payment_method = params[:payment_method]
payment_method_reference = params[:payment_method_reference] payment_method_reference = params[:payment_method_reference]
type = params[:type]
p_jour = PaymentJournal.new p_jour = PaymentJournal.new
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id)
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
current_shift = ShiftSale.current_shift current_shift = ShiftSale.current_shift
# set cashier # set cashier
if shift != nil if shift != nil
shift = shift shift = shift
else else
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0 if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0].id)
if shift
shift = ShiftSale.current_open_shift(shift.id)
else
shift = ShiftSale.current_open_shift(current_shift.id)
end
else
shift = Employee.find(current_shift.employee_id).name
end shift = ShiftSale.current_open_shift(open_cashier[0].id)
if shift
shift = ShiftSale.current_open_shift(shift.id)
else
shift = ShiftSale.current_open_shift(current_shift.id)
end
else
shift = Employee.find(current_shift.employee_id).name
end end
end
shift.cash_in = shift.cash_in + amount.to_f shift.cash_in = shift.cash_in + amount.to_f
shift.save shift.save

View File

@@ -62,7 +62,13 @@ class Origami::PendingOrderController < BaseOrigamiController
@table_id = nil @table_id = nil
@dining = nil @dining = nil
end end
end
def cash_ins
render "origami/cash_ins/new"
end
def cash_outs
render "origami/cash_outs/new"
end end
end end

View File

@@ -56,6 +56,9 @@
</div> </div>
<script> <script>
cashier_type = window.location.href.indexOf("quick_service");
console.log(cashier_type)
var payment_method = ""; var payment_method = "";
$('.payment-type').on('click',function(){ $('.payment-type').on('click',function(){
$('.payment-type').css("background-color","#7a62d3") $('.payment-type').css("background-color","#7a62d3")
@@ -80,11 +83,19 @@
url: "<%= origami_cash_ins_path %>", url: "<%= origami_cash_ins_path %>",
data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount + "&payment_method="+payment_method + "&payment_method_reference="+ payment_method_reference, data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount + "&payment_method="+payment_method + "&payment_method_reference="+ payment_method_reference,
success:function(result){ success:function(result){
window.location.href = '/origami'; if (cashier_type == -1) {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service/pending_order';
}
} }
}); });
}) })
$('#back').on('click',function(){ $('#back').on('click',function(){
window.location.href = '/origami'; if (cashier_type == -1) {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service/pending_order';
}
}) })
</script> </script>

View File

@@ -25,6 +25,7 @@
</div> </div>
</div> </div>
<script> <script>
cashier_type = window.location.href.indexOf("quick_service");
$('#cash_out').on('click',function(){ $('#cash_out').on('click',function(){
var reference = $('#reference').val(); var reference = $('#reference').val();
var remark = $('#remark').val(); var remark = $('#remark').val();
@@ -33,12 +34,22 @@
url: "<%= origami_cash_outs_path %>", url: "<%= origami_cash_outs_path %>",
data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount, data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount,
success:function(result){ success:function(result){
window.location.href = '/origami';
if (cashier_type == -1) {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service/pending_order';
}
} }
}); });
}) })
$('#back').on('click',function(){ $('#back').on('click',function(){
window.location.href = '/origami'; cashier_type = window.location.href.indexOf("quick_service");
if (cashier_type == -1) {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service/pending_order';
}
}) })
</script> </script>

View File

@@ -172,6 +172,8 @@
<button type="button" id="reprint" class="btn bg-blue btn-block">Reprint</button> <button type="button" id="reprint" class="btn bg-blue btn-block">Reprint</button>
<% if current_user.role != "waiter" %> <% if current_user.role != "waiter" %>
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button> <button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
<% end %> <% end %>
</div> </div>
</div> </div>
@@ -201,7 +203,13 @@ $(document).ready(function(){
var linkURL = '/origami/shift/quick_service/close'; var linkURL = '/origami/shift/quick_service/close';
warnBeforeRedirect(linkURL); warnBeforeRedirect(linkURL);
}); });
$('#cash_in').on('click',function(){
window.location.href = '/origami/quick_service/cash_ins';
})
$('#cash_out').on('click',function(){
window.location.href = '/origami/quick_service/cash_outs';
})
}); });
</script> </script>

View File

@@ -55,7 +55,9 @@
</button> </button>
<% if current_user.role != "waiter" %> <% if current_user.role != "waiter" %>
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button> <button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<% end %> <button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@@ -83,6 +85,14 @@
warnBeforeRedirect(linkURL); warnBeforeRedirect(linkURL);
}); });
$('#cash_in').on('click',function(){
window.location.href = '/origami/quick_service/cash_ins';
})
$('#cash_out').on('click',function(){
window.location.href = '/origami/quick_service/cash_outs';
})
function warnBeforeRedirect(linkURL) { function warnBeforeRedirect(linkURL) {
swal({ swal({
title: "Alert!", title: "Alert!",

View File

@@ -188,6 +188,8 @@
<%end%> <%end%>
<% if current_user.role != "waiter" %> <% if current_user.role != "waiter" %>
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button> <button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<!-- <button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button> -->
<% end %> <% end %>
</div> </div>
</div> </div>
@@ -321,5 +323,13 @@ $(document).ready(function(){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/pending"; window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/pending";
} }
}); });
$('#cash_in').on('click',function(){
window.location.href = '/origami/quick_service/cash_ins';
})
$('#cash_out').on('click',function(){
window.location.href = '/origami/quick_service/cash_outs';
})
}); });
</script> </script>

View File

@@ -110,6 +110,8 @@ scope "(:locale)", locale: /en|mm/ do
get "quick_service/modify_order/:sale_id" => "quick_service#modify_order" get "quick_service/modify_order/:sale_id" => "quick_service#modify_order"
post 'quick_service/update_modify_order' => "quick_service#update_modify_order", :defaults => { :format => 'json' } post 'quick_service/update_modify_order' => "quick_service#update_modify_order", :defaults => { :format => 'json' }
get "quick_service/cash_ins" => "pending_order#cash_ins"
get "quick_service/cash_outs" => "pending_order#cash_outs"
resources :cash_ins, only: [:new, :create] resources :cash_ins, only: [:new, :create]
resources :cash_outs, only: [:new, :create] resources :cash_outs, only: [:new, :create]