Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_material_ui

This commit is contained in:
Aung Myo
2017-12-12 18:06:52 +06:30
10 changed files with 351 additions and 229 deletions

View File

@@ -86,10 +86,10 @@ class HomeController < ApplicationController
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
pay = Sale.payment_sale('card', today)
@sale_data.push({'card' => pay})
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(payment.payment_method, today)
@sale_data.push({payment.payment_method => pay})
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
@summ_sale = Sale.summary_sale_receipt(today)

View File

@@ -1038,7 +1038,7 @@ end
else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end
query.sum("sp.payment_amount")
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end
def self.total_customer(today)

View File

@@ -323,7 +323,7 @@ class SalePayment < ApplicationRecord
self.sale.sale_status = "completed"
if MembershipSetting.find_by_rebate(1) && is_foc == 0
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
response = rebat(sObj)
#record an payment in sale-audit
@@ -369,6 +369,7 @@ class SalePayment < ApplicationRecord
def table_update_status(sale_obj)
status = true
booking = Booking.find_by_sale_id(sale_obj.id)
if booking
table = DiningFacility.find(booking.dining_facility_id)
bookings = table.bookings
@@ -377,12 +378,15 @@ class SalePayment < ApplicationRecord
if tablebooking.sale_id
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
status = false
else
status = true
end
else
status = false
end
end
end
if status
table.status = "available"
table.save
@@ -410,6 +414,7 @@ class SalePayment < ApplicationRecord
# overall_dis = SaleItem.get_overall_discount(sObj.id)
overall_dis = sObj.total_discount
if credit != 1
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
merchant_uid = memberaction.merchant_account_id.to_s
@@ -438,87 +443,89 @@ class SalePayment < ApplicationRecord
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
redeem_amount = payparcost + overall_dis
total_percentage = 0
redeem_amount = payparcost + overall_dis
type_arr = []
Rails.logger.debug "Get Member Campaign"
Rails.logger.debug response.to_json
# Check for present response fields
if response["membership_campaign_data"].present?
response["membership_campaign_data"].each do |a|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
type_arr.push(data)
end
end
total_percentage = 0
rebate_arr =[]
campaign_method.each do |a|
data = {:type => a[:type], :amount => a[:amount]}
type_arr.each do |si|
if si[:type] == a[:type]
if credit == 1
data[:amount] = 0
else
amount = (redeem_amount / total_percentage)*si[:percentage]
actual = a[:amount] - amount
data[:amount] = actual
end
type_arr = []
Rails.logger.debug "Get Member Campaign"
Rails.logger.debug response.to_json
# Check for present response fields
if response["membership_campaign_data"].present?
response["membership_campaign_data"].each do |a|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
type_arr.push(data)
end
end
rebate_arr.push(data)
end
total_amount = rebate_prices - payparcost - overall_dis
if credit == 1
total_amount = 0
end
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => {
generic_customer_id:generic_customer_id ,
total_sale_transaction_amount: sObj.grand_total,
merchant_uid:merchant_uid,
total_amount: total_amount,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
campaign_method: rebate_arr.to_json,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=2'
}, :timeout => 10)
rescue Net::OpenTimeout
response = { "status": false , "message": "Connect To" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
rebate_arr =[]
campaign_method.each do |a|
data = {:type => a[:type], :amount => a[:amount]}
type_arr.each do |si|
if si[:type] == a[:type]
if credit == 1
data[:amount] = 0
else
amount = (redeem_amount / total_percentage)*si[:percentage]
actual = a[:amount] - amount
data[:amount] = actual
end
end
end
rebate_arr.push(data)
end
total_amount = rebate_prices - payparcost - overall_dis
if credit == 1
total_amount = 0
end
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => {
generic_customer_id:generic_customer_id ,
total_sale_transaction_amount: sObj.grand_total,
merchant_uid:merchant_uid,
total_amount: total_amount,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
campaign_method: rebate_arr.to_json,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=2'
}, :timeout => 10)
rescue Net::OpenTimeout
response = { "status": false , "message": "Connect To" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
Rails.logger.debug "Rebage Response"
Rails.logger.debug response.to_json
return response
end
Rails.logger.debug "Rebage Response"
Rails.logger.debug response.to_json
return response
end
else
response = { "status": "no_member", "message": "Not membership"}
response = { "status": "no_member", "message": "Not membership"}
end
end

View File

@@ -13,74 +13,85 @@
<div class="row clearfix">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="card">
<div class="body table-responsive">
<table class="table table-hover table-striped">
<!-- <div class="table-responsive">
<table class="table table-striped"> -->
<thead>
<tr>
<td colspan="7">
<!-- <button id="member_acc_no" class="btn btn-success btn-md"><span class="fa fa-credit-card"></span> Member Card</button>
<button id="qr_code" class="btn btn-danger btn-md">
<span class="fa fa-credit-card"></span> QR CODE
</button> -->
<div class="body">
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control">
<input type="hidden" name="type" id="type" value="">
</div>
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn bg-blue waves-effect" style="margin-right: 10px;"><%= t("views.btn.search") %></button>
<!-- </div> -->
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;"><%= t("views.btn.memeber_card") %></button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
<div class="body">
<div class="row p-l-20 p-t-20">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control">
<input type="hidden" name="type" id="type" value="">
</div>
<% end %>
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn btn-sm bg-blue waves-effect" style="margin-right: 10px;"><%= t("views.btn.search") %></button>
<!-- </div> -->
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;"><%= t("views.btn.memeber_card") %></button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
</div>
</td>
</tr>
<tr>
<th></th>
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th><%= t("views.right_panel.detail.contact_no") %></th>
<th><%= t("views.right_panel.detail.email") %></th>
<th><%= t("views.right_panel.detail.action") %></th>
</tr>
</thead>
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<%= @i += 1 %>
<%else%>
-
<% end %>
</td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.card_no rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<td><%= link_to t("views.btn.show"), crm_customer_path(crm_customer) %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="7"><strong><p style="text-align: center;margin-bottom: -1px">There is no data for search <%=@filter%>....</p></strong></td></tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @crm_customers %>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="table-responsive">
<table class="table table-hover table-striped" style="width:100%">
<!-- <div class="table-responsive">
<table class="table table-striped"> -->
<thead>
<!-- <tr>
<td colspan="7">
<button id="member_acc_no" class="btn btn-success btn-md"><span class="fa fa-credit-card"></span> Member Card</button>
<button id="qr_code" class="btn btn-danger btn-md">
<span class="fa fa-credit-card"></span> QR CODE
</button>
</td>
</tr>-->
<tr>
<th></th>
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.email") %></th>
<th><%= t("views.right_panel.detail.action") %></th>
</tr>
</thead>
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" name="checkbox" class="checkbox_check" >
</td>
<td>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<%= @i += 1 %>
<%else%>
-
<% end %>
</td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.card_no rescue '-' %></td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.contact_no %></td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.email %></td>
<td><%= link_to t("views.btn.show"), crm_customer_path(crm_customer) %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="7"><strong><p style="text-align: center;margin-bottom: -1px">There is no data for search <%=@filter%>....</p></strong></td></tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @crm_customers %>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">

View File

@@ -157,16 +157,17 @@
<% end %>
<% end %>
<% end %>
<tr>
<td><%= t("views.right_panel.detail.card_sale") %> : </td>
<td align="right">
<% total_card = 0.0 %>
<% @sale_data.each do |data| %>
<% total_card = data["card"] %>
<% break end %>
<%= total_card.to_f %>
</td>
</tr>
<% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %>
<% if !total_card.nil? %>
<tr>
<td><%= t("views.right_panel.detail.card_sale") %> : </td>
<td align="right">
<%= total_card["card"].to_f %>
</td>
</tr>
<% end %>
<% end %>
</table>
</div>

View File

@@ -14,86 +14,84 @@
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="card">
<div class="main-box-body clearfix" id="order-detail-slimscroll" style="">
<div class="table-responsive">
<table id="origami-crm-table" class="table table-striped">
<div class="body">
<div class="row p-t-20 p-l-20">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<!-- <% path ="/origami/#{@sale_id}/customers" %>
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="input-append col-md-7 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
<input type="hidden" name="type" id="type" value="">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
<% path ="/origami/#{@sale_id}/customers" %>
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<thead>
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
<input type="hidden" name="type" id="type" value="<%= @dining_facility.type %>">
<tr>
<td colspan="6">
<!-- <% path ="/origami/#{@sale_id}/customers" %>
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="input-append col-md-7 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
<input type="hidden" name="type" id="type" value="">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
<div class="body">
<% path ="/origami/#{@sale_id}/customers" %>
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
<button type="submit" class="btn bg-blue waves-effect waves-effect">Search</button>
</div>
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
<input type="hidden" name="type" id="type" value="<%= @dining_facility.type %>">
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;">Member Card</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
<button type="submit" class="btn bg-blue waves-effect waves-effect">Search</button>
</div>
</div>
<% end %>
</div>
</div>
<div class="main-box-body clearfix" id="order-detail-slimscroll" style="">
<div class="table-responsive">
<table id="origami-crm-table" class="table table-striped" style="width:100%">
<thead>
<tr>
<th></th>
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.email") %></th>
<!-- <th>Paypar No</th> -->
</tr>
</thead>
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;">Member Card</button>
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
</div>
<% end %>
</div>
</td>
</tr>
<tr>
<th></th>
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th><%= t("views.right_panel.detail.contact_no") %></th>
<th><%= t("views.right_panel.detail.email") %></th>
<!-- <th>Paypar No</th> -->
</tr>
</thead>
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<%= @i += 1 %>
<%else%>
-
<% end %>
</td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<!-- <td><%= crm_customer.paypar_account_no %></td> -->
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<%= @i += 1 %>
<%else%>
-
<% end %>
</td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td style="width:20%;word-break: break-all;"><%= crm_customer.contact_no %></td>
<td style="width:20%;word-break: break-all;"><%= crm_customer.email %></td>
<!-- <td><%= crm_customer.paypar_account_no %></td> -->
</tr>
<% end %>
<%else%>
<tr><td colspan="5"><p style="text-align:center"><strong>There are no record for your search</strong></p></td></tr>
<% end %>
</tbody>
</table>
<br>
</tr>
<% end %>
<%else%>
<tr><td colspan="5"><p style="text-align:center"><strong>There are no record for your search</strong></p></td></tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @crm_customers %>
<%= paginate @crm_customers %>
</div>
</div>
</div>
</div>

View File

@@ -237,7 +237,7 @@
end
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
count += 1
@@ -306,7 +306,7 @@
<%
if @status_sale == 'sale'
unless @order_items.nil?
unless @order_items.nil? || @order_items.empty?
%>
Pending New Order
<table class="table table-striped">

View File

@@ -147,7 +147,7 @@
$('#used_amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#valid_amount').val();
var remain_amount = $('#redeemamt').val();
$('#used_amount').text(remain_amount);
break;

View File

@@ -232,7 +232,7 @@
end
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item |
count += 1
@@ -291,7 +291,7 @@
<br>
<%
if @status_sale == 'sale'
unless @order_items.nil?
unless @order_items.nil? || @order_items.empty?
%>
Pending New Order
<table class="table table-striped">