change tax profile structure

This commit is contained in:
phyusin
2018-07-25 17:19:00 +06:30
parent 2be9ff0613
commit 94a65a749f
6 changed files with 85 additions and 69 deletions

View File

@@ -39,7 +39,9 @@ class Crm::CustomersController < BaseCrmController
@membership_types = Lookup.collection_of("member_group_type") @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 @filter = filter

View File

@@ -87,7 +87,9 @@ class Origami::CustomersController < BaseOrigamiController
@crm_customer = Customer.new @crm_customer = Customer.new
@count_customer = Customer.count_customer @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"] # if flash["errors"]
# @crm_customer.valid? # @crm_customer.valid?
# end # end

View File

@@ -12,76 +12,82 @@ class Origami::RequestBillsController < ApplicationController
sale_order=SaleOrder.new sale_order=SaleOrder.new
if !ShiftSale.current_shift.nil? if !ShiftSale.current_shift.nil?
order_id = params[:id] # order_id tax_profiles = TaxProfile.unscoped.where("group_type='cashier'").pluck(:id)
bk_order = BookingOrder.find_by_order_id(order_id) customers = Customer.find('CUS-000000000002')
order = Order.find(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.dining_facility_id.to_i > 0
table = DiningFacility.find(check_booking.dining_facility_id)
else
table = nil
end
if check_booking.sale_id.nil? puts "data => "
# Create Sale if it doesn't exist puts tax_profiles.to_json
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source) puts customers.tax_profiles.to_json
@sale_data = Sale.find_by_sale_id(@sale_id) # order_id = params[:id] # order_id
@sale_items = SaleItem.where("sale_id=?",@sale_id) # bk_order = BookingOrder.find_by_order_id(order_id)
# order = Order.find(order_id)
# check_booking = Booking.find_by_booking_id(bk_order.booking_id)
# if check_booking.dining_facility_id.to_i > 0
# table = DiningFacility.find(check_booking.dining_facility_id)
# else
# table = nil
# end
# in-duty update # if check_booking.sale_id.nil?
in_duties = InDuty.where("booking_id=?",bk_order.booking_id) # # Create Sale if it doesn't exist
if !in_duties.empty? # @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
in_duties.each do |in_duty| # @sale_data = Sale.find_by_sale_id(@sale_id)
induty = InDuty.find(in_duty.id) # @sale_items = SaleItem.where("sale_id=?",@sale_id)
induty.sale_id = @sale_id
induty.save
end
end
else
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
# Bind shift sale id to sale # # in-duty update
# @sale_data.shift_sale_id = shift.id # in_duties = InDuty.where("booking_id=?",bk_order.booking_id)
# @sale_data.save # if !in_duties.empty?
# in_duties.each do |in_duty|
# induty = InDuty.find(in_duty.id)
# induty.sale_id = @sale_id
# induty.save
# end
# end
# else
# @sale_data = Sale.find_by_sale_id(check_booking.sale_id)
# @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
# end
action_by = current_user.name # # Bind shift sale id to sale
type = "REQUEST_BILL" # # @sale_data.shift_sale_id = shift.id
# # @sale_data.save
remark = "Request bill Receipt No #{@sale_data.receipt_no}" # action_by = current_user.name
sale_audit = SaleAudit.record_audit_sale(@sale_data.sale_id,remark,action_by,type ) # type = "REQUEST_BILL"
# Promotion Activation # remark = "Request bill Receipt No #{@sale_data.receipt_no}"
Promotion.promo_activate(@sale) # sale_audit = SaleAudit.record_audit_sale(@sale_data.sale_id,remark,action_by,type )
#bill channel # # Promotion Activation
if ENV["SERVER_MODE"] == 'cloud' # Promotion.promo_activate(@sale)
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table, from: from # #bill channel
if order.source == "quick_service" # if ENV["SERVER_MODE"] == 'cloud'
result = {:status=> @status, :data => @sale.sale_id } # from = request.subdomain + "." + request.domain
render :json => result.to_json # else
else # from = ""
# end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # ActionCable.server.broadcast "bill_channel",table: table, from: from
# if order.source == "quick_service"
# result = {:status=> @status, :data => @sale.sale_id }
# render :json => result.to_json
# else
printer = PrintSetting.find_by_unique_code("CheckInOutPdf") # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "CheckInOutPdf"
booking = Booking.find_by_booking_id(bk_order.booking_id)
# print when complete click # printer = PrintSetting.find_by_unique_code("CheckInOutPdf")
order_queue_printer = Printer::OrderQueuePrinter.new(printer) # unique_code = "CheckInOutPdf"
# booking = Booking.find_by_booking_id(bk_order.booking_id)
if !printer.nil? # # print when complete click
order_queue_printer.print_check_in_out(printer, booking, table) # order_queue_printer = Printer::OrderQueuePrinter.new(printer)
end
end # if !printer.nil?
end # order_queue_printer.print_check_in_out(printer, booking, table)
# end
# end
# end
else else
@status = false @status = false
@error_message = "No Current Open Shift for This Employee" @error_message = "No Current Open Shift for This Employee"

View File

@@ -76,9 +76,15 @@ class Settings::TaxProfilesController < ApplicationController
# DELETE /settings/tax_profiles/1 # DELETE /settings/tax_profiles/1
# DELETE /settings/tax_profiles/1.json # DELETE /settings/tax_profiles/1.json
def destroy def destroy
@settings_tax_profile.destroy customers = Customer.where("tax_profiles LIKE '%#{@settings_tax_profile.id}%'")
flash[:notice] = 'Tax profile was successfully destroyed.' if customers.nil? || customers.empty?
render :json => {:status=> "Success", :url => settings_tax_profiles_url }.to_json @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| # respond_to do |format|
# format.html { redirect_to settings_tax_profiles_url, notice: 'Tax profile was successfully destroyed.' } # format.html { redirect_to settings_tax_profiles_url, notice: 'Tax profile was successfully destroyed.' }
# format.json { head :no_content } # format.json { head :no_content }

View File

@@ -1498,7 +1498,7 @@ end
else else
query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
end end
query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date') .order('receipt_date')
else else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
@@ -1508,7 +1508,7 @@ end
else else
query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
end end
query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date') .order('receipt_date')
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)

View File

@@ -401,14 +401,14 @@
</button> </button>
<!-- --> <!-- -->
<% if current_login_employee.role == "cashier" %> <% if current_login_employee.role == "cashier" %>
<% if @other_payment < 0 && @sale_payment.nil? %> <% if @other_payment <= 0 && @sale_payment.nil? %>
<%if @sale_data.total_discount == 0 %> <%if @sale_data.total_discount == 0 %>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a> <a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
<% end %> <% end %>
<%end %> <%end %>
<% if @sale_payment.nil? %> <% if @sale_payment.nil? %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a> <a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
<% if @other_payment < 0 %> <% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %> <%if @sale_data.total_discount == 0 %>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a> <a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a> <a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
@@ -416,14 +416,14 @@
<% end %> <% end %>
<% end %> <% end %>
<% else %> <% else %>
<% if @other_payment < 0 && @sale_payment.nil?%> <% if @other_payment <= 0 && @sale_payment.nil?%>
<%if @sale_data.total_discount == 0 %> <%if @sale_data.total_discount == 0 %>
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button> <button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
<%end %> <%end %>
<%end %> <%end %>
<% if @sale_payment.nil? %> <% if @sale_payment.nil? %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button> <button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<% if @other_payment < 0 %> <% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %> <%if @sale_data.total_discount == 0 %>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button> <button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button> <button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>