add credit note payment process for online order
This commit is contained in:
@@ -34,13 +34,17 @@
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.select_customer") %></label>
|
||||
<select class="selectpicker form-control col-md-12 " name="customer" style="height: 40px" >
|
||||
<select class="selectpicker form-control col-md-12" name="customer">
|
||||
<option value=""><%= t("views.right_panel.detail.select_customer") %></option>
|
||||
<% @customers.each do |customer| %>
|
||||
<option value="<%= customer.customer_id %>">
|
||||
<%= customer.name %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.order_source") %></label>
|
||||
<%= select_tag "order_source", options_for_select(@sources, :selected => params[:order_source]), :class => "form-control" %>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
||||
@@ -67,38 +71,61 @@
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.sale_id") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th><%= t("views.right_panel.detail.credit_amount") %></th>
|
||||
<th><%= t :cashier %></th>
|
||||
<th><%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_date") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% if @credit_notes != 0 %>
|
||||
|
||||
<% @credit_notes.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
||||
<td><%= sale.receipt_no %></td>
|
||||
<td><%credit = SalePayment.where('sale_id = ? AND payment_method=?', sale.sale_id,"creditnote").first %>
|
||||
<%= credit.payment_amount rescue '-' %>
|
||||
</td>
|
||||
<td><%= sale.cashier_name rescue '-' %></td>
|
||||
<td><%= link_to sale.customer.name, crm_customer_path(sale.customer_id) %></td>
|
||||
<td> <%= sale.receipt_date.strftime("%d-%m-%Y %I:%M %p") %> </td>
|
||||
</tr>
|
||||
<% if (!@credit_notes.empty?) && (params[:order_source] == "doemal_order") %>
|
||||
<div class="row pt-3 pb-3 pr-3 float-right">
|
||||
<div class="col-md-12 col-sm-12 col-lg-12">
|
||||
<button class="btn btn-lg bg-blue waves-effect credit_payment"><%= t :credit %> <%= t :payment %></button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if params[:order_source] == "doemal_order" %>
|
||||
<th></th>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<tr><td colspan="8"><strong><p style="text-align: center"><%= t("views.right_panel.detail.no_data_txt") %>....</p></strong></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<th><%= t("views.right_panel.detail.sale_id") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th><%= t("views.right_panel.detail.credit_amount") %></th>
|
||||
<th><%= t :cashier %></th>
|
||||
<th><%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.order_source") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_date") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% if @credit_notes != 0 %>
|
||||
|
||||
<% @credit_notes.each do |sale| %>
|
||||
<tr>
|
||||
<% if params[:order_source] == "doemal_order" %>
|
||||
<td><input type="checkbox" class="" name="chk_order" value="<%= sale.sale_id %>"></td>
|
||||
<% end %>
|
||||
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
||||
<td><%= sale.receipt_no %></td>
|
||||
<td class="credit_<%= sale.sale_id %>"><%credit = SalePayment.where('sale_id = ? AND payment_method=?', sale.sale_id,"creditnote").first %>
|
||||
<%= credit.payment_amount rescue '-' %>
|
||||
</td>
|
||||
<td><%= sale.cashier_name rescue '-' %></td>
|
||||
<td><%= link_to sale.customer.name, crm_customer_path(sale.customer_id) %></td>
|
||||
<td>
|
||||
<%if sale.source == "cashier" || sale.source == "emenu" %>
|
||||
Cashier
|
||||
<% elsif sale.source == "quick_service" %>
|
||||
Quick Service
|
||||
<% else %>
|
||||
Online Order
|
||||
<% end %>
|
||||
</td>
|
||||
<td> <%= sale.receipt_date.strftime("%d-%m-%Y %I:%M %p") %> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<tr><td colspan="8"><strong><p style="text-align: center"><%= t("views.right_panel.detail.no_data_txt") %>....</p></strong></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<% if @credit_notes != 0 %>
|
||||
<%= paginate @credit_notes %>
|
||||
@@ -109,20 +136,64 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
|
||||
<script type="text/javascript">
|
||||
var arr_sale = [];
|
||||
$(function () {
|
||||
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
|
||||
$("input[name='chk_order']").on('click',function(){
|
||||
var arr = {};
|
||||
if($(this).is(':checked')){
|
||||
arr[$(this).val()] = parseFloat($(".credit_"+$(this).val()).html());
|
||||
// console.log(arr);
|
||||
arr_sale.push(arr);
|
||||
}else{
|
||||
arr[$(this).val()] = parseFloat($(".credit_"+$(this).val()).html());
|
||||
arr_sale = removeItem(arr_sale, arr, $(this).val());
|
||||
}
|
||||
// console.log(arr_sale);
|
||||
});
|
||||
|
||||
$(".credit_payment").on('click', function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/origami/payment/credit_payment',
|
||||
data: {data: JSON.stringify(arr_sale)},
|
||||
success: function (result) {
|
||||
// console.log(result);
|
||||
if (result.status == true) {
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Credit Payment Successfully",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}else{
|
||||
swal("Opps",result.message,"warning");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script> -->
|
||||
|
||||
function removeItem(arr_item, remove, sale_id){
|
||||
if((arr_item!=undefined) && (arr_item!=null)){
|
||||
if(arr_item.length > 0){
|
||||
$.each(arr_item, function(i_key, i_value){
|
||||
$.each(i_value, function(key,val){
|
||||
if(key == sale_id){
|
||||
arr_item.splice(arr_item.indexOf(key),1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return arr_item;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user