diff --git a/README.md b/README.md index 6980e6ac..b19922da 100755 --- a/README.md +++ b/README.md @@ -295,6 +295,10 @@ settings/lookups => { type:employee_roles, name: FoodCourt Cashier, value:foodco * ToDo list +For Membership Type +settings/lookups => { type:membership_type, name: Timecity staff, value:8 } + +- ToDo list 1. Migration 2. Quick Service diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 47ccbf62..71800d83 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -36,7 +36,7 @@ private crm_root_path elsif current_user.role == "account" reports_dailysale_index_path - elsif @current_user.role == "kitchen" + elsif current_user.role == "kitchen" oqs_root_path elsif @current_user.role == "foodcourt_cashier" #check if cashier has existing open cashier diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 4ade5a2b..0ca69f3a 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -31,47 +31,40 @@ class Origami::HomeController < BaseOrigamiController @status_order = "" @status_sale = "" - @sale_array = Array.new @shop = current_shop @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - @order_items = Array.new - @dining.current_bookings.each do |booking| - if @obj_sale || @booking.blank? - @booking = booking - end + @sale_array = @dining.current_sales + if (booking = @dining.current_checkin_booking) + @booking = booking + @order_items = booking.order_items + @obj_order = booking.orders.first + end - if booking.sale_id - @sale_array.push(booking.sale) + if (booking = @dining.current_checkout_booking) + @booking = booking + @obj_sale = booking.sale + @sale_taxes = @obj_sale.sale_taxes + @status_sale = 'sale' + end - if @obj_sale.blank? - @obj_sale = booking.sale - @sale_taxes = @obj_sale.sale_taxes - @status_sale = 'sale' - end - else - @order_items += booking.order_items - @obj_order = booking.orders.first + if @obj_sale || @customer.blank? + if obj = @obj_sale || @obj_order + @customer = obj.customer + @date = obj.created_at end + end - if @obj_sale || @customer.blank? - if obj = @obj_sale || @obj_order - @customer = obj.customer - @date = obj.created_at - end - end + if @obj_sale + @status_order = 'sale' + elsif @obj_order + @status_order = 'order' + end - if @obj_sale - @status_order = 'sale' - else - @status_order = 'order' - end - - if (@obj_sale || @account_arr.blank?) && @customer - @account_arr = TaxProfile.find_by(id: @customer.tax_profiles) - end + if (@obj_sale || @account_arr.blank?) && @customer + @account_arr = TaxProfile.find_by(id: @customer.tax_profiles) end #for bank integration diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f2128556..254a9a0f 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -610,7 +610,7 @@ class Origami::PaymentsController < BaseOrigamiController end # get printer info - print_settings = PrintSetting.find_by_unique_code(unique_code) + # print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) diff --git a/app/controllers/reports/customer_controller.rb b/app/controllers/reports/customer_controller.rb new file mode 100644 index 00000000..b623d1e0 --- /dev/null +++ b/app/controllers/reports/customer_controller.rb @@ -0,0 +1,58 @@ +class Reports::CustomerController < BaseReportController + authorize_resource :class => false + def index + @membership_type = Lookup.where(lookup_type: 'membership_type') + from, to = get_date_range_from_params + customer_filter = params[:customer] + + @shift_sale_range = '' + + @shift = '' + if params[:shift_name].to_i != 0 + + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) + + @shift_sale = ShiftSale.find(params[:shift_name]) + if to.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) + else + if @shift_sale.shift_closed_at.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at) + else + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at) + end + end + end + + @lookup = Lookup.find_by_lookup_type('reprint_receipt') + if @lookup.nil? + @lookup = Lookup.create_reprint_receipt_lookup + end + if params[:membership_type] == "0" + membership_type = '' + else + membership_type = params[:membership_type] + end + @sale_data = Sale.get_shift_sales_by_customer(@shift_sale_range, @shift, from, to, membership_type, customer_filter) + @sale_taxes = Sale.get_separate_tax(@shift_sale_range, @shift, from, to, nil) + @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) + + @from = from + @to = to + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + if @shift.present? + @shift.each do |sh| + @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_data = sh + end + end + + respond_to do |format| + format.html + format.xls + end + end + + end diff --git a/app/models/booking.rb b/app/models/booking.rb index 14a440a1..b0e7b779 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -59,9 +59,9 @@ class Booking < ApplicationRecord end end - scope :active, -> {where("booking_status != 'moved'")} - scope :today, -> {where("created_at >= #{Time.now.utc}")} - scope :assign, -> { where(booking_status: 'assign')} + scope :active, -> { where('booking_status != ?', 'moved') } + scope :today, -> { where('created_at >= ?', Time.now) } + scope :assign, -> { where(booking_status: 'assign') } def self.sync_booking_records(bookings) if !bookings.nil? diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index c92fa465..c3e5838b 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -28,7 +28,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end else ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", - queue: oqs.station_name, + queue: oqs.printer_name, unique_code: print_settings.unique_code, print_copies: print_settings.print_copies, data: { @@ -73,7 +73,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end else ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", - queue: oqs.station_name, + queue: oqs.printer_name, unique_code: print_settings.unique_code, print_copies: print_settings.print_copies, data: { diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 855e0ece..c2c60370 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -115,7 +115,8 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker filename = "#{directory_name}/receipt_bill_#{sale_data.receipt_no}#{count != 1 ? "_#{count}" : ''}.pdf" pdf.render_file filename - if !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1') + + if printed_status != 'Paid' || !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1') #no print in cloud server puts "SERVER_MODE #{ENV["SERVER_MODE"]}" if ENV["SERVER_MODE"] != "cloud" @@ -125,7 +126,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker Rails.logger.debug "############## filename::" + filename else - if !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1') + if printed_status != 'Paid' || !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1') sale_payments = SalePayment .select(:payment_method, 'SUM(`sale_payments`.`payment_amount`) AS `payment_amount`') .where(sale_id: sale_data.sale_id).group(:payment_method) diff --git a/app/models/sale.rb b/app/models/sale.rb index 56336045..981bf2ac 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -804,7 +804,7 @@ class Sale < ApplicationRecord SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") .sale_payments_with_audit_except_void_between(from, to) .where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to) - .group("sale_id").to_sql + .group("sale_id") sale_taxes = Sale.select('sales.sale_id, sale_taxes.tax_name') .joins(:sale_taxes) @@ -829,13 +829,13 @@ class Sale < ApplicationRecord (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale, CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, #{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(`#{pm}`) as `#{pm}`"}.push('').join(', ')} - SUM(cash_amount) as cash_amount, - SUM(credit_amount) as credit_amount, - SUM(foc_amount) as foc_amount + SUM(`cash_amount`) as `cash_amount`, + SUM(`credit_amount`) as `credit_amount`, + SUM(`foc_amount`) as `foc_amount` FROM ( - #{sales} + #{sales.to_sql} ) as s - JOIN (#{sale_taxes.to_sql}) AS st ON s.sale_id = st.sale_id + LEFT JOIN (#{sale_taxes.to_sql}) AS st ON s.sale_id = st.sale_id GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys) return daily_total end @@ -1254,6 +1254,36 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range, shift, from, to, paymen return query end +def self.get_shift_sales_by_customer(shift_sale_range, shift, from, to, membership_type, customer_filter) + ## => left join -> show all sales although no orders + query = Sale.includes(:sale_items).select("sales.*, sale_payments.*") + .select("customers.customer_id, customers.name as customer_name,customers.membership_type as membership_type, dining_facilities.name, dining_facilities.type") + .joins("INNER JOIN sale_payments ON sale_payments.sale_id = sales.sale_id") + .joins("INNER JOIN bookings ON bookings.sale_id = sales.sale_id") + .joins("LEFT JOIN dining_facilities ON dining_facilities.id = bookings.dining_facility_id") + .completed.where.not(total_amount: 0) + .group("sales.sale_id") + + if customer_filter.present? + query = query.joins(sanitize_sql_array(["INNER JOIN customers ON customers.customer_id = sales.customer_id AND " + + "customers.name LIKE :filter", filter: "%#{customer_filter}%"])) + else + query = query.joins(:customer) + end + if !membership_type.blank? + query = query.where("customers.membership_type = (?)", membership_type) + end + + if shift.present? + query = query.where("sales.shift_sale_id in (?)", shift.to_a) + elsif shift_sale_range.present? + query = query.where("sales.shift_sale_id in (?)", shift_sale_range.to_a) + else + query = query.where("sales.receipt_date between ? and ?", from, to) + end + return query.group_by(&:membership_type) +end + def self.get_shift_sales_by_receipt_no_detail(shift_sale_range, shift, from, to, payment_type, customer_filter) ## => left join -> show all sales although no orders puts customer_filter diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 8118b272..ee99820f 100755 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -1,9 +1,6 @@ class SeedGenerator < ApplicationRecord # Generate ID for Tables def self.generate_id(model, prefix) - # model_name = self.get_model_name(model) - model_name = model - prefix ||= '' prefix << '-' if prefix.present? @@ -17,15 +14,12 @@ class SeedGenerator < ApplicationRecord prefix << shop.shop_code end - seed = self.update_seed(model_name) + seed = self.update_seed(model) length = 16 - prefix.length prefix + seed.to_s.rjust(length, '0') end def self.generate_ids(model, prefix, count = 1) - # model_name = self.get_model_name(model) - model_name = model - prefix ||= '' prefix << '-' if prefix.present? @@ -39,7 +33,7 @@ class SeedGenerator < ApplicationRecord prefix << shop.shop_code end - start = self.update_seed(model_name, count) + start = self.update_seed(model, count) stop = start + count - 1 length = 16 - prefix.length (start..stop).map { |c| prefix + c.to_s.rjust(length, '0') } @@ -129,7 +123,8 @@ class SeedGenerator < ApplicationRecord def self.update_seed(model, count = 1) SeedGenerator.transaction do - seed = SeedGenerator.lock.find_by_model(model) + seed = SeedGenerator.lock.find_by_model(get_model_name(model)) || + SeedGenerator.lock.find_by_model(model) seed.next = seed.next + (count * seed.increase_by) seed.current = seed.next - seed.increase_by seed.save! diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index e2916605..f5011aba 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -57,7 +57,7 @@
<%= f.input :name, :class => "form-control name", :required => true %> <% flash.each do |test, msg| %> - <% + <% str="[\"#{msg['name']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> @@ -94,7 +94,7 @@
-
+
@@ -107,12 +107,12 @@ <% if f.object.image_path? %>

<%= f.object.name %>

<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %> - <% else %> + <% else %> <%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %> - <% end %> + <% end %>
<%= f.file_field :image_path, :class => "img-thumbnail" %> - +
@@ -160,7 +160,7 @@ <%end %> - +
@@ -185,7 +185,7 @@
-
+
@@ -201,7 +201,7 @@ <%end %> - +
@@ -212,7 +212,7 @@ -
+
@@ -259,13 +259,10 @@ console.log(paypar_account_no); // Read Card Reader - $("#paypar_account_no").on('focus', function(e){ + $("#paypar_account_no").on('focus', function(e){ if($(this).val() == ''){ $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - },100); + getCardNo(); } }); @@ -289,6 +286,7 @@ $("#paypar_account_no").val(cardNo); $("#search").val(cardNo); $("#type").val("card"); + $("#filter_form").submit(); }else{ if($.inArray(cardNo, paypar_account_no) !== -1){ swal({ @@ -311,9 +309,10 @@ $("#sxModal").hide(); //$("#filter_form").submit(); } + $("#sxModal").hide(); } $("#sxModal .btn_cancel").on('click',function(){ $("#sxModal").hide(); }); - \ No newline at end of file + diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 52ef29c4..d1a8f7a2 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -1,9 +1,9 @@ - + + + <%= link_to 'Back', crm_customers_path %> + + +
@@ -79,7 +89,7 @@ <%= t("views.right_panel.detail.status") %> <%= t("views.right_panel.detail.from_account") %> - + <%= t("views.right_panel.detail.receipt_no") %> @@ -94,7 +104,7 @@ (<%= transaction["withdraw"] %>) <% end %> <%= transaction["status"] %> - <%= transaction["account_status"] %> + <%= transaction["account_status"] %> <%= transaction["receipt_no"] %> <% end %> @@ -126,7 +136,7 @@
<%= t :order_details %>
- +
@@ -150,13 +160,13 @@
<%= t("views.right_panel.detail.order_id") %>
- +
<%= t :sale_details %>
- +
@@ -195,19 +205,19 @@ <% end %> - +
<%= t("views.right_panel.detail.sale_id") %><%= add_grand_total %>
- +
<%= t :credit %> <%= t :details %>
- + @@ -230,4 +240,3 @@ - diff --git a/app/views/crm/dining_queues/assign.html.erb b/app/views/crm/dining_queues/assign.html.erb index 7c78ecc8..846cdbe5 100755 --- a/app/views/crm/dining_queues/assign.html.erb +++ b/app/views/crm/dining_queues/assign.html.erb @@ -1,6 +1,15 @@
-<% breadcrumb_add 'Queue', crm_dining_queues_path, dashboard_path, "Assign Queue #{@queue.queue_no}" %> - + +
diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index 85450b84..b0438dd0 100755 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -1,4 +1,13 @@ -<% breadcrumb_add t('queue'), "", dashboard_path %> +
+
@@ -9,7 +18,7 @@
<% if @dining_queues.count > 0 %>
- + <% @dining_queues.each do |queue| %> <% if queue.status == "Assign" @bg_color = "assign" @@ -42,7 +51,7 @@
<% end %> - +
<% else %>

There is no queue Now !

@@ -58,25 +67,25 @@
view_headline QUEUE DETAILs

1) Latest Queue No - <%= @complete_queue.last.queue_no rescue 0 %>
- 2) Next Queue No - <% @next = (@complete_queue.last.queue_no.to_i rescue 0) + 1%> + 2) Next Queue No - <% @next = (@complete_queue.last.queue_no.to_i rescue 0) + 1%> <%= @next rescue 0 %>
3) Today Completed Queue - <%= @complete_queue.count %>

list <%= t("views.right_panel.header.button_lists") %>

- 1) <%= t("views.right_panel.button.cancel") %> - <%= t("views.right_panel.button.queue") %> - - <%= t("views.right_panel.detail.cancel_btn_txt") %> + 1) <%= t("views.right_panel.button.cancel") %> + <%= t("views.right_panel.button.queue") %> - + <%= t("views.right_panel.detail.cancel_btn_txt") %> <%= t("views.right_panel.detail.queue_txt") %>
- 2) <%= t("views.btn.new") %> - <%= t("views.right_panel.button.queue") %> - - <%= t("views.right_panel.detail.create_btn_txt") %> + 2) <%= t("views.btn.new") %> + <%= t("views.right_panel.button.queue") %> - + <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.queue_txt") %>
- 2) <%= t("views.btn.assign") %> - <%= t("views.right_panel.button.queue") %> - - <%= t("views.right_panel.detail.assign_txt") %> + 2) <%= t("views.btn.assign") %> + <%= t("views.right_panel.button.queue") %> - + <%= t("views.right_panel.detail.assign_txt") %> <%= t("views.right_panel.detail.queue_txt") %>

list <%= t("views.right_panel.header.link_lists") %>
@@ -85,7 +94,7 @@ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %>

-
+
<%= link_to t("views.btn.new"),new_crm_dining_queue_path,:class => 'btn bg-green btn-block btn-lg btn-block', 'data-no-turbolink' => true %> @@ -157,4 +166,4 @@ function cancel_queue(id,url) { -moz-column-count: 4; column-count: 4; } - \ No newline at end of file + diff --git a/app/views/crm/dining_queues/new.html.erb b/app/views/crm/dining_queues/new.html.erb index e6aa5698..e41d788f 100755 --- a/app/views/crm/dining_queues/new.html.erb +++ b/app/views/crm/dining_queues/new.html.erb @@ -1,3 +1,15 @@
- <%= render 'form', dining_queue: @dining_queue %> -
\ No newline at end of file + + + <%= render 'form', dining_queue: @dining_queue %> + +
diff --git a/app/views/inventory/inventory/index.html.erb b/app/views/inventory/inventory/index.html.erb index 3b765c89..cee37a1f 100755 --- a/app/views/inventory/inventory/index.html.erb +++ b/app/views/inventory/inventory/index.html.erb @@ -1,4 +1,12 @@ -<% breadcrumb_add t('inventory'), "", dashboard_path %> +
diff --git a/app/views/inventory/inventory/show.html.erb b/app/views/inventory/inventory/show.html.erb index a570277c..5545e8bf 100644 --- a/app/views/inventory/inventory/show.html.erb +++ b/app/views/inventory/inventory/show.html.erb @@ -1,4 +1,13 @@ -<% breadcrumb_add t('inventory'), '', inventory_path %> + +
@@ -62,4 +71,4 @@ <%= paginate @stock_journals %> <% end %>
-
\ No newline at end of file +
diff --git a/app/views/inventory/inventory_definitions/new.html.erb b/app/views/inventory/inventory_definitions/new.html.erb index 20ea06c4..318d464b 100755 --- a/app/views/inventory/inventory_definitions/new.html.erb +++ b/app/views/inventory/inventory_definitions/new.html.erb @@ -1,6 +1,6 @@ <%if current_login_employee.role !="waiter" %> - - <% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "account" %> - - <% elsif current_login_employee.role == "supervisor" %> - - <% elsif current_login_employee.role == "cashier" || current_login_employee.role == "waiter"%> - <%if ShiftSale.current_open_shift(current_login_employee) %> - <%if current_login_employee.role == "cashier" && food_court %> - - <%else%> - - <%end%> - <%else%> - - <%end%> - <%else%> - - <% end %> + + <% else %> - + <%end%> Logo SX Restaurant @@ -55,7 +39,7 @@ <%end%> @@ -131,7 +115,7 @@ - +
- + diff --git a/app/views/reports/customer/index.html.erb b/app/views/reports/customer/index.html.erb new file mode 100644 index 00000000..328de17f --- /dev/null +++ b/app/views/reports/customer/index.html.erb @@ -0,0 +1,286 @@ + + +
+
+ + + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_customer_index_path} %> +
+ + + + + + + + +
+
+
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %> <%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t :cashier %> <%= t("views.right_panel.detail.credit_amount") %>
+ + + + + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + + + <% t_grand_total = 0 %> + <% t_old_grand_total = 0 %> + <% t_total_sum = 0 %> + <% t_discount_amt = 0 %> + <% t_rounding_adj = 0%> + + <% if !@sale_data.nil? %> + + <% @sale_data.each do |member_group| %> + <% grand_total = 0 %> + <% old_grand_total = 0 %> + <% total_tax = [] %> + <% total_sum = 0 %> + <% discount_amt = 0 %> + <% rounding_adj = 0%> + + + <%if member_group[0].nil?%> + + <%else%> + + <%end%> + + + <% member_group[1].each do |result|%> + <% grand_total += result.grand_total.to_f %> + <% t_grand_total += result.grand_total.to_f %> + <% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %> + <% t_old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f%> + <% total_sum += result.total_amount.to_f %> + <% t_total_sum += result.total_amount.to_f %> + <% discount_amt += result.total_discount.to_f %> + <% t_discount_amt += result.total_discount.to_f %> + <% rounding_adj += result.rounding_adjustment.to_f %> + <% t_rounding_adj += result.rounding_adjustment.to_f %> + + + + + + + + + <% @tax_profiles.each do |tax| %> + <%tax_value=0%> + <% if sale_tax = result.sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %> + <%tax_value=sale_tax.tax_payable_amount%> + + <% else %> + + <% end %> + <%total_tax << { + tax.name => tax_value + }%> + <% end %> + + + + + <% end %> + + <% total_tax = total_tax.reduce {|acc, h| acc.merge(h) {|_,v1,v2| v1 + v2 }}%> + + + + <% @tax_profiles.each do |tax| %> + <%if total_tax.has_key?(tax.name)%> + + <%end%> + <% end %> + + + + + + + + <%end%> + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + <%end%> + + + + + <% @tax_profiles.each do |tax| %> + <% if sale_tax = @sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %> + + <% else %> + + <% end %> + <% end %> + + + + + +
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
<%= t("views.right_panel.detail.dining") %><%= t("views.right_panel.detail.receipt_no") %><%= t :customer %><%= t :cashier %><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <%= tax.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
Group Type : Normal Group Type : <%= Lookup.where(:lookup_type=>'membership_type', :value=>member_group[0]).last.name %>
+ <%if result.type %> + <%= result.type %> - <%= result.name %> + <% else %> + - + <% end %> + <%= result.receipt_no rescue '-' %> <%= result.customer_name rescue '-' %><%= result.cashier_name rescue '-' %><%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) %><%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '0' %><%= number_format(sale_tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
 <%= number_format(total_sum, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(discount_amt, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(total_tax[tax.name], precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %><%= number_format(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
 
 <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %><%= tax.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
 <%= number_format(t_total_sum, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(t_discount_amt, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(sale_tax.st_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(t_old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %><%= number_format(t_rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(t_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
+
+ + + + + diff --git a/app/views/reports/customer/index.xls.erb b/app/views/reports/customer/index.xls.erb new file mode 100644 index 00000000..9ebfe63a --- /dev/null +++ b/app/views/reports/customer/index.xls.erb @@ -0,0 +1,165 @@ + + + + + + + +
+
+
+
+ + + + + + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + + + + + <% t_grand_total = 0 %> + <% t_old_grand_total = 0 %> + <% t_total_sum = 0 %> + <% t_discount_amt = 0 %> + <% t_rounding_adj = 0%> + + <% if @sale_data %> + <% @sale_data.each do |member_group| %> + <% grand_total = 0 %> + <% old_grand_total = 0 %> + <% total_tax = [] %> + <% total_sum = 0 %> + <% discount_amt = 0 %> + <% rounding_adj = 0%> + + + <%if member_group[0].nil?%> + + <%else%> + + <%end%> + + + <% member_group[1].each do |result|%> + <% grand_total += result.grand_total.to_f %> + <% t_grand_total += result.grand_total.to_f %> + <% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %> + <% t_old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f%> + <% total_sum += result.total_amount.to_f %> + <% t_total_sum += result.total_amount.to_f %> + <% discount_amt += result.total_discount.to_f %> + <% t_discount_amt += result.total_discount.to_f %> + <% rounding_adj += result.rounding_adjustment.to_f %> + <% t_rounding_adj += result.rounding_adjustment.to_f %> + + + + + + + + + <% @tax_profiles.each do |tax| %> + <%tax_value=0%> + <% if sale_tax = result.sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %> + <%tax_value=sale_tax.tax_payable_amount%> + + <% else %> + + <% end %> + <%total_tax << { + tax.name => tax_value + }%> + <% end %> + + + + + <% end %> + + <% total_tax = total_tax.reduce {|acc, h| acc.merge(h) {|_,v1,v2| v1 + v2 }}%> + + + + <% @tax_profiles.each do |tax| %> + <%if total_tax.has_key?(tax.name)%> + + <%end%> + <% end %> + + + + + + + + <%end%> + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + <%end%> + + + + + <% @tax_profiles.each do |tax| %> + <% if sale_tax = @sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %> + + <% else %> + + <% end %> + <% end %> + + + + + +
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
<%= t("views.right_panel.detail.dining") %><%= t("views.right_panel.detail.receipt_no") %><%= t :customer %><%= t :cashier %><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <%= tax.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
Group Type : Normal Group Type : <%= Lookup.where(:lookup_type=>'membership_type', :value=>member_group[0]).last.name %>
+ <%if result.type %> + <%= result.type %> - <%= result.name %> + <% else %> + - + <% end %> + <%= result.receipt_no rescue '-' %> <%= result.customer_name rescue '-' %><%= result.cashier_name rescue '-' %><%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) %><%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '0' %><%= number_format(sale_tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
 <%= number_format(total_sum, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(discount_amt, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(total_tax[tax.name], precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %><%= number_format(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
 
 <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %><%= tax.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
 <%= number_format(t_total_sum, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(t_discount_amt, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(sale_tax.st_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(t_old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %><%= number_format(t_rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %><%= number_format(t_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
+
+
+
+
+ + diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index d2ad7232..310783b9 100755 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -1,6 +1,6 @@ - diff --git a/app/views/settings/item_sets/new.html.erb b/app/views/settings/item_sets/new.html.erb index fd43dbc5..39aefb89 100755 --- a/app/views/settings/item_sets/new.html.erb +++ b/app/views/settings/item_sets/new.html.erb @@ -1,6 +1,6 @@ - diff --git a/app/views/settings/lookups/new.html.erb b/app/views/settings/lookups/new.html.erb index 68b2f068..d73df7cb 100755 --- a/app/views/settings/lookups/new.html.erb +++ b/app/views/settings/lookups/new.html.erb @@ -1 +1,11 @@ -<%= render 'form', settings_lookup: @settings_lookup %> \ No newline at end of file + +<%= render 'form', settings_lookup: @settings_lookup %> diff --git a/app/views/settings/lookups/show.html.erb b/app/views/settings/lookups/show.html.erb index 0989380b..d3514632 100755 --- a/app/views/settings/lookups/show.html.erb +++ b/app/views/settings/lookups/show.html.erb @@ -1,6 +1,6 @@