update customer and sale

This commit is contained in:
Aung Myo
2017-06-14 15:58:41 +06:30
parent c155c86970
commit 914069e3af
8 changed files with 378 additions and 128 deletions

View File

@@ -218,7 +218,7 @@ $(document).ready(function(){
'<td class="charges-name">' + data["response_data"]["data"][i]["accountable_type"] +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").append(row);
$(".rebate_amount").html(row);
}
}

View File

@@ -17,9 +17,9 @@ class Crm::CustomersController < BaseCrmController
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
if flash["errors"]
@crm_customer.valid?
end
# if flash["errors"]
# @crm_customer.valid?
# end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
@@ -65,15 +65,19 @@ class Crm::CustomersController < BaseCrmController
'Accept' => 'application/json'
}
)
@type = "-"
@balance = 0.00
response["data"].each do |res|
if res["accountable_type"] == "RebateAccount"
@balance = res["balance"]
@type = "RebateAccount"
end
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
# @type = "-"
# @balance = 0.00
# response["data"].each do |res|
# if res["accountable_type"] == "RebateAccount"
# @balance = res["balance"]
# @type = "RebateAccount"
# end
# end
#end customer amount

View File

@@ -10,7 +10,7 @@ class Transactions::SalesController < ApplicationController
today = Date.today
if receipt_no.nil?
@sales = Sale.order("sale_id").page(params[:page])
@sales = Sale.order("sale_id")
#@products = Product.order("name").page(params[:page]).per(5)
else
@sales = Sale.search(receipt_no)
@@ -27,7 +27,16 @@ class Transactions::SalesController < ApplicationController
def show
@sale = Sale.find(params[:id])
# @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id)
@order_items = []
@sale.sale_orders.each do |sale_order|
order = Order.find(sale_order.order_id)
#if (order.status == "new")
@order_items = @order_items + order.order_items
#end
end
@sale_receivables = SalePayment.where('sale_id = ?', @sale.id)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sale }

View File

@@ -74,22 +74,29 @@
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['name'] %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group">
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['contact_no'] %></span>
<% end -%>
</div>
<div class="form-group">
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['email'] %></span>
<% end -%>
</div>
<div class="form-group">

View File

@@ -19,31 +19,64 @@
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
<div class="tab-pane active" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<tr>
<th>Name</th>
<td><%= @crm_customer.name %></td>
</tr>
<tr>
<th>Email</th>
<td><%= @crm_customer.email %></td>
</tr>
<tr>
<th>Contact no</th>
<td><%= @crm_customer.contact_no %></td>
</tr>
<tr>
<th>Company</th>
<td><%= @crm_customer.company %></td>
</tr>
<tr>
<th>Date Of Birth</th>
<td><%= @crm_customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<br>
<h4>Customer Profile</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<tr>
<th>Name</th>
<td><%= @crm_customer.name %></td>
</tr>
<tr>
<th>Email</th>
<td><%= @crm_customer.email %></td>
</tr>
<tr>
<th>Contact no</th>
<td><%= @crm_customer.contact_no %></td>
</tr>
<tr>
<th>Company</th>
<td><%= @crm_customer.company %></td>
</tr>
<tr>
<th>Date Of Birth</th>
<td><%= @crm_customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<h4>Membership Detail</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<% if @membership == 0 %>
<tr>
<td colspan="2">"There is no membership data"</td>
</tr>
<% else %>
<% @membership.each do |member| %>
<tr>
<th><%= member["accountable_type"] %></th>
<td><%= member["balance"] %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@@ -3,10 +3,10 @@
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= settings_orders_path %>">Order</a>
<a href="<%= transactions_orders_path %>">Order</a>
</li>
<li class="active">
<a href="<%= settings_orders_path %>"><%= @order.order_id %></a>
<a href="<%= transactions_orders_path %>"><%= @order.order_id %></a>
</li>
</ol>
</div>
@@ -70,7 +70,7 @@
<% end %>
</tbody>
</table>
<a href="<%= settings_orders_path%>" class="btn btn-primary pull-left">
<a href="<%= transactions_orders_path%>" class="btn btn-primary pull-left">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</div>

View File

@@ -3,101 +3,186 @@
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= settings_sales_path %>">Sale</a>
<a href="<%= transactions_sales_path %>">Sale</a>
</li>
<li class="active">
<a href="<%= settings_sales_path %>"><%= @sale.sale_id %></a>
<a href="<%= transactions_sales_path %>"><%= @sale.sale_id %></a>
</li>
</ol>
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Receipt Date </th>
<th>Receipt no</th>
<th>Cashier</th>
<th>Sales status</th>
<th>Receipt generated at</th>
</tr>
</thead>
<div class="col-lg-10 col-md-10 col-sm-10">
<!-- Column One -->
<tbody>
<tr>
<td><%= @sale.receipt_date.strftime("%d-%M-%Y") %></td>
<td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at.strftime("%d-%m-%Y") %> </td>
</tr>
<tr style="border-top:2px solid #000">
<th>Sale item name</th>
<th> Qty</th>
<th>Unit price</th>
<th>Total pirce </th>
<th>Created at</th>
</tr>
<% @sale.sale_items.each do |s| %>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<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>
</li>
<!-- <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Sales</a>
</li> -->
</ul>
<!-- Nav tabs - End -->
<tr>
<td><%=s.product_name rescue ' '%></td>
<td><%=s.qty rescue ' '%></td>
<td><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
</tr>
<% end %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td>Total</td>
<td colspan="2"><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Tax</td>
<td colspan="2"><%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Discount</td>
<td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Grand Total</td>
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr><td>&nbsp;<td></tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Change</td>
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
<div class="tab-pane active" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<th>Receipt Date </th>
<th>Receipt no</th>
<th>Cashier</th>
<th>Sales status</th>
<th>Receipt generated at</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @sale.receipt_date.strftime("%d-%M-%Y") %></td>
<td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at.strftime("%d-%m-%Y") %> </td>
</tr>
<tr style="border-top:2px solid #000">
<th>Sale item name</th>
<th> Qty</th>
<th>Unit price</th>
<th>Total pirce </th>
<th>Created at</th>
</tr>
<% @sale.sale_items.each do |s| %>
<tr>
<td><%=s.product_name rescue ' '%></td>
<td><%=s.qty rescue ' '%></td>
<td><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
</tr>
<% end %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td>Total</td>
<td colspan="2"><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Discount</td>
<td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Tax</td>
<td colspan="2"><%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Grand Total</td>
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr><td>&nbsp;<td></tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Change</td>
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<% @sale_receivables.each do |r|%>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Payment <%= r.payment_method rescue ' '%></td>
<td><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="booking" role="tabpanel">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Order ID</th>
<th>Menu Item</th>
<th>QTY</th>
<th>Unit Price </th>
<th>Option</th>
<th>Status</th>
<th>Waiter</th>
<th>Created at </th>
</tr>
</thead>
<tbody>
<% @order_items.each do |order_item| %>
<tr>
<td><%= order_item.order_id %></td>
<td><%= order_item.item_name %></td>
<td><%= order_item.qty %></td>
<td><%= order_item.price %></td>
<td><%= order_item.options %></td>
<td><%= order_item.order_item_status %></td>
<td><%= order_item.item_order_by %> </td>
<td><%= order_item.created_at.strftime("%d-%m-%y") %></td>
</tr>
<% end %>
</tbody>
</table>
</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>
</div>
</tbody>
</table>
<a href="<%= settings_sales_path%>" class="btn btn-primary pull-left">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</div>
</div>
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
<i class="fa fa-trash fa-lg"></i> Void Sale
</a>
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
<i class="fa fa-invoice fa-lg"></i> Complete Sale
</a>
</div>
</div>

View File

@@ -0,0 +1,112 @@
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= transactions_sales_path %>">Sale</a>
</li>
<li class="active">
<a href="<%= transactions_sales_path %>"><%= @sale.sale_id %></a>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td colspan="4">
</td>
<td>
</td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<th>Receipt Date </th>
<th>Receipt no</th>
<th>Cashier</th>
<th>Sales status</th>
<th>Receipt generated at</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @sale.receipt_date.strftime("%d-%M-%Y") %></td>
<td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at.strftime("%d-%m-%Y") %> </td>
</tr>
<tr style="border-top:2px solid #000">
<th>Sale item name</th>
<th> Qty</th>
<th>Unit price</th>
<th>Total pirce </th>
<th>Created at</th>
</tr>
<% @sale.sale_items.each do |s| %>
<tr>
<td><%=s.product_name rescue ' '%></td>
<td><%=s.qty rescue ' '%></td>
<td><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
</tr>
<% end %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td>Total</td>
<td colspan="2"><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Discount</td>
<td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Tax</td>
<td colspan="2"><%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Grand Total</td>
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr><td>&nbsp;<td></tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Change</td>
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>