diff --git a/README.md b/README.md index d57ed858..ee8846a0 100755 --- a/README.md +++ b/README.md @@ -135,6 +135,10 @@ ADD COLUMN image_path VARCHAR(255); ALTER TABLE sales ADD COLUMN equal_persons INT(11) after rebate_status; <---- Extra Fields Script -----> +For CloseCashierCustomisePdf in lookups + *** change CloseCashierPdf to CloseCashierCustomisePdf + 1) settings/print_settings + 2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 } * ToDo list diff --git a/app/models/print_setting.rb b/app/models/print_setting.rb index b4f17a62..d28b852b 100755 --- a/app/models/print_setting.rb +++ b/app/models/print_setting.rb @@ -3,6 +3,6 @@ class PrintSetting < ApplicationRecord validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies def self.get_precision_delimiter - PrintSetting.find_by_unique_code("CloseCashierPdf") + PrintSetting.find_by_unique_code("ReceiptBillPdf") end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 3fa19ef9..54c60eb3 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -870,18 +870,20 @@ def self.get_menu_item_query(order_by) query = MenuItem.unscoped.select("acc.id as account_id, acc.title as account_name, mii.item_instance_code as item_code, " + - "(CASE WHEN si.qty > 0 THEN SUM(si.qty) ELSE 0 END) as total_item," + - "(CASE WHEN si.unit_price > 0 THEN si.unit_price ELSE mii.price END) as unit_price," + - "(CASE WHEN (si.qty * si.unit_price) > 0 THEN (si.qty * si.unit_price) ELSE 0 END) as grand_total," + - "mii.price as unit_price, menu_items.name as product_name, + "(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," + + "(CASE WHEN si.unit_price != mii.price THEN si.unit_price ELSE mii.price END) as unit_price," + + "(CASE WHEN si.qty IS NOT NULL THEN (SUM(si.qty) * si.unit_price) ELSE 0 END) as grand_total," + + "mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE mii.item_instance_name END) as product_name, mc.name as" + - " menu_category_name,mc.id as menu_category_id, si.remark as status_type, si.price as price ") + " menu_category_name,mc.id as menu_category_id, si.remark as status_type, + si.price as price ") .joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" + " LEFT JOIN menu_categories mc ON mc.id = menu_items.menu_category_id" + " LEFT JOIN accounts acc ON acc.id = menu_items.account_id" + " LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" + " LEFT JOIN sales s ON s.sale_id = si.sale_id") - .group("mc.id, menu_items.name, si.qty, (CASE WHEN si.unit_price > 0 THEN si.unit_price ELSE mii.price END)") + .where("(CASE WHEN s.sale_status IS NOT NULL THEN s.sale_status='completed' ELSE 1 END)") + .group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE mii.item_instance_name END)") .order("si.qty #{order_by}, menu_items.menu_category_id #{order_by}") end #product sale report query diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 91cce7e3..a30cae23 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -164,7 +164,7 @@ <%= @summ_sale.total_receipt %> - <%= t("views.right_panel.detail.total") %> <%= t :sale %> : + <%= t("views.right_panel.detail.net") %> <%= t :sale %> : <%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> @@ -176,7 +176,7 @@ <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> - <%= t("views.right_panel.detail.grand_total") %> : + <%= t("views.right_panel.detail.gross_sale") %> : <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> diff --git a/app/views/reports/product_sale/index.html.erb b/app/views/reports/product_sale/index.html.erb index eb797122..ffad886a 100644 --- a/app/views/reports/product_sale/index.html.erb +++ b/app/views/reports/product_sale/index.html.erb @@ -58,29 +58,29 @@ <% total_qty = 0 %> <% @sale_data.each do |sale| %> - <% if sale.status_type != "Discount" && sale.status_type != "foc" - total_qty += sale.total_item - grand_total += sale.grand_total - end %> - <% if sale.status_type == "foc" && sale.price > 0 - total_qty += sale.total_item - grand_total += sale.grand_total - end %> + <% grand_total += sale.grand_total %> + <% if sale.status_type != "Discount" && sale.status_type != "foc" + total_qty += sale.total_item + end %> + <% if sale.status_type == "foc" && sale.price > 0 + total_qty += sale.total_item + end %> - -   - <% if !cate_arr.include?(sale.menu_category_id) %> - <%= sale.menu_category_name %> - <% cate_arr.push(sale.menu_category_id) %> - <% else %> -   - <% end %> - <%= sale.item_code rescue '-' %> - <%= sale.product_name rescue '-' %> - <%= sale.total_item rescue '-' %> - <%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%> - <%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> - + +   + <% if !cate_arr.include?(sale.menu_category_id) %> + <%= sale.menu_category_name %> + <% cate_arr.push(sale.menu_category_id) %> + <% else %> + <% cate_arr = Array.new %> +   + <% end %> + <%= sale.item_code rescue '-' %> + <%= sale.product_name rescue '-' %> + <%= sale.total_item rescue '-' %> + <%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> + <% end %> diff --git a/app/views/reports/product_sale/index.xls.erb b/app/views/reports/product_sale/index.xls.erb index 7123588c..f0410810 100755 --- a/app/views/reports/product_sale/index.xls.erb +++ b/app/views/reports/product_sale/index.xls.erb @@ -34,12 +34,7 @@   - <% if !cate_arr.include?(sale.menu_category_id) %> <%= sale.menu_category_name %> - <% cate_arr.push(sale.menu_category_id) %> - <% else %> -   - <% end %> <%= sale.item_code rescue '-' %> <%= sale.product_name rescue '-' %> <%= sale.total_item rescue '-' %>