update fixed conflict
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
white-space: normal !important;
|
||||
height: 60px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
@@ -168,6 +169,8 @@
|
||||
background-color: blue
|
||||
}
|
||||
|
||||
/* End Colors */
|
||||
|
||||
.left{
|
||||
margin-left:1px;
|
||||
}
|
||||
@@ -175,6 +178,7 @@
|
||||
.bottom{
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
|
||||
/*----- Reset -----*/
|
||||
|
||||
select.form-control {
|
||||
@@ -197,6 +201,7 @@ tr.discount-item-row:hover {
|
||||
.required abbr{
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
/* Jquery Confirm */
|
||||
|
||||
.jconfirm-box-container{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
helper_method :current_token, :current_login_employee
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
|
||||
private
|
||||
@@ -13,6 +13,11 @@ class Api::ApiController < ActionController::API
|
||||
end
|
||||
end
|
||||
|
||||
# Get current Cashier
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(current_token)
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ class Api::BillController < Api::ApiController
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee)
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier)
|
||||
else
|
||||
@status = true
|
||||
@sale_id = booking.sale_id
|
||||
@@ -22,7 +22,7 @@ class Api::BillController < Api::ApiController
|
||||
|
||||
elsif (params[:order_id])
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee)
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
||||
end
|
||||
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
@@ -67,13 +67,19 @@ class Api::OrdersController < Api::ApiController
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
check_order_with_booking(booking)
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
check_order_with_table(params[:table_id])
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return false
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
@@ -90,9 +96,11 @@ class Api::OrdersController < Api::ApiController
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
return true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -101,9 +109,11 @@ class Api::OrdersController < Api::ApiController
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
return true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
# Description
|
||||
|
||||
@@ -29,7 +29,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if discount_items.length > 0
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
puts di
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
sale_item = SaleItem.new
|
||||
|
||||
@@ -53,6 +52,59 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
# Remove selected discount Items
|
||||
def remove_discount_items
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
discount_items.each do |di|
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
sale.save
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table_type }
|
||||
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
# Remove all discount Items
|
||||
def remove_all_discount
|
||||
sale_id = params[:id]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
|
||||
#destroy all discount sale item
|
||||
sale.sale_items.each do |si|
|
||||
if si.remark == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
si.destroy
|
||||
end
|
||||
end
|
||||
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
sale.save
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table_type }
|
||||
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
#discount for selected order
|
||||
# def create
|
||||
# sale_id = params[:sale_id]
|
||||
|
||||
@@ -12,7 +12,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
# Create Sale if it doesn't exist
|
||||
puts "current_login_employee"
|
||||
puts current_login_employee.name
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee)
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
|
||||
@@ -42,6 +42,8 @@ class Ability
|
||||
|
||||
can :index, :discount
|
||||
can :create, :discount
|
||||
can :remove_discount_items, :discount
|
||||
can :remove_all_discount, :discount
|
||||
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
@@ -65,6 +67,8 @@ class Ability
|
||||
|
||||
can :index, :discount
|
||||
can :create, :discount
|
||||
can :remove_discount_items, :discount
|
||||
can :remove_all_discount, :discount
|
||||
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
|
||||
@@ -34,13 +34,13 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order_items.each do|odi|
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
# check for item not to show
|
||||
if odi.price != 0 || odi.price != 10
|
||||
if odi.price != 0
|
||||
pdf = OrderItemPdf.new(odi, print_status, options, oqs.use_alternate_name)
|
||||
# pdf.render_file "tmp/order_item.pdf"
|
||||
pdf.render_file filename
|
||||
|
||||
@@ -71,8 +71,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
# print as print copies in printer setting
|
||||
count = printer_settings.print_copies
|
||||
begin
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
count -= 1
|
||||
end until count == 0
|
||||
end
|
||||
|
||||
#Queue No Print
|
||||
|
||||
@@ -25,7 +25,7 @@ class Sale < ApplicationRecord
|
||||
SALE_STATUS_OUTSTANDING = "outstanding"
|
||||
SALE_STATUS_COMPLETED = "completed"
|
||||
|
||||
def generate_invoice_from_booking(booking_id, requested_by)
|
||||
def generate_invoice_from_booking(booking_id, requested_by, cashier)
|
||||
booking = Booking.find(booking_id)
|
||||
status = false
|
||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
||||
@@ -35,9 +35,9 @@ class Sale < ApplicationRecord
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
if booking.sale_id
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier)
|
||||
else
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by)
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier)
|
||||
end
|
||||
booking.sale_id = sale_id
|
||||
end
|
||||
@@ -47,7 +47,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def generate_invoice_from_order (order_id, sale_id, booking, requested_by)
|
||||
def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil)
|
||||
taxable = true
|
||||
#if sale_id is exsit and validate
|
||||
#add order to that invoice
|
||||
@@ -66,12 +66,19 @@ class Sale < ApplicationRecord
|
||||
#Default Tax - Values
|
||||
self.tax_type = "exclusive"
|
||||
|
||||
# set cashier by current login
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
# set cashier
|
||||
if cashier != nil
|
||||
self.cashier_id = cashier[0].id
|
||||
self.cashier_name = cashier[0].name
|
||||
else
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
end
|
||||
|
||||
# set waiter
|
||||
self.requested_by = requested_by.name
|
||||
|
||||
self.requested_at = DateTime.now.utc
|
||||
self.requested_at = DateTime.now.utc.getlocal
|
||||
|
||||
Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}"
|
||||
if order
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="20" data-type="add">20%</div>
|
||||
<div class="fluid cashier_number" data-value="20" data-type="add">15%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="7" data-type="num">7</div>
|
||||
@@ -149,7 +149,7 @@
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="30" data-type="add">30%</div>
|
||||
<div class="fluid cashier_number" data-value="30" data-type="add">20%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="0" data-type="num">0</div>
|
||||
@@ -160,7 +160,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="50" data-type="add">50%</div>
|
||||
<div class="fluid cashier_number" data-value="50" data-type="add">30%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number"></div>
|
||||
@@ -172,7 +172,7 @@
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<button id="net" class="btn btn-warning fluid action-btn">Nett</button>
|
||||
<button id="net" class="btn btn-info fluid action-btn">Nett</button>
|
||||
<button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button>
|
||||
<button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
|
||||
</div>
|
||||
@@ -187,6 +187,8 @@
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami';"><i class="fa fa-arrow-left"></i> Back </button>
|
||||
<button id="remove-item-discount" class="btn btn-warning btn-block action-btn">Remove Discount</button>
|
||||
<button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button>
|
||||
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -358,6 +360,64 @@ $(document).ready(function(){
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Remove selected given discount item
|
||||
$("#remove-item-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_items = [];
|
||||
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
if(sale_items.length == 0){
|
||||
alert("You have no selected item!");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(sale_items[i].price < 0){
|
||||
discount_items.push(sale_items[i]);
|
||||
}
|
||||
else {
|
||||
alert("You have selected no discount item!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/" + sale_id + "/remove_discount_items",
|
||||
data: params,
|
||||
success: function(result){
|
||||
alert('Removed Discount');
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#remove-all").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/origami/" + sale_id + "/remove_all_discount",
|
||||
success: function(result){
|
||||
alert('Removed All Discount');
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
|
||||
@@ -136,13 +136,13 @@
|
||||
<% if @ppamount != 0.0 %>
|
||||
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Paypar</div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="row" style="display:none">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Paypar</div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<div class="col-md-4" id="ppamount">0.0</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -93,6 +93,8 @@ Rails.application.routes.draw do
|
||||
|
||||
get "/:id/discount" => "discounts#index"
|
||||
post "/:id/discount" => "discounts#create"
|
||||
get "/:id/remove_all_discount" => "discounts#remove_all_discount"
|
||||
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
|
||||
|
||||
post "/:id/request_bills" => "request_bills#print",:as => "request_bill" ,:defaults => { :format => 'json' }
|
||||
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
|
||||
|
||||
Reference in New Issue
Block a user