update void and complete sale

This commit is contained in:
Aung Myo
2017-06-16 10:20:20 +06:30
parent f0ea6f3c56
commit 09a96372c8
7 changed files with 93 additions and 100 deletions

View File

@@ -15,6 +15,7 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues/new
def new
@dining_queue = DiningQueue.new
@queue_no = DiningQueue.generate_queue_no
end
# GET /crm/dining_queues/1/edit
@@ -25,7 +26,9 @@ class Crm::DiningQueuesController < BaseCrmController
# POST /crm/dining_queues.json
def create
@dining_queue = DiningQueue.new(dining_queue_params)
puts "ffffffffffff"
puts @queue_no
respond_to do |format|
if @dining_queue.save
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }

View File

@@ -0,0 +1,77 @@
class Transactions::ManualSalesController < ApplicationController
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
end
end
def manual_void_sale
sale_id = params[:sale_id]
reason = params[:reason]
sale = Sale.find(sale_id)
sale.sale_status = 'void'
sale.requested_by = current_login_employee.id
if sale.save
@sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason)
if sale.sale_orders
sale.sale_orders.each do |bo|
order =Order.find(bo.order_id)
order.status= 'void'
order.save
booking_order = BookingOrder.find_by_order_id(bo.order_id)
if booking_order.booking_id
booking = Booking.find(booking_order.booking_id)
dining_facility = booking.dining_facility
dining_facility.status = 'available'
dining_facility.save
end
end
end
end
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 = "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)
if sale.sale_orders
sale.sale_orders.each do |bo|
# order =Order.find(bo.order_id)
# order.status= 'void'
# order.save
booking_order = BookingOrder.find_by_order_id(bo.order_id)
if booking_order.booking_id
booking = Booking.find(booking_order.booking_id)
dining_facility = booking.dining_facility
dining_facility.status = 'available'
dining_facility.save
end
end
end
end
redirect_to transactions_sales_path
end
end

View File

@@ -60,7 +60,7 @@ class Transactions::SalesController < ApplicationController
else
@membership = 0
end
#end customer amount
#end customer amount
respond_to do |format|
format.html # show.html.erb
@@ -117,38 +117,6 @@ class Transactions::SalesController < ApplicationController
end
end
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
end
def manual_void_sale
sale_id = params[:sale_id]
reason = params[:reason]
sale = Sale.find(sale_id)
sale.sale_status = 'void'
sale.requested_by = current_login_employee.id
if sale.save
@sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason)
end
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

@@ -1,2 +1,7 @@
class DiningQueue < ApplicationRecord
def self.generate_queue_no
queue_no = DiningQueue.all.count + 1
return queue_no
end
end

View File

@@ -160,67 +160,7 @@
<div class="tab-pane" id="customer" role="tabpanel">
<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>
@@ -238,9 +178,9 @@
<i class="fa fa-trash fa-lg"></i> Void Sale
</a>
<!-- <a href="<%= transactions_manual_complete_sale_path(@sale)%>" 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> -->
</a>
</div>
</div>

View File

@@ -199,9 +199,9 @@ Rails.application.routes.draw 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"
get "/sales/:sale_id/manual_complete_sale" =>"manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" =>"manual_sales#void", :as => "void"
post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale"
end
#--------- Reports Controller Sections ------------#