Pull from master

This commit is contained in:
San Wai Lwin
2018-08-06 17:52:03 +06:30
parent 35ac07b0a6
commit e99e907bc4
33 changed files with 455 additions and 126 deletions

View File

@@ -14,10 +14,35 @@ class Api::BillController < Api::ApiController
# for Multiple Cashier by Zone
table = DiningFacility.find(booking.dining_facility_id)
bk_order = BookingOrder.find_by_booking_id(booking.booking_id)
order = Order.find(bk_order.order_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
puts cashier_zone.to_json
puts "cashier_zone"
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
if !shift.nil?
cashier = Employee.find(shift.employee_id)
else
multiple_zone = CashierTerminalByZone.where('zone_id = #{cashier_zone.zone_id}')
puts cashier_zone.to_json
puts "cashier_zone"
multiple_zone.each do |zone|
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first
puts shift.to_json
puts "shift"
if !shift.nil? then
cashier = Employee.find(shift.employee_id)
break
end
end
end
if booking
if booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, current_login_employee, "cashier")
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source)
@sale_data = Sale.find_by_sale_id(@sale_id)
else
@status = true
@@ -41,8 +66,9 @@ class Api::BillController < Api::ApiController
end
elsif (params[:order_id])
order = Order.find(params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, "cashier")
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
# for Job
booking = Booking.find_by_sale_id(@sale_id)

View File

@@ -0,0 +1,30 @@
class Api::SoundEffectController < Api::ApiController
#sound effect / alarm api for doemal side calling
def sound_effect
shop = Shop.find_by_id(1)
if !shop.nil?
shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
if !order_audio.nil?
audio = order_audio.image
end
else
shop_code = nil
audio = nil
end
if !shop_code.nil? && !audio.nil?
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "sound_effect_channel",data: {status: params[:status], message: params[:message]},shop_code: shop_code,from:from,audio:audio
else
render :json => { :status => true, :message => "Something wrongs!" }
end
end
#sound effect / alarm api for doemal side calling
end

View File

@@ -39,7 +39,9 @@ class Crm::CustomersController < BaseCrmController
@membership_types = Lookup.collection_of("member_group_type")
@taxes = TaxProfile.where(:group_type => 'cashier')
# @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC")
@filter = filter

View File

@@ -126,8 +126,11 @@ class HomeController < ApplicationController
if !employee_sales.nil?
employee_sales.each do |emp|
emp_data = []
emp_data.push([emp.e_name, emp.payment_amount])
@employee_sales.push({'name' => emp.payment_method, 'data' => emp_data})
if emp.payment_amount > 0
emp_data.push([emp.e_name, emp.payment_amount])
@employee_sales.push({'name' => emp.payment_method, 'data' => emp_data})
end
end
end
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance)

View File

@@ -87,7 +87,9 @@ class Origami::CustomersController < BaseOrigamiController
@crm_customer = Customer.new
@count_customer = Customer.count_customer
@taxes = TaxProfile.where(:group_type => 'cashier')
# @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC")
# if flash["errors"]
# @crm_customer.valid?
# end

View File

@@ -130,6 +130,19 @@ class Origami::HomeController < BaseOrigamiController
end
end
end
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
if changable_tax[1] == '0'
@changable_tax = false
end
end
end
end
end
def check_emp_access_code

View File

@@ -241,7 +241,7 @@ class Origami::PaymentsController < BaseOrigamiController
sale_id = params[:sale_id]
@cashier_type = params[:type]
if path.include? ("credit_payment")
@sale_payment = SalePayment.get_credit_total_left(sale_id)
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
end
@member_discount = MembershipSetting.find_by_discount(1)
@@ -271,6 +271,20 @@ class Origami::PaymentsController < BaseOrigamiController
if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
end
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
if changable_tax[1] == '0'
@changable_tax = false
end
end
end
end
@shop = shop_detail #show shop info
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")

View File

@@ -154,6 +154,19 @@ class Origami::RoomsController < BaseOrigamiController
end
end
end
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
if changable_tax[1] == '0'
@changable_tax = false
end
end
end
end
end
end

View File

@@ -25,6 +25,7 @@ class Origami::SalesController < BaseOrigamiController
def add_to_existing_invoice
dining = params[:dining_id]
sale_id = params[:sale_id]
tax_type = params[:tax_type]
table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id)
table.bookings.each do |booking|
@@ -51,7 +52,7 @@ class Origami::SalesController < BaseOrigamiController
end
# Re-compute for add
saleobj.compute(order.source)
saleobj.compute(order.source,tax_type)
saleobj.save
order.save
booking.save

View File

@@ -76,9 +76,15 @@ class Settings::TaxProfilesController < ApplicationController
# DELETE /settings/tax_profiles/1
# DELETE /settings/tax_profiles/1.json
def destroy
@settings_tax_profile.destroy
flash[:notice] = 'Tax profile was successfully destroyed.'
render :json => {:status=> "Success", :url => settings_tax_profiles_url }.to_json
customers = Customer.where("tax_profiles LIKE '%#{@settings_tax_profile.id}%'")
if customers.nil? || customers.empty?
@settings_tax_profile.destroy
flash[:notice] = 'Tax profile was successfully destroyed.'
render :json => {:status=> "Success", :url => settings_tax_profiles_url }.to_json
else
flash[:error] = 'Tax profile could not destroy! This record is using in somewhere.'
render :json => {:status=> "Error", :url => settings_tax_profiles_url }.to_json
end
# respond_to do |format|
# format.html { redirect_to settings_tax_profiles_url, notice: 'Tax profile was successfully destroyed.' }
# format.json { head :no_content }