From 7a09ed01080b80ab6b726bfc012871a24814bb4f Mon Sep 17 00:00:00 2001
From: yarzar_code
Date: Thu, 30 Jan 2020 11:57:28 +0630
Subject: [PATCH 01/25] Menu Item Groups
---
.../javascripts/api/menu_item_groups.coffee | 3 +
.../settings/menu_item_groups.coffee | 3 +
.../stylesheets/api/menu_item_groups.scss | 3 +
.../settings/menu_item_groups.scss | 3 +
.../api/menu_item_groups_controller.rb | 8 +++
.../settings/menu_item_groups_controller.rb | 59 ++++++++++++++++
app/helpers/api/menu_item_groups_helper.rb | 2 +
.../settings/menu_item_groups_helper.rb | 2 +
.../api/menu_item_groups/index.json.jbuilder | 2 +
.../settings/menu_item_groups/edit.html.erb | 70 +++++++++++++++++++
.../settings/menu_item_groups/index.html.erb | 69 ++++++++++++++++++
.../settings/menu_item_groups/new.html.erb | 70 +++++++++++++++++++
config/routes.rb | 4 +-
.../api/menu_item_groups_controller_spec.rb | 5 ++
.../menu_item_groups_controller_spec.rb | 5 ++
.../api/menu_item_groups_helper_spec.rb | 15 ++++
.../settings/menu_item_groups_helper_spec.rb | 15 ++++
17 files changed, 337 insertions(+), 1 deletion(-)
create mode 100644 app/assets/javascripts/api/menu_item_groups.coffee
create mode 100644 app/assets/javascripts/settings/menu_item_groups.coffee
create mode 100644 app/assets/stylesheets/api/menu_item_groups.scss
create mode 100644 app/assets/stylesheets/settings/menu_item_groups.scss
create mode 100644 app/controllers/api/menu_item_groups_controller.rb
create mode 100644 app/controllers/settings/menu_item_groups_controller.rb
create mode 100644 app/helpers/api/menu_item_groups_helper.rb
create mode 100644 app/helpers/settings/menu_item_groups_helper.rb
create mode 100644 app/views/api/menu_item_groups/index.json.jbuilder
create mode 100755 app/views/settings/menu_item_groups/edit.html.erb
create mode 100644 app/views/settings/menu_item_groups/index.html.erb
create mode 100644 app/views/settings/menu_item_groups/new.html.erb
create mode 100644 spec/controllers/api/menu_item_groups_controller_spec.rb
create mode 100644 spec/controllers/settings/menu_item_groups_controller_spec.rb
create mode 100644 spec/helpers/api/menu_item_groups_helper_spec.rb
create mode 100644 spec/helpers/settings/menu_item_groups_helper_spec.rb
diff --git a/app/assets/javascripts/api/menu_item_groups.coffee b/app/assets/javascripts/api/menu_item_groups.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/api/menu_item_groups.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/settings/menu_item_groups.coffee b/app/assets/javascripts/settings/menu_item_groups.coffee
new file mode 100644
index 00000000..fad9c6c6
--- /dev/null
+++ b/app/assets/javascripts/settings/menu_item_groups.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
\ No newline at end of file
diff --git a/app/assets/stylesheets/api/menu_item_groups.scss b/app/assets/stylesheets/api/menu_item_groups.scss
new file mode 100644
index 00000000..90b85063
--- /dev/null
+++ b/app/assets/stylesheets/api/menu_item_groups.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the api/menu_item_groups controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/settings/menu_item_groups.scss b/app/assets/stylesheets/settings/menu_item_groups.scss
new file mode 100644
index 00000000..297b27f5
--- /dev/null
+++ b/app/assets/stylesheets/settings/menu_item_groups.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the settings/menu_item_groups controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/api/menu_item_groups_controller.rb b/app/controllers/api/menu_item_groups_controller.rb
new file mode 100644
index 00000000..6041ec14
--- /dev/null
+++ b/app/controllers/api/menu_item_groups_controller.rb
@@ -0,0 +1,8 @@
+class Api::MenuItemGroupsController < ApplicationController
+ def index
+ # @groups = Lookup.where(lookup_type:'menu_item_groups')
+ # @group = @groups.group_by(&:name).map { |k, v| { k => v.map { |l| m = eval(l.value); { m[:menu_category] => m[:menu_items] } }.inject({}) { |h, v| p h; h.merge!(v) } } }
+ @group = Lookup.where(lookup_type:'menu_item_groups')
+ @group = @group.group_by(&:name).map{|k ,v| { k => v.map{|k, v| JSON.parse(k.value)}.inject({}) { |h, v| p h; h.merge!(v) }}}.inject({}) { |h, v| p h; h.merge!(v) }
+ end
+end
diff --git a/app/controllers/settings/menu_item_groups_controller.rb b/app/controllers/settings/menu_item_groups_controller.rb
new file mode 100644
index 00000000..538d8d94
--- /dev/null
+++ b/app/controllers/settings/menu_item_groups_controller.rb
@@ -0,0 +1,59 @@
+class Settings::MenuItemGroupsController < ApplicationController
+ def index
+ @menu_item_group = Lookup.where(lookup_type:'menu_item_groups')
+ end
+ def new
+ @settings_menu_item_group = Lookup.new
+ @menu_category = MenuCategory.order(:name)
+ end
+ def create
+ @settings_menu_item_group = Lookup.new(settings_lookup_params)
+ menu_item = settings_lookup_params[:value].reject(&:empty?)
+ menu_category = "{\"#{settings_lookup_params[:lookup_type]}\" : #{menu_item} }"
+ @settings_menu_item_group.lookup_type = "menu_item_groups"
+ @settings_menu_item_group.value = menu_category
+ respond_to do |format|
+ if @settings_menu_item_group.save
+ format.html { redirect_to settings_menu_item_groups_path, notice: 'Menu item group was successfully created.' }
+ format.json { render :show, status: :created, location: @settings_menu_item_group }
+ else
+ format.html { render :new }
+ format.json { render json: settings_menu_item_groups_path.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+ def edit
+ @settings_menu_item_group = Lookup.find(params[:id])
+ @menu_category = MenuCategory.order(:name)
+ end
+ def update
+ @settings_menu_item_group = Lookup.find(params[:id])
+ menu_item = settings_lookup_params[:value].reject(&:empty?)
+ menu_category = "{\"#{settings_lookup_params[:lookup_type]}\" : #{menu_item} }"
+ @settings_menu_item_group.lookup_type = "menu_item_groups"
+ @settings_menu_item_group.value = menu_category
+ @settings_menu_item_group.name = settings_lookup_params[:name]
+ respond_to do |format|
+ if @settings_menu_item_group.save
+ format.html { redirect_to settings_menu_item_groups_path, notice: 'Menu item group was successfully updated.' }
+ format.json { render :show, status: :ok, location: @settings_menu_item_group }
+ else
+ format.html { render :edit }
+ format.json { render json: settings_menu_item_groups_path.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+ def destroy
+ @settings_menu_item_group = Lookup.find(params[:id])
+ if @settings_menu_item_group.destroy
+ flash[:notice] = 'Menu item group was successfully deleted.'
+ redirect_to settings_menu_item_groups_path
+ end
+ end
+ private
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def settings_lookup_params
+ params.require(:lookup).permit(:lookup_type, :name, :value=>[])
+ end
+end
diff --git a/app/helpers/api/menu_item_groups_helper.rb b/app/helpers/api/menu_item_groups_helper.rb
new file mode 100644
index 00000000..5c7ab225
--- /dev/null
+++ b/app/helpers/api/menu_item_groups_helper.rb
@@ -0,0 +1,2 @@
+module Api::MenuItemGroupsHelper
+end
diff --git a/app/helpers/settings/menu_item_groups_helper.rb b/app/helpers/settings/menu_item_groups_helper.rb
new file mode 100644
index 00000000..6b689f13
--- /dev/null
+++ b/app/helpers/settings/menu_item_groups_helper.rb
@@ -0,0 +1,2 @@
+module Settings::MenuItemGroupsHelper
+end
diff --git a/app/views/api/menu_item_groups/index.json.jbuilder b/app/views/api/menu_item_groups/index.json.jbuilder
new file mode 100644
index 00000000..20b29060
--- /dev/null
+++ b/app/views/api/menu_item_groups/index.json.jbuilder
@@ -0,0 +1,2 @@
+json.status true
+json.data @group
\ No newline at end of file
diff --git a/app/views/settings/menu_item_groups/edit.html.erb b/app/views/settings/menu_item_groups/edit.html.erb
new file mode 100755
index 00000000..8d285d49
--- /dev/null
+++ b/app/views/settings/menu_item_groups/edit.html.erb
@@ -0,0 +1,70 @@
+
+
+
+
+ <%= simple_form_for ([:settings,@settings_menu_item_group]), :url => settings_menu_item_group_path do |f| %>
+ <%= f.error_notification %>
+
+ <%= f.input :name, :label => "Group Name" ,input_html: {required: true }%>
+ <%= f.label :lookup_type, label: 'Menu Category', :class => "control-label string optional bmd-label-static" %>
+ <%= f.collection_select :lookup_type, @menu_category, :id, :name, {}, {:class =>"form-control"} %>
+ <%= f.label :value, label: 'Menu Items', :class => "control-label string optional bmd-label-static" %>
+ <%= f.grouped_collection_select :value, @menu_category, :menu_items, :name, :item_code, :name, {}, {:class =>"form-control", :multiple=> true} %>
+
+
+
+ <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
+
+ <% end %>
+
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+
+ 1) <%= t("views.right_panel.detail.lookup") + " " + t("views.right_panel.detail.type_txt") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+ 2) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.name_txt2") %>
+ 3) <%= t("views.right_panel.detail.value") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.value_txt") %>
+
+
list <%= t("views.right_panel.header.button_lists") %>
+
+ 1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+
+
list <%= t("views.right_panel.header.link_lists") %>
+
+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+
+
+
+
+
+
+
+
diff --git a/app/views/settings/menu_item_groups/index.html.erb b/app/views/settings/menu_item_groups/index.html.erb
new file mode 100644
index 00000000..89ec57e7
--- /dev/null
+++ b/app/views/settings/menu_item_groups/index.html.erb
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+ <%= link_to t("views.btn.new"),new_settings_menu_item_group_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>
+
+
+
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+
+ 1) <%= t("views.right_panel.detail.lookup") + " " + t("views.right_panel.detail.type_txt") %> - <%= t("views.right_panel.detail.type_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.lookup_txt") %>
+ 2) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.name_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.lookup_txt") %>
+ 3) <%= t("views.right_panel.detail.value") %> - <%= t("views.right_panel.detail.value_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.lookup_txt") %>
+ 4) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+
+
list <%= t("views.right_panel.header.button_lists") %>
+
+ 1) <%= t("views.right_panel.button.new") %> - <%= t("views.right_panel.detail.new_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+ 2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+
+
list <%= t("views.right_panel.header.link_lists") %>
+
+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %>
+
+
+
+
+
+
diff --git a/app/views/settings/menu_item_groups/new.html.erb b/app/views/settings/menu_item_groups/new.html.erb
new file mode 100644
index 00000000..70b137a7
--- /dev/null
+++ b/app/views/settings/menu_item_groups/new.html.erb
@@ -0,0 +1,70 @@
+
+
+
+
+ <%= simple_form_for ([:settings,@settings_menu_item_group]), :url => settings_menu_item_groups_path do |f| %>
+ <%= f.error_notification %>
+
+
+ <%= f.input :name, :label => "Group Name" ,input_html: {required: true }%>
+ <%= f.label :lookup_type, label: 'Menu Category', :class => "control-label string optional bmd-label-static" %>
+ <%= f.collection_select :lookup_type, @menu_category, :id, :name, {}, {:class =>"form-control"} %>
+ <%= f.label :value, label: 'Menu Items', :class => "control-label string optional bmd-label-static" %>
+ <%= f.grouped_collection_select :value, @menu_category, :menu_items, :name, :item_code, :name, {}, {:class =>"form-control", :multiple=> true} %>
+
+
+
+ <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
+
+ <% end %>
+
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+
+ 1) <%= t("views.right_panel.detail.lookup") + " " + t("views.right_panel.detail.type_txt") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+ 2) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.name_txt2") %>
+ 3) <%= t("views.right_panel.detail.value") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.value_txt") %>
+
+
list <%= t("views.right_panel.header.button_lists") %>
+
+ 1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+
+
list <%= t("views.right_panel.header.link_lists") %>
+
+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.lookup_txt") %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 933002d9..2d335b80 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -44,7 +44,7 @@ scope "(:locale)", locale: /en|mm/ do
#Session Login and Logout
post 'authenticate' => "authenticate#create"
delete 'authenticate' => "authenticate#destroy"
-
+ get "menu_item_groups" => "menu_item_groups#index"
namespace :restaurant do
get 'zones' => "zones#index"
resources :menu, only: [:index, :show]
@@ -461,6 +461,8 @@ scope "(:locale)", locale: /en|mm/ do
resources :products
#lookups
resources :lookups
+ #menu_item_groups
+ resources :menu_item_groups
#cashier_terminals
resources :cashier_terminals
#order_job_stations
diff --git a/spec/controllers/api/menu_item_groups_controller_spec.rb b/spec/controllers/api/menu_item_groups_controller_spec.rb
new file mode 100644
index 00000000..cb965035
--- /dev/null
+++ b/spec/controllers/api/menu_item_groups_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Api::MenuItemGroupsController, type: :controller do
+
+end
diff --git a/spec/controllers/settings/menu_item_groups_controller_spec.rb b/spec/controllers/settings/menu_item_groups_controller_spec.rb
new file mode 100644
index 00000000..34ae5c89
--- /dev/null
+++ b/spec/controllers/settings/menu_item_groups_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Settings::MenuItemGroupsController, type: :controller do
+
+end
diff --git a/spec/helpers/api/menu_item_groups_helper_spec.rb b/spec/helpers/api/menu_item_groups_helper_spec.rb
new file mode 100644
index 00000000..0f29393f
--- /dev/null
+++ b/spec/helpers/api/menu_item_groups_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the Api::MenuItemGroupsHelper. For example:
+#
+# describe Api::MenuItemGroupsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe Api::MenuItemGroupsHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/settings/menu_item_groups_helper_spec.rb b/spec/helpers/settings/menu_item_groups_helper_spec.rb
new file mode 100644
index 00000000..8fa377e7
--- /dev/null
+++ b/spec/helpers/settings/menu_item_groups_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the Settings::MenuItemGroupsHelper. For example:
+#
+# describe Settings::MenuItemGroupsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe Settings::MenuItemGroupsHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
From 4a3d429a532a6e995af0350c20140433594115da Mon Sep 17 00:00:00 2001
From: Thein Lin Kyaw
Date: Thu, 28 May 2020 12:05:42 +0630
Subject: [PATCH 02/25] dashboard sale revenue
---
app/views/home/dashboard.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index 6cd52f4e..b7bd5c44 100755
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -189,7 +189,7 @@
<%= @summ_sale.total_receipt %> |
- <% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
+ <% revenue = @summ_sale.grand_total - @summ_sale.total_discount - @summ_sale.total_tax %>
| <%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : |
<%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %> |
From 51932b8a86ca5084a303a9e772463b0d8548d951 Mon Sep 17 00:00:00 2001
From: Thein Lin Kyaw
Date: Mon, 1 Jun 2020 15:46:27 +0630
Subject: [PATCH 03/25] other payments
---
app/assets/javascripts/origami.js | 4 +-
.../origami/others_payments_controller.rb | 85 +++
.../origami/payments_controller.rb | 279 ++++------
app/models/sale_payment.rb | 22 +-
.../others_payments/create.json.jbuilder | 5 +
.../origami/others_payments/index.html.erb | 4 +-
.../origami/others_payments/new.html.erb | 279 ++++++++++
app/views/origami/payments/show.html.erb | 498 ++++++------------
config/initializers/action_controller.rb | 10 +-
config/routes.rb | 52 +-
10 files changed, 665 insertions(+), 573 deletions(-)
create mode 100644 app/views/origami/others_payments/create.json.jbuilder
create mode 100644 app/views/origami/others_payments/new.html.erb
diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js
index 8c910119..d282b611 100755
--- a/app/assets/javascripts/origami.js
+++ b/app/assets/javascripts/origami.js
@@ -326,8 +326,8 @@ function setCommPorts(comPortLists) {
/** pay with CB bank **/
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) {
$("#loading_wrapper").show();
- var com_port = $("#com_port_name").val();
- reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
+ var com_port = $("#com_port_name").val();
+ reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
}
//add req data to card_sale_trans table
diff --git a/app/controllers/origami/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb
index 3d95bbb0..964af260 100755
--- a/app/controllers/origami/others_payments_controller.rb
+++ b/app/controllers/origami/others_payments_controller.rb
@@ -39,7 +39,92 @@ class Origami::OthersPaymentsController < BaseOrigamiController
# end
end
+ def new
+ @sale_id = params[:sale_id]
+ @cashier_type = params[:type]
+ payment_methods = PaymentMethodSetting.pluck(:payment_method)
+ if @payment_method = payment_methods.find { |m| m.parameterize == params[:method] }
+ path = request.fullpath
+ # limit master_amount
+ if path.include? ("credit_payment")
+ sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
+ else
+ sale_data = Sale.find_by_sale_id(@sale_id)
+ end
+ total = 0
+ @shop = Shop.current_shop
+ @paid_amount = 0
+ @can_paid = 0
+ @rounding_adj = 0
+ @member_discount = 0
+ @sub_total = 0
+ @membership_id = nil
+ @receipt_no = nil
+ if !sale_data.nil?
+ total = sale_data.grand_total
+
+ others = 0
+
+ if @shop.is_rounding_adj
+ new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
+ else
+ new_total = sale_data.grand_total
+ end
+
+ @rounding_adj = new_total-sale_data.grand_total
+
+ if path.include? ("credit_payment")
+ sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
+ else
+ sale_payment_data = sale_data.sale_payments
+ end
+
+ sale_payment_data.each do |sale_payment|
+ if sale_payment.payment_method == @payment_method.parameterize
+ @paid_amount = @paid_amount + sale_payment.payment_amount
+ else
+ others = others + sale_payment.payment_amount
+ end
+ end
+ @can_paid = total - @paid_amount - others
+ @member_discount = MembershipSetting.find_by_discount(1)
+ @sub_total = sale_data.total_amount
+ @membership_id = sale_data.customer.membership_id
+ #for bank integration
+ @receipt_no = sale_data.receipt_no
+ end
+ bank_integration = Lookup.collection_of('bank_integration')
+ @bank_integration = 0
+ if !bank_integration[0].nil?
+ @bank_integration = bank_integration[0][1]
+ end
+ else
+ if path.include? ("credit_payment")
+ redirect_to "sale/#{@sale_id}/#{@cashier_type}/payment/others_payment"
+ else
+ redirect_to "sale/#{@sale_id}/#{@cashier_type}/credit_payment/others_payment"
+ end
+ end
+ end
+
def create
+ cash = params[:amount]
+ sale_id = params[:sale_id]
+ ref_no = params[:ref_no]
+ payment_method = params[:method]
+ if PaymentMethodSetting.pluck(:payment_method).map(&:parameterize).include? payment_method
+ if saleObj = Sale.find(sale_id)
+ shop_details = Shop.current_shop
+
+ path = request.fullpath
+ payment_for = false
+ if path.include? ("credit_payment")
+ payment_for = true
+ end
+ sale_payment = SalePayment.new
+ @status, @sale = sale_payment.process_payment(saleObj, current_user, cash, payment_method, ref_no, payment_for)
+ end
+ end
end
end
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 8693e6be..e86449ac 100755
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -51,7 +51,8 @@ class Origami::PaymentsController < BaseOrigamiController
#TODO :: KBZPAY ( QR )
# On/Off setting ( show or not qr )
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
- kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
+ kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
+ .where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
status = false
qr = nil
@@ -232,15 +233,29 @@ class Origami::PaymentsController < BaseOrigamiController
# end
def show
+ @sale = Sale.find(params[:sale_id])
+ @shop = Shop.current_shop
+ @customer = @sale.customer
+ @customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
+ @member_discount = MembershipSetting.find_by_discount(1)
+
+ if dining_facility = @sale.booking.dining_facility
+ @table_no = dining_facility.type + ' ' + dining_facility.name
+ @checkin_time = @sale.booking.checkin_at
+ @dining = dining_facility
+ end
+
display_type = Lookup.find_by_lookup_type("display_type")
- if !display_type.nil? && display_type.value.to_i ==2
+ if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else
@display_type = nil
- end
+ end
+
path = request.fullpath
- sale_id = params[:sale_id]
+
@trans_flag = true
+
if params[:type] == "transaction"
@trans_flag = false
@cashier_type = "cashier"
@@ -248,201 +263,111 @@ class Origami::PaymentsController < BaseOrigamiController
@cashier_type = params[:type]
end
- if path.include? ("credit_payment")
- @sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
+ if path.include? 'credit_payment'
+ @sale_payment = false
+ @amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
+ payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
+ else
+ @sale_payment = true
+ @amount_due = @sale.grand_total
+ payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
end
- @member_discount = MembershipSetting.find_by_discount(1)
- @membership_rebate_balance=0
+ @payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
+ @cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
+ @credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
+ @other_payments = payments.select { |payment| !['cash', 'creditnote'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
+ @other_payment = @other_payments.sum { |payment| payment[1] }
- if Sale.exists?(sale_id)
- @cash = 0.0
- @kbz_pay_amount = 0.0
- @other = 0.0
- @ppamount = 0.0
- @visacount= 0.0
- @jcbcount= 0.0
- @mastercount = 0.0
- @unionpaycount = 0.0
- @alipaycount = 0.0
- @junctionpaycount = 0.0
- @credit = 0.0
- @paymalcount = 0.0
- @dingacount = 0.0
- @giftvouchercount = 0.0
- @sale_data = Sale.find_by_sale_id(sale_id)
- @balance = 0
- @accountable_type = ''
- @table_no = ''
- @dining = ''
- @other_payment = 0.0
- @pdf_view = nil
- @lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
- if !@lookup_pdf.nil?
- @pdf_view = @lookup_pdf.value
- end
+ #total customer with individual total amount
+ @individual_total = Array.new
+ if !@sale.equal_persons.nil?
+ per_person_amount = @sale.grand_total / @sale.equal_persons.to_i
+ @individual_total.push({'total_customer' => @sale.equal_persons.to_i, 'per_person_amount' => per_person_amount })
+ end
- amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
- @kbz_pay_amount += amount.to_f
-
- #for changable on/off
- @changable_tax = true
- lookup_changable_tax = Lookup.collection_of('changable_tax')
- if !lookup_changable_tax.empty?
- lookup_changable_tax.each do |changable_tax|
- if changable_tax[0].downcase == "change"
- if changable_tax[1] == '0'
- @changable_tax = false
- end
+ #for changable on/off
+ @changable_tax = true
+ lookup_changable_tax = Lookup.collection_of('changable_tax')
+ if !lookup_changable_tax.empty?
+ lookup_changable_tax.each do |changable_tax|
+ if changable_tax[0].downcase == "change"
+ if changable_tax[1] == '0'
+ @changable_tax = false
end
end
end
+ end
- @shop = shop_detail #show shop info
+ # get printer info
+ @print_settings = PrintSetting.get_precision_delimiter()
- @customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
+ @pdf_view = nil
+ @lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
+ if !@lookup_pdf.nil?
+ @pdf_view = @lookup_pdf.value
+ end
- saleObj = Sale.find(sale_id)
+ # amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
+ # @kbz_pay_amount += amount.to_f
- #total customer with individual total amount
- @individual_total = Array.new
- if !saleObj.equal_persons.nil?
- per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
- @individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
+ # rounding adjustment
+ # if @shop.is_rounding_adj
+ # a = saleObj.grand_total % 25 # Modulus
+ # b = saleObj.grand_total / 25 # Division
+ # #not calculate rounding if modulus is 0 and division is even
+ # #calculate rounding if modulus is zero or not zero and division are not even
+ # if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
+ # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
+ # @rounding_adj = new_total-saleObj.grand_total
+ # saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
+ # @sale_data.grand_total = new_total
+ # @sale_data.old_grand_total = saleObj.grand_total
+ # @sale_data.rounding_adjustment = @rounding_adj
+ # else
+ # @rounding_adj = @sale_data.rounding_adjustment
+ # end
+ # else
+ # @rounding_adj = @sale_data.rounding_adjustment
+ # end
+ #end rounding adjustment
+
+ # accounts = @customer.tax_profiles
+ accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
+ @account_arr =[]
+ @tax_arr =[]
+
+ accounts.each do |acc|
+ account = TaxProfile.find(acc.id)
+ # @account_arr.push(account)
+ @tax_arr.push(account.name)
+ end
+
+ sale_taxes = @sale.sale_taxes
+ if !sale_taxes.empty?
+ sale_taxes.each do |sale_tax|
+ @account_arr.push(sale_tax)
end
+ end
- # rounding adjustment
- # if @shop.is_rounding_adj
- # a = saleObj.grand_total % 25 # Modulus
- # b = saleObj.grand_total / 25 # Division
- # #not calculate rounding if modulus is 0 and division is even
- # #calculate rounding if modulus is zero or not zero and division are not even
- # if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
- # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
- # @rounding_adj = new_total-saleObj.grand_total
- # else
- # @rounding_adj = @sale_data.rounding_adjustment
- # end
- # else
- # @rounding_adj = @sale_data.rounding_adjustment
- # end
- #end rounding adjustment
+ rebate = MembershipSetting.find_by_rebate(1)
- # rounding adjustment
- if @shop.is_rounding_adj
- a = saleObj.grand_total % 25 # Modulus
- b = saleObj.grand_total / 25 # Division
- #not calculate rounding if modulus is 0 and division is even
- #calculate rounding if modulus is zero or not zero and division are not even
- if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
- new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
- @rounding_adj = new_total-saleObj.grand_total
- saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
- @sale_data.grand_total = new_total
- @sale_data.old_grand_total = saleObj.grand_total
- @sale_data.rounding_adjustment = @rounding_adj
- else
- @rounding_adj = @sale_data.rounding_adjustment
- end
- else
- @rounding_adj = @sale_data.rounding_adjustment
- end
- #end rounding adjustment
-
- # get printer info
- @print_settings = PrintSetting.get_precision_delimiter()
-
- #get customer amount
- @customer = Customer.find(@sale_data.customer_id)
- # accounts = @customer.tax_profiles
- accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
- @account_arr =[]
- @tax_arr =[]
- accounts.each do |acc|
- account = TaxProfile.find(acc.id)
- # @account_arr.push(account)
- @tax_arr.push(account.name)
- end
- sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
- if !sale_taxes.empty?
- sale_taxes.each do |sale_tax|
- @account_arr.push(sale_tax)
- end
- end
- rebate = MembershipSetting.find_by_rebate(1)
- # get member information
- if @customer.membership_id != nil && rebate
- response = Customer.get_member_account(@customer)
- if response["status"]==true
- response["account_data"].each do |res|
+ # get member information
+ @balance = 0
+ @accountable_type = ''
+ if @customer.membership_id != nil && rebate
+ response = Customer.get_member_account(@customer)
+ if response["status"]==true
+ response["account_data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@balance = @balance.to_f + res["balance"].to_f
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
end
- end
- end
-
- #end customer amount
-
- #paymal payment
-
- @sale_data.bookings.each do |sbk|
- if sbk.dining_facility_id.to_i >0
- df = DiningFacility.find(sbk.dining_facility_id)
- @table_no = df.type + ' ' + df.name
- @checkin_time = sbk.checkin_at
- @dining = df
- break
- else
- @table_no = nil
- @checkin_time = nil
- @dining = nil
- end
- end
-
- if path.include? ("credit_payment")
- @sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
- else
- @sale_payment_data = SalePayment.get_sale_payments(@sale_data)
- end
- @sale_payment_data.each do |spay|
- if spay.payment_method == "cash"
- @cash += spay.payment_amount
- end
- if spay.payment_method !="creditnote"
- @other_payment += spay.payment_amount
- end
-
- if spay.payment_method == "mpu"
- @other += spay.payment_amount
- elsif spay.payment_method == "paypar"
- @ppamount += spay.payment_amount
- elsif spay.payment_method == "visa"
- @visacount += spay.payment_amount
- elsif spay.payment_method == "jcb"
- @jcbcount += spay.payment_amount
- elsif spay.payment_method == "master"
- @mastercount += spay.payment_amount
- elsif spay.payment_method == "unionpay"
- @unionpaycount += spay.payment_amount
- elsif spay.payment_method == "JunctionPay"
- @junctionpaycount += spay.payment_amount
- elsif spay.payment_method == "creditnote"
- @credit += spay.payment_amount
- elsif spay.payment_method == "paymal"
- @paymalcount += spay.payment_amount
- elsif spay.payment_method == "alipay"
- @alipaycount += spay.payment_amount
- elsif spay.payment_method == "dinga"
- @dingacount += spay.payment_amount
- elsif spay.payment_method == "giftvoucher"
- @giftvouchercount += spay.payment_amount
- end
-
end
end
+ #end customer amount
end
def reprint
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index ee89704a..70812e11 100755
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -36,7 +36,8 @@ class SalePayment < ApplicationRecord
def self.get_kbz_pay_amount(sale_id, current_user)
amount = 0
- kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
+ kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
+ .where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
if !sale_payment.nil? and !kbz_pay_method.nil?
if sale_payment.payment_status == 'pending'
@@ -81,7 +82,7 @@ class SalePayment < ApplicationRecord
amount_due = invoice.sale_payments
.map(&:payment_amount).reduce(invoice.grand_total, :-)
end
-
+
if amount_due > 0
payment_status = false
membership_data = nil
@@ -121,10 +122,8 @@ class SalePayment < ApplicationRecord
payment_status,membership_data = dinga_payment
when "GiftVoucher"
payment_status = giftvoucher_payment
- when KbzPay::KBZ_PAY
- payment_status = kbz_payment
- else
- puts "it was something else"
+ else
+ payment_status = external_terminal_card_payment(payment_method, payment_for)
end
if payment_status
@@ -623,17 +622,6 @@ class SalePayment < ApplicationRecord
return payment_status
end
- def kbz_payment
- payment_status = false
- self.payment_amount = self.received_amount
- self.payment_reference = self.payment_reference
- self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
- self.payment_status = "paid"
- payment_status = self.save!
- # sale_update_payment_status(self.received_amount)
- return payment_status
- end
-
def sale_update_payment_status(paid_amount, check_foc = false)
#update amount_outstanding
if ['completed'].include? sale.sale_status
diff --git a/app/views/origami/others_payments/create.json.jbuilder b/app/views/origami/others_payments/create.json.jbuilder
new file mode 100644
index 00000000..9767a7d8
--- /dev/null
+++ b/app/views/origami/others_payments/create.json.jbuilder
@@ -0,0 +1,5 @@
+if(@status)
+ json.status @status
+else
+ json.status false
+end
diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb
index 8bbc9747..d9ea86bc 100755
--- a/app/views/origami/others_payments/index.html.erb
+++ b/app/views/origami/others_payments/index.html.erb
@@ -19,7 +19,7 @@
<% end %>
-
<%= payment_method.payment_method %>
+
<%= payment_method.payment_method %>
<% end %>
@@ -45,7 +45,7 @@
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
if(payment_type) {
$(".others-payment").hide();
- $(payment_type).each(function(i){
+ $(payment_type).each(function(i){
$("."+payment_type[i]).show();
});
}
diff --git a/app/views/origami/others_payments/new.html.erb b/app/views/origami/others_payments/new.html.erb
new file mode 100644
index 00000000..8962ceb6
--- /dev/null
+++ b/app/views/origami/others_payments/new.html.erb
@@ -0,0 +1,279 @@
+
+
+
+
+
+
<%= @membership_id%>
+
<%= @member_discount%>
+
<%= @sub_total%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index 4f5d387a..6ed4044e 100755
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -9,24 +9,24 @@
+ <%= render 'shared/license_expire_warning' %>
<%= render 'layouts/header' %>
<% flash.each do |type, message| %>
@@ -22,7 +23,6 @@
<%= message %>
<% end %>
- <%= render 'shared/license_expire_warning' %>
<%= yield %>
diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb
index e767bafe..c7b52bb8 100644
--- a/app/views/oqs/home/index.html.erb
+++ b/app/views/oqs/home/index.html.erb
@@ -1,5 +1,5 @@
-
+
<%= @filter %>
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 27d13860..c0e3a61d 100644
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -4,7 +4,7 @@
<% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%>
<% modify_order = request.path_info.include?('modify_order')%>
-
+
diff --git a/app/views/origami/cash_ins/new.html.erb b/app/views/origami/cash_ins/new.html.erb
index 5b23656e..675a82c4 100755
--- a/app/views/origami/cash_ins/new.html.erb
+++ b/app/views/origami/cash_ins/new.html.erb
@@ -1,4 +1,4 @@
-
+
<%= t :cash_in %>
diff --git a/app/views/origami/cash_outs/new.html.erb b/app/views/origami/cash_outs/new.html.erb
index ea83b2e0..f31feb62 100755
--- a/app/views/origami/cash_outs/new.html.erb
+++ b/app/views/origami/cash_outs/new.html.erb
@@ -1,4 +1,4 @@
-
+
<%= t :cash_out %>
diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb
index 5d24c9d1..2fa34e8c 100755
--- a/app/views/origami/discounts/index.html.erb
+++ b/app/views/origami/discounts/index.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb
index 39c33749..a583e659 100755
--- a/app/views/origami/home/index.html.erb
+++ b/app/views/origami/home/index.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index 8e3c3b18..c6bdfca3 100755
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb
index 4355c06a..dcc6af33 100644
--- a/app/views/origami/order_reservation/index.html.erb
+++ b/app/views/origami/order_reservation/index.html.erb
@@ -1,6 +1,6 @@
<%= stylesheet_link_tag 'order_reservation', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'order_reservation', 'data-turbolinks-track': 'reload' %>
-
+
<%
pending_count = 0
diff --git a/app/views/origami/other_charges/index.html.erb b/app/views/origami/other_charges/index.html.erb
index 886eda51..06208b2f 100755
--- a/app/views/origami/other_charges/index.html.erb
+++ b/app/views/origami/other_charges/index.html.erb
@@ -1,4 +1,4 @@
-
+
@@ -202,7 +202,7 @@
<%else%>
<%end%>
-
+
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index 6ed4044e..c9795298 100755
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb
index 903c13a5..fe8ba72f 100644
--- a/app/views/origami/pending_order/index.html.erb
+++ b/app/views/origami/pending_order/index.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb
index 73ee0040..9ad89797 100644
--- a/app/views/origami/pending_order/show.html.erb
+++ b/app/views/origami/pending_order/show.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb
index a752e5b5..ec529e8c 100755
--- a/app/views/origami/shifts/show.html.erb
+++ b/app/views/origami/shifts/show.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb
index 8bc99b8b..40e52db6 100755
--- a/app/views/origami/surveys/_form.html.erb
+++ b/app/views/origami/surveys/_form.html.erb
@@ -1,4 +1,4 @@
-
+
diff --git a/app/views/renew_license/expire.html.erb b/app/views/renew_license/expire.html.erb
index 67e9fe1a..d29c5923 100644
--- a/app/views/renew_license/expire.html.erb
+++ b/app/views/renew_license/expire.html.erb
@@ -8,13 +8,24 @@
text = "Your license will expire in #{day}."
end
%>
+
-
-
+
-
Renew Your License
+
Review Your License
<%= link_to origami_dashboard_url do %>

<% end %>
@@ -51,11 +62,10 @@
-
+
- <%= link_to 'Home', origami_dashboard_url, class: 'btn btn-primary btn-lg' %>
- <%= link_to 'Renew License', renew_url, class: 'btn btn-primary btn-lg float-right m-l-5 m-r-5' %>
-
+ <%= link_to 'Review License', renew_url, class: 'btn btn-primary btn-lg float-right m-l-10 m-r-5' %>
+ <%= link_to 'Go To Home', origami_dashboard_url, class: 'btn btn-default btn-lg float-right' %>
@@ -64,9 +74,9 @@
diff --git a/app/views/shared/_license_expire_warning.html.erb b/app/views/shared/_license_expire_warning.html.erb
index 0949aff7..a1292d4c 100644
--- a/app/views/shared/_license_expire_warning.html.erb
+++ b/app/views/shared/_license_expire_warning.html.erb
@@ -10,12 +10,38 @@
end
%>
<% if license_status == 0 || license_status == 2 %>
-
+
<%= text %>
- <%= link_to 'Renew License', expire_url, class: 'btn btn-sm btn-primary', style: "margin-left: 40px !important"%>
-
-<% end %>
\ No newline at end of file
+<% end %>
+
+
\ No newline at end of file
diff --git a/config/license.yml b/config/license.yml
index 6148ed67..edd39369 100644
--- a/config/license.yml
+++ b/config/license.yml
@@ -1,19 +1,17 @@
---
localhost:
- iv_key: c5bODYtxFPckKXr3bLPdnQ==
+ iv_key: 03TLQUDDVSOPa/lEEHqhVw==
shop_name: scdemo3
email: hanwintun@code2lab.com
telephone: ''
fax: ''
address: ''
- dbhost: eFiEpFewQVPPylY1pefN2ZIVmxg9v7G1YrnHtNIPIbQQg7WtffKz35uCcOwgwzEvCTPUhPQama4B80FHyTpn3Q==
- dbschema: PRMtXnRsDZQjF319ItO7Lw==
- dbusername: QYngtMBsTBV/B17XiH5zhQ==
- dbpassword: vXsZqV2sJQ+tjIiGBb7N8A==
+ dbhost: gG0jQLrVX6l0dZaA5wVP9bNTrfgzotwAcjcFKQmM9WUQ5121pkwg+9mYh5XDrIwL4//1UNjRR6CNZPorBMGtAw==
+ dbschema: M9ddWoBb89JN51Ld1r7vTw==
+ dbusername: 8Lc2lKIyJld/xfG6+ZxcOw==
+ dbpassword: "+EhtSe5kJuVKp+wFMRlmoA=="
api_token: UQFLAbMvJxUCnDVCOhIdqYZEGRqVQMvI
app_token: DvRXGlomaBFpGVLYsidekVVZyqosntouTA
- plan_sku: AqCfY9X2C03i+XBLnvRz5w==
- renewable_date: 'MXf+rRgjWFxIRgpf+Aa4JA==
-
-'
- plan_name: bDYhVmEo9MNZmfIxwxE30BFHUKWTDVkVDnUiE6htM5Y=
+ plan_sku: 2NY6p1HAlR7UqE8AsBEytg==
+ renewable_date: vlKVqrJyCB6LxXTkv63COg==
+ plan_name: 6NSPpVHcwHBoFZPcVNjkvD6F5quXIWVaWieCRzpspbE=
From 98ca01533e66feda02b89729af1abb724faaa1ab Mon Sep 17 00:00:00 2001
From: NyanLinHtut
Date: Mon, 8 Jun 2020 10:13:55 +0630
Subject: [PATCH 07/25] change hardcoded payment methods
---
.../origami/discounts_controller.rb | 2 +-
.../origami/others_payments_controller.rb | 2 +-
app/controllers/origami/shifts_controller.rb | 4 +-
.../reports/payment_method_controller.rb | 26 +-
.../reports/shiftsale_controller.rb | 5 +-
app/models/printer/cashier_station_printer.rb | 6 +-
app/models/sale.rb | 156 +++++------
app/models/sale_payment.rb | 12 +-
app/models/shift_sale.rb | 16 +-
app/pdf/close_cashier_pdf.rb | 251 +++++++++---------
app/views/origami/dashboard/index.html.erb | 55 ++--
app/views/origami/payments/show.html.erb | 13 +-
app/views/reports/dailysale/index.html.erb | 177 +-----------
app/views/reports/dailysale/index.xls.erb | 162 +----------
.../reports/payment_method/index.html.erb | 31 +--
.../reports/payment_method/index.xls.erb | 30 +--
16 files changed, 302 insertions(+), 646 deletions(-)
diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb
index 6f4690f0..19a9f087 100755
--- a/app/controllers/origami/discounts_controller.rb
+++ b/app/controllers/origami/discounts_controller.rb
@@ -87,7 +87,7 @@ class Origami::DiscountsController < BaseOrigamiController
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
-
+
end
end
diff --git a/app/controllers/origami/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb
index 964af260..fb75288d 100755
--- a/app/controllers/origami/others_payments_controller.rb
+++ b/app/controllers/origami/others_payments_controller.rb
@@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
@cashier_type = params[:type]
path = request.fullpath
if path.include? ("credit_payment")
- @payment_method_setting = PaymentMethodSetting.where("LOWER(payment_method) in ('mpu','visa','master','jcb','unionpay','alipay') and is_active='1'")
+ @payment_method_setting = PaymentMethodSetting.where("is_active='1'")
else
@payment_method_setting = PaymentMethodSetting.all
end
diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb
index f28c1428..be13f2d0 100755
--- a/app/controllers/origami/shifts_controller.rb
+++ b/app/controllers/origami/shifts_controller.rb
@@ -112,7 +112,7 @@ class Origami::ShiftsController < BaseOrigamiController
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
-
+ @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
@@ -125,7 +125,7 @@ class Origami::ShiftsController < BaseOrigamiController
end
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
if find_close_cashier_print[0][1].to_i > 0
- printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
+ printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods)
end
end
end
diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb
index 414c4e07..752a2f4e 100644
--- a/app/controllers/reports/payment_method_controller.rb
+++ b/app/controllers/reports/payment_method_controller.rb
@@ -1,28 +1,30 @@
-class Reports::PaymentMethodController < BaseReportController
+class Reports::PaymentMethodController < BaseReportController
# authorize_resource :class => false
def index
- @payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"],
- ["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"],
- ["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
- ["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"],
- ["JunctionPay","junctionpay"],["Redeem Payment","paypar"],["Gift Voucher","giftvoucher"]]
+ @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
+
+ @payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"],
+ ["FOC Payment","foc"]]
+
+ @payment_methods.each do |m|
+ @payments.push(["#{m} Payment", m.parameterize])
+ end
from, to = get_date_range_from_params
- @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
- if to.blank?
+ 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)
+ @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@payment_type = params[:payment_type]
- @sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
+ @sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift,from,to,@payment_type)
@from = from
@to = to
# get printer info
@@ -58,10 +60,10 @@ class Reports::PaymentMethodController < BaseReportController
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
+end
diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb
index 0c42a05f..ce927f8e 100755
--- a/app/controllers/reports/shiftsale_controller.rb
+++ b/app/controllers/reports/shiftsale_controller.rb
@@ -80,6 +80,7 @@ class Reports::ShiftsaleController < BaseReportController
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
+ @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@@ -95,8 +96,8 @@ class Reports::ShiftsaleController < BaseReportController
printer = Printer::CashierStationPrinter.new(print_settings)
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
- printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
-
+ printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods)
+
respond_to do |format|
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
format
diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb
index 5e37164f..63ffc53e 100755
--- a/app/models/printer/cashier_station_printer.rb
+++ b/app/models/printer/cashier_station_printer.rb
@@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# self.print(filename, cashier_terminal.printer_name)
# end
- def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
+ def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
if !sale_items.blank? or !sale_items.nil?
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@@ -59,7 +59,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
- pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
+ pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty?
@@ -68,7 +68,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
if close_cashier[1] == '1'
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
else
- pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
+ pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
end
end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index f990c947..aa2b6992 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -748,66 +748,46 @@ class Sale < ApplicationRecord
return num
end
-def self.daily_sales_list(from,to)
+ def self.daily_sales_list(from,to)
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
+
sales = select("
- sales.*,
- SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
- SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
- SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
- SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
- SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
- SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
- SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
- SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
- SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
- SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
- SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
- SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
- CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote')
- then sale_payments.payment_amount else 0 end) < sales.grand_total
- THEN sales.grand_total - SUM(case when sale_payments.payment_method not in('creditnote')
- then sale_payments.payment_amount else 0 end)
- ELSE 0 END as credit_amount,
- SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
- SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
- .along_with_sale_payments_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
+ sales.*,
+ #{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method}"}.join(', ')},
+ SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
+ CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote')
+ then sale_payments.payment_amount else 0 end) < sales.grand_total
+ THEN sales.grand_total - SUM(case when sale_payments.payment_method not in('creditnote')
+ then sale_payments.payment_amount else 0 end)
+ ELSE 0 END as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
+ .along_with_sale_payments_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
daily_total = connection.select_all("SELECT
- IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
- IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale,
- IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
- IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
- IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
- IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
- IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
- IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21 as tax,
- (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0))-(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
- (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,
- SUM(kbzpay_amount) as kbzpay_amount,
- SUM(mpu_amount) as mpu_amount,
- SUM(master_amount) as master_amount,
- SUM(visa_amount) as visa_amount,
- SUM(jcb_amount) as jcb_amount,
- SUM(paypar_amount) as paypar_amount,
- SUM(unionpay_amount) as unionpay_amount,
- SUM(alipay_amount) as alipay_amount,
- SUM(paymal_amount) as paymal_amount,
- SUM(dinga_amount) as dinga_amount,
- SUM(junctionpay_amount) as junctionpay_amount,
- SUM(cash_amount) as cash_amount,
- SUM(credit_amount) as credit_amount,
- SUM(giftvoucher_amount) as giftvoucher_amount,
- SUM(foc_amount) as foc_amount
- FROM (
- #{sales}
- ) as s
- GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
+ IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
+ IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale,
+ IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
+ IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
+ IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
+ IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
+ IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
+ IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21 as tax,
+ (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0))-(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
+ (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| "SUM(#{method}) as #{method}"}.join(', ')},
+ SUM(cash_amount) as cash_amount,
+ SUM(credit_amount) as credit_amount,
+ SUM(foc_amount) as foc_amount
+ FROM (
+ #{sales}
+ ) as s
+ GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
return daily_total
-end
+ end
def self.get_by_range_by_saleitems(from,to,status,report_type)
query = Sale.select("
@@ -973,6 +953,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
other_charges = self.get_other_charges()
end
product = self.get_product_sale()
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
if shift.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
@@ -982,7 +963,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1005,7 +986,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1029,7 +1010,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1060,6 +1041,8 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
customer_id = customer_id.to_s
customer_id[0] = ""
customer_id = customer_id.chomp("]")
+ else
+ customer_id = "''"
end
query = self.get_staff_meal_query()
@@ -1076,16 +1059,17 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
# other_charges = self.get_other_charges()
# end
product = self.get_product_sale()
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
if shift.present?
- query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift.to_a)
+ query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN (#{customer_id})",shift.to_a)
# if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
# end
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1101,14 +1085,14 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
### => get all sales range in shift_sales
elsif shift_sale_range.present?
- query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift_sale_range.to_a)
+ query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN (#{customer_id})",shift_sale_range.to_a)
# if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
# end
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1124,7 +1108,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else
- query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to)
+ query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN (#{customer_id})",from,to)
# if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
# end
@@ -1132,7 +1116,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -1343,20 +1327,12 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
end
end
-def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type)
+def self.get_payment_method_by_shift(shift,from,to,payment_type)
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
+
payments_total = SalePayment.select("
sales.receipt_date as sale_date,
- SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
- SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
- SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
- SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
- SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
- SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
- SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
- SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
- SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
- SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
- SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
+ #{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method}"}.join(', ')},
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='cash') then
sales.amount_changed else 0 end) as total_change_amount,
@@ -1384,9 +1360,6 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
if shift.present?
payments_total = payments_total.where(sales: {shift_sale_id: shift.to_a})
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift.to_a}))
- elsif shift_sale_range.present?
- payments_total = payments_total.where(sales: {shift_sale_id: shift_sale_range.to_a})
- sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift_sale_range.to_a}))
end
if payment_type.present?
@@ -1513,11 +1486,12 @@ end
end
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
query = employee_sale(shift, from, to)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount,
- CASE WHEN sale_payments.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card'
+ CASE WHEN sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card'
ELSE sale_payments.payment_method END AS payment_method, employees.name AS e_name")
end
@@ -1541,8 +1515,9 @@ end
end
def self.total_card_sale(current_user=nil,from=nil,to=nil)
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
query = Sale.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
- .where('sales.sale_status = "completed" and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")')
+ .where("sales.sale_status = 'completed' and (sp.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }))")
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
@@ -1602,10 +1577,11 @@ end
end
def self.total_payment_methods(current_user=nil,from=nil,to=nil)
- query = Sale.select("CASE WHEN sp.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' ELSE sp.payment_method END as payment_method")
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
+ query = Sale.select("CASE WHEN sp.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card' ELSE sp.payment_method END as payment_method")
.where("sales.sale_status = 'completed'")
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
- .group("CASE WHEN sp.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' ELSE sp.payment_method END")
+ .group("CASE WHEN sp.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card' ELSE sp.payment_method END")
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
@@ -2039,6 +2015,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
other_charges = self.get_other_charges()
end
product = self.get_product_sale()
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
if shift.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
@@ -2048,7 +2025,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -2071,7 +2048,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -2095,7 +2072,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
@@ -2255,8 +2232,9 @@ def self.get_daily_sale_data(transaction_date)
end
def self.get_check_sale_data(transaction_date)
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sale_receivables_subquery = "SELECT sale_payments.sale_id,
- CASE WHEN sale_payments.payment_method = 'mpu' OR sale_payments.payment_method = 'visa' OR sale_payments.payment_method = 'master' OR sale_payments.payment_method = 'jcb' OR sale_payments.payment_method = 'paypar' OR sale_payments.payment_method = 'unionpay' OR sale_payments.payment_method = 'alipay' OR sale_payments.payment_method = 'paymal' OR sale_payments.payment_method = 'dinga' OR sale_payments.payment_method = 'JunctionPay' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as credit_card_sales,
+ SUM(case when (sale_payments.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as credit_card_sales,
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
FROM sale_payments
GROUP BY sale_payments.sale_id, sale_payments.payment_method"
@@ -2315,7 +2293,9 @@ private
self.total_tax = self.total_tax.round(precision)
end
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
- adjust_rounding
+ if (!['foc'].include? self.payment_status)
+ adjust_rounding
+ end
end
def update_stock_journal
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 70812e11..9ade9920 100755
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -11,7 +11,7 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
scope :credits, -> { where(payment_method: 'creditnote') }
- scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher']) }
+ scope :cards, -> { where(payment_method: PaymentMethodSetting.where("is_active='1'").pluck("payment_method")) }
def self.sync_sale_payment_records(sale_payments)
if !sale_payments.nil?
@@ -364,10 +364,16 @@ class SalePayment < ApplicationRecord
# Check for Card Payment
def self.get_sale_payments_by_card(sale_payments)
# Check for Card Payment
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sale_payments.each do |sp|
- if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay"
- return true;
+ payment_methods.each do |m|
+ if sp.payment_method == m
+ return true;
+ end
end
+ # if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay"
+ # return true;
+ # end
end
end
diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb
index 56db452f..f3280f76 100755
--- a/app/models/shift_sale.rb
+++ b/app/models/shift_sale.rb
@@ -150,21 +150,11 @@ class ShiftSale < ApplicationRecord
end
def self.get_by_shift_other_payment(shift)
+ payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
other_payment = Sale.select("sale_payments.payment_method as name,
- SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
- SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
- SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
- SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
- SUM(case when (sale_payments.payment_method='unionpay') then (sale_payments.payment_amount) else 0 end) as unionpay_amount,
- SUM(case when (sale_payments.payment_method='alipay') then (sale_payments.payment_amount) else 0 end) as alipay_amount,
- SUM(case when (sale_payments.payment_method='KBZPay') then (sale_payments.payment_amount) else 0 end) as kbzpay_amount,
- SUM(case when (sale_payments.payment_method='dinga') then (sale_payments.payment_amount) else 0 end) as dinga_amount,
- SUM(case when (sale_payments.payment_method='giftvoucher') then (sale_payments.payment_amount) else 0 end) as giftvoucher_amount,
- SUM(case when (sale_payments.payment_method='JunctionPay') then (sale_payments.payment_amount) else 0 end) as junctionpay_amount,
- SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
- SUM(case when (sale_payments.payment_method='paymal') then (sale_payments.payment_amount) else 0 end) as paymal_amount,
- SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
+ #{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method}"}.join(', ')},
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
end
diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb
index 976c3d93..e6b594bc 100755
--- a/app/pdf/close_cashier_pdf.rb
+++ b/app/pdf/close_cashier_pdf.rb
@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
- def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
+ def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -43,7 +43,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,payment_methods)
if !sale_items.nil? or !sale_items.blank?
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
@@ -63,7 +63,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
- def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
+ def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,payment_methods)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -173,125 +173,138 @@ class CloseCashierPdf < Prawn::Document
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
- if other.mpu_amount && other.mpu_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "MPU Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+
+ if !payment_methods.nil?
+ payment_methods.each do |method|
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "#{method} Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{ number_format(other[method.parameterize.to_sym], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ end
end
end
- if other.visa_amount && other.visa_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "VISA Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.master_amount && other.master_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Master Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.jcb_amount && other.jcb_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "JCB Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.unionpay_amount && other.unionpay_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.alipay_amount && other.alipay_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Alipay Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.kbzpay_amount && other.kbzpay_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "KBZ Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.junctionpay_amount && other.junctionpay_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.dinga_amount && other.dinga_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Dinga Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.paypar_amount && other.paypar_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Redeem Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.paymal_amount && other.paymal_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Paymal Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
-
- if other.giftvoucher_amount && other.giftvoucher_amount.to_f > 0
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
- end
+ # if other.mpu_amount && other.mpu_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "MPU Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.visa_amount && other.visa_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "VISA Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.master_amount && other.master_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "Master Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.jcb_amount && other.jcb_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "JCB Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.unionpay_amount && other.unionpay_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.alipay_amount && other.alipay_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "Alipay Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.kbzpay_amount && other.kbzpay_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "KBZ Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.junctionpay_amount && other.junctionpay_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.dinga_amount && other.dinga_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "Dinga Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.paypar_amount && other.paypar_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "Redeem Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.paymal_amount && other.paymal_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "Paymal Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
+ #
+ # if other.giftvoucher_amount && other.giftvoucher_amount.to_f > 0
+ # y_position = cursor
+ # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ # text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
+ # end
+ # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ # text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ # end
+ # end
end
else
y_position = cursor
diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb
index 713ba6a5..38df56b3 100644
--- a/app/views/origami/dashboard/index.html.erb
+++ b/app/views/origami/dashboard/index.html.erb
@@ -96,36 +96,35 @@
<% if !(@total_payment_methods.nil?) %>
- <% @total_payment_methods.each do |payment| %>
- <% if !@sale_data[0].empty? %>
- <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
-
- <% if payment.payment_method == 'paypar' %>
- | Redeem Sale : |
- <% else %>
- <%= payment.payment_method.to_s.capitalize %> Sale : |
- <% end %>
-
- <% @sale_data.each do |data| %>
- <% pay_mth = payment.payment_method %>
- <%= data[""+pay_mth+""] %>
+ <% @total_payment_methods.each do |payment| %>
+ <% if !@sale_data[0].empty? %>
+ <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
+ |
+ <% if payment.payment_method == 'paypar' %>
+ | Redeem Sale : |
+ <% else %>
+ <%= payment.payment_method.to_s.capitalize %> Sale : |
+ <% end %>
+
+ <% @sale_data.each do |data| %>
+ <% pay_mth = payment.payment_method %>
+ <%= data[""+pay_mth+""] %>
+ <% end %>
+ |
+
+ <% end %>
<% end %>
-
-
- <% end %>
- <% end %>
- <% end %>
-
- <% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %>
- <% if !total_card.nil? %>
-
- | <%= t("views.right_panel.detail.other_payment") %> : |
-
- <%= total_card["card"].to_f %>
- |
-
- <% end %>
+ <% end %>
+ <% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %>
+ <% if !total_card.nil? %>
+
+ | <%= t("views.right_panel.detail.other_payment") %> : |
+
+ <%= total_card["card"].to_f %>
+ |
+
+ <% end %>
<% end %>
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index 6ed4044e..482a2402 100755
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -600,9 +600,9 @@ $(document).ready(function(){
}
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
- payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
- other_payment = payment_methods.find(x => payment_type.indexOf(x) >= 0)
- // console.log(payment_type)
+ payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
+
+ console.log(payment_type)
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
@@ -611,7 +611,7 @@ $(document).ready(function(){
$("#credit_payment").show();
}
- if(other_payment){
+ if(payment_type && payment_methods.some(x => payment_type.indexOf(x) >= 0)){
$("#card_payment").show();
} else{
$("#card_payment").hide();
@@ -680,9 +680,8 @@ $(document).ready(function(){
$('#pay').click(function() {
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
- // console.log(member)
- if (other_payment && !other_payments.some(x => x[0] == other_payment && x[1] > 0 ) && sub_total != 0.0 && member) {
- swal("Oops","Please Pay with " + other_payment + " Payment","warning");
+ if (payment_type && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0 ) && sub_total != 0.0 && member) {
+ swal("Oops","Please Pay with " + payment_methods.find(x => payment_type.indexOf(x) >= 0) + " Payment","warning");
} else {
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb
index 13b315de..db25ce0c 100755
--- a/app/views/reports/dailysale/index.html.erb
+++ b/app/views/reports/dailysale/index.html.erb
@@ -82,44 +82,11 @@
| <%= t("views.right_panel.detail.sr") %> |
- <%= t("views.right_panel.detail.date") %> |
+ <%= t("views.righ_panel.detail.date") %> |
+ <% @payment_methods.each do |method| %>
+ <%= t("views.right_panel.detail.#{method}") %> |
+ <% end %>
- <% if @payment_methods.include? ("MPU") %>
- <%= t("views.right_panel.detail.mpu_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("Master") %>
- <%= t("views.right_panel.detail.master_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("VISA") %>
- <%= t("views.right_panel.detail.visa_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("JCB") %>
- <%= t("views.right_panel.detail.jcb_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("UNIONPAY") %>
- <%= t("views.right_panel.detail.unionpay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("KBZPay") %>
- <%= t("views.right_panel.detail.kbzpay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("Alipay") %>
- <%= t("views.right_panel.detail.alipay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("PAYMAL") %>
- <%= t("views.right_panel.detail.paymal_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("DINGA") %>
- <%= t("views.right_panel.detail.dinga_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("JunctionPay") %>
- <%= t("views.right_panel.detail.junctionpay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("Redeem") %>
- <%= t("views.right_panel.detail.redeem_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("GiftVoucher") %>
- <%= t("views.right_panel.detail.giftvoucher_sales") %> |
- <% end %>
<%= t("views.right_panel.detail.cash_sales") %> |
<%= t("views.right_panel.detail.credit_sales") %> |
<%= t("views.right_panel.detail.void_amount") %> |
@@ -140,22 +107,10 @@
<% unless @sale_data.blank? %>
<% void = 0 %>
- <% mpu = 0 %>
- <% master = 0 %>
- <% visa = 0 %>
- <% jcb = 0 %>
- <% unionpay = 0 %>
- <% alipay = 0 %>
- <% paymal = 0 %>
- <% dinga = 0 %>
- <% junctionpay = 0 %>
- <% giftvoucher = 0 %>
- <% paypar = 0 %>
<% cash = 0 %>
<% credit = 0 %>
<% foc = 0 %>
<% discount = 0 %>
- <% kbzpay = 0 %>
<% total = 0 %>
<% grand_total = 0 %>
<% old_grand_total = 0 %>
@@ -164,24 +119,13 @@
<% tax = 0 %>
<% net_sale = 0 %>
<% count = 1 %> <% rounding_adj = 0 %>
+
<% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %>
- <% mpu += sale[:mpu_amount] %>
- <% master += sale[:master_amount] %>
- <% visa += sale[:visa_amount] %>
- <% jcb += sale[:jcb_amount] %>
- <% unionpay += sale[:unionpay_amount] %>
- <% alipay += sale[:alipay_amount] %>
- <% paymal += sale[:paymal_amount] %>
- <% dinga += sale[:dinga_amount] %>
- <% junctionpay += sale[:junctionpay_amount] %>
- <% giftvoucher += sale[:giftvoucher_amount] %>
- <% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
- <% kbzpay += sale[:kbzpay_amount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %>
<% old_grand_total += sale[:old_grand_total].to_f %>
@@ -193,41 +137,8 @@
| <%= count %> |
<%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %> |
- <% if @payment_methods.include? ("MPU") %>
- <%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Master") %>
- <%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("VISA") %>
- <%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("JCB") %>
- <%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("UNIONPAY") %>
- <%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Alipay") %>
- <%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("KBZPay") %>
- <%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("PAYMAL") %>
- <%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("DINGA") %>
- <%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("JunctionPay") %>
- <%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Redeem") %>
- <%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("GiftVoucher") %>
- <%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <% @payment_methods.each do |method| %>
+ <%= number_format(sale[method.parameterize.to_sym], precision:precision.to_i, delimiter: delimiter) rescue 0 %> |
<% end %>
<%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%> |
<%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
@@ -236,7 +147,7 @@
(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>) |
- <%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <%= number_format(sale[:rounding_adj], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<% if @tax.blank? %>
@@ -250,75 +161,9 @@
<% colspan = 7 %>
| Total |
- <% if @payment_methods.include? ("MPU") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("Master") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("VISA") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("JCB") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("UNIONPAY") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Alipay") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("KBZPay") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("PAYMAL") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("DINGA") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("JunctionPay") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Redeem") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("GiftVoucher") %>
- <% colspan += 1 %>
- <%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <% @payment_methods.each do |method| %>
+ <% colspan += 1 %>
+ <%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[method.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue 0 %> |
<% end %>
<%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
diff --git a/app/views/reports/dailysale/index.xls.erb b/app/views/reports/dailysale/index.xls.erb
index f3d0aa2b..cc0eced9 100755
--- a/app/views/reports/dailysale/index.xls.erb
+++ b/app/views/reports/dailysale/index.xls.erb
@@ -27,41 +27,8 @@
<%= t("views.right_panel.detail.sr") %> |
<%= t("views.right_panel.detail.date") %> |
- <% if @payment_methods.include? ("MPU") %>
- <%= t("views.right_panel.detail.mpu_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("Master") %>
- <%= t("views.right_panel.detail.master_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("VISA") %>
- <%= t("views.right_panel.detail.visa_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("JCB") %>
- <%= t("views.right_panel.detail.jcb_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("UNIONPAY") %>
- <%= t("views.right_panel.detail.unionpay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("KBZPay") %>
- <%= t("views.right_panel.detail.kbzpay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("Alipay") %>
- <%= t("views.right_panel.detail.alipay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("PAYMAL") %>
- <%= t("views.right_panel.detail.paymal_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("DINGA") %>
- <%= t("views.right_panel.detail.dinga_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("JunctionPay") %>
- <%= t("views.right_panel.detail.junctionpay_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("Redeem") %>
- <%= t("views.right_panel.detail.redeem_sales") %> |
- <% end %>
- <% if @payment_methods.include? ("GiftVoucher") %>
- <%= t("views.right_panel.detail.giftvoucher_sales") %> |
+ <% @payment_methods.each do |method| %>
+ <%= t("views.right_panel.detail.#{method}") %> |
<% end %>
<%= t("views.right_panel.detail.cash_sales") %> |
<%= t("views.right_panel.detail.credit_sales") %> |
@@ -108,22 +75,10 @@
<% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %>
- <% mpu += sale[:mpu_amount] %>
- <% master += sale[:master_amount] %>
- <% visa += sale[:visa_amount] %>
- <% jcb += sale[:jcb_amount] %>
- <% unionpay += sale[:unionpay_amount] %>
- <% alipay += sale[:alipay_amount] %>
- <% paymal += sale[:paymal_amount] %>
- <% dinga += sale[:dinga_amount] %>
- <% junctionpay += sale[:junctionpay_amount] %>
- <% giftvoucher += sale[:giftvoucher_amount] %>
- <% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
- <% kbzpay += sale[:kbzpay_amount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %>
<% old_grand_total += sale[:old_grand_total].to_f %>
@@ -135,41 +90,8 @@
| <%= count %> |
<%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %> |
- <% if @payment_methods.include? ("MPU") %>
- <%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Master") %>
- <%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("VISA") %>
- <%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("JCB") %>
- <%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("UNIONPAY") %>
- <%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Alipay") %>
- <%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("KBZPay") %>
- <%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("PAYMAL") %>
- <%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("DINGA") %>
- <%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("JunctionPay") %>
- <%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Redeem") %>
- <%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("GiftVoucher") %>
- <%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <% @payment_methods.each do |method| %>
+ <%= number_format(sale[method.parameterize.to_sym], precision:precision.to_i, delimiter: delimiter) rescue 0 %> |
<% end %>
<%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%> |
<%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
@@ -192,75 +114,9 @@
<% colspan = 7 %>
| Total |
- <% if @payment_methods.include? ("MPU") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("Master") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("VISA") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("JCB") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end%>
- <% if @payment_methods.include? ("UNIONPAY") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Alipay") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("KBZPay") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("PAYMAL") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("DINGA") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("JunctionPay") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("Redeem") %>
- <% if !request.user_agent.include? "Mobile" %>
- <% colspan += 1 %>
- <% end %>
- <%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
- <% end %>
- <% if @payment_methods.include? ("GiftVoucher") %>
- <% colspan += 1 %>
- <%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <% @payment_methods.each do |method| %>
+ <% colspan += 1 %>
+ <%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[method.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue 0 %> |
<% end %>
<%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
@@ -293,12 +149,12 @@
<% net = net - total_tax %>
| <%= t("views.right_panel.detail.net_amount") %> |
- <%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<% else %>
| <%= t("views.right_panel.detail.net_amount") %> |
- <%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
+ <%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%> |
<% end %>
diff --git a/app/views/reports/payment_method/index.html.erb b/app/views/reports/payment_method/index.html.erb
index ed0ffec3..93f7be28 100755
--- a/app/views/reports/payment_method/index.html.erb
+++ b/app/views/reports/payment_method/index.html.erb
@@ -40,42 +40,25 @@
<% end %>
- | <%= t("views.right_panel.detail.mpu_sales") %> |
- <%= t("views.right_panel.detail.master_sales") %> |
- <%= t("views.right_panel.detail.visa_sales") %> |
- <%= t("views.right_panel.detail.jcb_sales") %> |
- <%= t("views.right_panel.detail.unionpay_sales") %> |
- <%= t("views.right_panel.detail.alipay_sales") %> |
- <%= t("views.right_panel.detail.kbzpay_sales") %> |
-
- <%= t("views.right_panel.detail.dinga_sales") %> |
- <%= t("views.right_panel.detail.junctionpay_sales") %> |
- <%= t("views.right_panel.detail.redeem_sales") %> |
+ <% @payment_methods.each do |method| %>
+ <%= t("views.right_panel.detail.#{method} Sales") %> |
+ <% end %>
<%= t("views.right_panel.detail.cash_sales") %> |
<%= t("views.right_panel.detail.credit_sales") %> |
<%= t("views.right_panel.detail.foc_sales") %> |
- <%= t("views.right_panel.detail.giftvoucher_sales") %> |
<% unless @sale_data.empty? %>
<% @sale_data.each do |sale| %>
- | <%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
-
- <%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <% @payment_methods.each do |method| %>
+ <%= number_format(sale[method.parameterize.to_sym] , precision: precision.to_i ,delimiter: delimiter) rescue 0 %> |
+ <% end %>
<%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+
<% end %>
diff --git a/app/views/reports/payment_method/index.xls.erb b/app/views/reports/payment_method/index.xls.erb
index a6fcf35d..ec4dfbee 100755
--- a/app/views/reports/payment_method/index.xls.erb
+++ b/app/views/reports/payment_method/index.xls.erb
@@ -27,42 +27,24 @@
<% end %>
- | <%= t("views.right_panel.detail.mpu_sales") %> |
- <%= t("views.right_panel.detail.master_sales") %> |
- <%= t("views.right_panel.detail.visa_sales") %> |
- <%= t("views.right_panel.detail.jcb_sales") %> |
- <%= t("views.right_panel.detail.unionpay_sales") %> |
- <%= t("views.right_panel.detail.alipay_sales") %> |
- <%= t("views.right_panel.detail.kbzpay_sales") %> |
-
- <%= t("views.right_panel.detail.dinga_sales") %> |
- <%= t("views.right_panel.detail.junctionpay_sales") %> |
- <%= t("views.right_panel.detail.redeem_sales") %> |
+ <% @payment_methods.each do |method| %>
+ <%= t("views.right_panel.detail.#{method} Sales") %> |
+ <% end %>
<%= t("views.right_panel.detail.cash_sales") %> |
<%= t("views.right_panel.detail.credit_sales") %> |
<%= t("views.right_panel.detail.foc_sales") %> |
- <%= t("views.right_panel.detail.giftvoucher_sales") %> |
<% unless @sale_data.empty? %>
<% @sale_data.each do |sale| %>
- | <%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
-
- <%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <% @payment_methods.each do |method| %>
+ <%= number_format(sale[method.parameterize.to_sym] , precision: precision.to_i ,delimiter: delimiter) rescue 0 %> |
+ <% end %>
<%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<% end %>
From f6a35d214fe20e9227136df34f3ef9cb8b3f2296 Mon Sep 17 00:00:00 2001
From: NyanLinHtut
Date: Wed, 10 Jun 2020 18:12:15 +0630
Subject: [PATCH 08/25] fixed payment methods & license
---
.gitignore | 1 +
Gemfile.lock | 4 +-
app/assets/stylesheets/BSBMaterial/style.css | 4 +-
app/controllers/home_controller.rb | 2 -
.../origami/waste_spoile_controller.rb | 5 +-
.../reports/payment_method_controller.rb | 10 +--
.../reports/receipt_no_detail_controller.rb | 64 +++++++++----------
.../transactions/shift_sales_controller.rb | 14 ++--
app/models/license.rb | 6 +-
app/models/sale.rb | 23 +++++--
app/models/sale_payment.rb | 5 +-
app/views/home/dashboard.html.erb | 36 ++++++-----
app/views/layouts/CRM.html.erb | 20 +++---
app/views/layouts/OQS.html.erb | 16 ++---
app/views/layouts/application.html.erb | 27 ++++----
app/views/layouts/inventory.html.erb | 14 ++--
app/views/layouts/origami.html.erb | 19 +++---
app/views/origami/dashboard/index.html.erb | 6 +-
.../_shift_sale_report_filter.html.erb | 9 +--
.../reports/waste_and_spoilage/index.html.erb | 2 +-
.../shared/_license_expire_warning.html.erb | 25 +++++---
.../transactions/shift_sales/show.html.erb | 60 ++++++-----------
config/license.yml | 17 -----
23 files changed, 187 insertions(+), 202 deletions(-)
delete mode 100644 config/license.yml
diff --git a/.gitignore b/.gitignore
index 3560a44c..42dc0371 100755
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@ pickle-email-*.html
/config/initializers/*
config/deploy/config/*
#config/puma.rb
+config/license.yml
config/shops.json
!/log/.keep
diff --git a/Gemfile.lock b/Gemfile.lock
index 4cdc2ded..578d79d3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -96,6 +96,7 @@ GEM
concurrent-ruby (1.1.5)
connection_pool (2.2.2)
crass (1.0.5)
+ cups (0.0.7)
database_cleaner (1.7.0)
diff-lcs (1.3)
erubi (1.9.0)
@@ -334,6 +335,7 @@ DEPENDENCIES
carrierwave (~> 1.0)
chartkick
coffee-rails (~> 4.2)
+ cups (~> 0.0.7)
database_cleaner
factory_girl_rails (~> 4.0)
faker
@@ -382,4 +384,4 @@ RUBY VERSION
ruby 2.6.5p114
BUNDLED WITH
- 2.0.2
+ 2.1.4
diff --git a/app/assets/stylesheets/BSBMaterial/style.css b/app/assets/stylesheets/BSBMaterial/style.css
index 004439e9..a4620cf5 100755
--- a/app/assets/stylesheets/BSBMaterial/style.css
+++ b/app/assets/stylesheets/BSBMaterial/style.css
@@ -11,7 +11,7 @@
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
border: none;
position: fixed;
- /*top: 0;*/
+ top: 0;
left: 0;
z-index: 12;
width: 100%; }
@@ -6649,7 +6649,7 @@ fieldset[disabled] .form-control {
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
border: none;
position: fixed;
- /*top: 0;*/
+ top: 0;
left: 0;
z-index: 12;
width: 100%; }
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 18928fc3..2665a330 100755
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -108,8 +108,6 @@ class HomeController < ApplicationController
@hourly_sales = Sale.hourly_sales(current_user,@from,@to)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
- logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><'
- logger.debug @hourly_sales.to_json
employee_sales = Sale.employee_sales(current_user,@from,@to)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
@employee_sales = []
diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb
index ba0846ee..e1055323 100755
--- a/app/controllers/origami/waste_spoile_controller.rb
+++ b/app/controllers/origami/waste_spoile_controller.rb
@@ -10,10 +10,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
existing_tax.delete
end
- sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
- sale.payment_status = remark
- sale.sale_status = remark
- sale.save
+ sale.update_attributes(total_discount: 0, total_tax: 0, grand_total: sale.total_amount, rounding_adjustment:0, payment_status: remark, sale_status: remark)
# add to sale item with foc
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb
index 752a2f4e..baad3350 100644
--- a/app/controllers/reports/payment_method_controller.rb
+++ b/app/controllers/reports/payment_method_controller.rb
@@ -4,12 +4,12 @@ class Reports::PaymentMethodController < BaseReportController
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
- @payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"],
- ["FOC Payment","foc"]]
+ @payments = [["All",''], ["Cash","cash"], ["Card", "card"], ["Credit","creditnote"],
+ ["FOC","foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
- @payment_methods.each do |m|
- @payments.push(["#{m} Payment", m.parameterize])
- end
+ # @payment_methods.each do |m|
+ # @payments.push(["#{m} Payment", m.parameterize])
+ # end
from, to = get_date_range_from_params
diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb
index 775b2651..eba6c3e6 100755
--- a/app/controllers/reports/receipt_no_detail_controller.rb
+++ b/app/controllers/reports/receipt_no_detail_controller.rb
@@ -1,46 +1,46 @@
class Reports::ReceiptNoDetailController < BaseReportController
authorize_resource :class => false
def index
- @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
- @payment_method = PaymentMethodSetting.all
+ @payment_methods = [["All", ''], ["Cash", "cash"], ["Card", "card"], ["Credit", "creditnote"], ["FOC", "foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
+
from, to = get_date_range_from_params
@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 = ''
+ 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
+ @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
- payment_type = params[:payment_type]
- @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
+ payment_type = params[:payment_type]
+ @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
- @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
+ @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
+ format.html
+ format.xls
+ end
end
def show
diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb
index f3a9fc05..562d45e4 100644
--- a/app/controllers/transactions/shift_sales_controller.rb
+++ b/app/controllers/transactions/shift_sales_controller.rb
@@ -10,16 +10,16 @@ class Transactions::ShiftSalesController < ApplicationController
to = params[:to]
if filter.nil? && from.nil? && to.nil?
- @shift_sales = ShiftSale.all.order("id desc")
+ @shift_sales = ShiftSale.all.order("id desc")
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
else
shift_sale = ShiftSale.search(filter,from,to)
if shift_sale.count > 0
- @shift_sales = shift_sale
+ @shift_sales = shift_sale
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
else
@shift_sales = 0
- end
+ end
end
respond_to do |format|
@@ -32,7 +32,7 @@ class Transactions::ShiftSalesController < ApplicationController
# GET /transactions/shift_sales/1
# GET /transactions/shift_sales/1.json
def show
-
+
@shift = ShiftSale.find(params[:id])
#get tax
@@ -40,13 +40,13 @@ class Transactions::ShiftSalesController < ApplicationController
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
-
+ @payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
-
+
respond_to do |format|
format.html # show.html.erb
@@ -59,7 +59,7 @@ class Transactions::ShiftSalesController < ApplicationController
redirect_to root_path
end
end
-
+
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_shift_sale
diff --git a/app/models/license.rb b/app/models/license.rb
index 92781a22..edbe5947 100755
--- a/app/models/license.rb
+++ b/app/models/license.rb
@@ -164,10 +164,10 @@ class License
elsif old_renewable_date.to_date < @varified['renewable_date'].to_date
update_license("renewable_date", @varified['renewable_date'])
status = 1
- message = "*** License con be verified. ***"
+ message = "*** License con be verified. ***"
end
return status, message
-
+
else
delete_license_file
end
@@ -204,7 +204,7 @@ class License
def days_to_expire
if renewal_date_str = read_license("renewable_date")
- Date.today - DateTime.parse(renewal_date_str).to_date
+ Date.today - DateTime.parse(renewal_date_str).to_date
end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index aa2b6992..7018f0ff 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -1200,11 +1200,21 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
.includes(:bookings => :dining_facility)
.select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount")
.joins(:bookings)
+ .joins("INNER JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.left_joins(:payments_for_credits)
.completed
.where.not(total_amount: 0)
.group(:sale_id)
.order(:receipt_date)
+
+ if payment_type.present?
+ if payment_type == 'card'
+ query = query.where(sanitize_sql_array(["sp.payment_method IN (?)", SalePayment::CARD]))
+ else
+ query = query.where("sp.payment_method = (?)", payment_type)
+ end
+ end
+
if shift.present?
query = query.where("sales.shift_sale_id in (?)", shift.to_a)
elsif shift_sale_range.present?
@@ -1363,7 +1373,11 @@ def self.get_payment_method_by_shift(shift,from,to,payment_type)
end
if payment_type.present?
- sale_payment = sale_payment.where(payment_method: payment_type)
+ if payment_type == 'card'
+ sale_payment = sale_payment.where(sanitize_sql_array(["payment_method IN (?)", SalePayment::CARD]))
+ else
+ sale_payment = sale_payment.where("payment_method = (?)", payment_type)
+ end
end
return payments_total, sale_payment
@@ -1577,11 +1591,10 @@ end
end
def self.total_payment_methods(current_user=nil,from=nil,to=nil)
- payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
- query = Sale.select("CASE WHEN sp.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card' ELSE sp.payment_method END as payment_method")
+ query = Sale.select(sanitize_sql_array(["CASE WHEN sp.payment_method IN (?) THEN 'card' ELSE sp.payment_method END as payment_method", SalePayment::CARD]))
.where("sales.sale_status = 'completed'")
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
- .group("CASE WHEN sp.payment_method IN (#{payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card' ELSE sp.payment_method END")
+ .group(sanitize_sql_array(["CASE WHEN sp.payment_method IN (?) THEN 'card' ELSE sp.payment_method END", SalePayment::CARD]))
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
@@ -2293,7 +2306,7 @@ private
self.total_tax = self.total_tax.round(precision)
end
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
- if (!['foc'].include? self.payment_status)
+ if (!['foc','waste','spoile'].include? self.payment_status)
adjust_rounding
end
end
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 9ade9920..95162fb2 100755
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -1,4 +1,7 @@
class SalePayment < ApplicationRecord
+
+ CARD = ['mpu', 'visa', 'master', 'jcb', 'unionpay']
+
self.primary_key = "sale_payment_id"
#primary key - need to be unique generated for multiple shops
@@ -11,7 +14,7 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
scope :credits, -> { where(payment_method: 'creditnote') }
- scope :cards, -> { where(payment_method: PaymentMethodSetting.where("is_active='1'").pluck("payment_method")) }
+ scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay']) }
def self.sync_sale_payment_records(sale_payments)
if !sale_payments.nil?
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index b7bd5c44..e77cee9d 100755
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -209,30 +209,36 @@
<% if !(@total_payment_methods.nil?) %>
<% @total_payment_methods.each do |payment| %>
- <% if payment.payment_method != 'card' %>
-
+ <% if !@sale_data[0].empty? %>
+ <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
+
<% if payment.payment_method == 'paypar' %>
| Redeem Sale : |
<% else %>
<%= payment.payment_method.to_s.capitalize %> Sale : |
<% end %>
-
- <%= number_format(@sale_data.find {|x| x.key?(payment.payment_method) }[payment.payment_method], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
- |
-
+
+ <% @sale_data.each do |data| %>
+ <% pay_mth = payment.payment_method %>
+ <%= data[""+pay_mth+""] %>
+ <% end %>
+ |
+
+ <% end %>
<% end %>
<% end %>
- <% total_card = @sale_data.find {|x| x.key?("card") } %>
- <% if !total_card.nil? %>
-
- | <%= t("views.right_panel.detail.other_payment") %> : |
-
- <%= number_format(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
- |
-
+ <% total_card = @sale_data.select { |hash| hash["card"]!=nil } %>
+ <% if !total_card.nil? %>
+
+ | <%= t("views.right_panel.detail.other_payment") %> : |
+
+ <% total_other_amt = 0 %>
+ <% @sale_data.map { |k,v| k.map{|meth,amt| meth != 'cash' && meth != 'foc' && meth != 'creditnote' ? total_other_amt += amt : meth }} %>
+ <%= total_other_amt %>
+ |
+
<% end %>
-
<% end %>
diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb
index 5c2fc4b7..3fca697d 100755
--- a/app/views/layouts/CRM.html.erb
+++ b/app/views/layouts/CRM.html.erb
@@ -31,38 +31,38 @@
Please wait...
- <%= render 'shared/license_expire_warning' %>
+ <%= render 'shared/license_expire_warning' if Rails.env.production? %>
<%= render 'layouts/header' %>
-
- <%= render 'layouts/left_sidebar' %>
- <%= render 'layouts/right_sidebar' %>
+
+ <%= render 'layouts/left_sidebar' %>
+ <%= render 'layouts/right_sidebar' %>
-
+
<% flash.each do |type, message| %>
<% if !flash["errors"]%>
- <%
+ <%
if type == "notice"
color = "alert-success"
end
if type == "error"
color = "alert-danger"
- end
+ end
%>
<% if flash["error"] || flash["notice"]%>
<% end %>
- <% end %>
+ <% end %>
<% end %>
- <%= yield %>
+ <%= yield %>