check tax profile process
This commit is contained in:
@@ -98,10 +98,10 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
|
|
||||||
def update_sale_by_customer
|
def update_sale_by_customer
|
||||||
|
|
||||||
id = params[:sale_id][0,3]
|
id = params[:sale_id][0,3]
|
||||||
customer_id = params[:customer_id]
|
customer_id = params[:customer_id]
|
||||||
customer = Customer.find(customer_id)
|
customer = Customer.find(customer_id)
|
||||||
|
order_source = params[:type]
|
||||||
# Check and find with card no
|
# Check and find with card no
|
||||||
# if(!customer_id.include? "CUS")
|
# if(!customer_id.include? "CUS")
|
||||||
# customer = Customer.find_by_paypar_account_no(customer_id)
|
# customer = Customer.find_by_paypar_account_no(customer_id)
|
||||||
@@ -135,7 +135,7 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
if status == true
|
if status == true
|
||||||
render json: JSON.generate({:status => true})
|
render json: JSON.generate({:status => true})
|
||||||
if(id == "SAL")
|
if(id == "SAL")
|
||||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
|
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
#discount page show from origami index with selected order
|
#discount page show from origami index with selected order
|
||||||
def create
|
def create
|
||||||
|
order_source = params[:cashier_type]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
discount_items = JSON.parse(params[:discount_items])
|
discount_items = JSON.parse(params[:discount_items])
|
||||||
overall_discount = params[:overall_discount]
|
overall_discount = params[:overall_discount]
|
||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
|
|
||||||
|
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||||
@@ -82,7 +84,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
|
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
|
||||||
end
|
end
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
|
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
|
||||||
if !table.nil?
|
if !table.nil?
|
||||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||||
else
|
else
|
||||||
@@ -102,6 +104,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
# Remove selected discount Items
|
# Remove selected discount Items
|
||||||
def remove_discount_items
|
def remove_discount_items
|
||||||
|
order_source = params[:cashier_type]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
discount_items = JSON.parse(params[:discount_items])
|
discount_items = JSON.parse(params[:discount_items])
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
@@ -136,7 +139,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||||
# sale.save
|
# sale.save
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||||
if table.nil?
|
if table.nil?
|
||||||
result = {:status=> "Success"}
|
result = {:status=> "Success"}
|
||||||
else
|
else
|
||||||
@@ -158,6 +161,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
# Remove all discount Items
|
# Remove all discount Items
|
||||||
def remove_all_discount
|
def remove_all_discount
|
||||||
sale_id = params[:id]
|
sale_id = params[:id]
|
||||||
|
order_source = params[:type]
|
||||||
|
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
@@ -197,7 +201,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
|
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||||
|
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
|
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
|
||||||
if table.nil?
|
if table.nil?
|
||||||
result = {:status=> "Success"}
|
result = {:status=> "Success"}
|
||||||
else
|
else
|
||||||
@@ -218,7 +222,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
# Member Discount
|
# Member Discount
|
||||||
def member_discount
|
def member_discount
|
||||||
|
order_source = params[:cashier_type]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
is_card = params[:is_card]
|
is_card = params[:is_card]
|
||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
@@ -297,7 +301,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
if response["discount_bonus_earned"]
|
if response["discount_bonus_earned"]
|
||||||
discount_amount = discount_amount + response["discount_bonus_earned"]
|
discount_amount = discount_amount + response["discount_bonus_earned"]
|
||||||
end
|
end
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
|
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source)
|
||||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||||
elsif response["status"] == "500"
|
elsif response["status"] == "500"
|
||||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||||
|
|||||||
@@ -443,7 +443,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
# if bookings.count > 1
|
# if bookings.count > 1
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
dining_id = params[:dining_id]
|
dining_id = params[:dining_id]
|
||||||
|
@cashier_type = params[:type]
|
||||||
@table = DiningFacility.find(dining_id)
|
@table = DiningFacility.find(dining_id)
|
||||||
@booking = @table.get_booking
|
@booking = @table.get_booking
|
||||||
@orders = Array.new
|
@orders = Array.new
|
||||||
@@ -76,6 +77,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
cashier_type = params[:cashier_type]
|
||||||
order_ids = params[:order_ids]
|
order_ids = params[:order_ids]
|
||||||
arr_order_ids = nil
|
arr_order_ids = nil
|
||||||
if !params[:arr_order_ids].nil?
|
if !params[:arr_order_ids].nil?
|
||||||
@@ -111,7 +113,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
if booking
|
if booking
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
sale = Sale.new
|
sale = Sale.new
|
||||||
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user)
|
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
|
||||||
sale_data = Sale.find_by_sale_id(sale_id)
|
sale_data = Sale.find_by_sale_id(sale_id)
|
||||||
else
|
else
|
||||||
status = true
|
status = true
|
||||||
@@ -324,7 +326,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
sale = Sale.new
|
sale = Sale.new
|
||||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user)
|
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
Promotion.promo_activate(sale)
|
Promotion.promo_activate(sale)
|
||||||
|
|||||||
@@ -343,7 +343,6 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
#compute - invoice total
|
#compute - invoice total
|
||||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil)
|
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil)
|
||||||
|
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
sales_items = sale_itemss
|
sales_items = sale_itemss
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,6 @@ class SalePayment < ApplicationRecord
|
|||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
sale_update_payment_status(self.received_amount)
|
sale_update_payment_status(self.received_amount)
|
||||||
|
|
||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -325,7 +324,7 @@ class SalePayment < ApplicationRecord
|
|||||||
sObj = Sale.find(self.sale_id)
|
sObj = Sale.find(self.sale_id)
|
||||||
is_credit = 0
|
is_credit = 0
|
||||||
is_foc = 0
|
is_foc = 0
|
||||||
is_cash = false
|
method_status = false
|
||||||
sObj.sale_payments.each do |spay|
|
sObj.sale_payments.each do |spay|
|
||||||
all_received_amount += spay.payment_amount.to_f
|
all_received_amount += spay.payment_amount.to_f
|
||||||
if spay.payment_method == "creditnote"
|
if spay.payment_method == "creditnote"
|
||||||
@@ -334,12 +333,12 @@ class SalePayment < ApplicationRecord
|
|||||||
if spay.payment_method == "foc"
|
if spay.payment_method == "foc"
|
||||||
is_foc = 1
|
is_foc = 1
|
||||||
end
|
end
|
||||||
if spay.payment_method.to_s == "cash"
|
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote"
|
||||||
is_cash = true
|
method_status = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.sale.grand_total <= all_received_amount) && is_cash
|
if (self.sale.grand_total <= all_received_amount) && method_status
|
||||||
if is_credit == 0
|
if is_credit == 0
|
||||||
self.sale.payment_status = "paid"
|
self.sale.payment_status = "paid"
|
||||||
else
|
else
|
||||||
@@ -386,7 +385,7 @@ class SalePayment < ApplicationRecord
|
|||||||
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
||||||
table_update_status(sObj)
|
table_update_status(sObj)
|
||||||
update_shift
|
update_shift
|
||||||
elsif is_cash && paid_amount.to_f == 0
|
elsif method_status && paid_amount.to_f == 0
|
||||||
table_update_status(sObj)
|
table_update_status(sObj)
|
||||||
update_shift
|
update_shift
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
var sub_total = $('#order-sub-total').text();
|
var sub_total = $('#order-sub-total').text();
|
||||||
var ajax_url = "/origami/" + sale_id + "/discount";
|
var ajax_url = "/origami/" + sale_id + "/discount";
|
||||||
|
|
||||||
var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -465,7 +465,7 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
|
var params = { 'cashier_type': cashier_type,'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/" + sale_id + "/remove_discount_items",
|
url: "/origami/" + sale_id + "/remove_discount_items",
|
||||||
@@ -496,7 +496,7 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
var sale_id = $('#sale-id').text();
|
var sale_id = $('#sale-id').text();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/origami/" + sale_id + "/remove_all_discount",
|
url: "/origami/" + sale_id + "/" + cashier_type + "/remove_all_discount",
|
||||||
success: function(result){
|
success: function(result){
|
||||||
swal({
|
swal({
|
||||||
title: "Information!",
|
title: "Information!",
|
||||||
@@ -532,7 +532,7 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
|
|
||||||
// var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
|
// var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
|
||||||
|
|
||||||
var params = {'sale_id':sale_id, 'sub_total':sub_total };
|
var params = {'cashier_type': cashier_type,'sale_id':sale_id, 'sub_total':sub_total };
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
|||||||
@@ -809,7 +809,7 @@
|
|||||||
//split bill process
|
//split bill process
|
||||||
$('#split_bills').click(function(){
|
$('#split_bills').click(function(){
|
||||||
var dining_id = "<%= @dining.id %>";
|
var dining_id = "<%= @dining.id %>";
|
||||||
window.location.href = '/origami/table/' + dining_id + "/split_bills";
|
window.location.href = '/origami/table/' + dining_id + "/" + cashier_type +"/split_bills";
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#move').on('click', function () {
|
$('#move').on('click', function () {
|
||||||
|
|||||||
@@ -776,7 +776,7 @@ $('#request_bills').click(function() {
|
|||||||
//split bill process
|
//split bill process
|
||||||
$('#split_bills').click(function(){
|
$('#split_bills').click(function(){
|
||||||
var dining_id = "<%= @room.id %>";
|
var dining_id = "<%= @room.id %>";
|
||||||
window.location.href = '/origami/room/' + dining_id + "/split_bills";
|
window.location.href = '/origami/room/' + dining_id + "/" + cashier_type + "/split_bills";
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#move').on('click',function(){
|
$('#move').on('click',function(){
|
||||||
|
|||||||
@@ -333,6 +333,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var split_sale_id = "";
|
var split_sale_id = "";
|
||||||
var split_receipt_no = "";
|
var split_receipt_no = "";
|
||||||
|
var cashier_type = '<%= @cashier_type %>';
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('#back').on('click',function(){
|
$('#back').on('click',function(){
|
||||||
backToOrigami();
|
backToOrigami();
|
||||||
@@ -658,7 +659,7 @@ function orderItemSplitBillProcess(cnt_items){
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'arr_order_ids': JSON.stringify(arr_order_ids), 'order_items' : JSON.stringify(order_items), 'orders' : ''},
|
data: {'cashier_type':cashier_type,'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'arr_order_ids': JSON.stringify(arr_order_ids), 'order_items' : JSON.stringify(order_items), 'orders' : ''},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (!result.status) {
|
if (!result.status) {
|
||||||
swal("Information!", result.error_message);
|
swal("Information!", result.error_message);
|
||||||
@@ -691,7 +692,7 @@ function orderSplitBillProcess(cnt_orders){
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders), 'arr_order_ids': []},
|
data: {'cashier_type':cashier_type,'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders), 'arr_order_ids': []},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (!result.status) {
|
if (!result.status) {
|
||||||
swal("Information!", result.error_message);
|
swal("Information!", result.error_message);
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
# Discount
|
# Discount
|
||||||
get "/:id/:type/discount" => "discounts#index"
|
get "/:id/:type/discount" => "discounts#index"
|
||||||
post "/:id/discount" => "discounts#create"
|
post "/:id/discount" => "discounts#create"
|
||||||
get "/:id/remove_all_discount" => "discounts#remove_all_discount"
|
get "/:id/:type/remove_all_discount" => "discounts#remove_all_discount"
|
||||||
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
|
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
|
||||||
|
|
||||||
# Discount for Member
|
# Discount for Member
|
||||||
@@ -168,7 +168,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
get 'sale/:sale_id/:type/payment' => 'payments#show'
|
get 'sale/:sale_id/:type/payment' => 'payments#show'
|
||||||
post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt
|
post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt
|
||||||
|
|
||||||
post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'}
|
post 'payment/:type/foc' => 'payments#foc', :defaults => {:format => 'json'}
|
||||||
post 'payment/cash' => 'payments#create'
|
post 'payment/cash' => 'payments#create'
|
||||||
post 'payment/mpu' => "mpu#create"
|
post 'payment/mpu' => "mpu#create"
|
||||||
post 'payment/jcb' => "jcb#create"
|
post 'payment/jcb' => "jcb#create"
|
||||||
@@ -236,8 +236,8 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans"
|
post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans"
|
||||||
|
|
||||||
#split bill
|
#split bill
|
||||||
get '/table/:dining_id/split_bills' => 'split_bill#index'
|
get '/table/:dining_id/:type/split_bills' => 'split_bill#index'
|
||||||
get '/room/:dining_id/split_bills' => 'split_bill#index'
|
get '/room/:dining_id/:type/split_bills' => 'split_bill#index'
|
||||||
post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills"
|
post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills"
|
||||||
|
|
||||||
post '/split_bills/equal_person', to: 'split_bill#update_sale'
|
post '/split_bills/equal_person', to: 'split_bill#update_sale'
|
||||||
|
|||||||
Reference in New Issue
Block a user