Merge branch 'crm' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-06-15 18:35:00 +06:30
6 changed files with 120 additions and 23 deletions

View File

@@ -50,6 +50,18 @@ class Transactions::SalesController < ApplicationController
end
@sale_receivables = SalePayment.where('sale_id = ?', @sale.id)
#get customer amount
@customer = Customer.find(@sale.customer_id)
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
#end customer amount
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sale }
@@ -111,7 +123,6 @@ class Transactions::SalesController < ApplicationController
end
def manual_void_sale
sale_id = params[:sale_id]
reason = params[:reason]
sale = Sale.find(sale_id)
@@ -123,9 +134,21 @@ class Transactions::SalesController < ApplicationController
respond_to do |format|
format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' }
end
end
def manual_complete_sale
sale_id = params[:sale_id]
sale = Sale.find(sale_id)
sale.sale_status = 'completed'
sale.requested_by = current_login_employee.id
remark = remark = "Complete for Sale ID #{sale_id} By #{current_login_employee.name}"
if sale.save
sale = SaleAudit.record_audit_complete(sale_id, remark, current_login_employee.id)
end
redirect_to transactions_sales_path
end
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_sale

View File

@@ -8,17 +8,28 @@ class SaleAudit < ApplicationRecord
def self.record_audit_void(sale_id, void_by, approved_by, reason)
#sale_audit
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id
sale_audit.action = "SALEVOID"
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = void_by
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id
sale_audit.action = "SALEVOID"
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = void_by
sale_audit.approved_by = approved_by
sale_audit.remark = reason
sale_audit.remark = reason
sale_audit.save!
#sale_audit.
end
def self.record_audit_complete(sale_id, remark, action_by)
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id
sale_audit.action = "SALECOMPLETE"
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = action_by
sale_audit.remark = remark
sale_audit.approved_by = Time.now
sale_audit.save!
end
def record_audit_discount(sale_id, discount_by, approved_by, reason)
#sale_audit
sale_audit = SaleAudit.new()

View File

@@ -16,9 +16,9 @@
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
<div class="tab-content">
<div class="tab-pane active" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="tab-pane active" id="queue" role="tabpanel"">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
@@ -115,7 +115,7 @@
</div>
</div>
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="tab-pane" id="customer" role="tabpanel">
<h3>Sale Details</h3>
<div class="table-responsive">
<table class="table table-striped">

View File

@@ -6,7 +6,7 @@
<a href="<%= transactions_sales_path %>">Sale</a>
</li>
<li class="active">
<a href="<%= transactions_sales_path %>"><%= @sale.sale_id %></a>
<a href="<%= transactions_sale_path(@sale.sale_id) %>"><%= @sale.sale_id %></a>
</li>
</ol>
</div>
@@ -21,11 +21,11 @@
<a class="nav-link active" data-toggle="tab" href="#queue" role="tab">Sale Details </a>
</li>
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#booking" role="tab">Orders </a>
<a class="nav-link " data-toggle="tab" href="#booking" role="tab">Orders Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Customer Details</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Sales</a>
</li> -->
</ul>
<!-- Nav tabs - End -->
@@ -124,6 +124,9 @@
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td colspan="8">&nbsp;</td>
</tr>
<tr>
<th>Order ID</th>
<th>Menu Item</th>
@@ -154,11 +157,71 @@
</div>
</div>
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<h3>Sale Details</h3>
<div class="table-responsive">
<div class="tab-pane" id="customer" role="tabpanel">
</div>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<th width="20%"><h4>Customer Details</h4></th>
<th width="20%"></th>
<td></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Name</th>
<td><%= @customer.name %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Email</th>
<td><%= @customer.email %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Contact no</th>
<td><%= @customer.contact_no %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Company</th>
<td><%= @customer.company rescue '-' %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Date Of Birth</th>
<td><%= @customer.date_of_birth rescue '-' %> </td>
</tr>
<tr>
<th width="20%"><h4>Membership Details</h4></th>
<td width="20%"></td>
<td></td>
</tr>
<% if @membership == 0 %>
<tr>
<td colspan="2">"There is no membership data"</td>
</tr>
<% else %>
<% @membership.each do |member| %>
<tr>
<td width="20%"></td>
<th width="20%"><%= member["accountable_type"] %></th>
<td><%= member["balance"] %></td>
</tr>
<% end %>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@@ -175,7 +238,7 @@
<i class="fa fa-trash fa-lg"></i> Void Sale
</a>
<!-- <a href="<%= %>" style="margin-top: 10px " class="btn btn-success pull-right btn-lg">
<!-- <a href="<%= transactions_manual_complete_sale_path(@sale)%>" style="margin-top: 10px " class="btn btn-success pull-right btn-lg">
<i class="fa fa-invoice fa-lg"></i> Complete Sale
</a> -->
</div>

View File

@@ -60,8 +60,6 @@
var reason = $('input[type="radio"]:checked').val();
console.log(reason)
var url = 'manual_void_sale';alert(url)
var sale_id = $(this).find(".customer-id").text();
$.ajax({
type: 'POST',

View File

@@ -198,6 +198,8 @@ Rails.application.routes.draw do
namespace :transactions do
resources :sales
resources :orders
get "/sales/:sale_id/manual_complete_sale" =>"sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" =>"sales#void", :as => "void"
post "sales/:sale_id/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale"
end