update
This commit is contained in:
@@ -65,6 +65,8 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy
|
||||
# clear in employee session
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = nil
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
@@ -42,6 +42,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_item.unit_price = di["price"]
|
||||
sale_item.taxable_price = di["price"]
|
||||
sale_item.is_taxable = 0
|
||||
sale_item.account_id = origin_sale_item.account_id
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
@@ -120,6 +121,78 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
# Member Discount
|
||||
def member_discount
|
||||
sale_id = params[:sale_id]
|
||||
account_types = JSON.parse(params[:account_types])
|
||||
sub_total = params[:sub_total]
|
||||
sale = Sale.find(sale_id)
|
||||
price = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
|
||||
arr = Array.new;
|
||||
|
||||
account_types.each do |at|
|
||||
price.each do |pc|
|
||||
if pc[:name].to_s == at["name"].to_s && pc[:price]>0
|
||||
str={type:pc[:name],amount:pc[:price]}
|
||||
arr.push(str)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
generic_customer_id = sale.customer.membership_id
|
||||
|
||||
receipt_no = sale.receipt_no
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("member_discount")
|
||||
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 ,
|
||||
campaign_type_id: campaign_type_id,
|
||||
receipt_no: receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
discount_method:arr.to_json,
|
||||
total_sale_transaction_amount: sale.grand_total,
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {status: false, message: "Can't open membership server "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
|
||||
response = { status: false , message: "Can't open membership server "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
end
|
||||
|
||||
puts response.to_json
|
||||
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
if response["status"] == true
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, response["rebate_earned"].to_f,"member_discount")
|
||||
end
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table_type,:table_type => table_type,:url_status => response[:status],:url_message => response[:message] }
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
#discount for selected order
|
||||
# def create
|
||||
# sale_id = params[:sale_id]
|
||||
|
||||
@@ -67,10 +67,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
|
||||
|
||||
|
||||
end
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -87,6 +85,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0.00
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
@@ -107,6 +106,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
#end customer amount
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
break
|
||||
end
|
||||
|
||||
@sale_data.sale_payments.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash = spay.payment_amount
|
||||
|
||||
@@ -41,10 +41,8 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
|
||||
end
|
||||
|
||||
session[:session_token] = nil
|
||||
redirect_to root_path
|
||||
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = nil
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
@@ -84,6 +84,7 @@ class Ability
|
||||
can :create, :discount
|
||||
can :remove_discount_items, :discount
|
||||
can :remove_all_discount, :discount
|
||||
can :member_discount, :discount
|
||||
|
||||
can :first_bill, :payment
|
||||
can :show, :payment
|
||||
|
||||
@@ -54,6 +54,7 @@ class Employee < ApplicationRecord
|
||||
def self.logout(session_token)
|
||||
if (session_token)
|
||||
user = Employee.find_by_token_session(session_token)
|
||||
|
||||
if user
|
||||
user.token_session = nil
|
||||
user.session_expiry = nil
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
class MenuCategory < ApplicationRecord
|
||||
|
||||
before_create :generate_menu_category_code
|
||||
|
||||
belongs_to :menu
|
||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||
@@ -12,7 +15,7 @@ class MenuCategory < ApplicationRecord
|
||||
# find the sub menu item of current item
|
||||
sub_menu_cat = MenuCategory.where("menu_category_id=?",menu_category.id)
|
||||
if sub_menu_cat.length != 0
|
||||
sub_menu_cat.each do |sub|
|
||||
sub_menu_cat.each do |sub|
|
||||
if destroyCategory(sub)
|
||||
end
|
||||
end
|
||||
@@ -20,17 +23,22 @@ class MenuCategory < ApplicationRecord
|
||||
items = MenuItem.where("menu_category_id=?",menu_category.id)
|
||||
items.each do |item|
|
||||
abc = MenuItem.deleteRecursive(item)
|
||||
end
|
||||
end
|
||||
menu_category.destroy
|
||||
return true
|
||||
else
|
||||
items = MenuItem.where("menu_category_id=?",menu_category.id)
|
||||
items.each do |item|
|
||||
abc = MenuItem.deleteRecursive(item)
|
||||
end
|
||||
end
|
||||
menu_category.destroy
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_menu_category_code
|
||||
self.code = SeedGenerator.generate_id(self.class.name, "C")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
class MenuItem < ApplicationRecord
|
||||
|
||||
before_create :generate_menu_item_code
|
||||
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
@@ -11,7 +13,7 @@ class MenuItem < ApplicationRecord
|
||||
default_scope { order('item_code asc') }
|
||||
|
||||
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }
|
||||
scope :set_menu_item, -> { where(type: 'SetMenuItem') }
|
||||
scope :set_menu_item, -> { where(type: 'SetMenuItem') }
|
||||
|
||||
def self.collection
|
||||
MenuItem.select("id, name").map { |e| [e.name, e.id] }
|
||||
@@ -46,7 +48,7 @@ class MenuItem < ApplicationRecord
|
||||
# find the sub menu item of current item
|
||||
sub_menu_items = MenuItem.where("menu_item_id=?",menu_item.id)
|
||||
if sub_menu_items.length != 0
|
||||
sub_menu_items.each do |subitem|
|
||||
sub_menu_items.each do |subitem|
|
||||
if deleteRecursive(subitem)
|
||||
end
|
||||
end
|
||||
@@ -54,17 +56,24 @@ class MenuItem < ApplicationRecord
|
||||
instances = MenuItemInstance.where("menu_item_id=?",menu_item.id)
|
||||
instances.each do |instance|
|
||||
instance.destroy
|
||||
end
|
||||
end
|
||||
menu_item.destroy
|
||||
return true
|
||||
else
|
||||
instances = MenuItemInstance.where("menu_item_id=?",menu_item.id)
|
||||
instances.each do |instance|
|
||||
instance.destroy
|
||||
end
|
||||
end
|
||||
menu_item.destroy
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_menu_item_code
|
||||
self.item_code = SeedGenerator.generate_id(self.class.name, "I")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class MenuItemInstance < ApplicationRecord
|
||||
belongs_to :menu_item
|
||||
|
||||
before_create :generate_menu_item_instance_code
|
||||
|
||||
def self.findParentCategory(item)
|
||||
if item.menu_category_id
|
||||
return item.menu_category_id
|
||||
@@ -9,4 +10,10 @@ class MenuItemInstance < ApplicationRecord
|
||||
findParentCategory(parentitem)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_menu_item_instance_code
|
||||
self.item_instance_code = SeedGenerator.generate_id(self.class.name, "II")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,9 +26,13 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
cashier = shift_sale.employee.name
|
||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details)
|
||||
pdf.render_file "tmp/print_close_cashier.pdf"
|
||||
self.print("tmp/print_close_cashier.pdf")
|
||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
pdf.render_file filename
|
||||
self.print(filename)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
#Print
|
||||
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||
|
||||
filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf"
|
||||
filename = "tmp/order_item.pdf"
|
||||
|
||||
# check for item not to show
|
||||
if order_item[0].price != 0
|
||||
@@ -35,7 +35,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||
filename = "tmp/order_item.pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -54,7 +54,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary_#{ order_id }" + ".pdf"
|
||||
filename = "tmp/order_summary.pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
@@ -75,7 +75,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||
filename = "tmp/order_item.pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -97,7 +97,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/booking_summary_#{ booking_id }" + ".pdf"
|
||||
filename = "tmp/booking_summary.pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
|
||||
@@ -75,8 +75,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
# 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")
|
||||
if count == 1
|
||||
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf")
|
||||
else
|
||||
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
self.print("tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf")
|
||||
end
|
||||
|
||||
count -= 1
|
||||
end until count == 0
|
||||
end
|
||||
|
||||
@@ -208,7 +208,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount)
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil)
|
||||
sale = Sale.find(sale_id)
|
||||
sales_items = sale_itemss
|
||||
|
||||
@@ -227,6 +227,9 @@ class Sale < ApplicationRecord
|
||||
sale.total_amount = subtotal_price
|
||||
sale.total_discount = total_discount
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
||||
if discount_type == "member_discount"
|
||||
sale.discount_type = discount_type
|
||||
end
|
||||
#compute rounding adjustment
|
||||
# adjust_rounding
|
||||
|
||||
@@ -427,7 +430,7 @@ class Sale < ApplicationRecord
|
||||
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='credit') then sale_payments.payment_amount else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||
.joins("join (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0", 'completed', from, to)
|
||||
@@ -682,7 +685,7 @@ def self.get_separate_tax(from,to,payment_method=nil)
|
||||
end
|
||||
|
||||
def grand_total_after_rounding
|
||||
return self.grand_total.to_f + self.rounding_adjustment.to_f
|
||||
return self.old_grand_total.to_f + self.rounding_adjustment.to_f
|
||||
end
|
||||
|
||||
def get_cash_amount
|
||||
|
||||
@@ -57,7 +57,7 @@ class SaleItem < ApplicationRecord
|
||||
# Check for actual sale items
|
||||
sale_items.where("is_taxable = false AND remark = 'Discount'").find_each do |si|
|
||||
if si.account_id == a.id
|
||||
discount_account[:price] = (discount_account[:price] + si.price) * -1
|
||||
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * -1
|
||||
end
|
||||
end
|
||||
discount_accounts.push(discount_account)
|
||||
|
||||
@@ -118,6 +118,23 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "#{shift_sale.closing_balance}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Cash In:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{shift_sale.cash_in}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Cash Out:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{shift_sale.cash_out}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Net Sales:", :size => self.item_font_size, :align => :right
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="20" data-type="add">15%</div>
|
||||
<div class="fluid cashier_number" data-value="15" 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">20%</div>
|
||||
<div class="fluid cashier_number" data-value="20" 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">30%</div>
|
||||
<div class="fluid cashier_number" data-value="30" data-type="add">30%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number"></div>
|
||||
@@ -190,8 +190,9 @@
|
||||
<button id="remove-item-discount" class="btn btn-warning btn-block action-btn">RemoveItem 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>
|
||||
<!-- <hr />
|
||||
<button id="member-discount" class="btn btn-success btn-block action-btn">Member Discount</button> -->
|
||||
<hr />
|
||||
<button id="member-discount" class="btn btn-success btn-block action-btn
|
||||
<%= @sale_data.customer.membership_id ? " " : "disabled"%>">Member Discount</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -283,7 +284,7 @@ $(document).ready(function(){
|
||||
$("#net").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_value = $('#discount-amount').val();
|
||||
var discount_value = parseFloat($('#discount-amount').val());
|
||||
var ajax_url = "/origami/" + sale_id + "/discount";
|
||||
|
||||
// Selected Items
|
||||
@@ -330,10 +331,15 @@ $(document).ready(function(){
|
||||
// Remove selected discount items
|
||||
$("#remove-item").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text());
|
||||
var total = 0;
|
||||
|
||||
$('.discount-item-row.selected-item').each(function(i){
|
||||
var amount = parseFloat($(this).find('#item-total-price').text());
|
||||
total = total + Math.abs(amount);
|
||||
$(this).remove();
|
||||
});
|
||||
$("#order-sub-total").text(origin_sub_total + total);
|
||||
});
|
||||
|
||||
// Pay Discount for Payment
|
||||
@@ -477,31 +483,50 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
// Pay Discount for membership
|
||||
// $("#member-discount").on('click', function(e){
|
||||
// e.preventDefault();
|
||||
// var sale_id = $('#sale-id').text();
|
||||
// var sub_total = $('#order-sub-total').text();
|
||||
// var ajax_url = "/origami/" + sale_id + "/member_discount";
|
||||
$("#member-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var ajax_url = "/origami/" + sale_id + "/member_discount";
|
||||
|
||||
// // Selected Account
|
||||
// var account_types = JSON.stringify(get_selected_account_types());
|
||||
// var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
|
||||
// Selected Account
|
||||
var account_types = JSON.stringify(get_selected_account_types());
|
||||
var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
|
||||
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: ajax_url,
|
||||
// data: params,
|
||||
// success:function(result){
|
||||
// alert("Successfully Discount!");
|
||||
// if(result.table_type == "Table"){
|
||||
// window.location.href = "/origami/table/" + result.table_id
|
||||
// }
|
||||
// else {
|
||||
// window.location.href = "/origami/room/" + result.table_id
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
|
||||
if (result.url_status == false) {
|
||||
status = result.url_message
|
||||
}else{
|
||||
status = result.status
|
||||
}
|
||||
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: status,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
@@ -628,21 +653,21 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
dis_amount = (0 - amount);
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(account_types.length > 0){
|
||||
for(var j=0; j < account_types.length; j++){
|
||||
if(sale_items[i].account_id == account_types[j].id){
|
||||
// Discount Items
|
||||
var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + amount;
|
||||
}
|
||||
// if(account_types.length > 0){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(sale_items[i].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + amount;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,23 +715,23 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
// Check sale items exists
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(account_types.length > 0){
|
||||
for(var j=0; j < account_types.length; j++){
|
||||
if(sale_items[i].account_id == account_types[j].id){
|
||||
// Discount Items
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + dis_amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// if(account_types.length > 0){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(sale_items[i].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + dis_amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + dis_amount;
|
||||
}
|
||||
// }
|
||||
}
|
||||
sub_total = origin_sub_total + total_discount;
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
json.status true
|
||||
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
<td style="width:50%;"><strong>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Table No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></td>
|
||||
<td><strong>Table No</strong> - <%=@table_no%></td>
|
||||
<td><strong>Sale Id</strong> <span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
|
||||
<td style="width:50%;"><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
|
||||
<td style="width:50%;"><strong>Customer ID :</strong> <%= @sale_data.customer.customer_id%></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -351,10 +352,11 @@ $( document ).ready(function() {
|
||||
url: "<%= origami_payment_cash_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||
success:function(result){
|
||||
localStorage.removeItem("cash");
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
}
|
||||
|
||||
@@ -372,10 +374,9 @@ $( document ).ready(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
||||
}
|
||||
else{
|
||||
$('#pay').text("Pay")
|
||||
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: 'Thank you !',
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<% grand_total = 0 %>
|
||||
<% old_grand_total = 0 %>
|
||||
<% total_tax = 0 %>
|
||||
<% guest_count = 0 %>
|
||||
<% total_sum = 0 %>
|
||||
@@ -64,6 +65,7 @@
|
||||
<% @sale_data.each do |result| %>
|
||||
|
||||
<% grand_total = grand_total.to_f + result.grand_total.to_f %>
|
||||
<% old_grand_total = old_grand_total.to_f + result.old_grand_total.to_f %>
|
||||
<% total_tax += result.total_tax.to_f %>
|
||||
<% total_sum += result.total_amount.to_f %>
|
||||
<% discount_amt += result.total_discount.to_f %>
|
||||
@@ -75,7 +77,7 @@
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%= result.total_amount rescue '-' %></td>
|
||||
<td><%= result.total_discount rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f",result.total_tax rescue '-' %></td>
|
||||
<td><%= result.total_tax rescue '-' %></td>
|
||||
|
||||
|
||||
<td><%= result.grand_total %></td>
|
||||
@@ -93,7 +95,7 @@
|
||||
<!-- <td><b><%= other_amt rescue '-'%></b></td> -->
|
||||
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
|
||||
<td><b><%= rounding_adj rescue '-'%></b></td>
|
||||
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
|
||||
<td><b><%= old_grand_total.to_f.round + rounding_adj %></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"> </td>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li>Daily Sale Report</li>
|
||||
</ul>
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li>Sale Item Report</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user