From fd1bfb7c0e9ebd0c7463af632d4ec96309791829 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 23 Aug 2017 10:24:26 +0630 Subject: [PATCH 1/7] load commissioner --- .idea/workspace.xml | 671 ++++++++++++------ .../origami/commissions_controller.rb | 15 + app/models/commission.rb | 2 + app/models/commissioner.rb | 4 +- app/models/employee.rb | 3 +- app/models/product.rb | 3 +- .../_commissioners_form.html.erb | 16 + .../origami/commissioners/_form.html.erb | 5 +- .../origami/commissioners/index.html.erb | 40 +- app/views/origami/commissioners/show.html.erb | 8 +- .../commissions/load_commissioners.html.erb | 217 ++++++ app/views/origami/home/show.html.erb | 6 + config/routes.rb | 3 + 13 files changed, 738 insertions(+), 255 deletions(-) create mode 100644 app/views/origami/commissioners/_commissioners_form.html.erb create mode 100644 app/views/origami/commissions/load_commissioners.html.erb diff --git a/.idea/workspace.xml b/.idea/workspace.xml index de9b54ce..feb2e6c0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,10 +3,16 @@ - - - + + + + + + + + + @@ -23,74 +29,91 @@ - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + + - - + + + + + + + + + + + + @@ -106,6 +129,13 @@ void red origami + order + orders + table + tables + sale_edit#edit + @saleobj + edit @@ -132,25 +162,31 @@ @@ -161,10 +197,10 @@ DEFINITION_ORDER - @@ -184,8 +220,21 @@ - + + + + + + + + + + @@ -297,11 +346,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + @@ -397,6 +589,7 @@ + @@ -732,35 +925,37 @@ - + + + - - + - + - + - - + - + - - + + - + + @@ -774,14 +969,6 @@ - - - - - - - - @@ -805,13 +992,6 @@ - - - - - - - @@ -819,13 +999,6 @@ - - - - - - - @@ -842,14 +1015,6 @@ - - - - - - - - @@ -857,27 +1022,10 @@ - - - - - - - - - - - - - - - - - @@ -885,15 +1033,6 @@ - - - - - - - - - @@ -905,59 +1044,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -965,7 +1055,6 @@ - @@ -973,7 +1062,6 @@ - @@ -981,7 +1069,6 @@ - @@ -989,31 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1021,7 +1083,6 @@ - @@ -1029,7 +1090,6 @@ - @@ -1037,7 +1097,6 @@ - @@ -1045,17 +1104,185 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/origami/commissions_controller.rb b/app/controllers/origami/commissions_controller.rb index fdd1bf73..a10e59c6 100644 --- a/app/controllers/origami/commissions_controller.rb +++ b/app/controllers/origami/commissions_controller.rb @@ -61,6 +61,21 @@ class Origami::CommissionsController < BaseOrigamiController end end + def load_commissioners + sale_id = params[:sale_id] + @table_id = params[:table_id] + @saleobj = Sale.find(sale_id) + + @commissioners = [] + end + + def select_sale_item + byebug + sale_item_id = params[:sale_item_id] + @sale_item = SaleItem.find_by_sale_item_id(sale_item_id) + @commissioners = Commissioner.active.all + end + private # Use callbacks to share common setup or constraints between actions. def set_commission diff --git a/app/models/commission.rb b/app/models/commission.rb index 8d14db70..48f73f87 100644 --- a/app/models/commission.rb +++ b/app/models/commission.rb @@ -1,2 +1,4 @@ class Commission < ApplicationRecord + belongs_to :product, foreign_key: 'product_id' + has_many :commissioners end diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb index c6d4ab4c..ac199468 100644 --- a/app/models/commissioner.rb +++ b/app/models/commissioner.rb @@ -1,3 +1,5 @@ class Commissioner < ApplicationRecord - has_many :employees + belongs_to :employee, foreign_key: 'emp_id' + belongs_to :commission, foreign_key: 'commission_type' + scope :active, -> { where(is_active: true) } end diff --git a/app/models/employee.rb b/app/models/employee.rb index a6b52f21..a12521cb 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -1,7 +1,8 @@ class Employee < ApplicationRecord has_secure_password - belongs_to :commissioner + has_many :commissioners has_many :shit_sales + validates_presence_of :name, :role validates_presence_of :password, :on => [:create] validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true diff --git a/app/models/product.rb b/app/models/product.rb index 8f6811e2..fed8ee97 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,6 +1,7 @@ class Product < ApplicationRecord validates_presence_of :name - + has_many :commissions + # Product Image Uploader mount_uploader :image_path, ProductImageUploader end diff --git a/app/views/origami/commissioners/_commissioners_form.html.erb b/app/views/origami/commissioners/_commissioners_form.html.erb new file mode 100644 index 00000000..10637a82 --- /dev/null +++ b/app/views/origami/commissioners/_commissioners_form.html.erb @@ -0,0 +1,16 @@ +
+
+
COMMISSIONERS
+
+
+
+ <% @commissioners.each do |commissioner| %> +
+
+ <%= commissioner.name %> +
+
+ <% end %> +
+
+
diff --git a/app/views/origami/commissioners/_form.html.erb b/app/views/origami/commissioners/_form.html.erb index 4c2a17f8..3923d564 100644 --- a/app/views/origami/commissioners/_form.html.erb +++ b/app/views/origami/commissioners/_form.html.erb @@ -5,8 +5,9 @@
<%= f.input :name %> <%= f.label :emp_id %> - <%= f.collection_select :emp_id, Employee.all.order('name asc'), :emp_id, :name, {prompt: "Select an Employee"}, {class: "form-control"} %>
- <%= f.input :commission_type %> + <%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %>
+ <%= f.label :commission_type %> + <%= f.collection_select :commission_type, Commission.all, :id, :product_id, {prompt: 'Select Commission Type'}, class: 'form-control' %>
diff --git a/app/views/origami/commissioners/index.html.erb b/app/views/origami/commissioners/index.html.erb index baadb225..cf06ed6d 100644 --- a/app/views/origami/commissioners/index.html.erb +++ b/app/views/origami/commissioners/index.html.erb @@ -1,11 +1,11 @@
@@ -23,22 +23,18 @@ <% @commissioners.each do |commissioner| %> - - <%= commissioner.name %> - - <% if Employee.exists? %> - <% employee = Employee.where('emp_id=?',commissioner.emp_id) %> - <%= employee[0].name %> - <% end %> - - - <%= commissioner.commission_type %> - <%= commissioner.is_active %> - <%= link_to 'Show', origami_commissioner_path(commissioner) %> - <%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %> - <%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: { confirm: 'Are you sure?' } %> - + + <%= commissioner.name %> + + <%= commissioner.employee.name rescue '-' %> + + <%= commissioner.commission.product.name rescue '-' %> + <%= commissioner.is_active %> + <%= link_to 'Show', origami_commissioner_path(commissioner) %> + <%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %> + <%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %> + <% end %> - + diff --git a/app/views/origami/commissioners/show.html.erb b/app/views/origami/commissioners/show.html.erb index 83d5442b..1f9b2780 100644 --- a/app/views/origami/commissioners/show.html.erb +++ b/app/views/origami/commissioners/show.html.erb @@ -21,16 +21,12 @@ Employee Name - <% if Employee.exists? %> - <% employee = Employee.where('emp_id=?', @commissioner.emp_id) %> - <%= employee[0].name %> - <% end %> - + <%= @commissioner.employee.name rescue '-' %> Commission Type - <%= @commissioner.commission_type %> + <%= @commissioner.commission.product.name rescue '-' %> Active diff --git a/app/views/origami/commissions/load_commissioners.html.erb b/app/views/origami/commissions/load_commissioners.html.erb new file mode 100644 index 00000000..5252b1bd --- /dev/null +++ b/app/views/origami/commissions/load_commissioners.html.erb @@ -0,0 +1,217 @@ +
+ +
+ <%= render 'origami/commissioners/commissioners_form', commissioners: @commissioners %> +
+ + +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

Date: + <%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %> +

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + @saleobj.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + %> + +
#ItemsQTY + + Price + +
<%= count %> + <%= sale_item.product_name %> + + <%= sale_item.qty %> + + <%= sale_item.unit_price %> +
+
+ +
+
+
+ + +
+ + + +
+
+ diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a79c1ce1..1e39bd8d 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -572,6 +572,12 @@ window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit"; }); + $('#commissions').on('click', function () { + var dining_id = "<%= @dining.id %>" + var sale_id = "<%= @obj_sale.sale_id rescue "" %>" + window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners"; + }); + $('#void').on('click', function () { var sure = confirm("Are you sure want to Void"); if (sure == true) { diff --git a/config/routes.rb b/config/routes.rb index 7276e31f..8277e58f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,9 @@ Rails.application.routes.draw do post 'item_void_cancel' => "sale_edit#item_void_cancel" post 'cancel_all_void' => 'sale_edit#cancel_all_void' post 'apply_void' => 'sale_edit#apply_void' + # commissions + get '/table/:table_id/sale/:sale_id/load_commissioners' => 'commissions#load_commissioners', as: 'load_commissioners' + post 'select_sale_item' => 'commissions#select_sale_item' get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining" From 3132bc7c3448d414dfec198c3487aa02aec2c231 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 23 Aug 2017 11:14:24 +0630 Subject: [PATCH 2/7] commission update --- .idea/sxrestaurant.iml | 1 + .idea/workspace.xml | 302 ++++++++++-------- Gemfile | 1 + Gemfile.lock | 3 + app/assets/javascripts/application.js | 2 + app/assets/stylesheets/application.scss | 3 +- .../origami/commissions_controller.rb | 2 + app/models/commission.rb | 2 +- app/models/menu_item.rb | 2 + app/models/product.rb | 1 - app/views/origami/commissions/_form.html.erb | 6 +- app/views/origami/commissions/index.html.erb | 38 +-- app/views/origami/commissions/show.html.erb | 7 +- 13 files changed, 204 insertions(+), 166 deletions(-) diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml index e1c0cfaa..23c2b8f5 100644 --- a/.idea/sxrestaurant.iml +++ b/.idea/sxrestaurant.iml @@ -210,6 +210,7 @@ + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index feb2e6c0..1e51bfe8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,17 +2,19 @@ + + + + + - - + - - - - - + + + @@ -29,31 +31,51 @@ - - + + - - + + - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,58 +84,41 @@ - - + + - - + + - - + + - - + + - - - + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - + + @@ -163,12 +168,9 @@ @@ -927,12 +936,12 @@ - + - @@ -943,19 +952,19 @@ + + - - @@ -969,16 +978,6 @@ - - - - - - - - - - @@ -1058,20 +1057,6 @@ - - - - - - - - - - - - - - @@ -1178,28 +1163,6 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -1208,14 +1171,6 @@ - - - - - - - - @@ -1263,14 +1218,6 @@ - - - - - - - - @@ -1280,9 +1227,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + diff --git a/Gemfile b/Gemfile index 7b2cdca5..06b49df2 100644 --- a/Gemfile +++ b/Gemfile @@ -116,3 +116,4 @@ gem 'httparty', '~> 0.15.5' # # gem 'momentjs-rails', '>= 2.9.0' # gem 'bootstrap3-datetimepicker-rails'z gem 'bootstrap-datepicker-rails' +gem 'select2-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 912f79ef..602a5b15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -196,6 +196,8 @@ GEM tilt (>= 1.1, < 3) schema_to_scaffold (0.8.0) activesupport (>= 3.2.1) + select2-rails (4.0.3) + thor (~> 0.14) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) sidekiq (5.0.3) @@ -280,6 +282,7 @@ DEPENDENCIES rspec-rails (~> 3.5) sass-rails (~> 5.0) schema_to_scaffold + select2-rails shoulda-matchers (~> 3.1) sidekiq simple_form diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index cd056d1c..e0e5eba8 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,6 +20,8 @@ //= require settings/processing_items //= require jquery-ui //= require bootstrap-datepicker +//= require select2 +//= require select2-full $(document).on('turbolinks:load', function() { $('.datepicker').datepicker({ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1c5ada90..03e049b4 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -4,7 +4,8 @@ @import "theme"; @import "jquery-ui"; @import "bootstrap-datepicker3"; - +@import "select2"; +@import "select2-bootstrap"; /* Show it is fixed to the top */ // body { diff --git a/app/controllers/origami/commissions_controller.rb b/app/controllers/origami/commissions_controller.rb index a10e59c6..f18bd11e 100644 --- a/app/controllers/origami/commissions_controller.rb +++ b/app/controllers/origami/commissions_controller.rb @@ -15,10 +15,12 @@ class Origami::CommissionsController < BaseOrigamiController # GET /commissions/new def new @commission = Commission.new + @products = MenuItem.all end # GET /commissions/1/edit def edit + @products = MenuItem.all end # POST /commissions diff --git a/app/models/commission.rb b/app/models/commission.rb index 48f73f87..df11eb24 100644 --- a/app/models/commission.rb +++ b/app/models/commission.rb @@ -1,4 +1,4 @@ class Commission < ApplicationRecord - belongs_to :product, foreign_key: 'product_id' + belongs_to :menu_item, foreign_key: 'product_id' has_many :commissioners end diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 8213ae88..c581a7b0 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -3,6 +3,8 @@ class MenuItem < ApplicationRecord belongs_to :menu_category, :optional => true has_many :menu_item_instances + has_many :commissions + # belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true # has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" belongs_to :account diff --git a/app/models/product.rb b/app/models/product.rb index fed8ee97..5aff41f5 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,6 +1,5 @@ class Product < ApplicationRecord validates_presence_of :name - has_many :commissions # Product Image Uploader mount_uploader :image_path, ProductImageUploader diff --git a/app/views/origami/commissions/_form.html.erb b/app/views/origami/commissions/_form.html.erb index a5c0d2c0..1f7fee4a 100644 --- a/app/views/origami/commissions/_form.html.erb +++ b/app/views/origami/commissions/_form.html.erb @@ -4,11 +4,11 @@
<%= f.label :product_id %> - <%= f.collection_select :product_id, Product.all.order('name asc'), :id, :name, {prompt: "Select a Product"}, {class: "form-control"} %>
+ <%= f.collection_select :product_id, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %>
<%= f.input :amount %> - <%= f.input :commission_type, :collection => [:percentage, :net_amount] %> + <%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %> -
+
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %> <%= f.button :submit, class: 'btn btn-info' %> diff --git a/app/views/origami/commissions/index.html.erb b/app/views/origami/commissions/index.html.erb index e5a83639..da589347 100644 --- a/app/views/origami/commissions/index.html.erb +++ b/app/views/origami/commissions/index.html.erb @@ -1,11 +1,11 @@
@@ -23,22 +23,16 @@ <% @commissions.each do |commission| %> - - - <% if Product.exists? %> - <% product = Product.find(commission.product_id) %> - <%= product.name %> - <% end %> - - - <%= commission.amount %> - <%= commission.commission_type %> - <%= commission.is_active %> - <%= link_to 'Show', origami_commission_path(commission) %> - <%= link_to 'Edit', edit_origami_commission_path(commission) %> - <%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: { confirm: 'Are you sure?' } %> - + + <%= commission.menu_item.name rescue '-' %> + <%= commission.amount rescue '-' %> + <%= commission.commission_type rescue '-' %> + <%= commission.is_active rescue '-' %> + <%= link_to 'Show', origami_commission_path(commission) %> + <%= link_to 'Edit', edit_origami_commission_path(commission) %> + <%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %> + <% end %> - +
diff --git a/app/views/origami/commissions/show.html.erb b/app/views/origami/commissions/show.html.erb index da04710e..439e2c45 100644 --- a/app/views/origami/commissions/show.html.erb +++ b/app/views/origami/commissions/show.html.erb @@ -16,12 +16,7 @@ Product Name - - <% if Product.exists? %> - <% product = Product.find(@commission.product_id) %> - <%= product.name %> - <% end %> - + <%= @commission.menu_item.name rescue '-' %> Amount From d6b8e8bdee6acd49ab18489ef2d10e7e0ebaebe0 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 23 Aug 2017 11:36:36 +0630 Subject: [PATCH 3/7] update commissioner --- .idea/sxrestaurant.iml | 1 - .idea/workspace.xml | 281 +++++++----------- Gemfile | 1 - Gemfile.lock | 3 - app/assets/javascripts/application.js | 2 - app/assets/stylesheets/application.scss | 2 - .../origami/commissioners/index.html.erb | 2 +- 7 files changed, 113 insertions(+), 179 deletions(-) diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml index 23c2b8f5..e1c0cfaa 100644 --- a/.idea/sxrestaurant.iml +++ b/.idea/sxrestaurant.iml @@ -210,7 +210,6 @@ - diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1e51bfe8..70f67cc7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -8,13 +8,7 @@ - - - - - - - + @@ -31,94 +25,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -180,7 +121,6 @@ @@ -206,7 +147,7 @@ DEFINITION_ORDER - - - + @@ -1149,13 +1090,6 @@
- - - - - - - @@ -1171,14 +1105,6 @@ - - - - - - - - @@ -1242,57 +1168,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1312,15 +1187,83 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gemfile b/Gemfile index 06b49df2..7b2cdca5 100644 --- a/Gemfile +++ b/Gemfile @@ -116,4 +116,3 @@ gem 'httparty', '~> 0.15.5' # # gem 'momentjs-rails', '>= 2.9.0' # gem 'bootstrap3-datetimepicker-rails'z gem 'bootstrap-datepicker-rails' -gem 'select2-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 602a5b15..912f79ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -196,8 +196,6 @@ GEM tilt (>= 1.1, < 3) schema_to_scaffold (0.8.0) activesupport (>= 3.2.1) - select2-rails (4.0.3) - thor (~> 0.14) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) sidekiq (5.0.3) @@ -282,7 +280,6 @@ DEPENDENCIES rspec-rails (~> 3.5) sass-rails (~> 5.0) schema_to_scaffold - select2-rails shoulda-matchers (~> 3.1) sidekiq simple_form diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e0e5eba8..cd056d1c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,8 +20,6 @@ //= require settings/processing_items //= require jquery-ui //= require bootstrap-datepicker -//= require select2 -//= require select2-full $(document).on('turbolinks:load', function() { $('.datepicker').datepicker({ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 03e049b4..2db849ab 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -4,8 +4,6 @@ @import "theme"; @import "jquery-ui"; @import "bootstrap-datepicker3"; -@import "select2"; -@import "select2-bootstrap"; /* Show it is fixed to the top */ // body { diff --git a/app/views/origami/commissioners/index.html.erb b/app/views/origami/commissioners/index.html.erb index cf06ed6d..dfef0320 100644 --- a/app/views/origami/commissioners/index.html.erb +++ b/app/views/origami/commissioners/index.html.erb @@ -28,7 +28,7 @@ <%= commissioner.employee.name rescue '-' %> - <%= commissioner.commission.product.name rescue '-' %> + <%= commissioner.commission.menu_item.name rescue '-' %> <%= commissioner.is_active %> <%= link_to 'Show', origami_commissioner_path(commissioner) %> <%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %> From 248b80763389ef8bfba19c0b027c873c1f17deed Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 23 Aug 2017 13:59:27 +0630 Subject: [PATCH 4/7] Dining Charges Fix for free time --- app/models/dining_charge.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/models/dining_charge.rb b/app/models/dining_charge.rb index 75cf7d7b..b7be007d 100644 --- a/app/models/dining_charge.rb +++ b/app/models/dining_charge.rb @@ -3,19 +3,22 @@ class DiningCharge < ApplicationRecord belongs_to :room def self.amount_calculate(dining_charges_obj, checkin , checkout) - + # note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil? price = 0 minutes = DiningCharge.time_diff(checkout, checkin) - free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.strftime('%H:%M')) + free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M')) dining_minutes = minutes - free_time # stayminutes - free minutes - charge_type = dining_charges_obj.charge_type - if charge_type == 'hr' - price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr') - elsif charge_type == 'day' - price = charges(dining_charges_obj, dining_minutes, 'day') + if dining_minutes <= 0 + price = 0 + else + charge_type = dining_charges_obj.charge_type + if charge_type == 'hr' + price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr') + elsif charge_type == 'day' + price = charges(dining_charges_obj, dining_minutes, 'day') + end end - return price else puts "<<<<<<<< NO" @@ -25,14 +28,15 @@ class DiningCharge < ApplicationRecord def self.charges(chargesObj, dining_minutes, type) solid_price = 0 - block = DiningCharge.convert_to_minutes(chargesObj.charge_block.strftime('%H:%M')) + block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M')) + result = dining_minutes / block if result.to_i < 1 return chargesObj.unit_price elsif result.to_i >= 1 solid_price = result * chargesObj.unit_price remain_value = dining_minutes % block - rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.strftime('%H:%M')) + rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M')) roundingblock = remain_value / rounding_block if roundingblock.to_i < 1 return DiningCharge.check_rounding(chargesObj, solid_price) @@ -48,7 +52,7 @@ class DiningCharge < ApplicationRecord end end - def self.check_rounding(chargesObj) + def self.check_rounding(chargesObj,solid_price) if chargesObj.time_rounding == "down" return solid_price else From 874a9b60bec90d40b500b3ed927092435ceec744 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 23 Aug 2017 15:02:27 +0630 Subject: [PATCH 5/7] create InJuty --- .idea/.generators | 2 +- .idea/workspace.xml | 828 ++++++------------ .../origami/commissions_controller.rb | 91 -- .../origami/in_juties_controller.rb | 74 ++ app/helpers/origami/in_juties_helper.rb | 2 + app/models/in_juty.rb | 2 + app/views/origami/in_juties/_form.html.erb | 10 + .../origami/in_juties/_in_juty.json.jbuilder | 2 + app/views/origami/in_juties/edit.html.erb | 6 + app/views/origami/in_juties/index.html.erb | 25 + .../origami/in_juties/index.json.jbuilder | 1 + app/views/origami/in_juties/new.html.erb | 5 + app/views/origami/in_juties/show.html.erb | 4 + .../origami/in_juties/show.json.jbuilder | 1 + config/routes.rb | 1 + db/migrate/20170823081747_create_in_juties.rb | 11 + .../origami/in_juties_controller_spec.rb | 141 +++ spec/helpers/origami/in_juties_helper_spec.rb | 15 + spec/models/in_juty_spec.rb | 5 + .../origami/origami_in_juties_spec.rb | 10 + .../routing/origami/in_juties_routing_spec.rb | 39 + .../origami/in_juties/edit.html.erb_spec.rb | 14 + .../origami/in_juties/index.html.erb_spec.rb | 14 + .../origami/in_juties/new.html.erb_spec.rb | 14 + .../origami/in_juties/show.html.erb_spec.rb | 11 + 25 files changed, 692 insertions(+), 636 deletions(-) delete mode 100644 app/controllers/origami/commissions_controller.rb create mode 100644 app/controllers/origami/in_juties_controller.rb create mode 100644 app/helpers/origami/in_juties_helper.rb create mode 100644 app/models/in_juty.rb create mode 100644 app/views/origami/in_juties/_form.html.erb create mode 100644 app/views/origami/in_juties/_in_juty.json.jbuilder create mode 100644 app/views/origami/in_juties/edit.html.erb create mode 100644 app/views/origami/in_juties/index.html.erb create mode 100644 app/views/origami/in_juties/index.json.jbuilder create mode 100644 app/views/origami/in_juties/new.html.erb create mode 100644 app/views/origami/in_juties/show.html.erb create mode 100644 app/views/origami/in_juties/show.json.jbuilder create mode 100644 db/migrate/20170823081747_create_in_juties.rb create mode 100644 spec/controllers/origami/in_juties_controller_spec.rb create mode 100644 spec/helpers/origami/in_juties_helper_spec.rb create mode 100644 spec/models/in_juty_spec.rb create mode 100644 spec/requests/origami/origami_in_juties_spec.rb create mode 100644 spec/routing/origami/in_juties_routing_spec.rb create mode 100644 spec/views/origami/in_juties/edit.html.erb_spec.rb create mode 100644 spec/views/origami/in_juties/index.html.erb_spec.rb create mode 100644 spec/views/origami/in_juties/new.html.erb_spec.rb create mode 100644 spec/views/origami/in_juties/show.html.erb_spec.rb diff --git a/.idea/.generators b/.idea/.generators index 98526fe7..16189766 100644 --- a/.idea/.generators +++ b/.idea/.generators @@ -5,4 +5,4 @@ You are allowed to: 2. Remove generators 3. Add installed generators To add new installed generators automatically delete this file and reload the project. ---> +--> diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 70f67cc7..0ba2fcb2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,31 @@ - + + + + + + + + + + + + + + + + + + + + + + + - - - - - + @@ -25,11 +43,51 @@ - - + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + @@ -38,28 +96,18 @@ - - + + - - + + - - - - - - - - - - - - + + @@ -123,13 +171,11 @@ @@ -170,368 +221,49 @@ - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +