From fae91f701b949a0d0b1b5da4574f81349d4e99cf Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 22 Jan 2020 14:26:14 +0630 Subject: [PATCH] tax --- app/controllers/api/shops_controller.rb | 2 +- app/controllers/foodcourt/food_court_controller.rb | 3 ++- app/controllers/foodcourt/orders_controller.rb | 2 +- app/models/sale.rb | 3 ++- app/views/api/orders/create.json.jbuilder | 12 +++++++++++- lib/tasks/shop_create.rake | 1 + 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index 73d329a9..af22cab0 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -1,5 +1,5 @@ class Api::ShopsController < Api::ApiController - skip_before_action :set_current_tenant_by_subdomain_or_first + skip_before_action :set_current_tenant_by_subdomain_or_first, only: [:index, :show] def index @shops = Shop.select('id,logo,name,shop_code,address,phone_no').all diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index 20c467eb..0fd51763 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -43,11 +43,12 @@ class Foodcourt::FoodCourtController < ApplicationController end end @app_order_new_count = Booking.select("bookings.*,customers.*") + .joins(" JOIN sales ON bookings.sale_id=sales.sale_id") .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length + .where("sales.sale_status =? and sales.payment_status =? and orders.source='app' and DATE(bookings.created_at)=?",'completed','paid',Date.today).order("bookings.created_at desc").uniq.length render "foodcourt/addorders/detail" end diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 8d75e0ae..4b9d6956 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -71,7 +71,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',Date.today).order("bookings.created_at desc").uniq + .where("sales.sale_status =? and sales.payment_status =? and orders.source='app' and DATE(bookings.created_at)=?",'completed','paid',Date.today).order("bookings.created_at desc").uniq end def completed customer =Customer.find_by_customer_id(params[:customer_id]) diff --git a/app/models/sale.rb b/app/models/sale.rb index a5ba30ac..f1d13222 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -462,7 +462,8 @@ class Sale < ApplicationRecord tax_profiles = unique_tax_profiles(order_source, self.customer_id) if tax_type.nil? - if tax_profiles.count == 2 + #in previous >> if tax_profiles.count ==2 + if tax_profiles.count >= 2 tax_type = "all" elsif tax_profiles.count == 1 if tax_profiles.name.downcase == "service charges" diff --git a/app/views/api/orders/create.json.jbuilder b/app/views/api/orders/create.json.jbuilder index 28a7f764..2c5c7e43 100755 --- a/app/views/api/orders/create.json.jbuilder +++ b/app/views/api/orders/create.json.jbuilder @@ -5,7 +5,17 @@ if @status == true json.order_items do json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark,:price end - json.sale_id @sale.sale_id + if @sale + json.sale_id @sale.sale_id + json.sale_items do + json.array! @sale.sale_items, :product_name, :qty, :remark,:price + end + json.grand_total @sale.grand_total + json.total_tax @sale.total_tax + json.taxes do + json.array! @sale.sale_taxes, :tax_name, :tax_rate, :tax_payable_amount, :inclusive + end + end else json.status :error if @error_messages diff --git a/lib/tasks/shop_create.rake b/lib/tasks/shop_create.rake index f872db36..a0e56263 100644 --- a/lib/tasks/shop_create.rake +++ b/lib/tasks/shop_create.rake @@ -215,6 +215,7 @@ namespace :shop do {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: args.shop_code}, {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: args.shop_code}, {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: args.shop_code}, + {membership_type:"void",is_active:1,gateway_url:"/api/payments/payment_void",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: args.shop_code}, {membership_type:"search_paypar_security_code",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_security_code",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: args.shop_code}]) puts " Finished member_actions Set Up Data"