transactions for order reservation and api for tax profile
This commit is contained in:
@@ -15,7 +15,9 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
|
||||
var active_class = "";
|
||||
if(key==0){
|
||||
active_class = "tr-active";
|
||||
showNewOrder(order[key],shop_code);
|
||||
if (typeof showNewOrder !== 'undefined' && $.isFunction(showNewOrder)) {
|
||||
showNewOrder(order[key],shop_code);
|
||||
}
|
||||
}
|
||||
var rowCount = key+1;
|
||||
var date = new Date(value.created_at);
|
||||
@@ -49,7 +51,9 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
|
||||
});
|
||||
}
|
||||
|
||||
customTableClick();
|
||||
if (typeof customTableClick !== 'undefined' && $.isFunction(customTableClick)) {
|
||||
customTableClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -158,6 +158,7 @@ $(document).ready(function() {
|
||||
//end Notificaiotn message
|
||||
});
|
||||
|
||||
/* start order reservation function */
|
||||
function audioPlayBackground(shop_code){
|
||||
//audio play
|
||||
var audio = new Audio('/'+shop_code+'-beep.mp3'); // define your audio
|
||||
@@ -166,3 +167,4 @@ function audioPlayBackground(shop_code){
|
||||
audio.play();
|
||||
// },10000);
|
||||
}
|
||||
/* end order reservation function */
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
//= require origami.js
|
||||
|
||||
$(function() {
|
||||
$("#discount").hide();
|
||||
$(".expected_time").hide();
|
||||
@@ -482,15 +484,6 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
|
||||
});
|
||||
}
|
||||
|
||||
function timeFormat(date){
|
||||
var isPM = date.getHours() >= 12;
|
||||
var isMidday = date.getHours() == 12;
|
||||
var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0),
|
||||
(date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') +
|
||||
(isPM ? ' PM' : ' AM');
|
||||
return time;
|
||||
}
|
||||
|
||||
function showNewOrder(order_reservation,shop_code){
|
||||
if((order_reservation!=undefined) && (order_reservation!=null) && (order_reservation!="")){
|
||||
var date = new Date(order_reservation.requested_time);
|
||||
|
||||
@@ -464,3 +464,14 @@ function createAccessCode(code) {
|
||||
localStorage.setItem("access_code",code);
|
||||
}
|
||||
|
||||
/* start order reservation function */
|
||||
function timeFormat(date){
|
||||
var isPM = date.getHours() >= 12;
|
||||
var isMidday = date.getHours() == 12;
|
||||
var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0),
|
||||
(date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') +
|
||||
(isPM ? ' PM' : ' AM');
|
||||
return time;
|
||||
}
|
||||
|
||||
/* end order reservation function */
|
||||
@@ -74,7 +74,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
|
||||
order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
from = "" #request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
@@ -84,8 +84,8 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
end
|
||||
end
|
||||
|
||||
puts "!!! send doemal ::"
|
||||
puts result
|
||||
# puts "!!! send doemal ::"
|
||||
# puts result
|
||||
|
||||
Rails.logger.debug "send status to doemal"
|
||||
Rails.logger.debug result
|
||||
@@ -129,4 +129,14 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
|
||||
render :json => result
|
||||
end
|
||||
|
||||
def get_tax_profile
|
||||
tax_profiles = TaxProfile.where("group_type = 'doemal_order'")
|
||||
|
||||
if !tax_profiles.nil?
|
||||
render :json => { :status => true, :data => tax_profiles }
|
||||
else
|
||||
render :json => { :status => false, :message => 'There is no record!' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
142
app/controllers/transactions/order_reservations_controller.rb
Normal file
142
app/controllers/transactions/order_reservations_controller.rb
Normal file
@@ -0,0 +1,142 @@
|
||||
class Transactions::OrderReservationsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_transactions_order_reservation, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /transactions/order_reservations
|
||||
# GET /transactions/order_reservations.json
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
filter = params[:filter]
|
||||
|
||||
if from.nil? && to.nil?
|
||||
@order_reservations = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.where("NOT order_reservation_status='new'")
|
||||
.order("order_reservation_id desc")
|
||||
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)
|
||||
else
|
||||
order_reservation = OrderReservation.search(filter,from,to)
|
||||
if order_reservation.length > 0
|
||||
@order_reservations = order_reservation
|
||||
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)
|
||||
else
|
||||
@order_reservations = 0
|
||||
end
|
||||
end
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @order_reservations }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# GET /transactions/order_reservations/1
|
||||
# GET /transactions/order_reservations/1.json
|
||||
def show
|
||||
|
||||
@order_reservation = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.where("order_reservations.order_reservation_id = ?", params[:id])
|
||||
.first()
|
||||
#get customer amount
|
||||
@customer = Customer.find(@order_reservation.customer_id)
|
||||
#get delivery details
|
||||
@delivery = Delivery.find_by_order_reservation_id(@order_reservation.order_reservation_id)
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @order_reservation }
|
||||
end
|
||||
end
|
||||
|
||||
# date range
|
||||
PERIOD = {
|
||||
"today" => 0,
|
||||
"yesterday" => 1,
|
||||
"this_week" => 2,
|
||||
"last_week" => 3,
|
||||
"last_7" => 4,
|
||||
"this_month" => 5,
|
||||
"last_month" => 6,
|
||||
"last_30" => 7,
|
||||
"this_year" => 8,
|
||||
"last_year" => 9
|
||||
}
|
||||
|
||||
def get_date_range_from_params
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
day_ref = Time.now.utc.getlocal
|
||||
|
||||
if from.present? && to.present?
|
||||
f_date = DateTime.parse(from)
|
||||
t_date = DateTime.parse(to)
|
||||
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
from = f_time.beginning_of_day.utc.getlocal
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
from = (day_ref - 1.day).beginning_of_day.utc
|
||||
to = (day_ref - 1.day).end_of_day.utc
|
||||
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_week"]
|
||||
from = (day_ref - 7.day).beginning_of_week.utc
|
||||
to = (day_ref - 7.day).end_of_week.utc
|
||||
when PERIOD["last_7"]
|
||||
from = (day_ref - 7.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_month"]
|
||||
from = (day_ref - 1.month).beginning_of_month.utc
|
||||
to = (day_ref - 1.month).end_of_month.utc
|
||||
when PERIOD["last_30"]
|
||||
from = (day_ref - 30.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_year"]
|
||||
from = (day_ref - 1.year).beginning_of_year.utc
|
||||
to = (day_ref - 1.year).end_of_year.utc
|
||||
end
|
||||
end
|
||||
|
||||
return from, to
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_transactions_order_reservation
|
||||
@transactions_order_reservation = OrderReservation.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def transactions_order_reservation_params
|
||||
params.require(:transactions_order_reservation).permit(:cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :order_reservation_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed)
|
||||
end
|
||||
end
|
||||
@@ -34,6 +34,8 @@ class Ability
|
||||
can :manage, Customer
|
||||
can :manage, DiningQueue
|
||||
|
||||
can :manage, OrderReservation
|
||||
|
||||
can :index, :dailysale
|
||||
can :index, :saleitem
|
||||
can :index, :receipt_no
|
||||
@@ -135,7 +137,10 @@ class Ability
|
||||
can :read, Sale
|
||||
can :update, Sale
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, Customer
|
||||
|
||||
can :manage, OrderReservation
|
||||
|
||||
can :get_customer, Customer
|
||||
can :add_customer, Customer
|
||||
can :update_sale_by_customer, Customer
|
||||
@@ -244,6 +249,8 @@ class Ability
|
||||
can :manage, Customer
|
||||
can :manage, DiningQueue
|
||||
|
||||
can :manage, OrderReservation
|
||||
|
||||
can :first_bill, :payment
|
||||
can :create, :payment
|
||||
can :show, :payment
|
||||
|
||||
@@ -365,41 +365,57 @@ class OrderReservation < ApplicationRecord
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
# if ENV["SERVER_MODE"] == 'cloud'
|
||||
# ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_order_reservation_by_shift(shift_sale_range,shift,from,to,provider)
|
||||
## => left join -> show all sales although no orders
|
||||
if provider.blank?
|
||||
provider = ''
|
||||
else
|
||||
if provider.present?
|
||||
provider = " and deliveries.provider = '#{provider}'"
|
||||
end
|
||||
end
|
||||
## => left join -> show all sales although no orders
|
||||
if provider.blank?
|
||||
provider = ''
|
||||
else
|
||||
if provider.present?
|
||||
provider = " and deliveries.provider = '#{provider}'"
|
||||
end
|
||||
end
|
||||
|
||||
query = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee, customers.name, customers.email")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.joins(" JOIN customers on customers.customer_id = order_reservations.customer_id")
|
||||
.joins(" JOIN sales on sales.sale_id = order_reservations.sale_id")
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id in (?) #{provider} and sales.sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.sale_status='completed' #{provider} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
else
|
||||
query = query.where("sales.sale_status='completed' and sales.receipt_date between ? and ? #{provider} and sale_payments.payment_amount != 0",from,to)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
end
|
||||
return query
|
||||
end
|
||||
query = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee, customers.name, customers.email")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.joins(" JOIN customers on customers.customer_id = order_reservations.customer_id")
|
||||
.joins(" JOIN sales on sales.sale_id = order_reservations.sale_id")
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id in (?) #{provider} and sales.sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.sale_status='completed' #{provider} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
else
|
||||
query = query.where("sales.sale_status='completed' and sales.receipt_date between ? and ? #{provider} and sale_payments.payment_amount != 0",from,to)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
end
|
||||
return query
|
||||
end
|
||||
|
||||
def self.search(filter,from,to)
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
else
|
||||
keyword = "status LIKE '%#{filter}%'"
|
||||
end
|
||||
|
||||
if from.present? && to.present?
|
||||
order_reservation = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.where("order_reservations.created_at >= ?" + " AND order_reservations.created_at <= ? and NOT status = 'new' ", from,to)
|
||||
query = order_reservation.where(keyword)
|
||||
else
|
||||
select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.where("status LIKE '%#{filter}%'")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
|
||||
@@ -114,6 +114,11 @@
|
||||
<a href="<%= transactions_surveys_path %>"><%= t("views.right_panel.detail.survey") %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if can? :manage, OrderReservation %>
|
||||
<li>
|
||||
<a href="<%= transactions_order_reservations_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% if can? :index, :dailysale %>
|
||||
|
||||
181
app/views/transactions/order_reservations/index.html.erb
Normal file
181
app/views/transactions/order_reservations/index.html.erb
Normal file
@@ -0,0 +1,181 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t :order_reservation %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="main-box-body clearfix p-l-5 p-r-5">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<%= form_tag transactions_order_reservations_path, :method => :get do %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label><%= t("views.right_panel.detail.enter_keyboards") %></label>
|
||||
<input type="text" id="filter" name="filter" class="form-control" placeholder="Status" style="margin-right: 10px;height: 34px;">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
|
||||
<select name="period" id="sel_period" class="form-control">
|
||||
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
|
||||
<option value="0">Today</option>
|
||||
<option value="1">Yesterday</option>
|
||||
<option value="2">This week</option>
|
||||
<option value="3">Last week</option>
|
||||
<option value="4">Last 7 days</option>
|
||||
<option value="5">This month</option>
|
||||
<option value="6">Last month</option>
|
||||
<option value="7">Last 30 days</option>
|
||||
<option value="8">This year</option>
|
||||
<option value="9">Last year</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class=""><%= t("views.right_panel.detail.from") %></label>
|
||||
<input class="form-control datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 34px;">
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class=""><%= t("views.right_panel.detail.to") %></label>
|
||||
<input class="form-control datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 34px;">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
|
||||
<label></label>
|
||||
<br><input type="submit" value="Search" class='btn btn-primary btn-md'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.order_reservation_id") %></th>
|
||||
<th><%= t("views.right_panel.detail.type") %></th>
|
||||
<th><%= t("views.right_panel.detail.requested_time") %></th>
|
||||
<th><%= t("views.right_panel.detail.status") %></th>
|
||||
<th><%= t :payment_method %></th>
|
||||
<th><%= t :payment %> <%= t("views.right_panel.detail.status")%></th>
|
||||
<th><%= t("views.right_panel.detail.sub_total") %></th>
|
||||
<th><%= t("views.right_panel.detail.discount_amount") %></th>
|
||||
<th><%= t("views.right_panel.detail.delivery_fee") %></th>
|
||||
<th><%= t("views.right_panel.detail.convenience_charge") %></th>
|
||||
<th><%= t("views.right_panel.detail.delivery_tax") %></th>
|
||||
<th><%= t("views.right_panel.detail.convenience_tax") %></th>
|
||||
<th><%= t("views.right_panel.detail.commercial_tax") %></th>
|
||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %></th>
|
||||
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end %>
|
||||
<%
|
||||
discount_amount = 0.0
|
||||
delivery_fee = 0.0
|
||||
convenience_charge = 0.0
|
||||
delivery_tax = 0.0
|
||||
convenience_tax = 0.0
|
||||
commercial_tax = 0.0
|
||||
%>
|
||||
<% if @order_reservations != 0 %>
|
||||
<% @order_reservations.each do |order_reservation| %>
|
||||
<%
|
||||
provider = ""
|
||||
discount_amount = order_reservation.discount_amount
|
||||
delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0
|
||||
convenience_charge = order_reservation.convenience_charge
|
||||
JSON.parse(order_reservation.taxes).each do |tax_data|
|
||||
if tax_data[0] == "delivery_tax"
|
||||
delivery_tax = tax_data[1]
|
||||
elsif tax_data[0] == "convenience_tax"
|
||||
convenience_tax = tax_data[1]
|
||||
elsif tax_data[0] == "commercial_tax"
|
||||
commercial_tax = tax_data[1]
|
||||
end
|
||||
end
|
||||
%>
|
||||
<%
|
||||
if order_reservation.provider == 'pick_up'
|
||||
provider = "Pick-Up"
|
||||
elsif order_reservation.provider == 'direct_delivery'
|
||||
provider = "Direct Delivery"
|
||||
else
|
||||
provider = order_reservation.provider
|
||||
end
|
||||
%>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<%= link_to order_reservation.order_reservation_id, transactions_order_reservation_path(order_reservation) %>
|
||||
<td><%= order_reservation.order_reservation_type %></td>
|
||||
<td><%= order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></td>
|
||||
<td><%= order_reservation.status %></td>
|
||||
<td><%= provider%></td>
|
||||
<td><%= order_reservation.payment_type%></td>
|
||||
<td><%= order_reservation.payment_status%></td>
|
||||
<td><%= number_with_precision(order_reservation.total_amount, precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(discount_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(delivery_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(convenience_charge , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(delivery_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(convenience_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(commercial_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(order_reservation.total_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(order_reservation.grand_total , precision:precision.to_i, delimiter:delimiter) rescue '0.0' %></td>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<tr><td colspan="16"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<% if @order_reservations != 0 %>
|
||||
<%= paginate @order_reservations %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#from').val("<%= params[:from] %>");
|
||||
$('#to').val("<%= params[:to] %>");
|
||||
$('#sel_period').val("<%= params[:period] %>");
|
||||
$('#filter').val("<%= params[:filter] %>");
|
||||
});
|
||||
</script>
|
||||
257
app/views/transactions/order_reservations/show.html.erb
Executable file
257
app/views/transactions/order_reservations/show.html.erb
Executable file
@@ -0,0 +1,257 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item"><a href="<%= transactions_order_reservations_path %>"><%= t :order_reservation %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t :details %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', transactions_order_reservations_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end %>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#order_reservation" role="tab"><%= t :order_reservation_details %> </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#customer" role="tab"><%= t :customer_details %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#delivery" role="tab"><%= t :delivery_details %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px;">
|
||||
<div class="tab-pane active" id="order_reservation" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t :reference_number %></th>
|
||||
<th><%= t("views.right_panel.detail.type") %></th>
|
||||
<th><%= t("views.right_panel.detail.requested_time") %></th>
|
||||
<th><%= t("views.right_panel.detail.cooking_time") %></th>
|
||||
<th><%= t("views.right_panel.detail.status") %></th>
|
||||
<th><%= t("views.right_panel.detail.remark") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><%= @order_reservation.transaction_ref %></td>
|
||||
<td><%= @order_reservation.order_reservation_type %></td>
|
||||
<td><%= @order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></td>
|
||||
<td><%= @order_reservation.expected_waiting_time rescue '-' %></td>
|
||||
<td><%= @order_reservation.status %></td>
|
||||
<td><%= @order_reservation.order_remark ? @order_reservation.order_remark : @order_reservation.reservation_remark %></td>
|
||||
</tr>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<th><%= t :sale %> <%= t("views.right_panel.detail.item_txt") %> <%= t("views.right_panel.detail.name_txt2") %></th>
|
||||
<th><%= t("views.right_panel.detail.qty") %></th>
|
||||
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||
<th><%= t("views.right_panel.detail.total_price") %></th>
|
||||
<th><%= t("views.right_panel.detail.created_at") %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<% @order_reservation.order_reservation_items.each do |item| %>
|
||||
<tr>
|
||||
<td><%=item.item_name rescue ' '%></td>
|
||||
<td><%=item.qty rescue ' '%></td>
|
||||
<td><%= number_with_precision(item.price > 0 ? item.price : item.unit_price, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
<td><%= number_with_precision(item.price > 0 ? item.qty * item.price : item.qty * item.unit_price, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
<td><%=l item.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<%
|
||||
discount_amount = 0.0
|
||||
delivery_fee = 0.0
|
||||
convenience_charge = 0.0
|
||||
delivery_tax = 0.0
|
||||
convenience_tax = 0.0
|
||||
commercial_tax = 0.0
|
||||
|
||||
total_discount_amount = 0
|
||||
total_delivery_fee = 0
|
||||
total_convenience_charge = 0
|
||||
total_delivery_tax = 0
|
||||
total_convenience_tax = 0
|
||||
total_commercial_tax = 0
|
||||
total_tax = 0.0
|
||||
total_amount = 0.0
|
||||
grand_total = 0.0
|
||||
%>
|
||||
<%
|
||||
discount_amount = @order_reservation.discount_amount
|
||||
delivery_fee = @order_reservation.delivery_fee ? @order_reservation.delivery_fee : 0.0
|
||||
convenience_charge = @order_reservation.convenience_charge
|
||||
JSON.parse(@order_reservation.taxes).each do |tax_data|
|
||||
if tax_data[0] == "delivery_tax"
|
||||
delivery_tax = tax_data[1]
|
||||
elsif tax_data[0] == "convenience_tax"
|
||||
convenience_tax = tax_data[1]
|
||||
elsif tax_data[0] == "commercial_tax"
|
||||
commercial_tax = tax_data[1]
|
||||
end
|
||||
end
|
||||
total_discount_amount += discount_amount.to_f
|
||||
total_delivery_fee += delivery_fee.to_f
|
||||
total_convenience_charge += convenience_charge.to_f
|
||||
total_delivery_tax += delivery_tax.to_f
|
||||
total_convenience_tax += convenience_tax.to_f
|
||||
total_commercial_tax += commercial_tax.to_f
|
||||
total_tax += @order_reservation.total_tax.to_f
|
||||
total_amount += @order_reservation.total_amount.to_f
|
||||
grand_total += @order_reservation.grand_total.to_f
|
||||
%>
|
||||
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_amount, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% if total_discount_amount > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.discount_amount") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_discount_amount, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if total_delivery_fee > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.delivery_fee") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_delivery_fee, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if total_convenience_charge > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.convenience_charge") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_convenience_charge, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- <% if total_delivery_tax > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.delivery_tax") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_delivery_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if total_convenience_tax > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.convenience_tax") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_convenience_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if total_commercial_tax > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.commercial_tax") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_commercial_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %> -->
|
||||
<% if total_tax > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %></td>
|
||||
<td colspan="3"><%= number_with_precision(total_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if grand_total > 0 %>
|
||||
<tr style="border-top:2px solid #000">
|
||||
<td colspan=2 style="text-align:center"></td>
|
||||
<td><%= t("views.right_panel.detail.grand_total") %> </td>
|
||||
<td colspan="3"><%= number_with_precision(grand_total, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- panel-2 -->
|
||||
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.company") %></th>
|
||||
<th><%= t("views.right_panel.detail.contact_no") %></th>
|
||||
<th><%= t("views.right_panel.detail.email") %></th>
|
||||
<th><%= t("views.right_panel.detail.nrc_passport_no") %></th>
|
||||
<th><%= t("views.right_panel.detail.address") %></th>
|
||||
<th><%= t("views.right_panel.detail.dob") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% if !@customer.nil? %>
|
||||
<tr>
|
||||
<td><%= @customer.name %></td>
|
||||
<td><%= @customer.company rescue '-' %></td>
|
||||
<td><%= @customer.contact_no %></td>
|
||||
<td><%= @customer.email %></td>
|
||||
<td><%= @customer.nrc_no %></td>
|
||||
<td><%= @customer.address%></td>
|
||||
<td><%= @customer.date_of_birth %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- panel-3 -->
|
||||
<div class="tab-pane" id="delivery" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.provider") %></th>
|
||||
<th><%= t("views.right_panel.detail.delivery_type") %></th>
|
||||
<th><%= t("views.right_panel.detail.address") %></th>
|
||||
<th><%= t("views.right_panel.detail.township") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if !@delivery.nil? %>
|
||||
<%
|
||||
if @delivery.provider == 'pick_up'
|
||||
provider = "Pick-Up"
|
||||
elsif @delivery.provider == 'direct_delivery'
|
||||
provider = "Direct Delivery"
|
||||
else
|
||||
provider = @delivery.provider
|
||||
end
|
||||
%>
|
||||
<tr>
|
||||
<td><%= provider%></td>
|
||||
<td><%= @delivery.delivery_type%></td>
|
||||
<td><%= @delivery.address%></td>
|
||||
<td><%= @delivery.township%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,6 +80,7 @@ en:
|
||||
delivering: "Delivering"
|
||||
completed: "Completed"
|
||||
processed: "Processed"
|
||||
delivery_details: "Delivery Details"
|
||||
|
||||
views:
|
||||
btn:
|
||||
@@ -475,11 +476,15 @@ en:
|
||||
requested_time: "Requested Time"
|
||||
provider: "Provider"
|
||||
delivery_fee: "Delivery Fee"
|
||||
delivery_type: "Delivery Type"
|
||||
delivery_tax: "Delivery Tax"
|
||||
convenience_charge: "Convenience Charge"
|
||||
convenience_tax: "Convenience Tax"
|
||||
commercial_tax: "Commercial Tax"
|
||||
select_providers: "Select Providers"
|
||||
order_reservation: "Order Reservation"
|
||||
cooking_time: "Cooking Time"
|
||||
township: "Township"
|
||||
|
||||
code_txt: "code "
|
||||
charge_txt: "charge"
|
||||
|
||||
@@ -75,6 +75,7 @@ mm:
|
||||
delivering: "Delivering"
|
||||
completed: "Completed"
|
||||
processed: "Processed"
|
||||
delivery_details: "Delivery Details"
|
||||
|
||||
views:
|
||||
btn:
|
||||
@@ -469,11 +470,15 @@ mm:
|
||||
requested_time: "Requested Time"
|
||||
provider: "Provider"
|
||||
delivery_fee: "Delivery Fee"
|
||||
delivery_type: "Delivery Type"
|
||||
delivery_tax: "Delivery Tax"
|
||||
convenience_charge: "Convenience Charge"
|
||||
convenience_tax: "Convenience Tax"
|
||||
commercial_tax: "Commercial Tax"
|
||||
select_providers: "Select Providers"
|
||||
order_reservation: "Order Reservation"
|
||||
cooking_time: "Cooking Time"
|
||||
township: "Township"
|
||||
|
||||
code_txt: "ကုတ်ဒ် "
|
||||
charge_txt: "ကောက်ခံသည်"
|
||||
|
||||
@@ -89,6 +89,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "customer" => "order_reservation#check_customer"
|
||||
post "order" => "order_reservation#create"
|
||||
post "callback/:id" => "order_reservation#update_status"
|
||||
get "get_tax_profile" => "order_reservation#get_tax_profile"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -429,6 +430,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
resources :bookings
|
||||
resources :shift_sales
|
||||
resources :surveys
|
||||
resources :order_reservations
|
||||
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user