diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index 9284b889..74a46b14 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -265,6 +265,7 @@ function show_order_detail(url,sr_no){ dataType: "json", success: function(data) { // console.log(data); + $("#order_remark").text(""); $(".tbl_customer").show(); if(data.status != "delivered"){ $('#accepted').show(); diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index 1bb257de..a7929653 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -18,7 +18,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController end if status - check_customer = Customer.find_by_email_and_membership_id(params[:email],params[:membership_id]) + check_customer = Customer.find_by_email_and_membership_id_and_customer_type(params[:email],params[:membership_id],'Doemal') if !check_customer.nil? customer_id = check_customer.customer_id else diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb index 04480864..27fe327d 100644 --- a/app/controllers/api/survey_controller.rb +++ b/app/controllers/api/survey_controller.rb @@ -18,8 +18,8 @@ class Api::SurveyController < Api::ApiController cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id) shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) - if params[:survey_id] - survey = Survey.find(params[:survey_id]) + if params[:id] + survey = Survey.find(params[:id]) else survey = Survey.new end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index cba2bd18..045afafb 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -6,7 +6,7 @@ class Origami::PaymentsController < BaseOrigamiController def first_bill sale_id = params[:sale_id] # sale_id sale_data = Sale.find_by_sale_id(sale_id) - sale_items = SaleItem.unscoped.select("sale_id,product_code,item_instance_code,product_name,product_alt_name,account_id,status,remark,SUM(qty) as qty,SUM(unit_price) as unit_price,SUM(taxable_price) as taxable_price,SUM(price) as price,is_taxable").where("sale_id=?",sale_id).group("item_instance_code,unit_price") + sale_items = SaleItem.get_all_sale_items(sale_id) member_info = nil # For Cashier by Zone @@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - sale_items = SaleItem.unscoped.select("sale_id,product_code,item_instance_code,product_name,product_alt_name,account_id,status,remark,SUM(qty) as qty,SUM(unit_price) as unit_price,SUM(taxable_price) as taxable_price,SUM(price) as price,is_taxable").where("sale_id=?",sale_id).group("item_instance_code,unit_price") + sale_items = SaleItem.get_all_sale_items(sale_id) shop_details = Shop.first # rounding adjustment if shop_details.is_rounding_adj diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 477ef631..057f6f9b 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -30,10 +30,19 @@ class OrderReservation < ApplicationRecord customer.address = params[:address] ? params[:address] : '' customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : '' customer.membership_id = params[:membership_id] - customer.customer_type = "Takeaway" + customer.customer_type = "Doemal" customer.tax_profiles = ["2"] customer.save + # unless customer.valid? + # render json: { + # status: 422, + # message: "Validation error", + # errors: customer.errors + # }.to_json + # return + # end + return customer end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index d01ee5e0..313be6a3 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -161,6 +161,20 @@ class SaleItem < ApplicationRecord # return price # end + def self.get_all_sale_items(sale_id) + sale_items = SaleItem.select("sale_id,product_code,item_instance_code, + product_name,product_alt_name,account_id,status,remark, + (CASE WHEN qty > 0 AND remark IS NULL THEN SUM(qty) ELSE qty END) as qty, + unit_price, + taxable_price, + (CASE WHEN price > 0 AND remark IS NULL THEN SUM(price) ELSE price END) as price, + is_taxable") + .where("sale_id = ?",sale_id) + .order("product_name asc") + .group("status,product_name,item_instance_code,unit_price") + return sale_items + end + private def generate_custom_id self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index 852b1f62..5fe53223 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -29,7 +29,9 @@ if (menu.menu_categories) if category.menu_items json.items category.menu_items do |item| - json.partial! 'origami/addorders/menu_item', item: item + if item.is_available + json.partial! 'origami/addorders/menu_item', item: item + end end end end diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index 85c7bed8..cd6e146b 100755 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -151,14 +151,24 @@ <%= number_with_precision(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%> - <% total_tax = 0 %> + <% total_tax = 0 + tax_amount = 0 + tax_name = '' + tax_arr = [] %> <% net = 0 %> <% unless @tax.empty? %> <% @tax.each do |tax| %> - <% total_tax += tax.tax_amount.to_f %> + <% if tax.tax_name.downcase == tax_name.downcase + tax_amount += tax.tax_amount + else + tax_amount = tax.tax_amount + end + tax_name = tax.tax_name + total_tax += tax.tax_amount.to_f + %> - <%= tax.tax_name rescue '-'%> - <%= number_with_precision(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <%= tax_name rescue '-'%> + <%= number_with_precision(tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>   <% end %> @@ -170,8 +180,8 @@   - <% net = grand_total%> - <% net = grand_total- discount%> + <% net = grand_total %> + <% net = grand_total + discount%> <% net = net - rounding_adj%> <% net = net - total_tax %>