From 0943808ac84ae73dc3621e68c2c2cefed8bb56e8 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 00:45:59 +0630 Subject: [PATCH 01/23] finished order and sales in setting --- app/assets/javascripts/settings/orders.coffee | 3 + app/assets/stylesheets/settings/orders.scss | 3 + app/controllers/crm/customers_controller.rb | 28 +-- app/controllers/origami/home_controller.rb | 20 +- app/controllers/settings/orders_controller.rb | 32 +++ app/controllers/settings/sales_controller.rb | 42 ++++ app/helpers/settings/orders_helper.rb | 2 + .../crm/customers/_error_messages.html.erb | 9 + app/views/crm/customers/index.html.erb | 2 +- app/views/crm/customers/show.html.erb | 116 ++++++--- app/views/kaminari/_first_page.html.erb | 11 + app/views/kaminari/_gap.html.erb | 8 + app/views/kaminari/_last_page.html.erb | 11 + app/views/kaminari/_next_page.html.erb | 11 + app/views/kaminari/_page.html.erb | 12 + app/views/kaminari/_paginator.html.erb | 23 ++ app/views/kaminari/_prev_page.html.erb | 11 + app/views/origami/customers/index.html.erb | 223 ++++++++++++++++++ app/views/origami/home/index.html.erb | 9 +- app/views/settings/orders/index.html.erb | 68 ++++++ app/views/settings/orders/show.html.erb | 85 +++++++ app/views/settings/sales/index.html.erb | 85 +++++++ app/views/settings/sales/show.html.erb | 103 ++++++++ config/routes.rb | 2 + ...0170611084537_create_membership_actions.rb | 2 +- .../settings/orders_controller_spec.rb | 5 + spec/helpers/settings/orders_helper_spec.rb | 15 ++ 27 files changed, 876 insertions(+), 65 deletions(-) create mode 100644 app/assets/javascripts/settings/orders.coffee create mode 100644 app/assets/stylesheets/settings/orders.scss create mode 100644 app/controllers/settings/orders_controller.rb create mode 100644 app/controllers/settings/sales_controller.rb create mode 100644 app/helpers/settings/orders_helper.rb create mode 100644 app/views/crm/customers/_error_messages.html.erb create mode 100644 app/views/kaminari/_first_page.html.erb create mode 100644 app/views/kaminari/_gap.html.erb create mode 100644 app/views/kaminari/_last_page.html.erb create mode 100644 app/views/kaminari/_next_page.html.erb create mode 100644 app/views/kaminari/_page.html.erb create mode 100644 app/views/kaminari/_paginator.html.erb create mode 100644 app/views/kaminari/_prev_page.html.erb create mode 100644 app/views/origami/customers/index.html.erb create mode 100644 app/views/settings/orders/index.html.erb create mode 100644 app/views/settings/orders/show.html.erb create mode 100644 app/views/settings/sales/index.html.erb create mode 100644 app/views/settings/sales/show.html.erb create mode 100644 spec/controllers/settings/orders_controller_spec.rb create mode 100644 spec/helpers/settings/orders_helper_spec.rb diff --git a/app/assets/javascripts/settings/orders.coffee b/app/assets/javascripts/settings/orders.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/settings/orders.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/stylesheets/settings/orders.scss b/app/assets/stylesheets/settings/orders.scss new file mode 100644 index 00000000..436ceee1 --- /dev/null +++ b/app/assets/stylesheets/settings/orders.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the settings/orders 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/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 8c477355..9f73edcf 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -30,6 +30,15 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers/1 # GET /crm/customers/1.json def show + @orders = Order.where("customer_id=?", params[:id]) + + if @orders + @order_items = [] + @orders.each do |bo| + @order_items = @order_items + bo.order_items + end + + end end # GET /crm/customers/new @@ -108,6 +117,7 @@ class Crm::CustomersController < BaseCrmController end end end +end # PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1.json @@ -158,24 +168,6 @@ class Crm::CustomersController < BaseCrmController end end - # DELETE /crm/customers/1 - # DELETE /crm/customers/1.json - - # def get_sale_id - - # @sale_id = params[:sale_id] - # @crm_customers = Customer.all - # @crm_customer = Customer.new - # @membership = Customer.get_member_group - # if @membership["status"] == true - # @member_group = @membership["data"] - # end - # respond_to do |format| - # format.html { render action: "index"} - # format.json { render json: @crm_customers } - # end - # end - private # Use callbacks to share common setup or constraints between actions. def set_crm_customer diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 309903b2..1b16ab54 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -41,8 +41,24 @@ class Origami::HomeController < BaseOrigamiController end def get_customer - @customer = Customer.find(params[:customer_id]) - render :json => @customer.to_json + @customer = Customer.find(params[:customer_id]) + + membership = MembershipSetting.find_by_membership_type("paypar_url") + + memberaction = MembershipAction.find_by_membership_type("get_all_member_account") + app_token = membership.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + response = HTTParty.post(url, :body => { membership_id: @customer.membership_id}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + } + ) + + + + render :json => response.to_json end end diff --git a/app/controllers/settings/orders_controller.rb b/app/controllers/settings/orders_controller.rb new file mode 100644 index 00000000..b5bbdc1c --- /dev/null +++ b/app/controllers/settings/orders_controller.rb @@ -0,0 +1,32 @@ +class Settings::OrdersController < ApplicationController + def index + + filter = params[:filter] + if filter.nil? + orders = Order.order("order_id desc").limit(1000) + else + order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page]) + if order.count > 0 + orders = order + else + orders = Order.order("order_id desc").limit(1000) + flash[:notice] = "There is no data." + end + end + @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @orders } + end + end + def show + + @order = Order.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @order } + end + end + +end diff --git a/app/controllers/settings/sales_controller.rb b/app/controllers/settings/sales_controller.rb new file mode 100644 index 00000000..6bb58244 --- /dev/null +++ b/app/controllers/settings/sales_controller.rb @@ -0,0 +1,42 @@ +class Settings::SalesController < ApplicationController + def index + + search_date = params[:date] + receipt_no = params[:receipt_no] + today = Date.today + + if receipt_no.nil? && search_date.nil? + @sales = Sale.where("NOT sale_status = 'void'" ).order("sale_id desc").limit(500) + else + if !search_date.blank? && receipt_no.blank? + sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", search_date).order("sale_id desc").limit(500).page(params[:page]) + elsif !search_date.blank? && !receipt_no.blank? + sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page]) + else + sale = Sale.where("receipt_no LIKE ?", receipt_no).order("sale_id desc").limit(500).page(params[:page]) + end + if sale.count > 0 + @sales = sale + else + @sales = Sale.where("NOT sale_status = 'void'").order("sale_id desc").limit(500) + end + end + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sales } + end + end + + def show + + @sale = Sale.find(params[:id]) + # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) + respond_to do |format| + format.html # show.html.erb + format.json { render json: @sale } + end + end + + +end \ No newline at end of file diff --git a/app/helpers/settings/orders_helper.rb b/app/helpers/settings/orders_helper.rb new file mode 100644 index 00000000..f5825365 --- /dev/null +++ b/app/helpers/settings/orders_helper.rb @@ -0,0 +1,2 @@ +module Settings::OrdersHelper +end diff --git a/app/views/crm/customers/_error_messages.html.erb b/app/views/crm/customers/_error_messages.html.erb new file mode 100644 index 00000000..bbff284b --- /dev/null +++ b/app/views/crm/customers/_error_messages.html.erb @@ -0,0 +1,9 @@ +
+ +
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index e4f6d07d..c3fb4064 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -51,7 +51,7 @@ <%= crm_customer.contact_no %> <%= crm_customer.email %> - <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> + <%= link_to 'Show', crm_customer_path(crm_customer) %> diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index da88e887..45529dc6 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,40 +1,84 @@ -

<%= notice %>

- -

- Name: - <%= @crm_customer.name %> -

- -

- Company: - <%= @crm_customer.company %> -

- -

- Contact no: - <%= @crm_customer.contact_no %> -

- -

- Email: - <%= @crm_customer.email %> -

- -

- Date of birth: - <%= @crm_customer.date_of_birth %> -

+
+
+ +
+
-

- Membership type: - <%= @crm_customer.membership_type %> -

+
+
+ +
+
+
+ + + + + + + + + + -

- Membership authentication code: - <%= @crm_customer.membership_authentication_code %> -

+ + + + + + + + + + +
NameEmailContact noCompanyDate Of Birth
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %>
+
+

Order Details

+ + + + + + + + + + + + + + + + <% @order_items.each do |order_item| %> + + + + + + + + + + <% end %> + +
Created at Menu ItemQTYUnit Price OptionStatusWaiter
<%= order_item.created_at %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %>
+
+
+ +
+ + +
+ + + + -<%= link_to 'Edit', edit_crm_customer_path(@crm_customer) %> | -<%= link_to 'Back', crm_customers_path %> diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb new file mode 100644 index 00000000..2682d341 --- /dev/null +++ b/app/views/kaminari/_first_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "First" page + - available local variables + url: url to the first page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote %> + diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb new file mode 100644 index 00000000..bbb0f983 --- /dev/null +++ b/app/views/kaminari/_gap.html.erb @@ -0,0 +1,8 @@ +<%# Non-link tag that stands for skipped pages... + - available local variables + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<%= t('views.pagination.truncate').html_safe %> diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb new file mode 100644 index 00000000..53d61307 --- /dev/null +++ b/app/views/kaminari/_last_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "Last" page + - available local variables + url: url to the last page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote %> + diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb new file mode 100644 index 00000000..4fc20712 --- /dev/null +++ b/app/views/kaminari/_next_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "Next" page + - available local variables + url: url to the next page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote %> + diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb new file mode 100644 index 00000000..582af7bc --- /dev/null +++ b/app/views/kaminari/_page.html.erb @@ -0,0 +1,12 @@ +<%# Link showing page number + - available local variables + page: a page object for "this" page + url: url to this page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> + diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb new file mode 100644 index 00000000..4fb445fd --- /dev/null +++ b/app/views/kaminari/_paginator.html.erb @@ -0,0 +1,23 @@ +<%# The container tag + - available local variables + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote + paginator: the paginator that renders the pagination tags inside +-%> +<%= paginator.render do -%> + +<% end -%> diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb new file mode 100644 index 00000000..9c4aff49 --- /dev/null +++ b/app/views/kaminari/_prev_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "Previous" page + - available local variables + url: url to the previous page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote %> + diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb new file mode 100644 index 00000000..974dceb8 --- /dev/null +++ b/app/views/origami/customers/index.html.erb @@ -0,0 +1,223 @@ +
+
+ +
+
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + <% @crm_customers.each do |crm_customer| %> + + + + + + + + + + <% end %> + +
+ <%= form_tag crm_customers_path, :method => :get do %> +
+ + +
+ <% end %> +
SelectNameCompanyContact noEmail
+ <%= crm_customer.name %><%= crm_customer.company %><%= crm_customer.contact_no %><%= crm_customer.email %> + <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> + +
+
+ + <%= paginate @crm_customers %> +
+
+ +
+ +
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + + + <%= f.error_notification %> + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> + +
+ <%= f.input :name, :class => "form-control col-md-6 name" %> + +
+
+ <%= f.input :company, :class => "form-control col-md-6 company" %> +
+
+ <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> + + +
+ +
+ <%= f.input :email, :class => "form-control col-md-6 email" %> +
+ +
+ + <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%> +
+ + + + + + +
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> + <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> +
+ <%end%> +
+
+ + + + + + + + diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 6ec5c978..459e8061 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -227,14 +227,9 @@ - -<<<<<<< HEAD - - -======= - + + ->>>>>>> 6d4ef8e2adaa39c710a9b30dcb35737b6be2410e diff --git a/app/views/settings/orders/index.html.erb b/app/views/settings/orders/index.html.erb new file mode 100644 index 00000000..bd3df8fb --- /dev/null +++ b/app/views/settings/orders/index.html.erb @@ -0,0 +1,68 @@ +
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + <% @orders.each do |order| %> + + + + + + + + + + + <% end %> + +
+ <%= form_tag settings_orders_path, :method => :get do %> +
+ + +
+ <% end %> +
Order ID TypeCustomerOrder statusOrder dateItems CountAction
<%= order.order_id %><%= order.order_type %><%= order.customer.name rescue '-' %><%= order.status %> <%= order.date.strftime("%d-%m-%Y") %> <%= order.item_count %> <%= link_to 'Show', settings_order_path(order) %>
+
+ + <%= paginate @orders %> +
+
+ +
+
+ + + + + diff --git a/app/views/settings/orders/show.html.erb b/app/views/settings/orders/show.html.erb new file mode 100644 index 00000000..bd17dadb --- /dev/null +++ b/app/views/settings/orders/show.html.erb @@ -0,0 +1,85 @@ +
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
TypeCustomerOrder statusOrder dateOrder By
<%= @order.order_type %><%= @order.customer.name rescue '-' %><%= @order.status %> <%= @order.date.strftime("%d-%m-%Y") %> <%= @order.waiter rescue '-' %>
+

Order Items

+ + + + + + + + + + + + + + + + + <% @order.order_items.each do |order| %> + + + + + + + + + + + + <% end %> + +
Item NameQty Unit PriceTotal PriceOptionStatusOrder ByCreated at
<%= order.item_name %><%= order.qty %><%= order.price %><%= order.qty * order.price %> <%= order.options %> <%= order.order_item_status %> <%= order.item_order_by %> <%= order.created_at.strftime("%d-%m-%Y") %>
+ + Back + +
+
+ +
+
+ + + + + diff --git a/app/views/settings/sales/index.html.erb b/app/views/settings/sales/index.html.erb new file mode 100644 index 00000000..c53a6e8d --- /dev/null +++ b/app/views/settings/sales/index.html.erb @@ -0,0 +1,85 @@ +
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + <% @sales.each do |sale| %> + + + + + + + + + + + + <% end %> + +
+ <%= form_tag settings_sales_path, :method => :get do %> +
+ + + + +
+ <% end %> +
Sale Id Receipt no Grand totalTax amountCashierSales statusReceipt DateAction
<%= sale.sale_id %><%= sale.receipt_no %><%= sale.grand_total rescue '-' %><%= sale.total_tax %><%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> <%= sale.receipt_date.strftime("%d-%m-%Y") %> <%= link_to 'Show', settings_sale_path(sale) %>
+
+ + <%= paginate @sales %> +
+
+ +
+
+ + + + + + + diff --git a/app/views/settings/sales/show.html.erb b/app/views/settings/sales/show.html.erb new file mode 100644 index 00000000..484de762 --- /dev/null +++ b/app/views/settings/sales/show.html.erb @@ -0,0 +1,103 @@ +
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + <% @sale.sale_items.each do |s| %> + + + + + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Receipt Date Receipt noCashierOSales statusReceipt generated at
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %>
Sale item name QtyUnit priceTotal pirce Created at
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %>
Total<%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
Tax<%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%>
Discount<%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
Grand Total<%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
Pay Amount<%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
Change<%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
+ + + Back + +
+
+ +
+
+ + + + + diff --git a/config/routes.rb b/config/routes.rb index 2c9be9e0..7dff2ad3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -166,6 +166,8 @@ Rails.application.routes.draw do resources :lookups #orders resources :orders + #sales + resources :sales #cashier_terminals resources :cashier_terminals #order_job_stations diff --git a/db/migrate/20170611084537_create_membership_actions.rb b/db/migrate/20170611084537_create_membership_actions.rb index 74695871..4a164add 100644 --- a/db/migrate/20170611084537_create_membership_actions.rb +++ b/db/migrate/20170611084537_create_membership_actions.rb @@ -8,7 +8,7 @@ class CreateMembershipActions < ActiveRecord::Migration[5.1] t.string :auth_token t.string :merchant_account_id t.string :created_by - t.jsonb :additional_parameter + t.string :additional_parameter,array: true, :default =>'{}' t.timestamps end diff --git a/spec/controllers/settings/orders_controller_spec.rb b/spec/controllers/settings/orders_controller_spec.rb new file mode 100644 index 00000000..e715e84f --- /dev/null +++ b/spec/controllers/settings/orders_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Settings::OrdersController, type: :controller do + +end diff --git a/spec/helpers/settings/orders_helper_spec.rb b/spec/helpers/settings/orders_helper_spec.rb new file mode 100644 index 00000000..028e7209 --- /dev/null +++ b/spec/helpers/settings/orders_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Settings::OrdersHelper. For example: +# +# describe Settings::OrdersHelper 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::OrdersHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end From ee208a5dcdd9401bc7ba13b9cc04e2c53b7f5772 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 13:26:09 +0630 Subject: [PATCH 02/23] Update --- app/assets/stylesheets/origami.scss | 13 ++--- app/controllers/api/orders_controller.rb | 5 +- app/models/dining_facility.rb | 5 +- app/models/order.rb | 16 +++--- app/models/sale_payment.rb | 4 +- app/views/origami/discounts/index.html.erb | 62 +++++++++++----------- app/views/origami/payments/show.html.erb | 9 ++-- 7 files changed, 60 insertions(+), 54 deletions(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 9e886d87..5e361f7e 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -21,8 +21,9 @@ } .cashier_number{ - height:60px; - line-height:60px; + width: 33%; + height:70px; + line-height:70px; text-align:center; background:#54A5AF; // float:left; @@ -34,8 +35,8 @@ .pay{ width: 98%; - height:210px; - line-height:210px; + height:211px; + line-height:211px; text-align:center; font-size:20px; color:white; @@ -46,7 +47,7 @@ } .long{ - width:100%; + width:49%; } .sold { @@ -121,4 +122,4 @@ select.form-control { tr.discount-item-row:hover { background-color: #e3e3e3 !important; -} \ No newline at end of file +} diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index df9b1542..8bd348e2 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -38,9 +38,8 @@ class Api::OrdersController < Api::ApiController #Create Table Booking or Room Booking - if !params["booking_id"].nil? && params[:booking_id].to_i > 0 - #@order.new_booking = false - @order.new_booking = true + if !params["booking_id"].nil? + @order.new_booking = false @order.booking_id = params[:booking_id] end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 9a4f7a75..a3f8948f 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -9,10 +9,11 @@ class DiningFacility < ApplicationRecord scope :active, -> {where(is_active: true)} def get_current_booking - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + puts "enter booking" + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) if booking.count > 0 then - return booking[0] + return booking[0].booking_id else return nil end diff --git a/app/models/order.rb b/app/models/order.rb index 5e123060..9dcd6949 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -28,11 +28,13 @@ class Order < ApplicationRecord booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) + table = DiningFacility.find(self.table_id) + table.status = "occupied" + table.save else if (self.booking_id.to_i > 0 ) booking = Booking.find(self.booking_id) end - end booking.save! @@ -226,7 +228,7 @@ class Order < ApplicationRecord bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -239,10 +241,10 @@ class Order < ApplicationRecord bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='complete'") - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id") end @@ -252,7 +254,7 @@ class Order < ApplicationRecord bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -269,7 +271,7 @@ class Order < ApplicationRecord .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") end #Origami: Cashier : to view order type Room @@ -298,7 +300,7 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id left join sales on sales.sale_id = sale_orders.sale_id") .where("sales.sale_status<>'complete' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) - .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id") end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 6609a28e..27ddafa6 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -211,18 +211,18 @@ class SalePayment < ApplicationRecord sObj.sale_payments.each do |spay| all_received_amount += spay.payment_amount.to_f end - if (self.sale.grand_total <= all_received_amount) self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! + #TODO: table status rebat() end end def rebat - + end private diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 65b376d8..4f6b7c9a 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -4,7 +4,7 @@
-
@@ -13,10 +13,10 @@

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

-
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

-
+
@@ -75,7 +75,7 @@
- + @@ -88,7 +88,7 @@
-
+
- -
-
+ +
+
-
+

-
+
5%
-
+
1
-
2
-
3
+
2
+
3
-
+
@@ -125,12 +125,12 @@
10%
-
+
4
-
5
-
6
+
5
+
6
-
+
@@ -138,12 +138,12 @@
20%
-
+
7
-
8
-
9
+
8
+
9
-
+
@@ -151,12 +151,12 @@
30%
-
+
0
-
.
-
00
+
.
+
00
-
+
@@ -166,13 +166,13 @@
-
DEL
-
CLR
+
DEL
+
CLR
-
+
- + - + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 198b9518..e8d35206 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -130,7 +130,7 @@
00
-
+
Nett
Del
Clr
@@ -195,6 +195,10 @@ $(document).on('click', '.cashier_number', function(event){ $('#cash').text("0.0"); update_balance(); break; + case 'nett': + $('#cash').text($('#amount_due').text()); + update_balance(); + break; } event.handled = true; } else { @@ -216,7 +220,6 @@ $( document ).ready(function() { }); $('#pay').click(function() { - if($('#balance').text() > 0){ alert(" Insufficient Amount!") }else{ @@ -230,7 +233,7 @@ $( document ).ready(function() { data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ alert("Thank you") - window.location.href = '/origami'; + // window.location.href = '/origami'; } }); } From a96444518a7526fbb342bc7abba4870e986d9f79 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 13:28:16 +0630 Subject: [PATCH 03/23] fixed conflict --- app/models/order.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 27fa8247..a76159be 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -243,13 +243,10 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") -<<<<<<< HEAD - .where("sales.sale_status='complete'") - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id") -======= + .where("sales.sale_status='completed'") .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") ->>>>>>> ca2dc181d62c8c15e0072d7ad01720fb19d28531 + end From c6b72a112b73616bc323391a8dd7d3ec047d88cf Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 13:31:01 +0630 Subject: [PATCH 04/23] For Pull --- dump.rdb | Bin 20156 -> 20365 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/dump.rdb b/dump.rdb index ebdb6db6aa4a16a1abe03b56aaa0c4d4053ff704..0e6392847a8e41d0312e82639916e8eec64d12a8 100644 GIT binary patch delta 394 zcmWm7y=qiJ6ae74yF?dO1-H>6cvp!a$SiYa&Y3f_5O4!_VlNhE=FSX)#6n{uglJ_I zFx)gE`Dw%;Tnoic8w;Pqi%(!BSOm=reBamoYUi+etuB7Lv3l?C=-Jbp!**z!fQYJc_-j>(yC;31c;QQB5*bYY9`+Nr-z1T_SQ{7r_Ja2;Q5`=!R{Lz9K5{y E4{QT>lmGw# delta 159 zcmV;Q0AT-(p8>p`0gx~ep&C6|`UrJ%Wn?XFWo^RnW066d5;-fi51C3;}49wE`an17c=3F_Ta+C6m1Y3zIA@FhXFU7cwwrWj8oAF*GzaWnwTj zF*r71VKrkpGa!@~V{&C-bY)~;VRRxoF*G?hF*i0hGdC_aKq~+>AZq|_V71^2vkL=y NOb9(%2Jyx?=AoT9F%|#- From 917ccd0294737ae459dc180240022471024568e0 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 13:48:54 +0630 Subject: [PATCH 05/23] booking update --- app/models/order.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index a76159be..4526ce35 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -25,6 +25,7 @@ class Order < ApplicationRecord booking = nil if self.new_booking + puts "a" booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) @@ -32,9 +33,10 @@ class Order < ApplicationRecord table.status = "occupied" table.save else - if (self.booking_id.to_i > 0 ) + puts "b" + booking = Booking.find(self.booking_id) - end + end booking.save! @@ -243,7 +245,6 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("sales.sale_status='completed'") .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -272,7 +273,6 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") - .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") From a2111f16355607559c3de5ce07e0c555e0227378 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 13:58:16 +0630 Subject: [PATCH 06/23] For Pull --- app/models/order.rb | 2 -- dump.rdb | Bin 20365 -> 20467 bytes 2 files changed, 2 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index a76159be..702855cc 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -243,7 +243,6 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("sales.sale_status='completed'") .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -272,7 +271,6 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") - .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") diff --git a/dump.rdb b/dump.rdb index 0e6392847a8e41d0312e82639916e8eec64d12a8..9a81a61e209e6152e39a6f20ab56fb2fd13d5afc 100644 GIT binary patch delta 324 zcmV-K0lWT;_R`UrJ%Wn?XFWo^PRYLP*l5t&B7AHW6x01yQL00aO4 zL8p^}E)$bQ15T4q0V5?5H!(G4HaIjeEn;LeWi2#jIW-^&4l*+>GBIUiG-PFCVq`fm zlTa}wlf3~8lPoPTPhg-IWH>oCIAUfwH!)%|VrDZpGiEU~Wiw(oAe0zma%Ew3Wn^Dr zbRs%2G&wgiH8C|dH!d(VAP4|4AZq|_V71^29|kuuF@6530pX~vlX3wjM;+2NDGU0Ad3G03ZS% zL8p_EDjow2bY+v#L}Zgk0wt4LMJ1EG0SlAJJTOjRpci9hHDNJkH!v_VVrDR6WjA3r zHa0Y5Gch2P9Ak22VRU6=Utx42Ix#dkH!(LhH#IOWGdMFfHaQ?`0B&Hl;0qrHH!w1N z{;C1tsFSk-DFk5m;Wd-q0y8`XGBh)N{;ol-0I1`oTOVRHF*P Date: Mon, 12 Jun 2017 14:11:13 +0630 Subject: [PATCH 07/23] updated for food and beverage bugs --- app/assets/javascripts/origami.js | 34 ++++++++++-------------- app/models/sale_item.rb | 17 ++++++------ app/views/origami/payments/show.html.erb | 1 - config/routes.rb | 2 +- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 14f9fbe9..d3ac9e76 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -64,12 +64,6 @@ $(document).ready(function(){ url: "/origami/" + unique_id, data: { 'booking_id' : unique_id }, success:function(result){ -// ======= -// type: "GET", -// url: "origami/" + unique_id, -// data: { 'id' : unique_id }, -// success:function(result){ -// >>>>>>> 5ee3ae257a59269b651dcc5c0232b95d7f41fb77 for (i = 0; i < result.length; i++) { var data = JSON.stringify(result[i]); var parse_data = JSON.parse(data); @@ -191,20 +185,20 @@ $(document).ready(function(){ }); function show_customer_details(customer_id){ - $('.customer_detail').removeClass('hide'); - //Start Ajax - $.ajax({ - type: "GET", - url: "origami/"+customer_id+"/get_customer/", - data: {}, - dataType: "json", - success: function(data) { - $("#customer_name").text(data.name); - $("#customer_name").text(data.name); - } - }); - //End Ajax -} + $('.customer_detail').removeClass('hide'); + //Start Ajax + $.ajax({ + type: "GET", + url: "origami/"+customer_id+"/get_customer/", + data: {}, + dataType: "json", + success: function(data) { + $("#customer_name").text(data.name); + $("#customer_name").text(data.name); + } + }); + //End Ajax + } /* For Receipt - Calculate discount or tax */ $('.cashier_number').on('click', function(event){ diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 0aed9a23..25b37178 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -36,24 +36,25 @@ class SaleItem < ApplicationRecord sale_items.each do |si| food_price = self.get_food_price(si.sale_item_id) - beverage_price = self.get_beverage_price(si.sale_item_id) -puts food_price - # food_prices = food_prices + food_price.price - # beverage_prices = beverage_prices + beverage_price.price + beverage_price = self.get_beverage_price(si.sale_item_id) + food_prices = food_prices + food_price + beverage_prices = beverage_prices + beverage_price end return food_prices, beverage_prices end def self.get_food_price(sale_item_id) - food_price=SaleItem.select("sale_items.price") + food=SaleItem.select("sale_items.price") .joins("left join menu_items on menu_items.item_code = sale_items.product_code") - .where("sale_items.sale_item_id=? and menu_items.account_id=0", sale_item_id) + .where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id.to_s) + food_price = food[0].price rescue 0 end def self.get_beverage_price(sale_item_id) - beverage_price=SaleItem.select("sale_items.price") + beverage=SaleItem.select("sale_items.price") .joins("left join menu_items on menu_items.item_code = sale_items.product_code") - .where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id) + .where("sale_items.sale_item_id=? and menu_items.account_id=2", sale_item_id.to_s) + beverage_price = beverage[0].price rescue 0 end private diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 198b9518..f52c99a1 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -216,7 +216,6 @@ $( document ).ready(function() { }); $('#pay').click(function() { - if($('#balance').text() > 0){ alert(" Insufficient Amount!") }else{ diff --git a/config/routes.rb b/config/routes.rb index 0666e0c4..ddb6e3ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,7 +72,7 @@ Rails.application.routes.draw do #--------- Cashier ------------# namespace :origami do root "home#index" - get "/:booking_id" => "home#show" do #origami/:booking_id will show + get "/:booking_id" => "home#index" do #origami/:booking_id will show # resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers #add customer type end From dd5de68bc0769804de7fd9f4a19762a6b30cb453 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 14:16:31 +0630 Subject: [PATCH 08/23] Seed --- db/seeds.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index fe7bdcc7..5cd38d12 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -51,6 +51,10 @@ menu_item_type = Lookup.create([{lookup_type:'menu_item_type', name: 'SIMPLE', v {lookup_type:'menu_item_type', name: 'Set Menu', value: 'setMenu'}, {lookup_type:'menu_item_type', name: 'DIY', value: 'diy'}]) +member_group_type = Lookup.create([{lookup_type:'member_group_type', name: 'Platinum', value: '1'}, + {lookup_type:'member_group_type', name: 'Silver', value: '2'} + ]) + #menu_item_attribute:[size|] menu_item_attribute_type = Lookup.create([{lookup_type:'menu_item_attribute_type', name: 'Size', value: 'size'}]) # {lookup_type:'menu_item_attribute_type', name: 'Spicy', value: 'spicy'}, @@ -141,7 +145,7 @@ order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSu request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "192.168.1."}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http//192.168.1.47:3006"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1}}, {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1}}, @@ -151,6 +155,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1}}, {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data"} ]) +payment_methods = PaymentMethodSetting.create({membership_type:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"}) # shop = Shop.create( # {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", From b0eb92b04323ad016aad7a8dd978e6b72f89b070 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 14:19:04 +0630 Subject: [PATCH 09/23] Seed --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 5cd38d12..ae2d617d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -155,7 +155,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1}}, {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data"} ]) -payment_methods = PaymentMethodSetting.create({membership_type:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"}) # shop = Shop.create( # {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", From c7ff5140d4929a8674e7b00baa4d59bf60a58db2 Mon Sep 17 00:00:00 2001 From: Phyo Date: Mon, 12 Jun 2017 14:22:45 +0630 Subject: [PATCH 10/23] Payment route change --- app/views/origami/mpu/index.html.erb | 2 +- app/views/origami/payments/show.html.erb | 2 +- config/routes.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index f082dc1a..7b483a75 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -13,7 +13,7 @@ Amount : var sale_id = "<%= @sale_id %>"; $.ajax({type: "POST", - url: "<%= origami_create_mpu_payment_path %>", + url: "<%= origami_payment_mpu_path %>", data: "amount="+ amount + "&sale_id="+ sale_id, success:function(result){ if(result){ diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index e8d35206..7eb890f4 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -229,7 +229,7 @@ $( document ).ready(function() { var card = $('#card').text(); var sale_id = $('#sale_id').text(); $.ajax({type: "POST", - url: "<%= origami_payment_process_path %>", + url: "<%= origami_payment_cash_path %>", data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ alert("Thank you") diff --git a/config/routes.rb b/config/routes.rb index ddb6e3ff..6337f4ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -82,17 +82,17 @@ Rails.application.routes.draw do get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" - get "/:id/request_bills" => "request_bills#print" + get "/:id/request_bills" => "request_bills#print" #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' - post 'payment_process' => 'payments#create' + post 'payment/cash' => 'payments#create' post 'paypar_payment_process' => 'paypar_payments#create' get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/payment/others_payment' => "others_payments#index" # get 'sale/:sale_id/payment/others_payment/:payment_method' => "redeem_payments#index" get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index" - post 'create_mpu_payment' => "mpu#create" + post 'payment/mpu' => "mpu#create" get 'sale/:sale_id/payment/others_payment/REDEEMREBATE' => "redeem_payments#index" #---------Add Customer --------------# @@ -167,7 +167,7 @@ Rails.application.routes.draw do resources :tax_profiles #lookups resources :lookups - #orders + #orders resources :orders #cashier_terminals resources :cashier_terminals From b12b52d75454d60003bbc7cbd513a21cd601c5c1 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 14:23:18 +0630 Subject: [PATCH 11/23] update table status --- app/models/order.rb | 5 +---- app/models/sale_payment.rb | 6 +++++- config/routes.rb | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 4526ce35..40bfbcb7 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -33,10 +33,7 @@ class Order < ApplicationRecord table.status = "occupied" table.save else - puts "b" - - booking = Booking.find(self.booking_id) - + booking = Booking.find(self.booking_id) end booking.save! diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 27ddafa6..5dff91b9 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -215,12 +215,16 @@ class SalePayment < ApplicationRecord self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! - #TODO: table status + table_update_status() rebat() end end + def table_update_status + + end + def rebat end diff --git a/config/routes.rb b/config/routes.rb index 0666e0c4..ddf7d9cd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -82,7 +82,7 @@ Rails.application.routes.draw do get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" - get "/:id/request_bills" => "request_bills#print" + get "/:id/request_bills" => "request_bills#print" #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' @@ -167,7 +167,7 @@ Rails.application.routes.draw do resources :tax_profiles #lookups resources :lookups - #orders + #orders resources :orders #cashier_terminals resources :cashier_terminals From e90178cfdcf505d9e27812eaefd1abc8a51519db Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 14:23:20 +0630 Subject: [PATCH 12/23] finished CRM and customer --- app/assets/javascripts/origami.js | 30 +++++++++++---- app/controllers/crm/customers_controller.rb | 38 +++++++++---------- .../origami/customers_controller.rb | 8 ++-- app/controllers/origami/home_controller.rb | 31 ++++++++++----- app/models/customer.rb | 4 +- app/models/dining_queue.rb | 1 - app/models/lookup.rb | 4 ++ app/models/order.rb | 10 +++-- app/views/crm/customers/index.html.erb | 20 +++++----- app/views/origami/customers/index.html.erb | 12 +++++- app/views/origami/home/index.html.erb | 16 ++++++-- ...=> 20170612031153_create_dining_queues.rb} | 4 +- spec/models/dining_queue_spec.rb | 5 +++ 13 files changed, 121 insertions(+), 62 deletions(-) rename db/migrate/{20170608105644_create_crm_dining_queues.rb => 20170612031153_create_dining_queues.rb} (59%) create mode 100644 spec/models/dining_queue_spec.rb diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index fe209451..34a25dc1 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -27,11 +27,8 @@ $(document).ready(function(){ control_button(order_status); //for customer button - if(unique_id.charAt(0) == 'S'){ $("#customer").removeAttr('disabled'); - }else{ - $("#customer").attr('disabled','disabled'); - } + var customer_id=$(this).find(".customer-id").text(); show_customer_details(customer_id); @@ -161,13 +158,20 @@ $(document).ready(function(){ }); $('#customer').click(function() { - var sale_id=$(".selected-item").find(".orders-id").text(); + var sale = $(".selected-item").find(".orders-id").text(); + if (sale.substring(0, 3)=="SAL") { + var sale_id = sale + }else{ + var sale_id = $(".selected-item").find(".order-cid").text(); + } + alert(sale_id); window.location.href = '/origami/'+ sale_id + "/add_customer" return false; }); function show_customer_details(customer_id){ + $('.customer_detail').removeClass('hide'); //Start Ajax $.ajax({ @@ -176,8 +180,20 @@ $(document).ready(function(){ data: {}, dataType: "json", success: function(data) { - $("#customer_name").text(data.name); - $("#customer_name").text(data.name); + $("#customer_name").text(data["customer"].name); + $.each(data["response_data"]["data"], function (i) { + if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ + var balance = data["response_data"]["data"][i]["balance"]; + console.log(balance); + if (balance) { + $("#customer_amount").text(balance); + }else{ + $("#customer_amount").text('00'); + } + + + } + }); } }); //End Ajax diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 9f73edcf..30c09f06 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -14,9 +14,9 @@ class Crm::CustomersController < BaseCrmController end #@crm_customers = Customer.all @crm_customer = Customer.new - @crm_customer.valid? - - + if @crm_customer.valid? + @crm_customer.errors.messages + end # @membership = Customer.get_member_group # if @membership["status"] == true # @member_group = @membership["data"] @@ -54,17 +54,17 @@ class Crm::CustomersController < BaseCrmController # POST /crm/customers # POST /crm/customers.json - def create + def create @crm_customers = Customer.new(customer_params) - + respond_to do |format| if @crm_customers.save name = customer_params[:name] phone = customer_params[:contact_no] email = customer_params[:email] date_of_birth = customer_params[:date_of_birth] - membership_id = params[:membership_id] + member_group_id = params[:member_group_id] membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") @@ -73,7 +73,7 @@ class Crm::CustomersController < BaseCrmController response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, date_of_birth: date_of_birth, - membership_id: membership_id}.to_json, + member_group_id: member_group_id}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -85,37 +85,34 @@ class Crm::CustomersController < BaseCrmController customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) - if params[:sale_id].nil? - - format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' } - + if params[:sale_id] + format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' } + else + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} + end # format.json { render :index, status: :created, location: @crm_customers } else @crm_customers.destroy - if params[:sale_id].nil? + if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} else format.html { redirect_to crm_customers_path, notice: response["message"] } end end - # format.json { render :index, status: :created, location: @crm_customers } - else - - if params[:sale_id].nil? - + + if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} else - format.html { redirect_to crm_customers_path} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } end end - end + end end @@ -131,6 +128,7 @@ end email = customer_params[:email] date_of_birth = customer_params[:date_of_birth] id = customer_params[:membership_id] + member_group_id = params[:member_group_id] membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("update_membership_customer") @@ -139,7 +137,7 @@ end response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, date_of_birth: date_of_birth, - id: id}.to_json, + id: id,member_group_id:member_group_id}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 7917b03f..74148296 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -23,10 +23,10 @@ class Origami::CustomersController < BaseOrigamiController @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end @crm_customer = Customer.new - @membership = Customer.get_member_group - if @membership["status"] == true - @member_group = @membership["data"] - end + # @membership = Customer.get_member_group + # if @membership["status"] == true + # @member_group = @membership["data"] + # end respond_to do |format| # format.html { render :template => "crm/customers/index" } format.html { render action: "index"} diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1b16ab54..e5e2128f 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -29,15 +29,21 @@ class Origami::HomeController < BaseOrigamiController def update_sale_by_customer - sale = Sale.find(params[:sale_id]) - status = sale.update_attributes(customer_id: params[:customer_id]) - - if status == true + id = params[:sale_id][0,3] + if(id == "SAL") + sale = Sale.find(params[:sale_id]) + else + sale = Order.find(params[:sale_id]) + end + + status = sale.update_attributes(customer_id: params[:customer_id]) + + if status == true render json: JSON.generate({:status => true}) - else + else render json: JSON.generate({:status => false, :error_message => "Record not found"}) - end + end end def get_customer @@ -50,15 +56,20 @@ class Origami::HomeController < BaseOrigamiController app_token = membership.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.post(url, :body => { membership_id: @customer.membership_id}.to_json, + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } ) - - - render :json => response.to_json + respond_to do |format| + format.js do + render :json => { + :response_data => response.as_json, + :customer => @customer} + end + end end + end diff --git a/app/models/customer.rb b/app/models/customer.rb index 4f013678..b5e101cb 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -14,9 +14,9 @@ class Customer < ApplicationRecord def self.get_member_group - membership = MembershipSetting.find_by_membership_type("paypar_url") + membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("get_all_member_group") - app_token = membership.auth_token.to_s + app_token = membership.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.get(url, diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb index dfcc5b43..ea6a1381 100644 --- a/app/models/dining_queue.rb +++ b/app/models/dining_queue.rb @@ -1,3 +1,2 @@ class DiningQueue < ApplicationRecord - end diff --git a/app/models/lookup.rb b/app/models/lookup.rb index e1b141df..5434cedd 100644 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -17,6 +17,10 @@ class Lookup < ApplicationRecord "Gateway Communication Type" => "gateway_communication_type"} end + # def self.get_by_type( lookup_type) + # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] } + # end + def self.collection_of(type) Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] } diff --git a/app/models/order.rb b/app/models/order.rb index f4a4eff9..0b57f9dc 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -222,7 +222,8 @@ class Order < ApplicationRecord #Origami: Cashier : to view booking order Table def self.get_booking_order_table - booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.customer_id as customer_id, + booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, + orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id, bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") @@ -235,7 +236,9 @@ class Order < ApplicationRecord #Origami: Cashier : to view order type Room def self.get_booking_order_rooms - booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,orders.customer_id as customer_id, + booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status, + orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id, + bookings.booking_id,orders.customer_id as customer_id, sales.sale_id as sale_id,dining_facilities.name as room_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") @@ -264,7 +267,8 @@ class Order < ApplicationRecord from = Time.now.beginning_of_day.utc to = Time.now.end_of_day.utc orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, - orders.customer_id as customer_id,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id + ,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.order_id = orders.order_id left join bookings on bookings.booking_id = booking_orders.order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index c3fb4064..9f62b55b 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -71,7 +71,6 @@ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> - <%= f.error_notification %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %> @@ -94,17 +93,20 @@
- <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%> + <%= f.text_field :date_of_birth,:class => "form-control datepicker date_of_birth "%>
+
+ +
+ -
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 974dceb8..070d6d26 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -96,6 +96,16 @@ <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
+ +
+ +
@@ -194,7 +204,7 @@ action: function(){ $.ajax({ type: "POST", - url: "update_sale/" , + url: "update_sale" , data: {customer_id:customer_id,sale_id:sale_id}, dataType: "json", success: function(data) { diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 459e8061..154f489d 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -25,19 +25,23 @@ @booking_orders.each do |bko| # Assigned Id for new Order? Sale? unique_id="" + customer_id="" # For CSS- Class for Order? Sale? sale_status="" if bko.order_status == 'new' unique_id=bko.booking_id + customer_id=bko.order_customer_id else unique_id=bko.sale_id + customer_id=bko.sale_customer_id sale_status="sold" end %>
- + +

<%= bko.table_name %>

@@ -72,15 +76,18 @@ sale_status="" if rmo.order_status == 'new' unique_id=rmo.booking_id + customer_id=rmo.order_customer_id else unique_id=rmo.sale_id + customer_id=rmo.sale_customer_id sale_status="sold" end %>

- + +

<%= rmo.room_name %>

Receipt No : @@ -114,15 +121,18 @@ sale_status="" if odr.order_status == 'new' unique_id=odr.booking_id + customer_id = odr.order_customer_id else unique_id=odr.sale_id + customer_id = odr.sale_customer_id sale_status="sold" end %>

- + +

<%= odr.table_name %>

Receipt No : diff --git a/db/migrate/20170608105644_create_crm_dining_queues.rb b/db/migrate/20170612031153_create_dining_queues.rb similarity index 59% rename from db/migrate/20170608105644_create_crm_dining_queues.rb rename to db/migrate/20170612031153_create_dining_queues.rb index 3929719e..3cf26418 100644 --- a/db/migrate/20170608105644_create_crm_dining_queues.rb +++ b/db/migrate/20170612031153_create_dining_queues.rb @@ -1,6 +1,6 @@ -class CreateCrmDiningQueues < ActiveRecord::Migration[5.1] +class CreateDiningQueues < ActiveRecord::Migration[5.1] def change - create_table :crm_dining_queues do |t| + create_table :dining_queues do |t| t.string :name t.string :contact_no t.string :queue_no diff --git a/spec/models/dining_queue_spec.rb b/spec/models/dining_queue_spec.rb new file mode 100644 index 00000000..185068c3 --- /dev/null +++ b/spec/models/dining_queue_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe DiningQueue, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 59520bf7ecf419f491d1d6a5c168c6cf14b14554 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 14:35:59 +0630 Subject: [PATCH 13/23] table status update --- app/models/sale_payment.rb | 13 ++++++++++--- app/views/origami/payments/show.html.erb | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5dff91b9..5804f602 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -215,14 +215,21 @@ class SalePayment < ApplicationRecord self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! - table_update_status() + table_update_status(sObj) rebat() end end - def table_update_status - + def table_update_status(sale_obj) + booking = Booking.find_by_sale_id(sale_obj.id) + if booking + table = DiningFacility.find(booking.dining_facility_id) + if table + table.status = "available" + table.save + end + end end def rebat diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 7eb890f4..4cff678d 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -233,7 +233,7 @@ $( document ).ready(function() { data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ alert("Thank you") - // window.location.href = '/origami'; + window.location.href = '/origami'; } }); } From 622aa4f121cdc73a4510e600d75e4b583acf4724 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 15:39:38 +0630 Subject: [PATCH 14/23] update origami js and index --- app/assets/javascripts/origami.js | 1 - app/views/origami/home/index.html.erb | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 6fcc9759..45c6d909 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -181,7 +181,6 @@ $(document).ready(function(){ }else{ var sale_id = $(".selected-item").find(".order-cid").text(); } - alert(sale_id); window.location.href = '/origami/'+ sale_id + "/add_customer" return false; diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 6892c04c..4bcc5863 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -28,10 +28,12 @@ # ToDo no need check new # Assigned Id for new Order? Sale? unique_id="" + customer_id="" # For CSS- Class for Order? Sale? sale_status="" if cpo.order_status == 'new' unique_id=cpo.booking_id + customer_id=cpo.order_customer_id # check selected item and assign if @selected_item != nil if cpo.order_id == @selected_item.order_id @@ -40,6 +42,7 @@ end else unique_id=cpo.sale_id + customer_id=cpo.sale_customer_id sale_status="paid" # check selected item and assign if @selected_item != nil @@ -52,7 +55,8 @@

- + +

<%= cpo.table_name %>

Receipt No : From 4af0c4fc13c1a13842e0a0d2833448d8087a4d9e Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 16:20:16 +0630 Subject: [PATCH 15/23] add seed --- db/seeds.rb | 14 +++++++------- dump.rdb | Bin 20467 -> 20762 bytes 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index ae2d617d..52a33c08 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -145,17 +145,17 @@ order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSu request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http//192.168.1.47:3006"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http//192.168.1.47:3006"},merchant_account_id:"vWSsseoZCzxd6xcNf_uS") member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1}}, - {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1}}, - {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer"}, - {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer"}, - {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group"}, - {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1}}, + {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data"} ]) -payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"},merchant_account_id:"vWSsseoZCzxd6xcNf_uS") # shop = Shop.create( # {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", diff --git a/dump.rdb b/dump.rdb index 9a81a61e209e6152e39a6f20ab56fb2fd13d5afc..62a327a0758d8fec91f4931d799425e149591f2c 100644 GIT binary patch delta 741 zcmW;FOG{Ky007`Sb90=$8l{V@teJ5f8>KUx_rpb`5<#y;5xpk#oO{l35eAjDlWEy9 z8CSLFK~h;W1yLllur_V{2QBh4XhF+@z=dRef8hJ|Fm?Y)>K@z`oH~4QBYW$nvtZgy ze||JPH~OG^eEGymZY2tWzK$Sh4}#HW^||4m`pfWi{mqeq62gK}h!xNdAwZFpz&PW9 zmrxoiNf;|m>X(j|>K{{4J++tAwDOE|t36YQGNBx2oM9~T^L_CRr)Qj<&@=rbh$?{@ z793V6CsNY<)!^FXyVWR{Q54N?E~W~N;Cb@2k#k1H-eCwRa}rRC7%-M`V2S3&NgfKx zRiStCPr@1jt|g$cn^R#pb%=TGVh9Ci#uF%Iem;pBY0N5xl@M`+k{!)E`8Led?B?s_ zMKeb|V_sMdta2VuMF}vFQy>);%0L_%E^T2?GSUoC0-9Ndy?_iMRkRVNLTZR=Rv4oH zMa}Izf zpcHZ-j)}L{X>0u0mt>?7kQS(JiyhObI8prG>7j8#3(lz}sDG^0UhPDJ3kEAh62?`l z#lVG(;=oB{%Tqh00SX@S8W_xDW*Co4KMTEE&3a`iYbiyBSSHKA zQ{I%11*o(yUEfIW@AgWdk$#DI>Yo YELO)Cljv<6-aVN;cktVpw*1%dFACn=!Tq1?3P6 z8DimsW#yyImGWcOEtl8i#8_>7vIw60Bv2%fQF!d{_lkSb?Z$A+?Ot33X^|^X8i!2w z+XVV|$la|EN8NlL0mdh9vU*zOAz}a_B^AyAmE0B7T8OkLL<%9gM)1iEdRxD1RS{9s zs$EQ?a*&X*!P_qL5glqRgMj{ieX2SGs8O+@FhXftpRSIwyoHR9Pu|t9tK0=dFRZ4~ zK%f$gr Date: Mon, 12 Jun 2017 16:24:56 +0630 Subject: [PATCH 16/23] Add Seed --- db/seeds.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 52a33c08..4e31b429 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -145,17 +145,17 @@ order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSu request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http//192.168.1.47:3006"},merchant_account_id:"vWSsseoZCzxd6xcNf_uS") +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http//192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) -member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1}}, +member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data"} + {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"} ]) -payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"},merchant_account_id:"vWSsseoZCzxd6xcNf_uS") +payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) # shop = Shop.create( # {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", From 870dc22249e32608037fa94afac8e526ccf81ec7 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 16:26:50 +0630 Subject: [PATCH 17/23] add merchant uid --- app/models/sale_payment.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5804f602..8606b44a 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -82,9 +82,10 @@ class SalePayment < ApplicationRecord membership_actions_data = MembershipAction.find_by_membership_type("redeem"); if !membership_actions_data.nil? url = paypar_url.to_s + membership_actions_data.gateway_url.to_s - campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] + merchant_uid = membership_actions_data.merchant_account_id + campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:""}.to_json, + :body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' From 6d34f925060119f84141d30403e8ecbaddc751ca Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 16:33:18 +0630 Subject: [PATCH 18/23] update crm api --- app/controllers/crm/customers_controller.rb | 8 ++++---- app/controllers/origami/customers_controller.rb | 9 +++++++-- app/controllers/origami/home_controller.rb | 4 ++-- config/initializers/kaminari_config.rb | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index c9c24240..b3656673 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -68,12 +68,12 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") - app_token = membership.auth_token.to_s + merchant_uid = memberaction.merchant_account_id.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, date_of_birth: date_of_birth, - member_group_id: member_group_id}.to_json, + member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -129,12 +129,12 @@ end membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("update_membership_customer") - app_token = membership.auth_token.to_s + merchant_uid = memberaction.merchant_account_id.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, date_of_birth: date_of_birth, - id: id,member_group_id:member_group_id}.to_json, + id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 74148296..a1a067fe 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -18,15 +18,20 @@ class Origami::CustomersController < BaseOrigamiController filter = params[:filter] if filter.nil? - @crm_customers = Customer.order("name").page(params[:page]) + @crm_customers = Customer.order("name").page params[:page] else - @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) + @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page params[:page] end + # @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2) @crm_customer = Customer.new # @membership = Customer.get_member_group # if @membership["status"] == true # @member_group = @membership["data"] # end + puts "Errrrrrrrrrrrrrrrrr" + puts @crm_customer.new_record? + + respond_to do |format| # format.html { render :template => "crm/customers/index" } format.html { render action: "index"} diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 3db086b9..5742c366 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -72,10 +72,10 @@ class Origami::HomeController < BaseOrigamiController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("get_all_member_account") - app_token = membership.auth_token.to_s + merchant_uid = memberaction.merchant_account_id.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.get(url, :body => { membership_id: @customer.membership_id}.to_json, + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index b1d87b01..bcf4e43b 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -1,5 +1,5 @@ Kaminari.configure do |config| - # config.default_per_page = 25 + config.default_per_page = 2 # config.max_per_page = nil # config.window = 4 # config.outer_window = 0 From e6647dd494e155712ed8dead9a410464209ca80d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 16:48:20 +0630 Subject: [PATCH 19/23] Seed Edit --- app/controllers/crm/customers_controller.rb | 2 +- db/seeds.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index b3656673..01acd441 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -68,7 +68,7 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") - merchant_uid = memberaction.merchant_account_id.to_s + merchant_uid = memberaction.merchant_account_id.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, diff --git a/db/seeds.rb b/db/seeds.rb index 4e31b429..6849f008 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -145,7 +145,7 @@ order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSu request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http//192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, @@ -155,7 +155,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"} ]) -payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) # shop = Shop.create( # {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", From d1ae734f50a131643975d4477558f6c6f22e18e1 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 17:30:49 +0630 Subject: [PATCH 20/23] update --- app/assets/javascripts/origami.js | 20 +-- app/models/order.rb | 4 +- app/models/sale_item.rb | 16 +-- app/views/origami/home/index.html.erb | 123 +++++++++--------- app/views/origami/payments/show.html.erb | 4 +- .../origami/redeem_payments/index.html.erb | 36 ++--- db/seeds.rb | 8 +- 7 files changed, 107 insertions(+), 104 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 6fcc9759..c15b6991 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -28,7 +28,7 @@ $(document).ready(function(){ $("#order-Tax").text(''); $("#order-grand-total").text(''); - var zone_name=$(this).find(".orders-table").text(); + var zone_name=$(this).find(".orders-table").text(); var receipt_no=$(this).find(".orders-receipt-no").text(); var unique_id = $(this).find(".orders-id").text(); var order_status=$(this).find(".orders-order-status").text().trim(); @@ -38,11 +38,11 @@ $(document).ready(function(){ //for customer button $("#customer").removeAttr('disabled'); - + var customer_id=$(this).find(".customer-id").text(); show_customer_details(customer_id); - + var cashier=""; var receipt_date=""; @@ -60,7 +60,7 @@ $(document).ready(function(){ type: "POST", url: "/origami/" + unique_id, data: { 'booking_id' : unique_id }, - success:function(result){ + success:function(result){ for (i = 0; i < result.length; i++) { var data = JSON.stringify(result[i]); var parse_data = JSON.parse(data); @@ -77,7 +77,7 @@ $(document).ready(function(){ //Receipt Charges sub_total += (parse_data.qty*parse_data.price); - + discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount; tax_amount = parse_data.tax_amount; grand_total_amount = parse_data.grand_total_amount; @@ -187,12 +187,12 @@ $(document).ready(function(){ return false; }); - function show_customer_details(customer_id){ + function show_customer_details(customer_id){ - $('.customer_detail').removeClass('hide'); + $('.customer_detail').removeClass('hide'); //Start Ajax - $.ajax({ - type: "GET", + $.ajax({ + type: "GET", url: "origami/"+customer_id+"/get_customer/", data: {}, dataType: "json", @@ -213,7 +213,7 @@ $(document).ready(function(){ }); } }); - //End Ajax + //End Ajax } /* For Receipt - Calculate discount or tax */ diff --git a/app/models/order.rb b/app/models/order.rb index ff16cb94..04274399 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -231,7 +231,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") end @@ -261,7 +261,7 @@ class Order < ApplicationRecord .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 25b37178..404787f7 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -1,6 +1,6 @@ class SaleItem < ApplicationRecord self.primary_key = "sale_item_id" - + #primary key - need to be unique generated for multiple shops before_create :generate_custom_id @@ -12,17 +12,17 @@ class SaleItem < ApplicationRecord def self.get_order_items_details(sale_id) - order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date, + order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,sales.receipt_date as receipt_date, sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") .joins("left join sales on sales.sale_id = sale_items.sale_id") .where("sale_items.sale_id=?",sale_id) # sale_orders = SaleOrder.where("sale_id=?",sale_id) # if sale_orders - # sale_orders.each do |sale_order| + # sale_orders.each do |sale_order| # order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") # .joins("left join sales on sales.id = sale_items.sale_id") - # .where("sale_items.sale_id=?",sale_order.sale_id) + # .where("sale_items.sale_id=?",sale_order.sale_id) # return order_details # end # else @@ -36,7 +36,7 @@ class SaleItem < ApplicationRecord sale_items.each do |si| food_price = self.get_food_price(si.sale_item_id) - beverage_price = self.get_beverage_price(si.sale_item_id) + beverage_price = self.get_beverage_price(si.sale_item_id) food_prices = food_prices + food_price beverage_prices = beverage_prices + beverage_price end @@ -47,16 +47,16 @@ class SaleItem < ApplicationRecord food=SaleItem.select("sale_items.price") .joins("left join menu_items on menu_items.item_code = sale_items.product_code") .where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id.to_s) - food_price = food[0].price rescue 0 + food_price = food[0].price rescue 0 end def self.get_beverage_price(sale_item_id) beverage=SaleItem.select("sale_items.price") .joins("left join menu_items on menu_items.item_code = sale_items.product_code") .where("sale_items.sale_item_id=? and menu_items.account_id=2", sale_item_id.to_s) - beverage_price = beverage[0].price rescue 0 + beverage_price = beverage[0].price rescue 0 end - + private def generate_custom_id self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 6892c04c..83678543 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -23,37 +23,38 @@

- <% - @completed_orders.each do |cpo| + <% + @completed_orders.each do |cpo| # ToDo no need check new # Assigned Id for new Order? Sale? - unique_id="" + unique_id = "" + customer_id = "" # For CSS- Class for Order? Sale? sale_status="" - if cpo.order_status == 'new' + if cpo.order_status == 'new' unique_id=cpo.booking_id - # check selected item and assign - if @selected_item != nil + # check selected item and assign + if @selected_item != nil if cpo.order_id == @selected_item.order_id sale_status = sale_status + " selected-item" end end - else + else unique_id=cpo.sale_id sale_status="paid" - # check selected item and assign + # check selected item and assign if @selected_item != nil if unique_id == @selected_item.sale_id sale_status = sale_status + " selected-item" end end - end + end %>
- - -

<%= cpo.table_name %>

+ + +

<%= cpo.table_name %>

Receipt No : @@ -64,12 +65,12 @@ Order Status : <%= cpo.order_status %> - + -

-
-
- <% +

+
+
+ <% end %>
@@ -78,39 +79,39 @@
- <% - @booking_orders.each do |bko| + <% + @booking_orders.each do |bko| # Assigned Id for new Order? Sale? unique_id="" customer_id="" # For CSS- Class for Order? Sale? sale_status="" - if bko.order_status == 'new' + if bko.order_status == 'new' unique_id=bko.booking_id customer_id=bko.order_customer_id - # check selected item and assign - if @selected_item != nil + # check selected item and assign + if @selected_item != nil if bko.order_id == @selected_item.order_id sale_status = sale_status + " selected-item" end end - else + else unique_id=bko.sale_id customer_id=bko.sale_customer_id sale_status="sold" - # check selected item and assign + # check selected item and assign if @selected_item != nil if unique_id == @selected_item.sale_id sale_status = sale_status + " selected-item" end end - end + end %>
- - - + + +

<%= bko.table_name %>

Receipt No : @@ -144,32 +145,32 @@ # For CSS- Class for Order? Sale? sale_status="" - if rmo.order_status == 'new' + if rmo.order_status == 'new' unique_id=rmo.booking_id customer_id=rmo.order_customer_id - # check selected item and assign - if @selected_item != nil + # check selected item and assign + if @selected_item != nil if rmo.order_id == @selected_item.order_id sale_status = sale_status + " selected-item" - end - end - else + end + end + else unique_id=rmo.sale_id customer_id=rmo.sale_customer_id sale_status="sold" - # check selected item and assign + # check selected item and assign if @selected_item != nil if unique_id == @selected_item.sale_id sale_status = sale_status + " selected-item" end end - end + end %>

- + - +

<%= rmo.room_name %>

Receipt No : @@ -194,19 +195,19 @@

-
- <% - @orders.each do |odr| +
+ <% + @orders.each do |odr| # Assigned Id for new Order? Sale? unique_id="" customer_id="" # For CSS- Class for Order? Sale? - sale_status="" + sale_status="" - if odr.order_status == 'new' + if odr.order_status == 'new' unique_id=odr.booking_id customer_id = odr.order_customer_id - if @selected_item != nil + if @selected_item != nil if odr.order_id == @selected_item.order_id sale_status = sale_status + " selected-item" end @@ -214,9 +215,9 @@ else unique_id=odr.sale_id customer_id = odr.sale_customer_id - sale_status="sold" - # check selected item and assign - if @selected_item != nil + sale_status="sold" + # check selected item and assign + if @selected_item != nil if unique_id == @selected_item.sale_id sale_status = sale_status + " selected-item" end @@ -225,9 +226,9 @@ %>
- - - + + +

<%= odr.table_name %>

Receipt No : @@ -266,19 +267,19 @@

Receipt No: <%=@selected_item.receipt_no rescue ' '%>

-
+

Date: <%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

-
+

Customer :

- -
+ +

Amount :

-
+
@@ -290,7 +291,7 @@ - <% + <% # For Sale Items sub_total = 0 if @selected_item_type == "Sale" @@ -298,16 +299,16 @@ sub_total += sale_item.qty*sale_item.unit_price %> - + - <% + <% end end %> - <% + <% # For Order Items sub_total = 0 if @selected_item_type == "Order" @@ -315,11 +316,11 @@ sub_total += order_item.qty*order_item.unit_price %> - + - <% + <% end end %> diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 4cff678d..072446a1 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -6,8 +6,8 @@
<%= sale_item.product_name %><%= sale_item.product_name %> <%= sale_item.qty %> <%= sale_item.qty*sale_item.price %>
<%= order_item.item_name %><%= order_item.item_name %> <%= order_item.qty %> <%= order_item.qty*order_item.price %>
- - + + diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 72c09d4d..0340134c 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -1,7 +1,7 @@
-
+
@@ -22,15 +22,15 @@
- -
+ +
-
+
1
-
2
-
3
+
2
+
3
@@ -39,10 +39,10 @@
-
+
4
-
5
-
6
+
5
+
6
@@ -51,10 +51,10 @@
-
+
7
-
8
-
9
+
8
+
9
@@ -63,10 +63,10 @@
-
+
0
-
.
-
00
+
.
+
00
@@ -75,10 +75,10 @@
-
+
-
DEL
-
CLR
+
DEL
+
CLR
diff --git a/db/seeds.rb b/db/seeds.rb index ae2d617d..563710c5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -156,10 +156,12 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"}) + # shop = Shop.create( -# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", -# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license", +# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", +# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license", # activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"} # ) - From 7a3957181c13c46a5119591eb47ad514c96f792d Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 18:15:19 +0630 Subject: [PATCH 21/23] update --- app/models/order.rb | 6 +++--- app/models/sale_payment.rb | 2 +- app/views/origami/payments/show.html.erb | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 04274399..8c0fadbc 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -237,14 +237,14 @@ class Order < ApplicationRecord #Origami: Cashier : to view booking order Table def self.get_completed_order - completed_orders = Booking.select("sales.receipt_no,orders.status as order_status, - bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + completed_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.order_id, + bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id") end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 8606b44a..386d6ca6 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -60,7 +60,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by) - + return false, "No outstanding Amount" end diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 072446a1..f9ae06b7 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -232,7 +232,12 @@ $( document ).ready(function() { url: "<%= origami_payment_cash_path %>", data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ - alert("Thank you") + if($('#balance').text() < 0){ + alert("Changed amount " + $('#balance').text() * (-1) ) + }else{ + alert("Thank you") + } + window.location.href = '/origami'; } }); From b47c983886fce6b353408feb05d7f79adf53a3bd Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 18:18:24 +0630 Subject: [PATCH 22/23] Edit Redim --- Gemfile | 2 +- Gemfile.lock | 2 -- .../origami/redeem_payments_controller.rb | 3 ++- app/models/sale_payment.rb | 6 +++--- .../origami/redeem_payments/index.html.erb | 7 ++++--- config/routes.rb | 2 +- dump.rdb | Bin 20762 -> 20860 bytes 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 02dca6af..b08df141 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' +# gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 4235d035..6a7c6340 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -110,7 +110,6 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) - pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -247,7 +246,6 @@ DEPENDENCIES kaminari (~> 0.16.3) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index 0821a2d8..5fd386e8 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -16,7 +16,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController if member_actions.gateway_url @campaign_type_id = member_actions.additional_parameter["campaign_type_id"] url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s - membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id) + merchant_uid= member_actions.merchant_account_id + membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid) if membership_data["status"]==true @membership_rebate_balance=membership_data["balance"] @out = true, @membership_rebate_balance,@membership_id diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 8606b44a..a86a16e4 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -66,9 +66,9 @@ class SalePayment < ApplicationRecord end - def self.get_paypar_account(url,token,membership_id,campaign_type_id) + def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid) response = HTTParty.get(url, - :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id}.to_json, + :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -85,7 +85,7 @@ class SalePayment < ApplicationRecord merchant_uid = membership_actions_data.merchant_account_id campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json, + :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 72c09d4d..81437de4 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -140,13 +140,14 @@ $("#redeem").click(function(){ membership_id = $("#valid_amount").attr('data-member-value'); redeem_amount = parseInt($("#used_amount").text()); if(redeem_amount<=0 ){ - alert(" Insufficient Amount!") - }else if(valid_amount< redeem_amount || redeem_amount == ""){ alert("Please type valid amount"); + + }else if(valid_amount< redeem_amount){ + alert(" Insufficient Amount!") }else{ $.ajax({ type: "POST", - url: "<%=origami_paypar_payment_process_path%>", + url: "<%=origami_payment_paypar_path%>", data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id}, success: function(result){ if(result.status == true){ diff --git a/config/routes.rb b/config/routes.rb index 816b53f7..76e1498c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -87,7 +87,7 @@ Rails.application.routes.draw do #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' post 'payment/cash' => 'payments#create' - post 'paypar_payment_process' => 'paypar_payments#create' + post 'payment/paypar' => 'paypar_payments#create' get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/payment/others_payment' => "others_payments#index" diff --git a/dump.rdb b/dump.rdb index 62a327a0758d8fec91f4931d799425e149591f2c..4d2c7d9e5136fdfd8a4a5fb5cafdaedbad0830f9 100644 GIT binary patch delta 453 zcmV~$OKTHB007|GOd2*WEm)~gRFbAisnrQHv-7M(2-Y49v7o0~eC%X)JxE2{3Z)RN z|3Dc}dXZwZ3cD9kh~P!=;?ZA_rPRAeixj`_)t>in&wGwfUfjIAdgMRZj4fJ^*T3UO zFWRpsmulUe%FZ|dKLY@K0NU@}pQ%&sSMj=A@#>AxN)yH`M1tcOF_REvxJ?koB2r2a zD0?Ay&z2iySX)`TQC%JZcV~fici&7gL2XYOVkAx?F0t(qX_I#GY;PluwqkoX+Nv!Q zrX>|jGu&iE5gJw>fQR=!kAg}`VbMSS=;iyV+wkW6yp;l$qtqRFXX?41LQbWaNsA&> ziseB%0+lh%NdGu%r(pl!?V9Tp=Euz7fUmjjLhI=`OE^!YjgZxGg6h{MLu9aENNFau z!PE$4XQuPT?67&l=QNR+6QXBri884oOs;+dQT1gWWM!h8QfjU>%_p+mswa6Ph_c^< zA&|8%P$-6HZvr+q^b&pL_5=+PC9#w6QsGD7wqX+=?a*F`epC zQWVh&6?KlzK0wgHmgpIRi0J!%d!f@_sB27sMrHjcda&;b*mm2m=QGFEv&q`a!XP=& z0Z5DiFakjJTBbEF7ehH&SMu_HE-#Pbl_kzROo-qfW+uXvxdanzSu}N$*xGY>#}%8r zlPQ~sQ43p?7)3-%wvAFdV7K-3p(i5@nTLP3p|lTff=gdMChR_GR@HaAQ`osw*+Q!#~N za?$^~(gDpptHee|c11%jM6#>aBY7S4Yfbs47S&JKl%ruB5AJ-03z}PtFallM6ou_^ W+kwpR_~S-6)`+f750|ynyZR4Kz++ng From 423776cadd49d6f9a4a7e2ef7e39ebbe1d4be130 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 12 Jun 2017 18:19:30 +0630 Subject: [PATCH 23/23] print format update --- app/assets/javascripts/cable.js | 9 +- app/controllers/origami/home_controller.rb | 1 + .../origami/request_bills_controller.rb | 2 +- app/models/order.rb | 8 +- app/models/sale_item.rb | 25 +-- app/pdf/receipt_bill_pdf.rb | 142 +++++++++--------- config/routes.rb | 2 +- 7 files changed, 99 insertions(+), 90 deletions(-) diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 739aa5f0..ce5ac871 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -5,9 +5,10 @@ //= require_self //= require_tree ./channels -(function() { - this.App || (this.App = {}); +// Temp Disable +// (function() { +// this.App || (this.App = {}); - App.cable = ActionCable.createConsumer(); +// App.cable = ActionCable.createConsumer(); -}).call(this); +// }).call(this); diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 669c8a7f..ae2492d9 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -12,6 +12,7 @@ class Origami::HomeController < BaseOrigamiController @selected_item_type="Order" end end + puts params[:booking_id] @completed_orders = Order.get_completed_order() @booking_orders = Order.get_booking_order_table() diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 4e884aaf..58ba0b11 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -30,7 +30,7 @@ class Origami::RequestBillsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) - redirect_to origami_path(sale_order.sale_id) + redirect_to origami_path(@sale_data.sale_id) end end diff --git a/app/models/order.rb b/app/models/order.rb index 4526ce35..ebb3b032 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -247,8 +247,6 @@ class Order < ApplicationRecord .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") - - end #Origami: Cashier : to view booking order Table @@ -259,7 +257,7 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) + .where("sales.sale_status<>'completed' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") end @@ -273,7 +271,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") - .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) + .where("sales.sale_status<>'completed' and sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") end @@ -303,7 +301,7 @@ class Order < ApplicationRecord left join order_items on order_items.order_id = orders.order_id left join sale_orders on sale_orders.order_id = orders.order_id left join sales on sales.sale_id = sale_orders.sale_id") - .where("sales.sale_status<>'complete' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) + .where("sales.sale_status<>'completed' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id") end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 25b37178..e98d3f7e 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -35,26 +35,27 @@ class SaleItem < ApplicationRecord beverage_prices=0 sale_items.each do |si| - food_price = self.get_food_price(si.sale_item_id) - beverage_price = self.get_beverage_price(si.sale_item_id) + food_price, beverage_price = self.get_price(si.sale_item_id) food_prices = food_prices + food_price beverage_prices = beverage_prices + beverage_price end return food_prices, beverage_prices end - def self.get_food_price(sale_item_id) - food=SaleItem.select("sale_items.price") - .joins("left join menu_items on menu_items.item_code = sale_items.product_code") - .where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id.to_s) - food_price = food[0].price rescue 0 - end + def self.get_price(sale_item_id) + food_price=0 + beverage_price=0 - def self.get_beverage_price(sale_item_id) - beverage=SaleItem.select("sale_items.price") + item=SaleItem.select("sale_items.price , menu_items.account_id") .joins("left join menu_items on menu_items.item_code = sale_items.product_code") - .where("sale_items.sale_item_id=? and menu_items.account_id=2", sale_item_id.to_s) - beverage_price = beverage[0].price rescue 0 + .where("sale_items.sale_item_id=?", sale_item_id.to_s) + if item[0].account_id == 1 + food_price = item[0].price + else + beverage_price = item[0].price + end + + return food_price, beverage_price end private diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index f91aebe1..dbaea572 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,16 +1,16 @@ class ReceiptBillPdf < Prawn::Document - attr_accessor :receipt_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 + 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 def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total) - self.page_width = 300 + self.page_width = 250 self.page_height = 1450 self.margin = 10 - self.price_width = 50 - self.qty_width = 30 - self.total_width = 50 - self.item_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.price_width = 40 + self.qty_width = 20 + self.total_width = 40 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4)) self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.receipt_width=100 + self.label_width=80 # @item_width = self.page_width.to_i / 2 # @qty_width = @item_width.to_i / 3 @@ -22,8 +22,8 @@ class ReceiptBillPdf < Prawn::Document # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 12 - self.item_font_size = 10 + self.header_font_size = 11 + self.item_font_size = 9 header( printer_settings.printer_name, printer_settings.name) @@ -31,66 +31,64 @@ class ReceiptBillPdf < Prawn::Document cashier_info(sale_data, customer_name) line_items(sale_items, food_total, beverage_total) - all_total(sale_data) - - + all_total(sale_data) + footer end def header (printer_name, name) - text "#{printer_name}", :size => self.header_font_size,:align => :center - move_down 5 - text "#{name}", :size => self.header_font_size,:align => :center - # move_down self.item_height - move_down 5 + text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center + move_down 5 + text "#{name}", :size => self.header_font_size,:align => :center + # move_down self.item_height + move_down 5 - stroke_horizontal_rule + stroke_horizontal_rule end def cashier_info(sale_data, customer_name) move_down 7 # move_down 2 y_position = cursor - bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "Receipt No:", :size => self.item_font_size,:align => :left end - bounding_box([self.receipt_width, y_position], :width =>self.receipt_width) do + bounding_box([self.label_width, y_position], :width =>self.item_width) do text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left end move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "Customer:", :size => self.item_font_size,:align => :left end - bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do + bounding_box([self.label_width,y_position], :width =>self.item_width) do text "#{customer_name}" , :size => self.item_font_size,:align => :left end move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do - text "Date:", :size => self.item_font_size,:align => :left + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "Date:", :size => self.item_font_size,:align => :left end - bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do - text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left + bounding_box([self.label_width,y_position], :width => self.item_width) do + text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left end - # stroke_horizontal_rule + + move_down 5 + stroke_horizontal_rule move_down 5 end def line_items(sale_items, food_total, beverage_total) y_position = cursor - stroke_horizontal_rule - move_down 5 - pad_top(15) { # @item_width.to_i + @half_qty.to_i - text_box "Items", :at =>[0,y_position], :width => self.item_width - 20, :height =>self.item_height, :size => self.item_font_size - text_box "Price", :at =>[self.item_width-20,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right - text_box "Qty", :at =>[self.item_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right - text_box "Total", :at =>[self.item_width+self.price_width+self.qty_width,y_position], :width => self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right + text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Total", :at =>[(self.item_width+self.price_width+2),y_position], :width => self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } @@ -99,88 +97,88 @@ class ReceiptBillPdf < Prawn::Document add_line_item_row(sale_items, food_total, beverage_total) - end def add_line_item_row(sale_items, food_total, beverage_total) - item_name_width = self.item_width-20 + item_name_width = (self.item_width+self.price_width) y_position = cursor move_down 5 sub_total = 0.0 - sale_items.each do |item| + sale_items.each do |item| + sub_total += (item.qty*item.unit_price) + qty = item.qty + total_price = item.qty*item.unit_price + price = item.unit_price + product_name = item.product_name + - sub_total += item.qty*item.unit_price - qty = item.qty - total_price = item.qty*item.unit_price - price = item.unit_price - product_name = item.product_name - + y_position = cursor - y_position = cursor + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - pad_top(15) { - # @item_width.to_i + @half_qty.to_i - text_box "#{product_name}", :at =>[0,y_position], :width => item_name_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size - text_box "#{price}", :at =>[item_name_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right - text_box "#{qty.to_i}", :at =>[item_name_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right - text_box "#{total_price}", :at =>[item_name_width+self.price_width+self.qty_width,y_position], :width =>self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right - - } - move_down 3 - end + } + move_down 3 + end stroke_horizontal_rule move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do - text "#{sub_total}" , :size => self.item_font_size,:align => :right + bounding_box([item_name_width,y_position], :width =>self.total_width) do + text "#{ sub_total }" , :size => self.item_font_size,:align => :right end # Food and Beverage - food_beverage_total = food_total.to_s + '/' + beverage_total.to_s + food_beverage_total = food_total.to_s + "/" + beverage_total.to_s + move_down 5 + y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do text "Food/Beverage Total", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do + bounding_box([item_name_width,y_position], :width =>self.total_width) do text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right end end def all_total(sale_data) - item_name_width = self.item_width-20 + item_name_width = self.item_width move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do text "Discount", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do + bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right end move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do text "Total Tax", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do + bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right end move_down 5 y_position = cursor move_down 5 - bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do text "Grand Total", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do + bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right end move_down 5 @@ -188,4 +186,14 @@ class ReceiptBillPdf < Prawn::Document end + def footer + move_down 5 + stroke_horizontal_rule + move_down 5 + + text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center + + move_down 5 + end + end diff --git a/config/routes.rb b/config/routes.rb index ddb6e3ff..689fe60d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,7 +9,7 @@ Rails.application.routes.draw do mount Sidekiq::Web => '/kiq' # Action Cable Creation - mount ActionCable.server => "/cable" + # mount ActionCable.server => "/cable" #--------- SmartSales Installation ------------# get 'install' => 'install#index'
Receipt No : <%=@sale_data.receipt_no rescue ' '%>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>Receipt No : <%=@sale_data.receipt_no rescue ' '%>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Table No <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %>