Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -48,4 +48,30 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_credit_payment
|
||||||
|
arr_sale = JSON.parse(params[:data])
|
||||||
|
if !ShiftSale.current_shift.nil?
|
||||||
|
if !arr_sale.nil?
|
||||||
|
arr_sale.each do |arr_sale|
|
||||||
|
arr_sale.each do |sale|
|
||||||
|
if(Sale.exists?(sale[0]))
|
||||||
|
saleObj = Sale.find(sale[0])
|
||||||
|
remark = "credit note payment for Receipt No #{saleObj.receipt_no}"
|
||||||
|
sale_payment = SalePayment.new
|
||||||
|
@status, @sale = sale_payment.process_payment(saleObj, current_user, sale[1], "cash", remark, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if @status
|
||||||
|
render :json => {status: true}
|
||||||
|
else
|
||||||
|
render :json => {status: false, message: 'Some error occurred!'}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render :json => {status: false, message: 'No current shift open for this employee!'}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class Reports::CreditPaymentController < BaseReportController
|
|||||||
authorize_resource :class => false
|
authorize_resource :class => false
|
||||||
def index
|
def index
|
||||||
@filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']]
|
@filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']]
|
||||||
|
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
|
||||||
from, to = get_date_range_from_params
|
from, to = get_date_range_from_params
|
||||||
|
|
||||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||||
@@ -18,7 +19,8 @@ authorize_resource :class => false
|
|||||||
end
|
end
|
||||||
|
|
||||||
@filter = params[:filter_check]
|
@filter = params[:filter_check]
|
||||||
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter)
|
@order_source = params[:order_source]
|
||||||
|
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source)
|
||||||
|
|
||||||
@from = from
|
@from = from
|
||||||
@to = to
|
@to = to
|
||||||
|
|||||||
@@ -6,27 +6,34 @@ class Transactions::CreditNotesController < ApplicationController
|
|||||||
# GET /transactions/sales
|
# GET /transactions/sales
|
||||||
# GET /transactions/sales.json
|
# GET /transactions/sales.json
|
||||||
def index
|
def index
|
||||||
|
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
|
||||||
@customers = Customer.all
|
@customers = Customer.all
|
||||||
|
|
||||||
filter = params[:filter]
|
filter = params[:filter]
|
||||||
customer = params[:customer]
|
customer = params[:customer]
|
||||||
from = params[:from]
|
from = params[:from]
|
||||||
to = params[:to]
|
to = params[:to]
|
||||||
|
order_source = params[:order_source]
|
||||||
if filter.nil? && from.nil? && to.nil? && customer.nil?
|
|
||||||
@credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
|
||||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
|
||||||
else
|
|
||||||
sale = Sale.search_credit_sales(customer,filter,from,to)
|
|
||||||
if sale.count > 0
|
|
||||||
@credit_notes = sale
|
|
||||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
|
||||||
else
|
|
||||||
@credit_notes = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil?
|
||||||
|
@credit_notes = Sale.select("sales.*, orders.source")
|
||||||
|
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||||
|
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
||||||
|
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
|
||||||
|
THEN NULL ELSE payment_method='creditnote' END)")
|
||||||
|
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
|
||||||
|
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||||
|
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
|
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||||
|
else
|
||||||
|
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
|
||||||
|
if !sale.nil?
|
||||||
|
@credit_notes = sale
|
||||||
|
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||||
|
else
|
||||||
|
@credit_notes = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: @credit_notes }
|
format.json { render json: @credit_notes }
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class OrderReservation < ApplicationRecord
|
|||||||
order_reservation.transaction_ref = order_reserve[:reference]
|
order_reservation.transaction_ref = order_reserve[:reference]
|
||||||
if order_reserve[:order_info]
|
if order_reserve[:order_info]
|
||||||
order_reservation.item_count = order_reserve[:order_info][:items].count
|
order_reservation.item_count = order_reserve[:order_info][:items].count
|
||||||
|
order_reservation.payment_methods = order_reserve[:payment_info][:payment_methods].to_json
|
||||||
order_reservation.payment_type = order_reserve[:payment_info][:payment_type]
|
order_reservation.payment_type = order_reserve[:payment_info][:payment_type]
|
||||||
order_reservation.payment_status = order_reserve[:payment_info][:payment_status]
|
order_reservation.payment_status = order_reserve[:payment_info][:payment_status]
|
||||||
order_reservation.payment_ref = order_reserve[:payment_info][:payment_ref]
|
order_reservation.payment_ref = order_reserve[:payment_info][:payment_ref]
|
||||||
@@ -164,8 +165,12 @@ class OrderReservation < ApplicationRecord
|
|||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash")
|
if(order.payment_type == "COD")
|
||||||
|
sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash")
|
||||||
|
else
|
||||||
|
remark = "credit payment for Receipt No #{saleObj.receipt_no}"
|
||||||
|
@status, @sale = sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "creditnote", remark)
|
||||||
|
end
|
||||||
#order status send to doemal
|
#order status send to doemal
|
||||||
callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED)
|
callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED)
|
||||||
#order reservation status updated
|
#order reservation status updated
|
||||||
|
|||||||
@@ -737,7 +737,7 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search_credit_sales(customer,filter,from,to)
|
def self.search_credit_sales(customer,filter,from,to,order_source="")
|
||||||
if filter.blank?
|
if filter.blank?
|
||||||
keyword = ''
|
keyword = ''
|
||||||
else
|
else
|
||||||
@@ -750,12 +750,30 @@ class Sale < ApplicationRecord
|
|||||||
custo = "and customer_id = '#{customer}'"
|
custo = "and customer_id = '#{customer}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
if from.present? && to.present?
|
if order_source.blank?
|
||||||
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
source = ""
|
||||||
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
|
|
||||||
else
|
else
|
||||||
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
if order_source == "cashier"
|
||||||
.where("sp.payment_method ='creditnote' #{keyword} #{custo}")
|
source = "and orders.source='cashier' or orders.source='emenu'"
|
||||||
|
else
|
||||||
|
source = "and orders.source='#{order_source}'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if from.present? && to.present?
|
||||||
|
sale = Sale.select("sales.*,orders.source").joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||||
|
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
|
||||||
|
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||||
|
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
|
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and (CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
||||||
|
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to)
|
||||||
|
else
|
||||||
|
sale = Sale.select("sales.*,orders.source").joins(" JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||||
|
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
|
||||||
|
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||||
|
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
|
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
||||||
|
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1186,7 +1204,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
|
|||||||
return query
|
return query
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
|
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
|
||||||
sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0
|
sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0
|
||||||
THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END)
|
THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END)
|
||||||
FROM `sale_payments`
|
FROM `sale_payments`
|
||||||
@@ -1223,10 +1241,19 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
|
|||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
||||||
WHERE sale_audits.sale_id = s.sale_id) = 0"
|
WHERE sale_audits.sale_id = s.sale_id) = 0"
|
||||||
end
|
end
|
||||||
|
if order_source.blank?
|
||||||
|
source = ""
|
||||||
|
else
|
||||||
|
if order_source == "cashier"
|
||||||
|
source = "and orders.source='cashier' or orders.source='emenu'"
|
||||||
|
else
|
||||||
|
source = "and orders.source='#{order_source}'"
|
||||||
|
end
|
||||||
|
end
|
||||||
query = SalePayment.select("s.receipt_no, sale_payments.*,
|
query = SalePayment.select("s.receipt_no, sale_payments.*,
|
||||||
SUM(sale_payments.payment_amount) as payment_amount,
|
SUM(sale_payments.payment_amount) as payment_amount,
|
||||||
s.receipt_date as sale_date,
|
s.receipt_date as sale_date,
|
||||||
|
orders.source as order_source,
|
||||||
s.cashier_name as cashier_name,
|
s.cashier_name as cashier_name,
|
||||||
(#{sub_query}) as credit_payment_receipt_date,
|
(#{sub_query}) as credit_payment_receipt_date,
|
||||||
(#{sub_query1}) as credit_payment,
|
(#{sub_query1}) as credit_payment,
|
||||||
@@ -1234,13 +1261,16 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
|
|||||||
(#{sub_query2}) as credit_payment_shift_name")
|
(#{sub_query2}) as credit_payment_shift_name")
|
||||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
.joins("INNER JOIN shift_sales ss ON ss.id = s.shift_sale_id")
|
.joins("INNER JOIN shift_sales ss ON ss.id = s.shift_sale_id")
|
||||||
|
.joins("INNER JOIN bookings ON bookings.sale_id=s.sale_id")
|
||||||
|
.joins("INNER JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||||
|
.joins("INNER JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
|
|
||||||
if shift.present?
|
if shift.present?
|
||||||
query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?)",shift.to_a)
|
query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift.to_a)
|
||||||
elsif shift_sale_range.present?
|
elsif shift_sale_range.present?
|
||||||
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?)",shift_sale_range.to_a)
|
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift_sale_range.to_a)
|
||||||
else
|
else
|
||||||
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? ",from,to)
|
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? #{source}",from,to)
|
||||||
end
|
end
|
||||||
query = query.group("s.sale_id")
|
query = query.group("s.sale_id")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
<%= select_tag "filter_check", options_for_select(@filter_for_credit, :selected => params[:filter_check]), :class => "form-control", :style => "height: 37px;" %>
|
<%= select_tag "filter_check", options_for_select(@filter_for_credit, :selected => params[:filter_check]), :class => "form-control", :style => "height: 37px;" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||||
|
<label class="font-14"><%= t("views.right_panel.detail.order_source") %></label>
|
||||||
|
<%= select_tag "order_source", options_for_select(@sources, :selected => params[:order_source]), :class => "form-control" %>
|
||||||
|
</div>
|
||||||
<div class="form-group col-md-2">
|
<div class="form-group col-md-2">
|
||||||
<!-- <label class="">Select Shift Period</label> -->
|
<!-- <label class="">Select Shift Period</label> -->
|
||||||
<label class="font-20">From</label>
|
<label class="font-20">From</label>
|
||||||
@@ -38,7 +42,9 @@
|
|||||||
<select class="form-control select" name="shift_name" id="shift_name" style="height: 37px;">
|
<select class="form-control select" name="shift_name" id="shift_name" style="height: 37px;">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-1 ">
|
</div>
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="form-group col-md-12" align="right">
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.order_source") %></th>
|
||||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||||
@@ -70,6 +71,15 @@
|
|||||||
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
|
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= credit.receipt_no rescue '-' %></td>
|
<td><%= credit.receipt_no rescue '-' %></td>
|
||||||
|
<td>
|
||||||
|
<%if credit.order_source == "cashier" || credit.order_source == "emenu" %>
|
||||||
|
Cashier
|
||||||
|
<% elsif credit.order_source == "quick_service" %>
|
||||||
|
Quick Service
|
||||||
|
<% else %>
|
||||||
|
Online Order
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td><%= credit.cashier_name rescue '-' %></td>
|
<td><%= credit.cashier_name rescue '-' %></td>
|
||||||
<td><%= credit.sale.customer.name rescue '-' %></td>
|
<td><%= credit.sale.customer.name rescue '-' %></td>
|
||||||
<td><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
<td><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.order_source") %></th>
|
||||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||||
@@ -42,6 +43,15 @@
|
|||||||
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
|
<td><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= credit.receipt_no rescue '-' %></td>
|
<td><%= credit.receipt_no rescue '-' %></td>
|
||||||
|
<td>
|
||||||
|
<%if credit.order_source == "cashier" || credit.order_source == "emenu" %>
|
||||||
|
Cashier
|
||||||
|
<% elsif credit.order_source == "quick_service" %>
|
||||||
|
Quick Service
|
||||||
|
<% else %>
|
||||||
|
Online Order
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td><%= credit.cashier_name rescue '-' %></td>
|
<td><%= credit.cashier_name rescue '-' %></td>
|
||||||
<td><%= credit.sale.customer.name rescue '-' %></td>
|
<td><%= credit.sale.customer.name rescue '-' %></td>
|
||||||
<td><%= credit.payment_amount rescue '-' %></td>
|
<td><%= credit.payment_amount rescue '-' %></td>
|
||||||
|
|||||||
@@ -34,13 +34,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||||
<label class="font-14"><%= t("views.right_panel.detail.select_customer") %></label>
|
<label class="font-14"><%= t("views.right_panel.detail.select_customer") %></label>
|
||||||
<select class="selectpicker form-control col-md-12 " name="customer" style="height: 40px" >
|
<select class="selectpicker form-control col-md-12" name="customer">
|
||||||
<option value=""><%= t("views.right_panel.detail.select_customer") %></option>
|
<option value=""><%= t("views.right_panel.detail.select_customer") %></option>
|
||||||
<% @customers.each do |customer| %>
|
<% @customers.each do |customer| %>
|
||||||
<option value="<%= customer.customer_id %>">
|
<option value="<%= customer.customer_id %>">
|
||||||
<%= customer.name %></option>
|
<%= customer.name %></option>
|
||||||
<%end %>
|
<%end %>
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||||
|
<label class="font-14"><%= t("views.right_panel.detail.order_source") %></label>
|
||||||
|
<%= select_tag "order_source", options_for_select(@sources, :selected => params[:order_source]), :class => "form-control" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||||
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
||||||
@@ -67,38 +71,61 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped">
|
<% if (!@credit_notes.empty?) && (params[:order_source] == "doemal_order") %>
|
||||||
<thead>
|
<div class="row pt-3 pb-3 pr-3 float-right">
|
||||||
<tr>
|
<div class="col-md-12 col-sm-12 col-lg-12">
|
||||||
<th><%= t("views.right_panel.detail.sale_id") %></th>
|
<button class="btn btn-lg bg-blue waves-effect credit_payment"><%= t :credit %> <%= t :payment %></button>
|
||||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
</div>
|
||||||
<th><%= t("views.right_panel.detail.credit_amount") %></th>
|
</div>
|
||||||
<th><%= t :cashier %></th>
|
<% end %>
|
||||||
<th><%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
<table class="table table-striped">
|
||||||
<th><%= t("views.right_panel.detail.receipt_date") %></th>
|
<thead>
|
||||||
</tr>
|
<tr>
|
||||||
</thead>
|
<% if params[:order_source] == "doemal_order" %>
|
||||||
|
<th></th>
|
||||||
<tbody>
|
|
||||||
<% if @credit_notes != 0 %>
|
|
||||||
|
|
||||||
<% @credit_notes.each do |sale| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
|
||||||
<td><%= sale.receipt_no %></td>
|
|
||||||
<td><%credit = SalePayment.where('sale_id = ? AND payment_method=?', sale.sale_id,"creditnote").first %>
|
|
||||||
<%= credit.payment_amount rescue '-' %>
|
|
||||||
</td>
|
|
||||||
<td><%= sale.cashier_name rescue '-' %></td>
|
|
||||||
<td><%= link_to sale.customer.name, crm_customer_path(sale.customer_id) %></td>
|
|
||||||
<td> <%= sale.receipt_date.strftime("%d-%m-%Y %I:%M %p") %> </td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<th><%= t("views.right_panel.detail.sale_id") %></th>
|
||||||
<tr><td colspan="8"><strong><p style="text-align: center"><%= t("views.right_panel.detail.no_data_txt") %>....</p></strong></td></tr>
|
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||||
<% end %>
|
<th><%= t("views.right_panel.detail.credit_amount") %></th>
|
||||||
</tbody>
|
<th><%= t :cashier %></th>
|
||||||
</table>
|
<th><%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.order_source") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.receipt_date") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% if @credit_notes != 0 %>
|
||||||
|
|
||||||
|
<% @credit_notes.each do |sale| %>
|
||||||
|
<tr>
|
||||||
|
<% if params[:order_source] == "doemal_order" %>
|
||||||
|
<td><input type="checkbox" class="" name="chk_order" value="<%= sale.sale_id %>"></td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
||||||
|
<td><%= sale.receipt_no %></td>
|
||||||
|
<td class="credit_<%= sale.sale_id %>"><%credit = SalePayment.where('sale_id = ? AND payment_method=?', sale.sale_id,"creditnote").first %>
|
||||||
|
<%= credit.payment_amount rescue '-' %>
|
||||||
|
</td>
|
||||||
|
<td><%= sale.cashier_name rescue '-' %></td>
|
||||||
|
<td><%= link_to sale.customer.name, crm_customer_path(sale.customer_id) %></td>
|
||||||
|
<td>
|
||||||
|
<%if sale.source == "cashier" || sale.source == "emenu" %>
|
||||||
|
Cashier
|
||||||
|
<% elsif sale.source == "quick_service" %>
|
||||||
|
Quick Service
|
||||||
|
<% else %>
|
||||||
|
Online Order
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td> <%= sale.receipt_date.strftime("%d-%m-%Y %I:%M %p") %> </td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<tr><td colspan="8"><strong><p style="text-align: center"><%= t("views.right_panel.detail.no_data_txt") %>....</p></strong></td></tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<% if @credit_notes != 0 %>
|
<% if @credit_notes != 0 %>
|
||||||
<%= paginate @credit_notes %>
|
<%= paginate @credit_notes %>
|
||||||
@@ -109,20 +136,64 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var arr_sale = [];
|
||||||
$(function () {
|
$(function () {
|
||||||
|
$("input[name='chk_order']").on('click',function(){
|
||||||
|
var arr = {};
|
||||||
|
if($(this).is(':checked')){
|
||||||
|
arr[$(this).val()] = parseFloat($(".credit_"+$(this).val()).html());
|
||||||
|
// console.log(arr);
|
||||||
|
arr_sale.push(arr);
|
||||||
|
}else{
|
||||||
|
arr[$(this).val()] = parseFloat($(".credit_"+$(this).val()).html());
|
||||||
|
arr_sale = removeItem(arr_sale, arr, $(this).val());
|
||||||
|
}
|
||||||
|
// console.log(arr_sale);
|
||||||
|
});
|
||||||
|
|
||||||
$('.datepicker').datepicker({
|
$(".credit_payment").on('click', function(){
|
||||||
format : 'dd-mm-yyyy',
|
$.ajax({
|
||||||
autoclose: true
|
type: 'POST',
|
||||||
});
|
url: '/origami/payment/credit_payment',
|
||||||
$('.datepicker').attr('ReadOnly','true');
|
data: {data: JSON.stringify(arr_sale)},
|
||||||
$('.datepicker').css('cursor','pointer');
|
success: function (result) {
|
||||||
|
// console.log(result);
|
||||||
|
if (result.status == true) {
|
||||||
|
swal({
|
||||||
|
title: "Information!",
|
||||||
|
text: "Credit Payment Successfully",
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
swal("Opps",result.message,"warning");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script> -->
|
|
||||||
|
function removeItem(arr_item, remove, sale_id){
|
||||||
|
if((arr_item!=undefined) && (arr_item!=null)){
|
||||||
|
if(arr_item.length > 0){
|
||||||
|
$.each(arr_item, function(i_key, i_value){
|
||||||
|
$.each(i_value, function(key,val){
|
||||||
|
if(key == sale_id){
|
||||||
|
arr_item.splice(arr_item.indexOf(key),1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr_item;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -497,6 +497,7 @@ en:
|
|||||||
out_time: "Out Time"
|
out_time: "Out Time"
|
||||||
transaction_fee: "Transaction Fee"
|
transaction_fee: "Transaction Fee"
|
||||||
checked_by: "Checked By"
|
checked_by: "Checked By"
|
||||||
|
order_source: "Order Source"
|
||||||
|
|
||||||
code_txt: "code "
|
code_txt: "code "
|
||||||
charge_txt: "charge"
|
charge_txt: "charge"
|
||||||
|
|||||||
@@ -491,6 +491,7 @@ mm:
|
|||||||
out_time: "Out Time"
|
out_time: "Out Time"
|
||||||
transaction_fee: "Transaction Fee"
|
transaction_fee: "Transaction Fee"
|
||||||
checked_by: "Checked By"
|
checked_by: "Checked By"
|
||||||
|
order_source: "Order Source"
|
||||||
|
|
||||||
code_txt: "ကုတ်ဒ် "
|
code_txt: "ကုတ်ဒ် "
|
||||||
charge_txt: "ကောက်ခံသည်"
|
charge_txt: "ကောက်ခံသည်"
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
post 'payment/junctionpay' => 'junction_pay#create'
|
post 'payment/junctionpay' => 'junction_pay#create'
|
||||||
post 'payment/dinga' => 'dinga#create'
|
post 'payment/dinga' => 'dinga#create'
|
||||||
post 'payment/gift_voucher' => 'gift_voucher#create'
|
post 'payment/gift_voucher' => 'gift_voucher#create'
|
||||||
|
post 'payment/credit_payment' => 'credit_payments#create_credit_payment'
|
||||||
|
|
||||||
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
|
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user