From 4b97cd530e13b9ae7189ccbec1e95d9c2139201c Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Tue, 29 Aug 2017 23:05:03 +0630 Subject: [PATCH 1/3] commission report export excel --- .idea/sxrestaurant.iml | 1 + .idea/workspace.xml | 241 +++++++----------- .../reports/commission_controller.rb | 10 +- .../_commission_report_filter.html.erb | 46 ++-- dump.rdb | Bin 741 -> 742 bytes 5 files changed, 139 insertions(+), 159 deletions(-) diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml index 7db49a58..6c1240f7 100644 --- a/.idea/sxrestaurant.iml +++ b/.idea/sxrestaurant.iml @@ -52,6 +52,7 @@ + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e3687c57..1c0d6110 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,18 +5,8 @@ - - - - - - - - - - @@ -58,10 +48,10 @@ - + - + @@ -82,34 +72,21 @@ - + - - + + - - - - - - - - - - - - - - - + + @@ -125,36 +102,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -189,7 +136,6 @@ @@ -264,10 +211,9 @@ - @@ -336,6 +282,21 @@ + + + + + + + + + + + + + + + + <% if @daterange %> + + <% else %> + + <% end %>
+
+ +
<% end %> @@ -35,21 +46,26 @@ placeholder: 'Select Commissioner' }); + $('#clear_filter').click(function () { + $('#daterange').val(''); + $('#commissioner').val('').text(''); + }); + $('input[name="daterange"]').daterangepicker({ - autoUpdateInput: false, - ranges: { - 'Today': [moment(), moment()], - 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], - 'Last 7 Days': [moment().subtract(6, 'days'), moment()], - 'Last 30 Days': [moment().subtract(29, 'days'), moment()], - 'This Month': [moment().startOf('month'), moment().endOf('month')], - 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] + autoUpdateInput: false, + ranges: { + 'Today': [moment(), moment()], + 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], + 'Last 7 Days': [moment().subtract(6, 'days'), moment()], + 'Last 30 Days': [moment().subtract(29, 'days'), moment()], + 'This Month': [moment().startOf('month'), moment().endOf('month')], + 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] + }, + locale: { + format: 'YYYY-MM-DD' + } }, - locale: { - format: 'YYYY-MM-DD' - } - }, - function(start, end, label) { + function (start, end, label) { $('input[name="daterange"]').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD')); }); diff --git a/dump.rdb b/dump.rdb index 569086721543bccef2d9a99dfea5def07e5e1b65..dfef99fa9e38d3f64010e723188ff089a36840af 100644 GIT binary patch delta 76 zcmV-S0JHz)1?B~iFc@K%rCIt2b#rB8Ep26O!f@af0R8~`4*`*X7qMSo0R&()*eIjq(>$MjJ=~ delta 75 zcmV-R0JQ(+1?2^hFc@%IrCIt2b#rB8Ep26O!a%4Q0R8~`4*`*X7qMSo0R+B7<}I_r h0SN&b5HU3{G%zqYH8nUcIW#gdHviTV*MILVLMkk88n*xd From 2208b8a526d00535508cc73640ae01b2f664bd8e Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 30 Aug 2017 09:20:35 +0630 Subject: [PATCH 2/3] Promo Phrase 1 --- app/models/promotion.rb | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/app/models/promotion.rb b/app/models/promotion.rb index 482d2c3b..98321078 100644 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -28,7 +28,8 @@ class Promotion < ApplicationRecord end def self.combine_item(saleObj) - itemList = saleObj.sale_items.group(:product_code).sum(:qty) + order_id = saleObj.sale_orders[0].order_id + itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty) end def self.is_promo_day(promoList, day, orderitemList, sale_id) @@ -44,7 +45,8 @@ class Promotion < ApplicationRecord end def self.find_promo_item(promo, orderitem, sale_id) - if promo.original_product.to_s == orderitem[0].to_s + item_code = OrderItem.find_by_item_instance_code(orderitem[0]).item_code + if promo.original_product.to_s == item_code if promo.min_qty.to_i > orderitem[1].to_i return false else @@ -75,7 +77,7 @@ class Promotion < ApplicationRecord def self.check_giveaway_product(promo, orderitem) promo.promotion_products.each do |promo_product| - if promo_product.item_code == orderitem + if promo_product.item_code == OrderItem.find_by_item_instance_code(orderitem).item_code return true, promo_product else return false, promo_product @@ -110,7 +112,13 @@ class Promotion < ApplicationRecord else charge_qty += qty end - item = OrderItem.find_by_item_code(orderitem[0]) + item = OrderItem.find_by_item_instance_code(orderitem[0]) + byebug + # if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_code + # item = OrderItem.find_by_item_instance_code(orderitem[0]) + # else + # item = OrderItem.find_by_item_code(promo_product) + # end update_existing_item(foc_qty, item, sale_id, "promotion", item.price) puts "Charged - " + charge_qty.to_s @@ -124,7 +132,7 @@ class Promotion < ApplicationRecord if (foc_qty < promotion_qty) promotion_qty = foc_qty end - item = OrderItem.find_by_item_code(promo_product) + item = OrderItem.find_by_item_instance_code(promo_product,orderID) update_existing_item(promotion_qty, item, sale_id, "promotion", item.price) end @@ -156,11 +164,11 @@ class Promotion < ApplicationRecord if same foc_qty = orderitem[1].to_i / foc_min_qty - item = OrderItem.find_by_item_code(orderitem[0]) + item = OrderItem.find_by_item_instance_code(orderitem[0]) update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) - item = OrderItem.find_by_item_code(promo_product.item_code) + item = OrderItem.find_by_item_instance_code(promo_product.item_code) update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off) end end @@ -170,12 +178,12 @@ class Promotion < ApplicationRecord if same foc_qty = orderitem[1].to_i / foc_min_qty - item = OrderItem.find_by_item_code(orderitem[0]) # need to specify with menu item instance + item = OrderItem.find_by_item_instance_code(orderitem[0]) # need to specify with menu item instance price = item.price.to_i - promo_product.net_price.to_i update_existing_item(foc_qty, item, sale_id, "promotion nett price", price) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) - item = OrderItem.find_by_item_code(promo_product.item_code) + item = OrderItem.find_by_item_instance_code(promo_product.item_code) price = item.price - promo_product.net_price update_existing_item(foc_qty, item, sale_id, "promotion nett price", price) end @@ -186,14 +194,14 @@ class Promotion < ApplicationRecord if same foc_qty = orderitem[1].to_i / foc_min_qty - item = OrderItem.find_by_item_code(orderitem[0]) + item = OrderItem.find_by_item_instance_code(orderitem[0]) # total = orderitem[1].to_i * item.price total = item.price price = calculate_discount(total, promo_product.percentage) update_existing_item(foc_qty, item, sale_id, "promotion discount", price) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) - item = OrderItem.find_by_item_code(promo_product.item_code) + item = OrderItem.find_by_item_instance_code(promo_product.item_code) # total = item.price * foc_qty total = item.price price = calculate_discount(total, promo_product.percentage) @@ -205,7 +213,7 @@ class Promotion < ApplicationRecord saleObj = Sale.find_by_sale_id(sale_id) itemList = combine_item(saleObj) itemList.each do |item| - if item[0] == promo_item + if OrderItem.find_by_item_instance_code(item[0]).item_code == promo_item return item[1] end end From df4caa288d1db5e5f02feb3674dbdb0c601fad50 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 30 Aug 2017 10:46:46 +0630 Subject: [PATCH 3/3] jquery date-time picker --- .idea/.generators | 2 +- .idea/sxrestaurant.iml | 4 +- .idea/workspace.xml | 315 +++++++++++------- Gemfile | 16 +- Gemfile.lock | 29 +- app/assets/javascripts/application.js | 5 +- app/assets/stylesheets/application.scss | 4 +- .../origami/in_juties_controller.rb | 19 +- .../in_juties/_assign_in_juty.html.erb | 73 ++-- .../origami/in_juties/index_in_juty.html.erb | 87 +++-- app/views/settings/promotions/new.html.erb | 1 - dump.rdb | Bin 742 -> 797 bytes 12 files changed, 283 insertions(+), 272 deletions(-) diff --git a/.idea/.generators b/.idea/.generators index 16189766..98526fe7 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/sxrestaurant.iml b/.idea/sxrestaurant.iml index 6c1240f7..53fef9e5 100644 --- a/.idea/sxrestaurant.iml +++ b/.idea/sxrestaurant.iml @@ -52,7 +52,6 @@ - @@ -66,7 +65,6 @@ - @@ -82,7 +80,7 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1c0d6110..705b1a97 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,10 +3,17 @@ + - - + + + + + + + + @@ -21,7 +28,7 @@ - + @@ -48,55 +55,85 @@
- - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -136,12 +173,8 @@ @@ -211,6 +248,7 @@ +