Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -8,6 +8,16 @@ class ApplicationController < ActionController::Base
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
|
||||
# rescue_from CanCan::AccessDenied do |exception|
|
||||
# flash[:warning] = exception.message
|
||||
# redirect_to root_path
|
||||
# end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
def current_company
|
||||
begin
|
||||
return Company.first
|
||||
|
||||
@@ -7,23 +7,19 @@ class Crm::CustomersController < BaseCrmController
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
@crm_customers = Customer.all
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
# @membership = Customer.get_member_group
|
||||
# if @membership["status"] == true
|
||||
# @member_group = @membership["data"]
|
||||
# end
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @crm_customers }
|
||||
@@ -51,14 +47,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(params[:id])
|
||||
response = Customer.get_member_account(@customer)
|
||||
|
||||
if(response["status"] == true)
|
||||
@membership = response["data"]
|
||||
else
|
||||
@membership = 0
|
||||
end
|
||||
|
||||
@response = Customer.get_membership_transactions(@customer)
|
||||
#end customer amount
|
||||
|
||||
end
|
||||
@@ -87,6 +76,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
dob = customer_params[:date_of_birth]
|
||||
address = customer_params[:address]
|
||||
nrc = customer_params[:nrc_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -95,14 +86,18 @@ class Crm::CustomersController < BaseCrmController
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
|
||||
@@ -151,6 +146,8 @@ end
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
dob = customer_params[:date_of_birth]
|
||||
address = customer_params[:address]
|
||||
nrc = customer_params[:nrc_no]
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
@@ -159,22 +156,24 @@ end
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
)
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @crm_customer }
|
||||
|
||||
else
|
||||
|
||||
flash[:errors] = @crm_customers.errors
|
||||
flash[:errors] = @crm_customer.errors
|
||||
format.html { redirect_to crm_customers_path}
|
||||
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
@@ -201,6 +200,7 @@ end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salution,:gender,:nrc_no,:address,:card_no)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -84,12 +84,15 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
queue = DiningQueue.find(params[:id])
|
||||
table_id = params[:table_id]
|
||||
|
||||
queue.update_attributes(dining_facility_id: table_id,status:"Assign")
|
||||
DiningFacility.find(table_id).update_attributes(status: "occupied")
|
||||
respond_to do |format|
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
|
||||
status = DiningFacility.find(table_id).update_attributes(status: "occupied")
|
||||
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -6,52 +6,91 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
end
|
||||
|
||||
@accounts = Account.all
|
||||
end
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def create
|
||||
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)
|
||||
sale.total_discount = overall_discount.to_f
|
||||
sale.total_amount = sub_total.to_f
|
||||
sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
sale.save
|
||||
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
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
sale_item.product_name = di["name"]
|
||||
sale_item.remark = "Discount"
|
||||
|
||||
sale_item.qty = 1
|
||||
sale_item.unit_price = di["price"]
|
||||
sale_item.taxable_price = di["price"]
|
||||
sale_item.is_taxable = 0
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#discount for selected order
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
sale_item_id = params[:sale_item_id]
|
||||
discount_type = params[:discount_type]
|
||||
discount_value = params[:discount_value]
|
||||
discount_amount = params[:discount_amount]
|
||||
grand_total = params[:grand_total]
|
||||
product_name = "Overall Discount"
|
||||
# def create
|
||||
# sale_id = params[:sale_id]
|
||||
# sale_item_id = params[:sale_item_id]
|
||||
# discount_type = params[:discount_type]
|
||||
# discount_value = params[:discount_value]
|
||||
# discount_amount = params[:discount_amount]
|
||||
# grand_total = params[:grand_total]
|
||||
# product_name = "Overall Discount"
|
||||
|
||||
if discount_type == 0
|
||||
remark="Discount " + discount_amount + " as net"
|
||||
else
|
||||
remark="Discount " + discount_amount + " as percentage"
|
||||
end
|
||||
# if discount_type == 0
|
||||
# remark="Discount " + discount_amount + " as net"
|
||||
# else
|
||||
# remark="Discount " + discount_amount + " as percentage"
|
||||
# end
|
||||
|
||||
#update discount for sale
|
||||
sale = Sale.find(sale_id)
|
||||
sale.total_discount = sale.total_discount + discount_amount.to_f
|
||||
sale.grand_total = grand_total
|
||||
sale.save
|
||||
# #update discount for sale
|
||||
# sale = Sale.find(sale_id)
|
||||
# sale.total_discount = sale.total_discount + discount_amount.to_f
|
||||
# sale.grand_total = grand_total
|
||||
# sale.save
|
||||
|
||||
#save sale item for discount
|
||||
if sale_item_id != nil
|
||||
origin_sale_item = SaleItem.find(sale_item_id)
|
||||
product_name = origin_sale_item.product_name + "-Disocunt"
|
||||
end
|
||||
sale_item = SaleItem.new
|
||||
# #save sale item for discount
|
||||
# if sale_item_id != nil
|
||||
# origin_sale_item = SaleItem.find(sale_item_id)
|
||||
# product_name = origin_sale_item.product_name + "-Disocunt"
|
||||
# end
|
||||
# sale_item = SaleItem.new
|
||||
|
||||
#pull
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
sale_item.product_name = product_name
|
||||
sale_item.remark = remark
|
||||
# #pull
|
||||
# sale_item.sale_id = sale_id
|
||||
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
# sale_item.product_name = product_name
|
||||
# sale_item.remark = remark
|
||||
|
||||
sale_item.qty = 1
|
||||
sale_item.unit_price = (0-discount_amount.to_f)
|
||||
sale_item.taxable_price = discount_amount
|
||||
sale_item.is_taxable = 0
|
||||
# sale_item.qty = 1
|
||||
# sale_item.unit_price = (0-discount_amount.to_f)
|
||||
# sale_item.taxable_price = discount_amount
|
||||
# sale_item.is_taxable = 0
|
||||
|
||||
sale_item.price = sale_item.qty * sale_item.unit_price
|
||||
sale_item.save
|
||||
# sale_item.price = sale_item.qty * sale_item.unit_price
|
||||
# sale_item.save
|
||||
|
||||
redirect_to origami_path(sale_id)
|
||||
end
|
||||
# redirect_to origami_path(sale_id)
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,11 +10,13 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
|
||||
rebate_amount = nil
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
rebate_amount = Customer.get_membership_transactions(customer)
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
|
||||
@@ -24,7 +26,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,7 +90,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
|
||||
rebate_amount = Customer.get_membership_transactions(customer)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
@@ -96,7 +98,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,11 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.where('customer_id=' + @sale_data.customer_id)
|
||||
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
|
||||
customer= Customer.find( @sale_data.customer_id)
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
@@ -32,6 +35,9 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
|
||||
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info)
|
||||
# redirect_to origami_path(@sale_data.sale_id)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
class Reports::DailySaleController < BaseReportController
|
||||
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
from, to ,report_type = get_date_range_from_params
|
||||
@sale_data = Sale.daily_sales_list(from,to)
|
||||
@tax = SaleTax.get_tax(from,to)
|
||||
end
|
||||
|
||||
# @locations = Location.all
|
||||
|
||||
# branch,from, to, report_type = get_date_range_from_params
|
||||
|
||||
# @location = Location.find_by_id(current_location)
|
||||
# @sale_data = Sale.daily_sales_report(current_location,from,to)
|
||||
# @tax = SaleT.get_tax(current_location,from,to)
|
||||
|
||||
# if @sale_data.blank? && @tax.blank? && request.post?
|
||||
# flash.now[:notice] = "No data available for selected filters"
|
||||
# end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Reports::ReceiptNoController < BaseReportController
|
||||
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
puts "from..."
|
||||
|
||||
14
app/controllers/reports/sale_item_controller.rb
Normal file
14
app/controllers/reports/sale_item_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class Reports::SaleItemController < BaseReportController
|
||||
|
||||
def index
|
||||
|
||||
from, to, report_type = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,8 @@
|
||||
class Settings::EmployeesController < ApplicationController
|
||||
# load_and_authorize_resource
|
||||
before_action :set_employee, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
|
||||
# GET /employees
|
||||
# GET /employees.json
|
||||
def index
|
||||
|
||||
@@ -53,13 +53,7 @@ class Transactions::SalesController < ApplicationController
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale.customer_id)
|
||||
response = Customer.get_member_account(@customer)
|
||||
|
||||
if(response["status"] == true)
|
||||
@membership = response["data"]
|
||||
else
|
||||
@membership = 0
|
||||
end
|
||||
@response = Customer.get_membership_transactions(@customer)
|
||||
#end customer amount
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
Reference in New Issue
Block a user