From ed17e5fd326ea4ca949fcf2b6610821d1c8f11f8 Mon Sep 17 00:00:00 2001 From: Nweni Date: Fri, 1 Sep 2017 09:40:50 +0630 Subject: [PATCH 1/8] Update --- dump.rdb | Bin 777 -> 777 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/dump.rdb b/dump.rdb index c92644232990e62aed0295b08f00a1ce8d263f35..0d22b51fd1d80209ebb112324c3d28de42fd095e 100644 GIT binary patch delta 73 zcmV-P0Ji^$28jlcFc`4fr&;<4b#rB8Ep26O!XV%k0R8~`5do8q0vWMk8vz52Bd?Qx f0WS Date: Fri, 1 Sep 2017 16:03:55 +0630 Subject: [PATCH 2/8] update item edit --- app/controllers/origami/sale_edit_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 900b0431..939e1cbf 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -77,7 +77,9 @@ class Origami::SaleEditController < BaseOrigamiController saleitemObj.unit_price = update_price saleitemObj.taxable_price = update_qty.to_f * update_price.to_f # saleitemObj.remark = 'edit' - saleitemObj.product_name = saleitemObj.product_name + " - updated" + if !saleitemObj.product_name.include? "updated" + saleitemObj.product_name = saleitemObj.product_name + " - updated" + end saleitemObj.save # re-calc tax From 2eaf89174847a6a9be5729d1df42ec832e5ef213 Mon Sep 17 00:00:00 2001 From: Phyo Date: Mon, 4 Sep 2017 10:22:54 +0630 Subject: [PATCH 3/8] Promotion multiple order --- app/models/promotion.rb | 34 ++++++++++++-------- app/views/settings/promotions/_form.html.erb | 30 ++++++++--------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/app/models/promotion.rb b/app/models/promotion.rb index dfab86e9..624818f1 100644 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -28,8 +28,13 @@ class Promotion < ApplicationRecord end def self.combine_item(saleObj) - order_id = saleObj.sale_orders[0].order_id - itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty) + # order_id = saleObj.sale_orders[0].order_id + # itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty) + itemList = [] + saleObj.sale_orders.each do |so| + itemList << OrderItem.where("order_id = ?",so.order_id).group(:item_instance_code).sum(:qty) + end + return itemList end def self.is_promo_day(promoList, day, orderitemList, sale_id) @@ -46,13 +51,15 @@ class Promotion < ApplicationRecord def self.find_promo_item(promo, orderitem, sale_id) # item_code = OrderItem.find_by_item_instance_code(orderitem[0]).item_code - if promo.original_product.to_s == orderitem[0] - if promo.min_qty.to_i > orderitem[1].to_i - return false - else - check_promo_type(promo,orderitem, sale_id) - end - end + orderitem.each do |odr_item| + if promo.original_product.to_s == odr_item[0] + if promo.min_qty.to_i > odr_item[1].to_i + return false + else + check_promo_type(promo,odr_item, sale_id) + end + end + end end def self.check_promo_type(promo, orderitem, sale_id) @@ -126,7 +133,6 @@ class Promotion < ApplicationRecord # AA - 10 # 3 # BB # orderList, #S34345 def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id) puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s - byebug promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty foc_qty = find_second_item_qty(sale_id, promo_product) if (foc_qty < promotion_qty) @@ -212,9 +218,11 @@ class Promotion < ApplicationRecord saleObj = Sale.find_by_sale_id(sale_id) itemList = combine_item(saleObj) itemList.each do |item| - if item[0] == promo_item - return item[1] - end + item.each do |i| + if i[0] == promo_item + return i[1] + end + end end return 0 end diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index bea1f981..c832461d 100644 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -41,16 +41,16 @@
- <%= f.hidden_field :promo_day, :value => "", :class => "form-control col-md-1" %> -
Sun
-
Mon
-
Tue
-
Wed
-
Thu
-
Fri
-
Sat
+ <%= f.hidden_field :promo_day, :value => "", :class => "form-control col-md-1" %> +
Sun
+
Mon
+
Tue
+
Wed
+
Thu
+
Fri
+
Sat
- +
<%= f.input :promo_type,input_html: { class: "" }, @@ -166,13 +166,13 @@ $(document).ready(function(){ var form = document.getElementById("new_promotion"); - var inputs = form.getElementsByTagName("input"); + var inputs = $("input"); var arr = []; var count = 0; var day = "["; - -$(".select").click(function() { - + +$(".selectDay").click(function() { + // debugger; day = "["; for (var j = 8; j <=15; j += 1){ @@ -192,8 +192,8 @@ $(".select").click(function() { } document.getElementById("promotion_promo_day").value = ''; document.getElementById("promotion_promo_day").value = day; - }); - + }); + $("#promotion_original_product").select2(); $(".item_code_place").select2(); $(".item_code_place").on('change', function(event) { From 98dae6d712d6ab7f0f80ffc58e4a18caf13b2c73 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Mon, 4 Sep 2017 10:24:24 +0630 Subject: [PATCH 4/8] show and update changes in commission and report --- .idea/workspace.xml | 482 ++++++++++-------- .../origami/sale_edit_controller.rb | 11 +- app/models/product_commission.rb | 32 +- .../load_commissioners.html.erb | 2 +- app/views/reports/commission/index.html.erb | 14 +- app/views/settings/commissions/_form.html.erb | 2 +- dump.rdb | Bin 777 -> 908 bytes 7 files changed, 306 insertions(+), 237 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0840cec0..7d13c01d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,13 @@ + + + + + + @@ -17,7 +23,7 @@ - + @@ -44,21 +50,11 @@ - + - - - - - - - - - - - - + + @@ -67,8 +63,18 @@ - - + + + + + + + + + + + + @@ -77,18 +83,68 @@ - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -129,8 +185,6 @@ @@ -204,10 +260,10 @@ - @@ -227,9 +283,6 @@ - - - @@ -291,6 +344,21 @@ + + + + + + + + + + + + + + + @@ -321,6 +389,9 @@ @@ -783,12 +779,12 @@ - + - @@ -810,7 +806,7 @@ - + @@ -879,39 +875,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -969,13 +937,6 @@ - - - - - - - @@ -990,20 +951,6 @@ - - - - - - - - - - - - - - @@ -1011,20 +958,6 @@ - - - - - - - - - - - - - - @@ -1069,13 +1002,6 @@ - - - - - - - @@ -1083,13 +1009,6 @@ - - - - - - - @@ -1190,14 +1109,6 @@ - - - - - - - - @@ -1222,14 +1133,6 @@ - - - - - - - - @@ -1248,8 +1151,114 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb index ff76d3b1..d78ef348 100644 --- a/app/controllers/origami/in_juties_controller.rb +++ b/app/controllers/origami/in_juties_controller.rb @@ -16,8 +16,7 @@ class Origami::InJutiesController < BaseOrigamiController # GET /in_juties/1 # GET /in_juties/1.json - def show - end + def show; end # GET /in_juties/new def new @@ -29,8 +28,7 @@ class Origami::InJutiesController < BaseOrigamiController end # GET /in_juties/1/edit - def edit - end + def edit; end def edit_in_juty @in_juty = InJuty.find(params[:id]) @@ -71,7 +69,7 @@ class Origami::InJutiesController < BaseOrigamiController out_time = out_time.change(offset: '+06:30') @in_juty = InJuty.new in_juty_id = in_juty[:id] - unless in_juty_id.nil? + unless in_juty_id.empty? @in_juty = InJuty.find(in_juty_id.to_i) end diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb index ada68f59..74dd8095 100644 --- a/app/controllers/origami/product_commissions_controller.rb +++ b/app/controllers/origami/product_commissions_controller.rb @@ -1,4 +1,4 @@ -class Origami::ProductCommissionsController < ApplicationController +class Origami::ProductCommissionsController < BaseOrigamiController before_action :set_product_commission, only: [:show, :edit, :update, :destroy] # GET /product_commissions diff --git a/app/views/inventory/inventory_definitions/_form.html.erb b/app/views/inventory/inventory_definitions/_form.html.erb index 36b80822..66c073ad 100644 --- a/app/views/inventory/inventory_definitions/_form.html.erb +++ b/app/views/inventory/inventory_definitions/_form.html.erb @@ -4,6 +4,47 @@
<%= f.input :item_code %> + +
+ <% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> + <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
+ + + +
+ + <% sample = [] %> + <% if @inventory_definition.item_code.nil? %> + <% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %> + <% sample = MenuItemInstance.where("item_instance_code=?",@inventory_definition.item_code).pluck(:item_instance_name,:item_instance_code)%> + <% else %> + <% sample = Product.where("item_code=?",@inventory_definition.item_code).pluck(:name,:item_code)%> + <% end %> + <% end %> +
<%= f.input :item_code, collection: sample %>
+ +
<%= f.input :min_qty %>
+
+ <%= f.input :min_order_level %> <%= f.input :max_stock_level %>
diff --git a/app/views/origami/in_juties/_assign_in_juty.html.erb b/app/views/origami/in_juties/_assign_in_juty.html.erb index b6363195..21bf2e2d 100644 --- a/app/views/origami/in_juties/_assign_in_juty.html.erb +++ b/app/views/origami/in_juties/_assign_in_juty.html.erb @@ -4,22 +4,11 @@ <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
- <%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %> - - - <%= @table.name %> -
-
- <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %> -

- <%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %> - <%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %> -

diff --git a/app/views/origami/in_juties/_form.html.erb b/app/views/origami/in_juties/_form.html.erb index 9bed9152..61342d7b 100644 --- a/app/views/origami/in_juties/_form.html.erb +++ b/app/views/origami/in_juties/_form.html.erb @@ -4,22 +4,15 @@ <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
- - <%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %> - <%= @table.name %> -
-
- +

+ <%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %> <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %> -

- +
<%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %> - <%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %> -

diff --git a/app/views/origami/in_juties/index_in_juty.html.erb b/app/views/origami/in_juties/index_in_juty.html.erb index 52d79c89..421e8a7f 100644 --- a/app/views/origami/in_juties/index_in_juty.html.erb +++ b/app/views/origami/in_juties/index_in_juty.html.erb @@ -1,6 +1,10 @@
-
+
+ + <%= @table.name %> +
+ @@ -33,11 +37,11 @@
<%= render 'form', in_juty: @in_juty, table: @table %>
- -
-      - +
+ + +