check tax profile process

This commit is contained in:
phyusin
2018-03-21 11:53:27 +06:30
parent b77435be48
commit 0977363518
11 changed files with 37 additions and 33 deletions

View File

@@ -98,10 +98,10 @@ class Origami::CustomersController < BaseOrigamiController
def update_sale_by_customer
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
order_source = params[:type]
# Check and find with card no
# if(!customer_id.include? "CUS")
# customer = Customer.find_by_paypar_account_no(customer_id)
@@ -135,7 +135,7 @@ class Origami::CustomersController < BaseOrigamiController
if status == true
render json: JSON.generate({:status => true})
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
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})

View File

@@ -20,10 +20,12 @@ class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def create
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
overall_discount = params[:overall_discount]
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -82,7 +84,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
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?
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
@@ -102,6 +104,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Remove selected discount Items
def remove_discount_items
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
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.save
# 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?
result = {:status=> "Success"}
else
@@ -158,6 +161,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Remove all discount Items
def remove_all_discount
sale_id = params[:id]
order_source = params[:type]
if Sale.exists?(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" )
# 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?
result = {:status=> "Success"}
else
@@ -218,7 +222,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Member Discount
def member_discount
order_source = params[:cashier_type]
sale_id = params[:sale_id]
is_card = params[:is_card]
sub_total = params[:sub_total]
@@ -297,7 +301,7 @@ class Origami::DiscountsController < BaseOrigamiController
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
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 }
elsif response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }

View File

@@ -443,7 +443,6 @@ class Origami::PaymentsController < BaseOrigamiController
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
# if bookings.count > 1

View File

@@ -3,6 +3,7 @@ class Origami::SplitBillController < BaseOrigamiController
def index
dining_id = params[:dining_id]
@cashier_type = params[:type]
@table = DiningFacility.find(dining_id)
@booking = @table.get_booking
@orders = Array.new
@@ -76,6 +77,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
def create
cashier_type = params[:cashier_type]
order_ids = params[:order_ids]
arr_order_ids = nil
if !params[:arr_order_ids].nil?
@@ -111,7 +113,7 @@ class Origami::SplitBillController < BaseOrigamiController
if booking
if booking.sale_id.nil?
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)
else
status = true
@@ -324,7 +326,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
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
Promotion.promo_activate(sale)

View File

@@ -343,7 +343,6 @@ class Sale < ApplicationRecord
#compute - invoice total
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil)
sale = Sale.find(sale_id)
sales_items = sale_itemss

View File

@@ -208,8 +208,7 @@ class SalePayment < ApplicationRecord
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
sale_update_payment_status(self.received_amount)
return payment_status
end
@@ -325,7 +324,7 @@ class SalePayment < ApplicationRecord
sObj = Sale.find(self.sale_id)
is_credit = 0
is_foc = 0
is_cash = false
method_status = false
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
@@ -334,12 +333,12 @@ class SalePayment < ApplicationRecord
if spay.payment_method == "foc"
is_foc = 1
end
if spay.payment_method.to_s == "cash"
is_cash = true
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote"
method_status = true
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
self.sale.payment_status = "paid"
else
@@ -386,7 +385,7 @@ class SalePayment < ApplicationRecord
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
table_update_status(sObj)
update_shift
elsif is_cash && paid_amount.to_f == 0
elsif method_status && paid_amount.to_f == 0
table_update_status(sObj)
update_shift
end

View File

@@ -414,7 +414,7 @@ var cashier_type = "<%= @cashier_type %>";
var sub_total = $('#order-sub-total').text();
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({
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({
type: "POST",
url: "/origami/" + sale_id + "/remove_discount_items",
@@ -496,7 +496,7 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#sale-id').text();
$.ajax({
type: "GET",
url: "/origami/" + sale_id + "/remove_all_discount",
url: "/origami/" + sale_id + "/" + cashier_type + "/remove_all_discount",
success: function(result){
swal({
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 };
var params = {'cashier_type': cashier_type,'sale_id':sale_id, 'sub_total':sub_total };
$.ajax({
type: "POST",

View File

@@ -809,7 +809,7 @@
//split bill process
$('#split_bills').click(function(){
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 () {

View File

@@ -776,7 +776,7 @@ $('#request_bills').click(function() {
//split bill process
$('#split_bills').click(function(){
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(){

View File

@@ -333,6 +333,7 @@
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var cashier_type = '<%= @cashier_type %>';
$(document).ready(function(){
$('#back').on('click',function(){
backToOrigami();
@@ -658,7 +659,7 @@ function orderItemSplitBillProcess(cnt_items){
type: "POST",
url: ajax_url,
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) {
if (!result.status) {
swal("Information!", result.error_message);
@@ -691,7 +692,7 @@ function orderSplitBillProcess(cnt_orders){
type: "POST",
url: ajax_url,
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) {
if (!result.status) {
swal("Information!", result.error_message);

View File

@@ -138,7 +138,7 @@ scope "(:locale)", locale: /en|mm/ do
# Discount
get "/:id/:type/discount" => "discounts#index"
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"
# Discount for Member
@@ -168,7 +168,7 @@ scope "(:locale)", locale: /en|mm/ do
get 'sale/:sale_id/:type/payment' => 'payments#show'
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/mpu' => "mpu#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"
#split bill
get '/table/:dining_id/split_bills' => 'split_bill#index'
get '/room/:dining_id/split_bills' => 'split_bill#index'
get '/table/:dining_id/:type/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/equal_person', to: 'split_bill#update_sale'