remove get_tax_profiles from api_controller and create tax_profiles api
This commit is contained in:
@@ -8,10 +8,6 @@ class Api::ApiController < ActionController::API
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
def get_tax_profiles
|
||||
@inclusive_tax, @exclusive_tax = TaxProfile.calculate_tax("online_order")
|
||||
end
|
||||
|
||||
private
|
||||
# ActionView::Rendering override render_to_body breaks render :json,
|
||||
# resulting in an ActionView::MissingTemplate error.
|
||||
|
||||
8
app/controllers/api/tax_profiles_controller.rb
Normal file
8
app/controllers/api/tax_profiles_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Api::TaxProfilesController < Api::ApiController
|
||||
|
||||
def index
|
||||
@tax_profiles = TaxProfile.where(nil)
|
||||
@tax_profiles = @tax_profiles.filter_by_group_type(params[:group_type]) if params[:group_type].present?
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5,6 +5,8 @@ class TaxProfile < ApplicationRecord
|
||||
# validations
|
||||
validates_presence_of :name, :rate, :group_type
|
||||
|
||||
scope :filter_by_group_type, -> (group_type) { where group_type: group_type }
|
||||
|
||||
def self.calculate_tax(group_type)
|
||||
divided_value =0.0
|
||||
exclusive =0.0
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
json.status true
|
||||
json.inclusive_tax @inclusive_tax
|
||||
json.exclusive_tax @exclusive_tax
|
||||
4
app/views/api/tax_profiles/index.json.jbuilder
Normal file
4
app/views/api/tax_profiles/index.json.jbuilder
Normal file
@@ -0,0 +1,4 @@
|
||||
json.status true
|
||||
json.data do
|
||||
json.tax_profiles @tax_profiles, :name, :group_type, :rate, :inclusive, :order_by
|
||||
end
|
||||
@@ -50,7 +50,11 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'authenticate' => "authenticate#create"
|
||||
delete 'authenticate' => "authenticate#destroy"
|
||||
get "menu_item_groups" => "menu_item_groups#index"
|
||||
get 'get_tax_profiles' => 'api#get_tax_profiles'
|
||||
|
||||
scope '/(:group_type)', defaults: { group_type: nil } do
|
||||
resources :tax_profiles, only: [:index]
|
||||
end
|
||||
|
||||
namespace :restaurant do
|
||||
get 'zones' => "zones#index"
|
||||
resources :menu, only: [:index, :show]
|
||||
@@ -69,7 +73,6 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "bill/:booking_id" => "bill#create"
|
||||
post "move" => "move#create"
|
||||
|
||||
|
||||
#Order Controller
|
||||
resources :orders, only: [:create, :show, :update] do
|
||||
post "bill" => "bill#create"
|
||||
|
||||
Reference in New Issue
Block a user