From 8c47371fa7a1af392a470a4f971f51f8518d4ef8 Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Tue, 6 Jun 2017 12:04:56 +0630 Subject: [PATCH 01/71] seed generator --- Gemfile.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5dce67dc..e2c1dd73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,7 +119,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) @@ -253,7 +252,6 @@ DEPENDENCIES kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) From 35277ac0005199730c9f0b7c2c3ab4fe2ffd1546 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 9 Jun 2017 09:29:25 +0630 Subject: [PATCH 02/71] queue and crm view updated --- Gemfile | 3 +- Gemfile.lock | 4 +- .../javascripts/crm/dining_queues.coffee | 3 + app/assets/stylesheets/CRM.scss | 2 + app/controllers/api/customers_controller.rb | 5 + app/controllers/crm/customers_controller.rb | 19 +- .../crm/dining_queues_controller.rb | 74 ++++++ app/controllers/crm/home_controller.rb | 6 +- app/helpers/crm/dining_queues_helper.rb | 2 + app/models/crm.rb | 5 + app/models/customer.rb | 11 +- app/models/dining_queue.rb | 3 + .../get_customer_order.json.jbuilder | 38 +++ app/views/crm/customers/_form.html.erb | 10 +- app/views/crm/customers/index.html.erb | 26 +- .../_crm_dining_queue.json.jbuilder | 2 + app/views/crm/dining_queues/_form.html.erb | 16 ++ app/views/crm/dining_queues/edit.html.erb | 11 + app/views/crm/dining_queues/index.html.erb | 38 +++ .../crm/dining_queues/index.json.jbuilder | 1 + app/views/crm/dining_queues/new.html.erb | 11 + app/views/crm/dining_queues/show.html.erb | 19 ++ .../crm/dining_queues/show.json.jbuilder | 1 + app/views/crm/home/_booking.html.erb | 228 ++++++++++++------ app/views/crm/home/_customer.html.erb | 2 +- app/views/crm/home/_queue.html.erb | 30 +-- app/views/crm/home/index.html.erb | 40 ++- config/initializers/kaminari_config.rb | 10 + config/locales/en.yml | 38 ++- config/routes.rb | 5 +- ...20170608105644_create_crm_dining_queues.rb | 12 + .../crm/bookings_controller_spec.rb | 5 - .../crm/customers_controller_spec.rb | 159 ------------ spec/helpers/crm/dining_queues_helper_spec.rb | 15 ++ spec/requests/crm/crm_dining_queues_spec.rb | 10 + .../routing/crm/dining_queues_routing_spec.rb | 39 +++ .../crm/dining_queues/edit.html.erb_spec.rb | 24 ++ .../crm/dining_queues/index.html.erb_spec.rb | 25 ++ .../crm/dining_queues/new.html.erb_spec.rb | 24 ++ .../crm/dining_queues/show.html.erb_spec.rb | 18 ++ test/system/dining_queues_test.rb | 9 + 41 files changed, 685 insertions(+), 318 deletions(-) create mode 100644 app/assets/javascripts/crm/dining_queues.coffee create mode 100644 app/controllers/crm/dining_queues_controller.rb create mode 100644 app/helpers/crm/dining_queues_helper.rb create mode 100644 app/models/crm.rb create mode 100644 app/models/dining_queue.rb create mode 100644 app/views/api/customers/get_customer_order.json.jbuilder create mode 100644 app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder create mode 100644 app/views/crm/dining_queues/_form.html.erb create mode 100644 app/views/crm/dining_queues/edit.html.erb create mode 100644 app/views/crm/dining_queues/index.html.erb create mode 100644 app/views/crm/dining_queues/index.json.jbuilder create mode 100644 app/views/crm/dining_queues/new.html.erb create mode 100644 app/views/crm/dining_queues/show.html.erb create mode 100644 app/views/crm/dining_queues/show.json.jbuilder create mode 100644 config/initializers/kaminari_config.rb create mode 100644 db/migrate/20170608105644_create_crm_dining_queues.rb delete mode 100644 spec/controllers/crm/bookings_controller_spec.rb delete mode 100644 spec/controllers/crm/customers_controller_spec.rb create mode 100644 spec/helpers/crm/dining_queues_helper_spec.rb create mode 100644 spec/requests/crm/crm_dining_queues_spec.rb create mode 100644 spec/routing/crm/dining_queues_routing_spec.rb create mode 100644 spec/views/crm/dining_queues/edit.html.erb_spec.rb create mode 100644 spec/views/crm/dining_queues/index.html.erb_spec.rb create mode 100644 spec/views/crm/dining_queues/new.html.erb_spec.rb create mode 100644 spec/views/crm/dining_queues/show.html.erb_spec.rb create mode 100644 test/system/dining_queues_test.rb diff --git a/Gemfile b/Gemfile index 551503f9..1487492d 100644 --- a/Gemfile +++ b/Gemfile @@ -61,7 +61,8 @@ gem 'sidekiq' # Pagination gem 'kaminari', '~> 0.16.3' - +# Datatable +gem 'filterrific' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development diff --git a/Gemfile.lock b/Gemfile.lock index 93c2a58f..e7deca12 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,6 +72,7 @@ GEM faker (1.7.3) i18n (~> 0.5) ffi (1.9.18) + filterrific (2.1.2) font-awesome-rails (4.7.0.2) railties (>= 3.2, < 5.2) globalid (0.4.0) @@ -109,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) @@ -238,6 +238,7 @@ DEPENDENCIES database_cleaner factory_girl_rails (~> 4.0) faker + filterrific font-awesome-rails httparty (~> 0.15.5) jbuilder (~> 2.5) @@ -245,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/assets/javascripts/crm/dining_queues.coffee b/app/assets/javascripts/crm/dining_queues.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/crm/dining_queues.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/CRM.scss b/app/assets/stylesheets/CRM.scss index b0f802f1..f43cc3f9 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -7,3 +7,5 @@ // min-height: 75rem; // padding-top: 4.5rem; // } + + diff --git a/app/controllers/api/customers_controller.rb b/app/controllers/api/customers_controller.rb index 8ce2041c..2adc7c8a 100644 --- a/app/controllers/api/customers_controller.rb +++ b/app/controllers/api/customers_controller.rb @@ -9,4 +9,9 @@ class Api::CustomersController < ActionController::API def show @customer = Customer.find_by(params[:id]) end + + #Show customer detail by Order item + def get_customer_order + @customer = Customer.find(params[:id]) + end end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 295a0d8f..fff260e2 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -5,12 +5,21 @@ class Crm::CustomersController < ApplicationController # GET /crm/customers.json def index @sale_id = 0 - @crm_customers = Customer.all - @crm_customer = Customer.new - @membership = Customer.get_member_group - if @membership["status"] == true - @member_group = @membership["data"] + filter = params[:filter] + + if filter.nil? + @crm_custome = Customer.order("name").page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) + else + @crm_custome = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end + @crm_customers = Kaminari.paginate_array(@crm_custome).page(params[:page]).per(5) + #@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 # index.html.erb format.json { render json: @crm_customers } diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb new file mode 100644 index 00000000..235703d2 --- /dev/null +++ b/app/controllers/crm/dining_queues_controller.rb @@ -0,0 +1,74 @@ +class Crm::DiningQueuesController < ApplicationController + before_action :set_dining_queue, only: [:show, :edit, :update, :destroy] + + # GET /crm/dining_queues + # GET /crm/dining_queues.json + def index + @dining_queues = DiningQueue.all + end + + # GET /crm/dining_queues/1 + # GET /crm/dining_queues/1.json + def show + end + + # GET /crm/dining_queues/new + def new + @dining_queue = DiningQueue.new + end + + # GET /crm/dining_queues/1/edit + def edit + end + + # POST /crm/dining_queues + # POST /crm/dining_queues.json + def create + @dining_queue = DiningQueue.new(dining_queue_params) + + respond_to do |format| + if @dining_queue.save + format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' } + format.json { render :show, status: :created, location: @dining_queue } + else + format.html { render :new } + format.json { render json: @dining_queue.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /crm/dining_queues/1 + # PATCH/PUT /crm/dining_queues/1.json + def update + respond_to do |format| + if @dining_queue.update(dining_queue_params) + format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' } + format.json { render :show, status: :ok, location: @dining_queue } + else + format.html { render :edit } + format.json { render json: @dining_queue.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /crm/dining_queues/1 + # DELETE /crm/dining_queues/1.json + def destroy + @dining_queue.destroy + respond_to do |format| + format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_dining_queue + @dining_queue = DiningQueue.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def dining_queue_params + params.require(:dining_queue).permit(:name, :contact_no, :queue_no) + end +end diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index 9ae2b413..c8d919e5 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -1,8 +1,12 @@ class Crm::HomeController < BaseCrmController def index - @booking = Booking.all + @booking = Booking.all @customer = Customer.all + from = Time.now.beginning_of_day.utc + to = Time.now.end_of_day.utc + @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to) + # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) end diff --git a/app/helpers/crm/dining_queues_helper.rb b/app/helpers/crm/dining_queues_helper.rb new file mode 100644 index 00000000..af60bd52 --- /dev/null +++ b/app/helpers/crm/dining_queues_helper.rb @@ -0,0 +1,2 @@ +module Crm::DiningQueuesHelper +end diff --git a/app/models/crm.rb b/app/models/crm.rb new file mode 100644 index 00000000..3407e215 --- /dev/null +++ b/app/models/crm.rb @@ -0,0 +1,5 @@ +module Crm + def self.table_name_prefix + 'crm_' + end +end diff --git a/app/models/customer.rb b/app/models/customer.rb index 6d2bd561..b0667206 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -9,7 +9,8 @@ class Customer < ApplicationRecord validates_presence_of :name, :contact_no, :email validates :contact_no, uniqueness: true validates :email, uniqueness: true - + + paginates_per 50 def self.get_member_group @@ -30,6 +31,14 @@ class Customer < ApplicationRecord end + def self.search(search) + if search + find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) + else + find(:all) + end + end + def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb new file mode 100644 index 00000000..dfcc5b43 --- /dev/null +++ b/app/models/dining_queue.rb @@ -0,0 +1,3 @@ +class DiningQueue < ApplicationRecord + +end diff --git a/app/views/api/customers/get_customer_order.json.jbuilder b/app/views/api/customers/get_customer_order.json.jbuilder new file mode 100644 index 00000000..f00ce173 --- /dev/null +++ b/app/views/api/customers/get_customer_order.json.jbuilder @@ -0,0 +1,38 @@ +if (@customer) + json.id @customer.customer_id + json.name @customer.name + json.email @customer.email + json.contact_no @customer.contact_no + json.date_of_birth @customer.date_of_birth + + + @total_amount = 0.00 + @total_tax = 0.00 + + if @customer.orders + order_items = [] + @customer.orders.each do |bo| + order = Order.find(bo.order_id) + #if (order.status == "new") + order_items = order_items + order.order_items + #end + end + + json.order_items order_items do |item| + json.item_instance_code item.item_code + json.item_name item.item_name + json.price item.price + json.qty item.qty + json.options item.options + json.remark item.remark + json.item_status item.order_item_status + @total_amount = @total_amount + (item.price * item.qty) + end + + end + + json.sub_total @total_amount + json.commerical_tax @total_amount * 0.05 + json.total @total_amount + (@total_amount * 0.05) + +end \ No newline at end of file diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb index 758a52a2..9e1046c3 100644 --- a/app/views/crm/customers/_form.html.erb +++ b/app/views/crm/customers/_form.html.erb @@ -16,5 +16,13 @@ <%= f.button :submit %> <% end %> - + \ No newline at end of file diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 86f267b0..786a9f42 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -11,7 +11,7 @@ -
+
@@ -21,6 +21,17 @@ + + + + @@ -48,6 +59,9 @@ <% end %>
+ <%= form_tag crm_customers_path, :method => :get do %> +
+ + +
+ <% end %> +
Select Name
+
+

asdfj;l

+ <%= paginate @crm_customers %>
@@ -81,15 +95,7 @@ <%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%> -
- -
+
diff --git a/app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder b/app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder new file mode 100644 index 00000000..f2580e52 --- /dev/null +++ b/app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! crm_dining_queue, :id, :name, :contact, :queue_no, :created_at, :updated_at +json.url crm_dining_queue_url(crm_dining_queue, format: :json) diff --git a/app/views/crm/dining_queues/_form.html.erb b/app/views/crm/dining_queues/_form.html.erb new file mode 100644 index 00000000..a99f6b76 --- /dev/null +++ b/app/views/crm/dining_queues/_form.html.erb @@ -0,0 +1,16 @@ + +<%= simple_form_for([:crm,@dining_queue]) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :name %> + <%= f.input :contact_no %> + <%= f.input :queue_no %> + +
+ +
+ <%= f.button :submit %> +
+<% end %> + diff --git a/app/views/crm/dining_queues/edit.html.erb b/app/views/crm/dining_queues/edit.html.erb new file mode 100644 index 00000000..e5ca3b9f --- /dev/null +++ b/app/views/crm/dining_queues/edit.html.erb @@ -0,0 +1,11 @@ + +
+ + <%= render 'form', dining_queue: @dining_queue %> +
diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb new file mode 100644 index 00000000..e7834b98 --- /dev/null +++ b/app/views/crm/dining_queues/index.html.erb @@ -0,0 +1,38 @@ + + + + +
+
+ + + + + + + + + + + + <% @dining_queues.each do |dining_queue| %> + + + + + + + <% end %> + +
NameContact NoQueue NoAction
<%= dining_queue.name %><%= dining_queue.contact_no %><%= dining_queue.queue_no %> + <%= link_to 'Edit', edit_crm_dining_queue_path(dining_queue) %> | <%= link_to 'Destroy', crm_dining_queue_path(dining_queue), method: :delete, data: { confirm: 'Are you sure?' } %>
+
+ diff --git a/app/views/crm/dining_queues/index.json.jbuilder b/app/views/crm/dining_queues/index.json.jbuilder new file mode 100644 index 00000000..979087b7 --- /dev/null +++ b/app/views/crm/dining_queues/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @crm_dining_queues, partial: 'crm_dining_queues/crm_dining_queue', as: :crm_dining_queue diff --git a/app/views/crm/dining_queues/new.html.erb b/app/views/crm/dining_queues/new.html.erb new file mode 100644 index 00000000..280a59b2 --- /dev/null +++ b/app/views/crm/dining_queues/new.html.erb @@ -0,0 +1,11 @@ + +
+ + <%= render 'form', dining_queue: @dining_queue %> +
\ No newline at end of file diff --git a/app/views/crm/dining_queues/show.html.erb b/app/views/crm/dining_queues/show.html.erb new file mode 100644 index 00000000..5e52a611 --- /dev/null +++ b/app/views/crm/dining_queues/show.html.erb @@ -0,0 +1,19 @@ +

<%= notice %>

+ +

+ Name: + <%= @crm_dining_queue.name %> +

+ +

+ Contact: + <%= @crm_dining_queue.contact %> +

+ +

+ Queue no: + <%= @crm_dining_queue.queue_no %> +

+ +<%= link_to 'Edit', edit_crm_dining_queue_path(@crm_dining_queue) %> | +<%= link_to 'Back', crm_dining_queues_path %> diff --git a/app/views/crm/dining_queues/show.json.jbuilder b/app/views/crm/dining_queues/show.json.jbuilder new file mode 100644 index 00000000..83c09bea --- /dev/null +++ b/app/views/crm/dining_queues/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "crm_dining_queues/crm_dining_queue", crm_dining_queue: @crm_dining_queue diff --git a/app/views/crm/home/_booking.html.erb b/app/views/crm/home/_booking.html.erb index 3a2a7684..b9cf7296 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -6,29 +6,29 @@ <% @booking.each do |booking| %> <% if booking.booking_status == "new" %>
-
- -

- <%= @i += 1 %> . <%= booking.dining_facility.name %> - - <%= booking.id %> -

- -

- - Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %> - -

-
-
- +
\ No newline at end of file + From 7ab9874b808d5906d8ae369c4571f69bbaa1abc2 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 11 Jun 2017 13:20:26 +0630 Subject: [PATCH 15/71] remove migration files --- app/views/origami/home/index.html.erb | 84 +++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index fa521d6c..9e406ede 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -21,23 +21,23 @@
- <% - @booking_orders.each do |bko| + <% + @booking_orders.each do |bko| # Assigned Id for new Order? Sale? unique_id="" # For CSS- Class for Order? Sale? sale_status="" - if bko.order_status == 'new' + if bko.order_status == 'new' unique_id=bko.booking_id - else + else unique_id=bko.sale_id sale_status="sold" - end + end %>
- -

<%= bko.table_name %>

+ +

<%= bko.table_name %>

Receipt No : @@ -48,12 +48,12 @@ Order Status : <%= bko.order_status %> - + -

-
-
- <% +

+
+
+ <% end %>
@@ -62,23 +62,23 @@
- <% - @booking_rooms.each do |rmo| + <% + @booking_rooms.each do |rmo| # Assigned Id for new Order? Sale? unique_id="" # For CSS- Class for Order? Sale? sale_status="" - if rmo.order_status == 'new' - unique_id=rmo.booking_id - else + if rmo.order_status == 'new' + unique_id=rmo.booking_id + else unique_id=rmo.sale_id sale_status="sold" - end + end %>
- -

<%= rmo.room_name %>

+ +

<%= rmo.room_name %>

Receipt No : @@ -89,12 +89,12 @@ Order Status : <%= rmo.order_status %> - + -

-
-
- <% +

+
+
+ <% end %>
@@ -103,23 +103,23 @@
- <% - @orders.each do |odr| + <% + @orders.each do |odr| # Assigned Id for new Order? Sale? unique_id="" # For CSS- Class for Order? Sale? sale_status="" - if odr.order_status == 'new' + if odr.order_status == 'new' unique_id=odr.booking_id - else + else unique_id=odr.sale_id sale_status="sold" - end + end %>
- -

<%= odr.table_name %>

+ +

<%= odr.table_name %>

Receipt No : @@ -130,16 +130,16 @@ Order Status : <%= odr.order_status %> - + -

-
-
- <% +

+
+
+ <% end %> - + @@ -157,10 +157,10 @@

Receipt No:

Cashier:

-
+

Date:

-
+
@@ -205,7 +205,7 @@
- + @@ -215,7 +215,7 @@ - + From d49dc3f8c894ab8f7b68b6f1d45f2efaa1f090b1 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Sun, 11 Jun 2017 13:55:14 +0630 Subject: [PATCH 16/71] change route --- app/models/membership_action.rb | 2 ++ app/models/sale_payment.rb | 2 +- app/views/origami/others_payments/index.html.erb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 app/models/membership_action.rb diff --git a/app/models/membership_action.rb b/app/models/membership_action.rb new file mode 100644 index 00000000..93a4b3d8 --- /dev/null +++ b/app/models/membership_action.rb @@ -0,0 +1,2 @@ +class MembershipAction < ApplicationRecord +end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 834dba1f..57188d5c 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -79,7 +79,7 @@ class SalePayment < ApplicationRecord end def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id) - membership_actions_data = Settings::MembershipAction.find_by_membership_type("redeem_url"); + 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 = 1 diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 4a43dd1e..404306e7 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -141,7 +141,7 @@ $("#REDIMREBATE").click(function(){ $.ajax({ type: "GET", url: "../../../../settings/membership_actions", - data: {type:"get_account_balance_url",gateway_url:gateway_url,sale_id:sale_id}, + data: {type:"get_account_balance",gateway_url:gateway_url,sale_id:sale_id}, success: function(result){ $("#redeem").attr("data-member-value",result[2]); $("#valid_amount").val(result[1]); From 596c16d27480ee526297627ae7dd57ff9837fe31 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Sun, 11 Jun 2017 14:09:19 +0630 Subject: [PATCH 17/71] edit redeem --- app/views/origami/others_payments/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 5cf1bfd4..bd77effd 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -133,7 +133,7 @@ $(document).on('click', '.cashier_number', function(event){ // return false; // } }); -$("#REDIMREBATE").click(function(){ +$("#REDEEMREBATE").click(function(){ $('.rebate-form').removeAttr("hidden"); gateway_url = $(this).attr("data-url"); sale_id = $(this).attr("data-sale-id"); From 33cc576f1e9f8695a56bba391236c93709cd749c Mon Sep 17 00:00:00 2001 From: Moe Su Date: Sun, 11 Jun 2017 15:48:53 +0630 Subject: [PATCH 18/71] edit membership setting , otherpayment page --- .../origami/redeem_payments.coffee | 3 + .../stylesheets/origami/redeem_payments.scss | 3 + .../origami/redeem_payments_controller.rb | 41 +++++ .../settings/membership_actions_controller.rb | 53 +----- app/helpers/origami/redeem_payments_helper.rb | 2 + app/models/settings/membership_action.rb | 2 - .../origami/others_payments/index.html.erb | 166 +----------------- .../origami/redeem_payments/index.html.erb | 157 +++++++++++++++++ .../membership_actions/_form.html.erb | 2 +- .../settings/membership_actions/edit.html.erb | 2 +- .../membership_actions/index.html.erb | 4 +- config/routes.rb | 1 + ...170611084537_create_membership_actions.rb} | 7 +- .../redeem_payments_controller_spec.rb | 5 + .../origami/redeem_payments_helper_spec.rb | 15 ++ 15 files changed, 248 insertions(+), 215 deletions(-) create mode 100644 app/assets/javascripts/origami/redeem_payments.coffee create mode 100644 app/assets/stylesheets/origami/redeem_payments.scss create mode 100644 app/controllers/origami/redeem_payments_controller.rb create mode 100644 app/helpers/origami/redeem_payments_helper.rb delete mode 100644 app/models/settings/membership_action.rb create mode 100644 app/views/origami/redeem_payments/index.html.erb rename db/migrate/{20170608104900_create_settings_membership_actions.rb => 20170611084537_create_membership_actions.rb} (64%) create mode 100644 spec/controllers/origami/redeem_payments_controller_spec.rb create mode 100644 spec/helpers/origami/redeem_payments_helper_spec.rb diff --git a/app/assets/javascripts/origami/redeem_payments.coffee b/app/assets/javascripts/origami/redeem_payments.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/redeem_payments.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/origami/redeem_payments.scss b/app/assets/stylesheets/origami/redeem_payments.scss new file mode 100644 index 00000000..8fdd1e53 --- /dev/null +++ b/app/assets/stylesheets/origami/redeem_payments.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the origami/redeem_payments 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/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb new file mode 100644 index 00000000..732f969e --- /dev/null +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -0,0 +1,41 @@ +class Origami::RedeemPaymentsController < BaseOrigamiController + def index + sale_id = params[:sale_id] + payment_method = params[:payment_method] + @membership_rebate_balance=0 + sale_data = Sale.find_by_sale_id(sale_id) + if sale_data + if sale_data.customer_id + customer_data= Customer.find_by_customer_id(sale_data.customer_id) + if customer_data + @membership_id = customer_data.membership_id + @campaign_type_id =1 + if !@membership_id.nil? + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") + puts 'Hello Hello' + puts membership_setting.to_json + member_actions =MembershipAction.find_by_membership_type("get_account_balance") + puts member_actions.to_json + url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s + puts url + + membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id) + if membership_data["status"]==true + @membership_rebate_balance=membership_data["balance"] + @out = true, @membership_rebate_balance,@membership_id + end + else + @out = false, 0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + @out = false, 0 + end +end diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index 50aad862..ad7311f2 100644 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -4,46 +4,7 @@ class Settings::MembershipActionsController < ApplicationController # GET /settings/membership_actions # GET /settings/membership_actions.json def index - type = params[:type] - @sale_id = params[:sale_id] - if type.nil? - @settings_membership_actions = Settings::MembershipAction.all - else - membership_actions_data=Settings::MembershipAction.find_by_membership_type(type) - - if !membership_actions_data.nil? - url = params[:gateway_url].to_s + membership_actions_data.gateway_url.to_s - puts url.to_json - sale_data = Sale.find_by_sale_id(@sale_id) - if sale_data.customer_id - customer_data= Customer.find_by_customer_id(sale_data.customer_id) - puts customer_data.to_json - @membership_id = customer_data.membership_id - @campaign_type_id =1 - if !@membership_id.nil? - membership_setting = MembershipSetting.find_by_membership_type("paypar_url") - puts membership_setting - membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id) - if membership_data["status"]==true - @membership_rebate_balance=membership_data["balance"] - @out = true, @membership_rebate_balance,@membership_id - else - @out = false, 0 - end - else - @out = false, 0 - end - else - @out =false, 0 - end - # campaign_type_id=1 - # get_account_data = MembershipAction.get_account_data(url) - else - @out = false, 0 - end - render :json => @out.to_json - end - + @settings_membership_actions = MembershipAction.all end # GET /settings/membership_actions/1 @@ -53,7 +14,7 @@ class Settings::MembershipActionsController < ApplicationController # GET /settings/membership_actions/new def new - @settings_membership_action = Settings::MembershipAction.new + @settings_membership_action = MembershipAction.new end # GET /settings/membership_actions/1/edit @@ -63,11 +24,11 @@ class Settings::MembershipActionsController < ApplicationController # POST /settings/membership_actions # POST /settings/membership_actions.json def create - @settings_membership_action = Settings::MembershipAction.new(settings_membership_action_params) + @settings_membership_action = MembershipAction.new(settings_membership_action_params) respond_to do |format| if @settings_membership_action.save - format.html { redirect_to @settings_membership_action, notice: 'Membership action was successfully created.' } + format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' } format.json { render :show, status: :created, location: @settings_membership_action } else format.html { render :new } @@ -81,7 +42,7 @@ class Settings::MembershipActionsController < ApplicationController def update respond_to do |format| if @settings_membership_action.update(settings_membership_action_params) - format.html { redirect_to @settings_membership_action, notice: 'Membership action was successfully updated.' } + format.html { redirect_to settings_membership_action_path, notice: 'Membership action was successfully updated.' } format.json { render :show, status: :ok, location: @settings_membership_action } else format.html { render :edit } @@ -103,11 +64,11 @@ class Settings::MembershipActionsController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_settings_membership_action - @settings_membership_action = Settings::MembershipAction.find(params[:id]) + @settings_membership_action = MembershipAction.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def settings_membership_action_params - params.require(:settings_membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter) + params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter) end end diff --git a/app/helpers/origami/redeem_payments_helper.rb b/app/helpers/origami/redeem_payments_helper.rb new file mode 100644 index 00000000..7e9151cb --- /dev/null +++ b/app/helpers/origami/redeem_payments_helper.rb @@ -0,0 +1,2 @@ +module Origami::RedeemPaymentsHelper +end diff --git a/app/models/settings/membership_action.rb b/app/models/settings/membership_action.rb deleted file mode 100644 index 814e4b97..00000000 --- a/app/models/settings/membership_action.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Settings::MembershipAction < ApplicationRecord -end diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 5cf1bfd4..6ea1ae5e 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -4,174 +4,20 @@
<% @payment_method_setting.each do |payment_method|%>
-
<%= payment_method.payment_method %>
+
<%= payment_method.payment_method %>
<% end %>
- -
- -
-
-
-
-
-
1
-
2
-
3
-
-
-
-
1000
-
-
-
-
-
-
4
-
5
-
6
-
-
-
-
5000
-
-
-
-
-
-
7
-
8
-
9
-
-
-
-
10000
-
-
-
-
-
-
0
-
.
-
00
-
-
-
-
50000
-
-
-
-
-
-
-
DEL
-
CLR
-
-
-
-
PAY
-
-
-
-
- -
diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb new file mode 100644 index 00000000..5e336ac4 --- /dev/null +++ b/app/views/origami/redeem_payments/index.html.erb @@ -0,0 +1,157 @@ +
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
+
1000
+
+
+
+
+
+
4
+
5
+
6
+
+
+
+
5000
+
+
+
+
+
+
7
+
8
+
9
+
+
+
+
10000
+
+
+
+
+
+
0
+
.
+
00
+
+
+
+
50000
+
+
+
+
+
+
+
DEL
+
CLR
+
+
+
+
PAY
+
+
+
+
+ +
+
+
+ +
+ diff --git a/app/views/settings/membership_actions/_form.html.erb b/app/views/settings/membership_actions/_form.html.erb index 9f4a2cd5..3084d4ac 100644 --- a/app/views/settings/membership_actions/_form.html.erb +++ b/app/views/settings/membership_actions/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for(@settings_membership_action) do |f| %> +<%= simple_form_for([:settings,@settings_membership_action]) do |f| %> <%= f.error_notification %>
diff --git a/app/views/settings/membership_actions/edit.html.erb b/app/views/settings/membership_actions/edit.html.erb index 3373d008..cd5cb98a 100644 --- a/app/views/settings/membership_actions/edit.html.erb +++ b/app/views/settings/membership_actions/edit.html.erb @@ -2,5 +2,5 @@ <%= render 'form', settings_membership_action: @settings_membership_action %> -<%= link_to 'Show', @settings_membership_action %> | +<%= link_to 'Show', settings_membership_action_path(@settings_membership_action) %> | <%= link_to 'Back', settings_membership_actions_path %> diff --git a/app/views/settings/membership_actions/index.html.erb b/app/views/settings/membership_actions/index.html.erb index 80b4420e..635fd34c 100644 --- a/app/views/settings/membership_actions/index.html.erb +++ b/app/views/settings/membership_actions/index.html.erb @@ -28,9 +28,9 @@ <%= settings_membership_action.merchant_account_id %> <%= settings_membership_action.created_by %> <%= settings_membership_action.additional_parameter %> - <%= link_to 'Show', settings_membership_action %> + <%= link_to 'Show', settings_membership_action_path(settings_membership_action) %> <%= link_to 'Edit', edit_settings_membership_action_path(settings_membership_action) %> - <%= link_to 'Destroy', settings_membership_action, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= link_to 'Destroy', settings_membership_action_path(settings_membership_action), method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 6d7be02e..91acd6a3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -85,6 +85,7 @@ Rails.application.routes.draw do 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" end diff --git a/db/migrate/20170608104900_create_settings_membership_actions.rb b/db/migrate/20170611084537_create_membership_actions.rb similarity index 64% rename from db/migrate/20170608104900_create_settings_membership_actions.rb rename to db/migrate/20170611084537_create_membership_actions.rb index 2b9dd85d..55f9bcb2 100644 --- a/db/migrate/20170608104900_create_settings_membership_actions.rb +++ b/db/migrate/20170611084537_create_membership_actions.rb @@ -1,7 +1,7 @@ -class CreateSettingsMembershipActions < ActiveRecord::Migration[5.1] +class CreateMembershipActions < ActiveRecord::Migration[5.1] def change - create_table :settings_membership_actions do |t| - t.string :membership_type + create_table :membership_actions do |t| + t.string :membership_type t.boolean :is_active t.string :gateway_communication_type t.string :gateway_url @@ -11,6 +11,7 @@ class CreateSettingsMembershipActions < ActiveRecord::Migration[5.1] t.string :additional_parameter t.timestamps + t.timestamps end end end diff --git a/spec/controllers/origami/redeem_payments_controller_spec.rb b/spec/controllers/origami/redeem_payments_controller_spec.rb new file mode 100644 index 00000000..22e705d7 --- /dev/null +++ b/spec/controllers/origami/redeem_payments_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Origami::RedeemPaymentsController, type: :controller do + +end diff --git a/spec/helpers/origami/redeem_payments_helper_spec.rb b/spec/helpers/origami/redeem_payments_helper_spec.rb new file mode 100644 index 00000000..580d73ff --- /dev/null +++ b/spec/helpers/origami/redeem_payments_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Origami::RedeemPaymentsHelper. For example: +# +# describe Origami::RedeemPaymentsHelper 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 Origami::RedeemPaymentsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end From b7bd68a461f3a16efdec5566e464650fc27c2b00 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 11 Jun 2017 15:51:22 +0630 Subject: [PATCH 19/71] payment keypad --- app/assets/javascripts/origami.js | 45 +++--- app/assets/stylesheets/origami.scss | 43 +++-- app/views/origami/home/index.html.erb | 8 +- .../origami/others_payments/index.html.erb | 4 +- app/views/origami/payments/show.html.erb | 147 +++++++++--------- lib/tasks/clear_data.rake | 16 ++ 6 files changed, 148 insertions(+), 115 deletions(-) create mode 100644 lib/tasks/clear_data.rake diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 8ce3d0c4..21ec1c92 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -18,17 +18,17 @@ $(document).ready(function(){ $(".orders").on('click', function(){ - 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(); + var order_status=$(this).find(".orders-order-status").text().trim(); // Enable/Disable Button control_button(order_status); //for customer button if(unique_id.charAt(0) == 'S'){ - $("#customer").removeAttr('disabled'); + $("#customer").removeAttr('disabled'); }else{ $("#customer").attr('disabled','disabled'); } @@ -49,7 +49,7 @@ $(document).ready(function(){ type: "GET", url: "origami/" + unique_id, data: { '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); @@ -78,7 +78,7 @@ $(document).ready(function(){ $("#order-grand-total").text(grand_total_amount); // Ordered Items - var order_items_rows = "" + + var order_items_rows = "" + "" + parse_data.item_name + "" + "" + parse_data.qty + "" + "" + parse_data.qty*parse_data.price + "" + @@ -94,9 +94,9 @@ $(document).ready(function(){ $(this).addClass('selected-item'); }); - // Bill Request + // Bill Request $('#request_bills').click(function() { - var order_id=$(".selected-item").find(".orders-id").text(); + var order_id=$(".selected-item").find(".orders-id").text(); if(order_id!=""){ window.location.href = '/origami/request_bills/'+ order_id } @@ -106,16 +106,16 @@ $(document).ready(function(){ return false; }); - // Discount for Payment + // Discount for Payment $('#discount').click(function() { - var order_id=$(".selected-item").find(".orders-id").text(); + var order_id=$(".selected-item").find(".orders-id").text(); if(order_id!=""){ window.location.href = '/origami/discount/'+ order_id } else { alert("Please select an order!"); - } - + } + return false; }); @@ -125,11 +125,11 @@ $(document).ready(function(){ var sub_total = $('#order-sub-total').text(); var grand_total = $('#order-grand-total').text(); var discount_type = $('#discount-type').val(); - var discount_value = $('#discount-amount').val(); + var discount_value = $('#discount-amount').val(); var discount_amount = discount_value; // For Percentage Discount - if(discount_type == 1){ + if(discount_type == 1){ discount_amount=(sub_total*discount_value)/100; } @@ -150,8 +150,8 @@ $(document).ready(function(){ } else { alert("Please select an order!"); - } - + } + return false; }); @@ -168,7 +168,7 @@ $(document).ready(function(){ original_value = $('#discount-amount').val(); var input_type = $(this).attr("data-type"); - + switch (input_type) { case 'num': var input_value = $(this).attr("data-value"); @@ -179,7 +179,7 @@ $(document).ready(function(){ else{ $('#discount-amount').val(original_value + '' + input_value); update_balance(); - } + } break; case 'add': @@ -210,16 +210,16 @@ $(document).ready(function(){ }); /* Button Control by Status */ -function control_button(order_status){ +function control_button(order_status){ if(order_status=="billed"){ $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', false); - $("#pay").prop('disabled', false); + $("#pay-bill").prop('disabled', false); } else if(order_status=="new") { $("#request_bills").prop('disabled', false); $("#discount").prop('disabled', true); - $("#pay").prop('disabled', true); + $("#pay-bill").prop('disabled', true); } } @@ -236,9 +236,6 @@ function update_balance(){ } var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount; - $('#order-discount').text(discount_amount); + $('#order-discount').text(discount_amount); $('#order-grand-total').text(total); } - - - diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 0be16266..c37f2678 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -7,17 +7,36 @@ // min-height: 75rem; // padding-top: 4.5rem; // } +.others-payment{ + line-height:100px; + text-align:center; + color:white; + width:300px; + height:100px; + font-size:18px; +} .cashier_number{ - height:76px; - line-height:80px; + width: 30%; + height:71px; + line-height:71px; + text-align:center; background:#54A5AF; - float:left; - margin:2px; + // float:left; + // margin:2px; + font-size:20px; + color:white; + // cursor:pointer; +} + +.pay{ + width: 98%; + height:210px; + line-height:210px; + text-align:center; font-size:20px; color:white; - cursor:pointer; } .cashier_number:hover{ @@ -25,7 +44,7 @@ } .long{ - width:100% + width:49% } .sold { @@ -42,17 +61,17 @@ } .charges-name { - width: 80%; + width: 80%; text-align: left; } .item-name { - width: 60%; + width: 60%; text-align: left; } .item-attr { - width: 20%; + width: 20%; text-align: right; } @@ -70,7 +89,13 @@ background-color: #009900 } +.left{ + margin-left:1px; +} +.bottom{ + margin-bottom: 1px; +} /*----- Reset -----*/ select.form-control { diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 9e406ede..e25aebd5 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -215,13 +215,13 @@ - - + + - + - +
diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index bd77effd..7ac1a145 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -1,10 +1,10 @@
-
+
<% @payment_method_setting.each do |payment_method|%>
-
<%= payment_method.payment_method %>
+
<%= payment_method.payment_method %>
<% end %>
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index f16ef927..4e7744f3 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1,25 +1,35 @@
-
+
- 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 %> - Sale Id <% if @sale_data %><%=@sale_data.sale_id %><% end %> + + + + + + + + + + + + + +
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 %>Sale Id <% if @sale_data %><%=@sale_data.sale_id %><% end %>
Customer : Default CustomerPoints : 1234
- - +
+ - - + - +
ItemsQTY - Price + ItemsQTY + Price
@@ -71,95 +81,80 @@
-
-
AMOUNT DUE
-
<%= @sale_data.grand_total %>
+
+
Amount Due
+
<%= @sale_data.grand_total %>

-
CASH
+
Cash
<%= @cash %>

-
CREDIT
+
Credit
0.0

-
OTHERS PAYMENT
+
Others Payment
0.0

-
BALANCE
+
Balance
<%= @sale_data.grand_total %>

-
-
-
-
-
-
1
-
2
-
3
-
-
-
-
1000
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
+
Del
+
Clr
-
-
-
-
4
-
5
-
6
-
+
+
+
1000
+
3000
-
-
5000
+
+
5000
+
10000
+
+
+
Pay
-
-
-
-
7
-
8
-
9
-
-
-
-
10000
-
-
-
-
-
-
0
-
.
-
00
-
-
-
-
50000
-
-
-
-
-
-
-
DEL
-
CLR
-
-
-
-
PAY
-
-
-
+ +
+
+ + +
diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake new file mode 100644 index 00000000..c9e0fe22 --- /dev/null +++ b/lib/tasks/clear_data.rake @@ -0,0 +1,16 @@ +namespace :clear do + desc "Clear Data" + task :data => :environment do + BookingOrder.delete_all + Booking.delete_all + OrderItem.delete_all + AssignedOrderItem.delete_all + Order.delete_all + SaleOrder.delete_all + SaleItem.delete_all + Sale.delete_all + SaleAudit.delete_all + SalePayment.delete_all + puts "Clear Data Done." + end +end From a8098183245190977a7db5aa4e1b23e0eef48cb1 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 11 Jun 2017 16:10:50 +0630 Subject: [PATCH 20/71] other payment --- app/controllers/origami/mpu_controller.rb | 8 +++++++ app/views/origami/mpu/index.html.erb | 1 + .../origami/others_payments/index.html.erb | 21 +++++++------------ config/routes.rb | 7 ++++--- 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 app/controllers/origami/mpu_controller.rb create mode 100644 app/views/origami/mpu/index.html.erb diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb new file mode 100644 index 00000000..8918d705 --- /dev/null +++ b/app/controllers/origami/mpu_controller.rb @@ -0,0 +1,8 @@ +class Origami::MpuController < BaseOrigamiController + + def index + end + + def create + end +end diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb new file mode 100644 index 00000000..6b339e0f --- /dev/null +++ b/app/views/origami/mpu/index.html.erb @@ -0,0 +1 @@ +Hello MPU diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 2e0feb11..b5ef15ae 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -1,25 +1,20 @@
-
+
<% @payment_method_setting.each do |payment_method|%> -
- -
<%= payment_method.payment_method %>
- -
+
<%= payment_method.payment_method %>
<% end %>
-
-
diff --git a/config/routes.rb b/config/routes.rb index 91acd6a3..26c00d10 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ require 'sidekiq/web' Rails.application.routes.draw do - + namespace :settings do resources :membership_actions end @@ -85,8 +85,9 @@ Rails.application.routes.draw do 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/:payment_method' => "redeem_payments#index" + get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index" + get 'sale/:sale_id/payment/others_payment/REDIMREBATE' => "redeem_payments#index" end #--------- Waiter/Ordering Station ------------# From 29cdcfb28d23f157ebe030355565ab4dd07ec227 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Sun, 11 Jun 2017 16:11:44 +0630 Subject: [PATCH 21/71] For Pull --- .../origami/redeem_payments_controller.rb | 31 ++++++++++------- .../origami/redeem_payments/index.html.erb | 34 +++++++++++-------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index 732f969e..fba759bb 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -1,9 +1,9 @@ class Origami::RedeemPaymentsController < BaseOrigamiController def index - sale_id = params[:sale_id] + @sale_id = params[:sale_id] payment_method = params[:payment_method] @membership_rebate_balance=0 - sale_data = Sale.find_by_sale_id(sale_id) + sale_data = Sale.find_by_sale_id(@sale_id) if sale_data if sale_data.customer_id customer_data= Customer.find_by_customer_id(sale_data.customer_id) @@ -12,18 +12,23 @@ class Origami::RedeemPaymentsController < BaseOrigamiController @campaign_type_id =1 if !@membership_id.nil? membership_setting = MembershipSetting.find_by_membership_type("paypar_url") - puts 'Hello Hello' - puts membership_setting.to_json - member_actions =MembershipAction.find_by_membership_type("get_account_balance") - puts member_actions.to_json - url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s - puts url - - membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id) - if membership_data["status"]==true - @membership_rebate_balance=membership_data["balance"] - @out = true, @membership_rebate_balance,@membership_id + if membership_setting.gateway_url + member_actions =MembershipAction.find_by_membership_type("get_account_balance") + if member_actions.gateway_url + 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) + if membership_data["status"]==true + @membership_rebate_balance=membership_data["balance"] + @out = true, @membership_rebate_balance,@membership_id + end + else + @out =false,0 + end + else + @out = false,0 end + + else @out = false, 0 end diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 5e336ac4..72c09d4d 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -6,7 +6,7 @@
- +

@@ -77,12 +77,12 @@
-
DEL
-
CLR
+
DEL
+
CLR
-
PAY
+
PAY
@@ -95,9 +95,9 @@
diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index b5ef15ae..4b2397a2 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -14,7 +14,6 @@ $('.others-payment').on('click',function(){ var input_type = $(this).attr("data-type"); var sale_id = $(this).attr("data-sale-id"); - alert(input_type) window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment/" + input_type; }) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 4e7744f3..d36902fb 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -93,12 +93,12 @@
Credit
-
0.0
+
0.0

Others Payment
-
0.0
+
<%= @other %>

@@ -159,6 +159,9 @@
diff --git a/db/migrate/20170611084537_create_membership_actions.rb b/db/migrate/20170611084537_create_membership_actions.rb index 5b5d1774..74695871 100644 --- a/db/migrate/20170611084537_create_membership_actions.rb +++ b/db/migrate/20170611084537_create_membership_actions.rb @@ -11,7 +11,6 @@ class CreateMembershipActions < ActiveRecord::Migration[5.1] t.jsonb :additional_parameter t.timestamps - t.timestamps end end end diff --git a/dump.rdb b/dump.rdb index 353820066c0a3587829039db72f6c8e60a1eedaa..ebdb6db6aa4a16a1abe03b56aaa0c4d4053ff704 100644 GIT binary patch delta 213 zcmV;`04o2*ngP6>0gx~kp&C6|`UrJ%Wn?XFWo^RnV-EoS0Q(P-M};B{adl;NWjbVK zW?^+~bOFObVnMbCwgCVD3IG5AAO;^nsFN`t9s>+?Ws~tgWF=%`G%+ Date: Sun, 11 Jun 2017 17:49:06 +0630 Subject: [PATCH 26/71] payment --- app/assets/javascripts/origami.js | 2 +- app/models/sale_payment.rb | 17 +++++++---------- app/views/origami/mpu/index.html.erb | 3 ++- app/views/origami/payments/create.json.jbuilder | 1 + app/views/origami/payments/show.html.erb | 3 ++- 5 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 app/views/origami/payments/create.json.jbuilder diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 21ec1c92..e37728c1 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -20,7 +20,7 @@ $(document).ready(function(){ $(".orders").on('click', function(){ 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 unique_id = $(this).find(".orders-id").text(); var order_status=$(this).find(".orders-order-status").text().trim(); // Enable/Disable Button diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index ff4c49b6..4b6edce8 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -106,7 +106,6 @@ class SalePayment < ApplicationRecord self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) return payment_status @@ -205,30 +204,28 @@ class SalePayment < ApplicationRecord end def sale_update_payment_status(paid_amount) - puts "sale update" #update amount_outstanding self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f - self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f - all_received_amount = 0.0 - sObj = self.sale + sObj = Sale.find(self.sale_id) sObj.sale_payments.each do |spay| - puts spay - puts spay.payment_amount all_received_amount += spay.payment_amount.to_f end - puts all_received_amount - puts self.sale.grand_total + if (self.sale.grand_total <= all_received_amount) - puts " sale update ......" self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! + rebat() end end + def rebat + + end + private def generate_custom_id self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index d82e6cd1..f082dc1a 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -11,12 +11,13 @@ Amount : $('#mpu_pay').on('click',function(){ var amount = $('#amount').val(); var sale_id = "<%= @sale_id %>"; - alert(amount); + $.ajax({type: "POST", url: "<%= origami_create_mpu_payment_path %>", data: "amount="+ amount + "&sale_id="+ sale_id, success:function(result){ if(result){ + alert("Payment success") window.location.href = '/origami/sale/'+ sale_id + "/payment"; } } diff --git a/app/views/origami/payments/create.json.jbuilder b/app/views/origami/payments/create.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/payments/create.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index d36902fb..198b9518 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -229,7 +229,8 @@ $( document ).ready(function() { url: "<%= origami_payment_process_path %>", data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ - alert("THANK YOU") + alert("Thank you") + window.location.href = '/origami'; } }); } From d65882ac5bcdce934116e65b66a8a3cb34965ba3 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 11 Jun 2017 18:00:34 +0630 Subject: [PATCH 27/71] crm update --- app/assets/javascripts/origami.js | 24 +++++- app/controllers/crm/customers_controller.rb | 75 ++++++++----------- .../origami/customers_controller.rb | 33 +++++++- app/controllers/origami/home_controller.rb | 20 +++++ app/models/order.rb | 6 +- app/views/crm/customers/index.html.erb | 22 ++---- app/views/crm/home/_booking.html.erb | 7 +- app/views/crm/home/index.html.erb | 4 +- app/views/origami/home/index.html.erb | 18 ++++- config/routes.rb | 12 ++- 10 files changed, 146 insertions(+), 75 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 8ce3d0c4..94d8e220 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -33,6 +33,10 @@ $(document).ready(function(){ $("#customer").attr('disabled','disabled'); } + var customer_id=$(this).find(".customer-id").text(); + show_customer_details(customer_id); + + var cashier=""; var receipt_date=""; var sub_total=0; @@ -142,6 +146,7 @@ $(document).ready(function(){ }); }); + // Payment for Bill $('#pay-bill').click(function() { var sale_id=$(".selected-item").find(".orders-id").text(); @@ -157,10 +162,27 @@ $(document).ready(function(){ $('#customer').click(function() { var sale_id=$(".selected-item").find(".orders-id").text(); - window.location.href = '/crm/customers/'+ sale_id + "/assign_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({ + 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){ if(event.handled !== true) { diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 7896fa45..042ec63a 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -4,21 +4,23 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers # GET /crm/customers.json def index - @sale_id = 0 filter = params[:filter] if filter.nil? - @crm_customers = Customer.order("name").page(params[:page]) + @crm_customers = Customer.order("customer_id").page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end #@crm_customers = Customer.all - @crm_customer = Customer.new - @membership = Customer.get_member_group - if @membership["status"] == true - @member_group = @membership["data"] - end + @crm_customer = Customer.new + @crm_customer.valid? + + + # @membership = Customer.get_member_group + # if @membership["status"] == true + # @member_group = @membership["data"] + # end respond_to do |format| format.html # index.html.erb format.json { render json: @crm_customers } @@ -49,8 +51,6 @@ class Crm::CustomersController < BaseCrmController respond_to do |format| if @crm_customers.save - - name = customer_params[:name] phone = customer_params[:contact_no] email = customer_params[:email] @@ -71,41 +71,41 @@ class Crm::CustomersController < BaseCrmController ) if response["status"] == true - puts "hhhhhhhhhhhhhhhhhh" - puts params[:sale_id] - puts response.to_json + customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) - if params[:sale_id] != 0 - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' } + + if params[:sale_id].nil? + + format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' } + else - format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' } + 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] != 0 - format.html { redirect_to crm_customers_path, notice: response["message"] } - + if params[:sale_id].nil? + format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} else - format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] } + 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] != 0 - format.html { redirect_to crm_customers_path} - format.json { render json: @crm_customers.errors, status: :unprocessable_entity } - - else - format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] } - end + + if params[:sale_id].nil? + + 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 @@ -161,20 +161,7 @@ class Crm::CustomersController < BaseCrmController # 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. @@ -185,7 +172,7 @@ class Crm::CustomersController < BaseCrmController # Never trust parameters from the scary internet, only allow the white list through. def customer_params - params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code) + params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth) end end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index d9bfc39b..7917b03f 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -1,7 +1,38 @@ class Origami::CustomersController < BaseOrigamiController #Form to add customer - def index + + end - def create + + # GET /crm/customers/1 + # GET /crm/customers/1.json + def show end + + + + def add_customer + + @sale_id = params[:sale_id] + filter = params[:filter] + + if filter.nil? + @crm_customers = Customer.order("name").page(params[:page]) + else + @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 + respond_to do |format| + # format.html { render :template => "crm/customers/index" } + format.html { render action: "index"} + format.json { render json: @crm_customers } + end + end + + end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 9733e488..309903b2 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -3,6 +3,7 @@ class Origami::HomeController < BaseOrigamiController @booking_orders = Order.get_booking_order_table() @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() + end def show @@ -25,4 +26,23 @@ class Origami::HomeController < BaseOrigamiController render :json => str.to_json end end + + def update_sale_by_customer + + sale = Sale.find(params[:sale_id]) + status = sale.update_attributes(customer_id: params[:customer_id]) + + if status == true + render json: JSON.generate({:status => true}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + + end + end + + def get_customer + @customer = Customer.find(params[:customer_id]) + + render :json => @customer.to_json + end end diff --git a/app/models/order.rb b/app/models/order.rb index 4817c3ce..f4a4eff9 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -222,7 +222,7 @@ 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, + booking_orders = Booking.select("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") .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 +235,7 @@ 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, + booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,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 +264,7 @@ 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, - bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + orders.customer_id as 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 184bce41..e4f6d07d 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -69,8 +69,10 @@
<%= 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 " %>
@@ -95,24 +97,14 @@ <%= 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' %> @@ -140,11 +132,11 @@ $(document).on('click',".checkbox_check",function(){ if(this.checked){ - var sale_id = $("#sale_id").val() || 0; + var sale_id = $("#sale_id").val() || 0; var customer_id = $(this).val(); if(sale_id != 0){ - var url = "../"+customer_id; + // var url = "/"+customer_id; update_sale(customer_id,sale_id); }else{ @@ -201,7 +193,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/crm/home/_booking.html.erb b/app/views/crm/home/_booking.html.erb index 5d865002..fbe837a7 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -76,8 +76,9 @@ $(function(){ //End Print Click $('.assign').click(function(e){ - var booking_id = $(this).val() - var type = $(this).attr("data-type") + var booking_id = $(this).val(); + var type = $(this).attr("data-type"); + alert(booking_id); update_booking(booking_id,type) }); @@ -190,7 +191,7 @@ function update_booking(booking_id,type) { //Start Ajax $.ajax({ type: "POST", - url: "update_booking/" , + url: "crm/update_booking/" , data: {booking_id:booking_id,type:type}, dataType: "json", success: function(data) { diff --git a/app/views/crm/home/index.html.erb b/app/views/crm/home/index.html.erb index 87e601d9..c1938bc4 100644 --- a/app/views/crm/home/index.html.erb +++ b/app/views/crm/home/index.html.erb @@ -3,7 +3,7 @@ -
+
-
+
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 38/71] 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 39/71] 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 40/71] 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 41/71] 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 42/71] 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 43/71] 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 44/71] 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 45/71] 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 46/71] 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 47/71] 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 48/71] 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 49/71] 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 50/71] 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 51/71] 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 52/71] 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 53/71] 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 54/71] 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 55/71] 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 56/71] 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 57/71] 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 58/71] 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' From b14f4d67a5a5def04a397164332db3dd82cc2add Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 18:23:12 +0630 Subject: [PATCH 59/71] origamijs --- app/assets/javascripts/origami.js | 14 ++++++++++---- app/controllers/crm/customers_controller.rb | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 45c6d909..b3872b84 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -188,11 +188,17 @@ $(document).ready(function(){ function show_customer_details(customer_id){ + if(window.location.pathname.substring(0, 12) == "/origami/SAL"){ + var url = customer_id+"/get_customer/" + }else{ + var url = "origami/"+customer_id+"/get_customer/" + } + $('.customer_detail').removeClass('hide'); //Start Ajax $.ajax({ type: "GET", - url: "origami/"+customer_id+"/get_customer/", + url: url, data: {}, dataType: "json", success: function(data) { @@ -201,10 +207,10 @@ $(document).ready(function(){ 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); + if (balance == "0.0") { + $("#customer_amount").text('0.0'); }else{ - $("#customer_amount").text('00'); + $("#customer_amount").text(balance); } diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 01acd441..c33db2e1 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -124,14 +124,14 @@ end phone = customer_params[:contact_no] email = customer_params[:email] date_of_birth = customer_params[:date_of_birth] - id = customer_params[:membership_id] + id = @crm_customer.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") 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,merchant_uid:merchant_uid}.to_json, From a247c142b8bfd650ba49a424e0288181b90747a0 Mon Sep 17 00:00:00 2001 From: Cherry Date: Mon, 12 Jun 2017 18:26:00 +0630 Subject: [PATCH 60/71] ReceiptList Report Rough --- Gemfile | 6 +- Gemfile.lock | 2 - app/assets/javascripts/application.js | 8 +- app/assets/stylesheets/application.scss | 2 +- .../reports/receipt_no_controller.rb | 80 +++++- app/models/sale.rb | 4 + app/views/layouts/_header.html.erb | 2 +- .../_shift_sale_report_filter.html.erb | 246 ++++++++++++++++++ app/views/reports/receipt_no/index.html.erb | 98 ++++++- app/views/reports/receipt_no/index.xls.erb | 135 ++++++++++ 10 files changed, 572 insertions(+), 11 deletions(-) create mode 100644 app/views/reports/receipt_no/_shift_sale_report_filter.html.erb create mode 100644 app/views/reports/receipt_no/index.xls.erb diff --git a/Gemfile b/Gemfile index 02dca6af..7295ffab 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' @@ -93,4 +93,8 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'httparty', '~> 0.15.5' +# gem 'momentjs-rails', '>= 2.9.0' +# gem 'bootstrap-datepicker-rails' +# gem 'momentjs-rails', '>= 2.9.0' +# gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47' gem 'bootstrap-datepicker-rails' 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/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8ff96589..59e4a386 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,5 +17,11 @@ //= require turbolinks //= require cable //= require settings/processing_items -//= require bootstrap-datepicker +//= require bootstrap-datepicker/core +//= require bootstrap-datepicker/locales/bootstrap-datepicker.es + +$(document).on("focus", "[data-behaviour~='datepicker']", function(e){ + $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); + $('.dropdown-toggle').dropdown(); +}); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d8101494..468ac33d 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,7 +2,7 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; -@import "bootstrap-datepicker3"; +@import 'bootstrap-datepicker'; /* Show it is fixed to the top */ // body { diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 05065fee..930659b9 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,9 +1,85 @@ -class Reports::ReceiptNoController < BaseReportController +class Reports::ReceiptNoController < ApplicationController + PERIOD = { + "today" => 0, + "yesterday" => 1, + "this_week" => 2, + "last_week" => 3, + "last_7" => 4, + "this_month" => 5, + "last_month" => 6, + "last_30" => 7, + "this_year" => 8, + "last_year" => 9 + } + def index - @hi = "hi" + from, to = get_date_range_from_params + puts "from..." + puts from + puts "to..." + puts to + @sale_data = Sale.get_receipt_no_list(from,to) + @sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50) end def show + + end + private + def get_date_range_from_params + period_type = params[:period_type] + period = params[:period] + from = params[:from] + to = params[:to] + day_ref = Time.now + if period_type.to_i == 1 + if params[:from] && params[:to] + if params[:from] != "" && params[:to] !="" + from = DateTime.strptime(params[:from], "%m/%d/%Y") + to = DateTime.strptime(params[:to], "%m/%d/%Y") + else + from = day_ref.beginning_of_day.utc + to = day_ref.end_of_day.utc + end + end + else + case period.to_i + when PERIOD["today"] + + from = day_ref.beginning_of_day.utc + to = day_ref.end_of_day.utc + + when PERIOD["yesterday"] + from = (day_ref - 1.day).beginning_of_day.utc + to = (day_ref - 1.day).end_of_day.utc + + when PERIOD["this_week"] + from = Time.now.beginning_of_week.utc + to = Time.now.utc + when PERIOD["last_week"] + from = (day_ref - 7.day).beginning_of_week.utc + to = (day_ref - 7.day).end_of_week.utc + when PERIOD["last_7"] + from = (day_ref - 7.day).utc + to = Time.now.utc + when PERIOD["this_month"] + from = Time.now.beginning_of_month.utc + to = Time.now.utc + when PERIOD["last_month"] + from = (day_ref - 1.month).beginning_of_month.utc + to = (day_ref - 1.month).end_of_month.utc + when PERIOD["last_30"] + from = (day_ref - 30.day).utc + to = Time.now.utc + when PERIOD["this_year"] + from = Time.now.beginning_of_year.utc + to = Time.now.utc + when PERIOD["last_year"] + from = (day_ref - 1.year).beginning_of_year.utc + to = (day_ref - 1.year).end_of_year.utc + end + end + return from, to end end \ No newline at end of file diff --git a/app/models/sale.rb b/app/models/sale.rb index 47d271f1..52625917 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -263,4 +263,8 @@ class Sale < ApplicationRecord def generate_custom_id self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") end + + def self.get_receipt_no_list(from,to) + sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to) + end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index bdd146b7..641678f9 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -36,7 +36,7 @@ diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..9c87d843 --- /dev/null +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -0,0 +1,246 @@ +<%= form_tag report_path, :method => :get, :id=>"frm_report" do %> +
+
+ <% if defined? product_account %> + <%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account])%> + <% end %> + <% if defined? shift_product_account %> + <%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account]), :prompt => 'All Group'%> + <% end %> +
+ +
+ <% if period_type != false %> + + + <% end %> +
+ +
+
+ Export to Excel + + +
+
+
+
+ +
+ +
+
+ <% if defined? show_sale_type %> + + <% end %> + + <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]) %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]) %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]) %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]) %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products" %> + <% end %> + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]) %> + <% end %> +
+ +
+ + +
+ To     + +
+
+ + + <% if defined? show_monthly %> +
+ +
+ + + +
+
+ <% end %> + +
+ +
+
+ +<% end %> + + \ No newline at end of file diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 0bae50e7..fac08039 100644 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -1,3 +1,95 @@ -
- <%= @hi %> -
\ No newline at end of file + +
+
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 %>
+ + + + + + + + + + + + + + + <% total_sales = 0 %> + <% net_sales = 0 %> + <% @sale_data.each do |sale| %> + <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> + <% net_sales = total_sales.to_f + sale.total_tax.to_f%> + + + + + + + + + + + <% end %> + +
DateReceipt NoCashier NameGross SalesDiscountTotal SalesCTNett Sales
<%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %><%=sale.receipt_no.to_s rescue ''%><%=sale.cashier_id rescue ''%><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
+
+<%= paginate @sale_data %> + \ No newline at end of file diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb new file mode 100644 index 00000000..2191d814 --- /dev/null +++ b/app/views/reports/receipt_no/index.xls.erb @@ -0,0 +1,135 @@ +
+
+ +<% unless @sale_data.empty? %> +

<%=current_active_location.name%>

+

Sales Summary Report (BreadTalk)

+<% if params[:from]%> +

From Date : <%= params[:from] %> , To Date : <%= params[:to] %>

+<% end %> + + + + + + + + + + + + + + + + + + + + + <% void = 0 %> + <% card = 0 %> + <% credit_payment = 0 %> + <% cash = 0 %> + <% credit = 0 %> + <% foc = 0 %> + <% discount = 0 %> + <% total = 0 %> + <% count = 1 %> + <% discount_rev = 0 %> + <% total_rev = 0 %> + <% grand_rev = 0 %> + <% total_other_charges=0 %> + <% total_tax=0 %> + <% cash_received = 0 %> + <% total_cash_received = 0 %> + <% today_credit_payment_amount = 0 %> + <% old_location_id = 0%> + <% sub_total = 0 %> + <% count_of_void = 0 %> + <% flag = false %> + <% @sale_data.each do |sale| %> + <% credit_payment += sale[:credit_payment].to_f %> + <% card += sale[:card_amount].to_f %> + <% cash += sale[:cash_amount].to_f %> + <% credit += sale[:credit_amount].to_f %> + <% foc += sale[:foc_amount].to_f %> + <% discount += sale[:total_discount].to_f %> + <% total += sale[:grand_total].to_f %> + <% total_other_charges +=sale[:other_charges].to_f %> + <% total_tax +=sale[:total_tax].to_f %> + + <% cash_received = sale[:cash_amount].to_f + sale[:credit_payment].to_f%> + <% total_cash_received = cash.to_f + credit_payment.to_f%> + <% today_credit_payment_amount += sale[:today_credit_payment].to_f %> + + + + + + + + + + + + + + + <% total_void_amount = 0 %> + <% if !@daily_void.nil? %> + <% @daily_void.each do |d_v|%> + + <% if d_v[:daily_void_amt].to_i > 0 %> + <% if d_v[:location_id] == sale[:location_id] %> + <% if d_v[:date].utc.getlocal.strftime("%Y-%m-%d").to_s == sale[:sale_date].to_s%> + <%count_of_void+=1%> + + <%total_void_amount += d_v[:daily_void_amt].to_f%> + <% flag = true %> + + + + <%end %> + <% end%> + <% end%> + <% end%> + <% end%> + <% if flag == true%> + <% void += total_void_amount.to_f %> + + <% flag = false %> + <% end%> + <%if count_of_void == 0%> + + <%end %> + + + + +<%count_of_void= 0%> + <% count = count + 1 %> + <% end %> + + + + + + + + + + + + + + + + + +<% end %> +
Location NameDateCash SalesCredit SalesCredit ReceivedCard PaymentTotal DiscountTotal TaxesTotal Other ChargesFOC SalesVoid SalesGrand Total
<%= sale[:location].to_s rescue '-' %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:credit_payment].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:card_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:total_discount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:total_tax].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:other_charges].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_void_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",0.to_f), :delimiter => ',') %> + <%= number_with_delimiter(sprintf("%.2f",((sale[:cash_amount].to_f + sale[:credit_amount].to_f + sale[:card_amount].to_f + sale[:credit_payment].to_f) - sale[:today_credit_payment].to_f) ).to_f, :delimiter => ',') %> +
Grand Total<%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit_payment ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",card ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",discount ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_tax ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_other_charges ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",foc ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",void ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f", (cash.to_f + credit.to_f + card.to_f + credit_payment.to_f) - today_credit_payment_amount.to_f ).to_f, :delimiter => ',') %>
+
+
\ No newline at end of file From 967d0350979abba96f8703db144cb92d70dc10d1 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 12 Jun 2017 18:31:42 +0630 Subject: [PATCH 61/71] change dob --- app/controllers/crm/customers_controller.rb | 8 ++++---- app/controllers/origami/customers_controller.rb | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index c33db2e1..525302c8 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -63,7 +63,7 @@ class Crm::CustomersController < BaseCrmController name = customer_params[:name] phone = customer_params[:contact_no] email = customer_params[:email] - date_of_birth = customer_params[:date_of_birth] + dob = customer_params[:date_of_birth] member_group_id = params[:member_group_id] membership = MembershipSetting.find_by_membership_type("paypar_url") @@ -72,7 +72,7 @@ class Crm::CustomersController < BaseCrmController 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, + dob: dob, member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', @@ -123,7 +123,7 @@ end name = customer_params[:name] phone = customer_params[:contact_no] email = customer_params[:email] - date_of_birth = customer_params[:date_of_birth] + dob = customer_params[:date_of_birth] id = @crm_customer.membership_id member_group_id = params[:member_group_id] @@ -133,7 +133,7 @@ end 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, + dob: dob, id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index a1a067fe..30ead5b0 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -28,9 +28,6 @@ class Origami::CustomersController < BaseOrigamiController # 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" } From e1e7064e47cc7a36b3449729fe6270a70d897f79 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 12 Jun 2017 18:33:09 +0630 Subject: [PATCH 62/71] add menu in Transaction --- app/models/order.rb | 1 - app/views/layouts/_header.html.erb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 5a4d6e2d..d3a3536d 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -244,7 +244,6 @@ 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("sales.sale_status='completed'") -<<<<<<< HEAD .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index bdd146b7..c5bd61e0 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -27,8 +27,8 @@