From 24fd399c170b1b86b9a07a71c50c2430df40777d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 28 Jul 2017 11:30:35 +0630 Subject: [PATCH 1/6] update view --- .../transactions/manual_sales_controller.rb | 1 + app/views/oqs/home/index.html.erb | 2 +- app/views/origami/home/index.html.erb | 9 ++++ app/views/origami/home/show.html.erb | 42 +++++++++---------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/app/controllers/transactions/manual_sales_controller.rb b/app/controllers/transactions/manual_sales_controller.rb index 77dd4371..d7f26f39 100644 --- a/app/controllers/transactions/manual_sales_controller.rb +++ b/app/controllers/transactions/manual_sales_controller.rb @@ -3,6 +3,7 @@ class Transactions::ManualSalesController < ApplicationController def void @sale = params[:sale_id] @reason = Lookup.where("lookup_type = 'void_reason'") + respond_to do |format| format.html # index.html.erb format.json { render json: @sales } diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 3e068b12..71077ec4 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -192,7 +192,7 @@ - + Back diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 77d85f10..04c12262 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -110,6 +110,12 @@ + + <%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %> + + <%end%> + @@ -218,4 +224,7 @@ $('#cash_out').on('click',function(){ $('#close_cashier').on('click',function(){ window.location.href = '/origami/shift/close'; }) +$('#back').on('click',function(){ + window.location.href = '/dashboard'; +}) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 709ed7ca..891524ec 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -305,27 +305,27 @@ <% if @dining.bookings.length >= 1 %> - <% if @status_order == 'order' && @status_sale != 'sale' %> - - - - - - - - - - <% else %> - - - - - - - - - - <% end %> + <% if @status_order == 'order' && @status_sale != 'sale' %> + + + + + + + + + + <% else %> + + + + + + + + + + <% end %> From 98c04f21d8d7ddc91cdb6427b3310730f26e58e7 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 28 Jul 2017 17:07:16 +0630 Subject: [PATCH 2/6] update report and view --- app/controllers/origami/home_controller.rb | 2 +- .../origami/payments_controller.rb | 9 +- .../reports/credit_payment_controller.rb | 61 ++++++ .../reports/void_sale_controller.rb | 60 ++++++ app/models/ability.rb | 2 +- app/models/sale.rb | 42 +++-- app/views/origami/home/show.html.erb | 7 +- .../_shift_sale_report_filter.html.erb | 125 +++++++++++++ .../reports/credit_payment/index.html.erb | 150 +++++++++++++++ .../reports/credit_payment/index.xls.erb | 39 ++++ .../_shift_sale_report_filter.html.erb | 125 +++++++++++++ app/views/reports/void_sale/index.html.erb | 175 ++++++++++++++++++ app/views/reports/void_sale/index.xls.erb | 39 ++++ config/routes.rb | 8 +- 14 files changed, 815 insertions(+), 29 deletions(-) create mode 100644 app/controllers/reports/credit_payment_controller.rb create mode 100644 app/controllers/reports/void_sale_controller.rb create mode 100644 app/views/reports/credit_payment/_shift_sale_report_filter.html.erb create mode 100644 app/views/reports/credit_payment/index.html.erb create mode 100644 app/views/reports/credit_payment/index.xls.erb create mode 100644 app/views/reports/void_sale/_shift_sale_report_filter.html.erb create mode 100644 app/views/reports/void_sale/index.html.erb create mode 100644 app/views/reports/void_sale/index.xls.erb diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index f78f162a..0e7f3388 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -15,7 +15,7 @@ class Origami::HomeController < BaseOrigamiController @rooms = Room.all.active.order('status desc') @complete = Sale.where("sale_status != 'new'") @orders = Order.all.order('date desc') - @shop = Shop.find_by_id(1) + @status_order = "" @status_sale = "" @sale_array = Array.new diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 24d63b71..8c328030 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -166,7 +166,14 @@ class Origami::PaymentsController < BaseOrigamiController def rounding_adj saleObj = Sale.find(params[:sale_id]) - new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + @shop = Shop.find_by_id(1) + + if @shop.is_rounding_adj + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + else + new_total = saleObj.grand_total + end + rounding_adj = new_total-saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb new file mode 100644 index 00000000..dd9b3987 --- /dev/null +++ b/app/controllers/reports/credit_payment_controller.rb @@ -0,0 +1,61 @@ +class Reports::CreditPaymentController < BaseReportController +authorize_resource :class => false + def index + + from, to = get_date_range_from_params + + @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + @shift = '' + if params[:shift_name].to_i != 0 + 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 + + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end + end + + @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to) + + @from = from + @to = to + + 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 + + def show + from, to = get_date_range_from_params + + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + date_arr = Array.new + @sale_data.each do |sale| + local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") + local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") + opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc + closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + date_arr.push(str) + end + + out = {:status => 'ok', :message => date_arr} + + respond_to do |format| + format.json { render json: out } + end + end +end \ No newline at end of file diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb new file mode 100644 index 00000000..80526ad0 --- /dev/null +++ b/app/controllers/reports/void_sale_controller.rb @@ -0,0 +1,60 @@ +class Reports::VoidSaleController < BaseReportController +authorize_resource :class => false + def index + + from, to = get_date_range_from_params + + # @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + @shift = '' + if params[:shift_name].to_i != 0 + 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 + + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end + end + + @sale_data = Sale.get_void_sale(@shift,from,to) + + @from = from + @to = to + + 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 + + def show + from, to = get_date_range_from_params + + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + date_arr = Array.new + @sale_data.each do |sale| + local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") + local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") + opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc + closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + date_arr.push(str) + end + + out = {:status => 'ok', :message => date_arr} + + respond_to do |format| + format.json { render json: out } + end + end +end \ No newline at end of file diff --git a/app/models/ability.rb b/app/models/ability.rb index 368aa424..bd3ce87e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -68,7 +68,7 @@ class Ability can :overall_void, :void elsif user.role == "cashier" - +can :overall_void, :void can :read, Order can :update, Order diff --git a/app/models/sale.rb b/app/models/sale.rb index 197c7106..fc064b96 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -642,10 +642,36 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to) .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .group("sales.sale_id") - end - + end +end + +def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to) + query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date, + s.cashier_name as cashier_name") + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + + if shift.present? + query = query.where("payment_method= 'creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a) + elsif shift_sale_range.present? + query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a) + else + query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to) + end end + def self.get_void_sale(shift,from,to) + sale_arr = Array.new + + account= Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment") + .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id") + .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? + OR sh.shift_closed_at between ? and ? )", from ,to, from, to) + + out = {:items => account} + sale_arr.push(out) + return sale_arr +end + def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type) if payment_type.blank? @@ -680,18 +706,6 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type) .group("sale_taxes.tax_name") .order("sale_taxes.sale_tax_id asc") end - - # query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name") - # .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id") - # .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - # .group("sale_taxes.tax_name") - # .order("sale_taxes.sale_tax_id asc") - - # if shift.present? - # query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed'", shift.to_a) - # else - # query = query.where("sales.receipt_date between ? and ? #{payment_type} and sale_status= 'completed' ",from,to) - # end end # def self.get_separate_tax(from,to,payment_method=nil) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 891524ec..206c8f20 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -20,7 +20,6 @@ -
@@ -452,9 +451,7 @@ $("#first_bill").on('click', function(){ $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); - var rounding_adj = $('#rounding_adj').val(); - if(rounding_adj == "true"){ var url = '/origami/sale/'+ sale_id + "/rounding_adj" ; $.ajax({ type: "POST", @@ -463,9 +460,7 @@ $('#pay').on('click',function() { window.location.href = '/origami/sale/'+ sale_id + "/payment"; } }); - }else{ - window.location.href = '/origami/sale/'+ sale_id + "/payment"; - } + }); diff --git a/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb b/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..5313e61d --- /dev/null +++ b/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb @@ -0,0 +1,125 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ +
+ + + +
+
+ + +
+
+ + +
+
+ +
+
+ <% end %> + + <% end %> +
+
+ + + diff --git a/app/views/reports/credit_payment/index.html.erb b/app/views/reports/credit_payment/index.html.erb new file mode 100644 index 00000000..6e3e6a58 --- /dev/null +++ b/app/views/reports/credit_payment/index.html.erb @@ -0,0 +1,150 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_credit_payment_index_path} %> +
+
+ +
+
+ +
+
+ +
+
+ <% unless @sale_data.blank? %> + + + + <% if !params[:from].blank?%> + + + + <% end %> + + + + + + + + + + <% @sale_data.each do |credit| %> + + + <% if @shift_from.nil? && @shift_to.nil? %> + + <% else %> + + <% end %> + + + + + + <% end %> + +
From Date : <%= params[:from] rescue '-'%> , To Date : <%= params[:to] rescue '-'%>
Shift Name Receive No Cashier Name Customer Name Credit Amount
<%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%><%= credit.receipt_no rescue '-' %><%= credit.cashier_name rescue '-' %><%= credit.sale.customer.name rescue '-' %><%= credit.payment_amount rescue '-' %>
+ <% end %> +
+
+ + \ No newline at end of file diff --git a/app/views/reports/credit_payment/index.xls.erb b/app/views/reports/credit_payment/index.xls.erb new file mode 100644 index 00000000..9597e3d9 --- /dev/null +++ b/app/views/reports/credit_payment/index.xls.erb @@ -0,0 +1,39 @@ +
+
+ <% unless @sale_data.blank? %> + + + + <% if !params[:from].blank?%> + + + + <% end %> + + + + + + + + + + <% @sale_data.each do |credit| %> + + + <% if @shift_from.nil? && @shift_to.nil? %> + + <% else %> + + <% end %> + + + + + + <% end %> + +
From Date : <%= params[:from] rescue '-'%> , To Date : <%= params[:to] rescue '-'%>
Shift Name Receive No Cashier Name Customer Name Credit Amount
<%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%><%= credit.receipt_no rescue '-' %><%= credit.cashier_name rescue '-' %><%= credit.sale.customer.name rescue '-' %><%= credit.payment_amount rescue '-' %>
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/reports/void_sale/_shift_sale_report_filter.html.erb b/app/views/reports/void_sale/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..5313e61d --- /dev/null +++ b/app/views/reports/void_sale/_shift_sale_report_filter.html.erb @@ -0,0 +1,125 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ +
+ + + +
+
+ + +
+
+ + +
+
+ +
+
+ <% end %> + + <% end %> +
+
+ + + diff --git a/app/views/reports/void_sale/index.html.erb b/app/views/reports/void_sale/index.html.erb new file mode 100644 index 00000000..b008f5e8 --- /dev/null +++ b/app/views/reports/void_sale/index.html.erb @@ -0,0 +1,175 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_void_sale_index_path} %> +
+
+ +
+
+ +
+
+ +
+
+ <% if @sale_data.count > 0 %> + + + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift.cashier_id %> + <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + + + <% total_amount = 0.0 %> + <% grand_total = 0.0 %> + <% rounding_adjustment = 0.0 %> + <% grand_rounding_adjustment = 0.0 %> + <% @sale_data.each do |result| %> + <% result[:items].each do |item| %> + + + + + + + + + + + <% total_amount = total_amount.to_f + item.total_amount.to_f %> + <% grand_total = grand_total.to_f + item.grand_total.to_f %> + <% rounding_adjustment = rounding_adjustment.to_f + item.rounding_adjustment.to_f %> + <% grand_rounding_adjustment = grand_rounding_adjustment.to_f + item.grand_total.to_f + item.rounding_adjustment.to_f %> + <% end %> + <% end %> + + + + + + + + +
From Date : <%= params[:from] rescue '-'%> , To Date : <%= params[:to] rescue '-'%>
Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
Receipt NoSale DateTotal AmountGrand TotalRounding Adj.Grand Total +
Rounding Adj.
Sale StatusRemarks
<%= item.receipt_no rescue '-' %> <%= item.date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-' %><%= item.total_amount.to_f rescue '-'%> <%= item.grand_total.to_f rescue '-'%> <%= item.rounding_adjustment.to_f rescue '-' %><%= item.grand_total.to_f + item.rounding_adjustment.to_f rescue '-'%> <%= item.sales_status rescue '-' %> <%= item.remarks rescue '-' %>
Total Void Amount :<%= total_amount rescue '-' %><%= grand_total rescue '-' %><%= rounding_adjustment rescue '-'%><%= grand_rounding_adjustment rescue '-'%>
+<% end %> +
+
+ + \ No newline at end of file diff --git a/app/views/reports/void_sale/index.xls.erb b/app/views/reports/void_sale/index.xls.erb new file mode 100644 index 00000000..9597e3d9 --- /dev/null +++ b/app/views/reports/void_sale/index.xls.erb @@ -0,0 +1,39 @@ +
+
+ <% unless @sale_data.blank? %> + + + + <% if !params[:from].blank?%> + + + + <% end %> + + + + + + + + + + <% @sale_data.each do |credit| %> + + + <% if @shift_from.nil? && @shift_to.nil? %> + + <% else %> + + <% end %> + + + + + + <% end %> + +
From Date : <%= params[:from] rescue '-'%> , To Date : <%= params[:to] rescue '-'%>
Shift Name Receive No Cashier Name Customer Name Credit Amount
<%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%><%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%><%= credit.receipt_no rescue '-' %><%= credit.cashier_name rescue '-' %><%= credit.sale.customer.name rescue '-' %><%= credit.payment_amount rescue '-' %>
+ <% end %> +
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d285cc2e..acb8b3f5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -276,14 +276,10 @@ Rails.application.routes.draw do resources :dailysale, :only => [:index, :show] resources :saleitem, :only => [:index, :show] resources :shiftsale, :only => [:index, :show] + resources :credit_payment, :only => [:index, :show] + resources :void_sale, :only => [:index, :show] get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date" - # resources :sales, :only => [:index, :show] - # resources :orders, :only => [:index, :show] - # resources :customers, :only => [:index, :show] - # resources :products, :only => [:index, :show] - # resources :inventory, :only => [:index, :show] - # resources :employees, :only => [:index, :show] end #mount_compendium at: '/report' #, controller: 'reports' From 78d383f5ece590c3737b4c47d9d6c91b8ec5369a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 28 Jul 2017 18:08:11 +0630 Subject: [PATCH 3/6] update customer validation messages --- app/models/customer.rb | 4 ++-- app/models/sale.rb | 8 +++++++- app/views/crm/customers/_new_form.html.erb | 11 ++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index 06f7f1d1..c1751104 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -7,8 +7,8 @@ class Customer < ApplicationRecord has_many :sales validates_presence_of :name, :contact_no, :email,:card_no - validates :contact_no, uniqueness: true - validates :email, uniqueness: true + validates :contact_no, uniqueness: true, numericality: true + validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create } validates :card_no, uniqueness: true validates :paypar_account_no, uniqueness: true diff --git a/app/models/sale.rb b/app/models/sale.rb index fc064b96..82b9b781 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -666,7 +666,13 @@ end .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id") .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? OR sh.shift_closed_at between ? and ? )", from ,to, from, to) - + + if shift.present? + query = query.where("sales.sale_status = 'void' and s.shift_sale_id in (?)",shift.to_a) + else + query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to) + end + out = {:items => account} sale_arr.push(out) return sale_arr diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index b99c25a3..5ec0b903 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -6,7 +6,7 @@
"> <%= f.input :card_no, :class => "form-control col-md-6 card_no"%> <% flash.each do |name, msg| %> - <% str="[\"#{msg['name']}\"]" + <% str="[\"#{msg['card_no']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> <%= str %> @@ -32,11 +32,12 @@ <%= f.radio_button :salutation,"Mdm", :class => "salutation mdm", :value=>"Mdm", :style=>"width: 30px"%>
- +
"> <%= f.input :name, :class => "form-control col-md-6 name", :required => true %> - <% flash.each do |name, msg| %> - <% str="[\"#{msg['name']}\"]" + <% flash.each do |test, msg| %> + <% + str="[\"#{msg['name']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> <%= str %> @@ -80,7 +81,7 @@ <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%> <% flash.each do |name, msg| %> - <% str="[\"#{msg['contact_no']}\"]" + <% str="[\"#{msg['email']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> <%= str %> From 6ac35bb8741e7c327beff45d825097dc07bda81b Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 31 Jul 2017 09:39:34 +0630 Subject: [PATCH 4/6] update receipt no twice and sale order double and report changes --- app/models/sale.rb | 18 +++++++++--------- app/models/seed_generator.rb | 2 +- app/views/reports/void_sale/index.html.erb | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 82b9b781..b23c630b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -91,7 +91,7 @@ class Sale < ApplicationRecord add_item(item) end - link_order_sale(order.id) + # link_order_sale(order.id) end self.save! @@ -352,7 +352,7 @@ class Sale < ApplicationRecord if saleOrder.nil? sale_order = SaleOrder.new - sale_order.create_sale_order(self.id, order_id) + sale = sale_order.create_sale_order(self.id, order_id) end # if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?) # SaleOrder.create(:sale_id => self.id, :order_id => order_id) @@ -662,18 +662,18 @@ end def self.get_void_sale(shift,from,to) sale_arr = Array.new - account= Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment") - .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id") - .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? - OR sh.shift_closed_at between ? and ? )", from ,to, from, to) + query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment") + # .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id") + # .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? + # OR sh.shift_closed_at between ? and ? )", from ,to, from, to) if shift.present? - query = query.where("sales.sale_status = 'void' and s.shift_sale_id in (?)",shift.to_a) + query = query.where("sales.sale_status = 'void' and sales.shift_sale_id in (?)",shift.to_a) else - query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to) + query = query.where("sales.sale_status = 'void' and sales.receipt_date between ? and ? ",from,to) end - out = {:items => account} + out = {:items => query} sale_arr.push(out) return sale_arr end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 335ab131..a5bf5976 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -35,7 +35,7 @@ class SeedGenerator < ApplicationRecord else current_no = seed.next - seed.next = seed.next + seed.increase_by + seed.next = seed.next seed.current = current_no seed.save end diff --git a/app/views/reports/void_sale/index.html.erb b/app/views/reports/void_sale/index.html.erb index b008f5e8..4e33c27d 100644 --- a/app/views/reports/void_sale/index.html.erb +++ b/app/views/reports/void_sale/index.html.erb @@ -31,8 +31,8 @@ <% end %> <% if @shift_from %> - <% if @shift.cashier_id %> - <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %> + <% if @shift %> + <% cashier_name = !@shift.nil? ? @shift[0].employee.name : '-' %> <% end %> Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> ) From df08569facf06c66b9d22653d76225ec60101b6e Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 31 Jul 2017 10:37:47 +0630 Subject: [PATCH 5/6] update rake file for membership data --- app/views/transactions/sales/show.html.erb | 4 ++-- lib/tasks/menu_osaka.rake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index cbd07c41..0ea005c9 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -13,13 +13,13 @@ Back - +
diff --git a/lib/tasks/menu_osaka.rake b/lib/tasks/menu_osaka.rake index 515abe53..9fe7da98 100644 --- a/lib/tasks/menu_osaka.rake +++ b/lib/tasks/menu_osaka.rake @@ -904,7 +904,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, - {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, + {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_account_data",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, {membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, {membership_type:"member_discount",gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:6},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, {membership_type:"get_member_campaign",gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:6},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}, From 24d6a530e734c2a0d585e9be412418da4840bc2e Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 31 Jul 2017 13:14:36 +0630 Subject: [PATCH 6/6] update --- app/models/ability.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index bd3ce87e..1a6596ff 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -68,7 +68,9 @@ class Ability can :overall_void, :void elsif user.role == "cashier" -can :overall_void, :void + + # can :overall_void, :void + can :read, Order can :update, Order