From 6f57bb8a7952c080d46de2a74883def37f82da4a Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 13 Jul 2017 11:12:02 +0630 Subject: [PATCH 1/5] adding shift sale summary --- app/assets/stylesheets/origami.scss | 12 ++++++----- app/controllers/origami/shifts_controller.rb | 5 +++++ app/views/origami/home/index.html.erb | 21 ++++++++++++++------ config/routes.rb | 1 + 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 7935b50e..a7b25b7a 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -10,7 +10,8 @@ // padding-top: 4.5rem; // } .card-columns { - font-size: 18px !important;} + font-size: 18px !important; +} .others-payment{ line-height:100px; @@ -53,7 +54,8 @@ .payment{ height:70px;line-height:70px; - align:center;color:white; + align:center; + color:white; font-size:16px; margin-top:5px; } @@ -161,15 +163,15 @@ } .green{ - background-color: #009900 + background-color: #009900; } .orange{ - background-color: #FF8C00 + background-color: #FF8C00; } .blue{ - background-color: blue + background-color: blue; } /* End Colors */ diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 92f174ae..1f085ac8 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -48,4 +48,9 @@ class Origami::ShiftsController < BaseOrigamiController def edit end + def sale_summary + @shift = ShiftSale.current_open_shift(current_user.id) + + end + end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 6bdadd85..3afea88d 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -105,9 +105,10 @@
- - - + + + +
@@ -116,20 +117,28 @@ $(document).ready(function(){ $(".tables").on('click', function(){ var dining_id = $(this).attr("data-id"); window.location.href = '/origami/table/' + dining_id; - }) + }); + $(".sales").on('click',function(){ var sale_id = $(this).attr("data-id"); window.location.href = '/origami/sale/' + sale_id; - }) + }); + $(".rooms").on('click', function(){ var dining_id = $(this).attr("data-id"); window.location.href = '/origami/room/' + dining_id; - }) + }); + $(".orders").on('click',function(){ var order_id = $(this).attr("data-id"); window.location.href = '/origami/order/' + order_id; + }); + + $('#sale_summary').on('click',function(){ + window.location.href = '/origami/shift/sale_summary'; }) }); + $(function() { var timer; diff --git a/config/routes.rb b/config/routes.rb index b9549c06..d285cc2e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,6 +114,7 @@ Rails.application.routes.draw do resources :shifts, only: [:index, :new, :create, :edit] post 'close_shift' => 'shifts#update_shift' get 'shift/close' => 'shifts#show' + get 'shift/sale_summary' => 'shifts#sale_summary' #shift - index (open/close shift landing page) #shift - show (sales summary display) #shift - new (open shift) From 0b7b5cae308c4d1ce3954b92c36b496692a92038 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 14 Jul 2017 17:23:40 +0630 Subject: [PATCH 2/5] update osaka demo bugs --- app/assets/images/ajax-loader.gif | Bin 0 -> 673 bytes app/assets/stylesheets/origami.scss | 26 ++++++++++++++++++ .../origami/discounts_controller.rb | 6 ++-- app/controllers/origami/home_controller.rb | 4 +-- app/controllers/origami/orders_controller.rb | 2 +- .../origami/payments_controller.rb | 4 +-- app/controllers/origami/rooms_controller.rb | 5 +--- app/controllers/origami/sales_controller.rb | 2 +- app/models/ability.rb | 4 +-- app/views/crm/customers/_new_form.html.erb | 4 +-- app/views/origami/customers/index.html.erb | 4 +-- app/views/origami/discounts/index.html.erb | 20 ++++++-------- .../origami/moveroom/move_dining.html.erb | 8 +++--- .../origami/movetable/move_dining.html.erb | 8 +++--- app/views/origami/orders/show.html.erb | 6 ++-- app/views/origami/payments/show.html.erb | 17 +++++++++--- app/views/origami/rooms/show.html.erb | 2 +- app/views/origami/shifts/new.html.erb | 2 +- .../membership_settings/_form.html.erb | 1 - .../membership_settings/index.html.erb | 2 -- .../order_queue_stations/show.html.erb | 2 +- public/image/loading-ajax.gif | Bin 0 -> 1915 bytes 22 files changed, 76 insertions(+), 53 deletions(-) create mode 100644 app/assets/images/ajax-loader.gif create mode 100755 public/image/loading-ajax.gif diff --git a/app/assets/images/ajax-loader.gif b/app/assets/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..4155add2f6d489085271c5c0594173867322cb98 GIT binary patch literal 673 zcmZ?wbhEHb6krfw_{6}lbITS628Q0wP6ItXAj93&H7+J5D?MHDpOkY^YGO%hib8p2 zNrpmVR$@g?eqxGVW?ou8gW^vX1}>m-#sA!Xt|7tBjsdPldIrplKp`C<1{y8Ez`$(G zvFpx1gHxW_!pR&~9FlX`{br!EJg8M-CNU(2bU`yt|CuQi6xwEBm0kDgA6GgcSKeBe5>d9Tc| z71~UZZ^i#GHXr6UTA3m>e?JSwJS>JT?TIpi ztK6D4T$E={3X1(~D{o+-Bh`OmNs*-w%x^5n<`{A8DpJ?>dY&TkLE^JdBad3y;e?o^ zkSVP#JLNJWoixv%au8sadubzoSPg7W&?J~KtjNXyouhDQf~EN5lIMGF%`=cZF7rT9 z&uQD-Q{ihC8S=1kixemB-eCHDDr2L;2F}ji^K&)5VCJwPn*(&toqr!V1#iv?jh)5# z?p9&J)P#<^iF59nOlx&?J8B>@Az}75MqZXf4g#|c8xCDNHxXtGJBBg9m|vahbY+g_ wbvX`>!wP-J3;9?K4OX7our5I25HPyJZY^a}C{2=RninlNfq}sqlyJZR09f(P*8l(j literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 7935b50e..ffd8aded 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -211,3 +211,29 @@ tr.discount-item-row:hover { margin-left:-40px !important; margin-top:-40px !important; } + +/*Loading gif for payment*/ + +#loading_wrapper{ + + position: fixed; + background-color: #C8C8C8 ; + height: 100%; + width: 100%; + left: 0; + opacity: 0.6; + top: 0; + z-index: 9999999; +} +#loading{ + position: relative; + height: 100%; + width: 100%; + background-image: url('../../../image/loading-ajax.gif'); + background-position: center center; + background-repeat: no-repeat; + opacity: 1; + filter: alpha(opacity=100); /* ie */ + -moz-opacity: 1; /* mozilla */ + +} \ No newline at end of file diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 4645ff1d..f7e1c63a 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -189,15 +189,15 @@ class Origami::DiscountsController < BaseOrigamiController discount_amount = discount_amount + response["discount_bonus_earned"] end sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount') - result = {:status=> "Success", :table_id => table_id,:table_type => table_type } + result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type } end if response["status"] == "500" - result = {:status=> response["error"], :table_id => table_id,:table_type => table_type } + result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type } end if !response.nil? if response[:status] == false - result = {:status=> response[:message], :table_id => table_id,:table_type => table_type } + result = {:status=> response[:message],:title=>"Alert", :table_id => table_id,:table_type => table_type } end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 32f4ab12..7ee03e47 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController def index @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.all + @complete = Sale.where("sale_status != 'new'") @orders = Order.all.order('date desc') # @shift = ShiftSale.current_open_shift(current_user.id) end @@ -13,7 +13,7 @@ class Origami::HomeController < BaseOrigamiController def show @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.all + @complete = Sale.where("sale_status != 'new'") @orders = Order.all.order('date desc') @status_order = "" @status_sale = "" diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index ef213ddd..f3cddd74 100644 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -3,7 +3,7 @@ class Origami::OrdersController < BaseOrigamiController def show @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.all + @complete = Sale.where("sale_status != 'new'") @orders = Order.all.order('status desc') @order = Order.find(params[:order_id]) sale_order = SaleOrder.find_by_order_id(@order.order_id) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index df1fbfcb..24d63b71 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -91,9 +91,9 @@ class Origami::PaymentsController < BaseOrigamiController #get customer amount @customer = Customer.find(@sale_data.customer_id) - + rebate = MembershipSetting.find_by_rebate(1) # get member information - if @customer.membership_id != nil + if @customer.membership_id != nil && rebate response = Customer.get_member_account(@customer) if response["status"]==true response["data"].each do |res| diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index e5728f99..823136b9 100644 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -3,7 +3,7 @@ class Origami::RoomsController < BaseOrigamiController def show @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.all + @complete = Sale.where("sale_status != 'new'") @orders = Order.all.order('date desc') @room = DiningFacility.find(params[:room_id]) @sale_array = Array.new @@ -31,9 +31,6 @@ class Origami::RoomsController < BaseOrigamiController end end end - puts "hhhhhhhhhh" - puts @status - puts @obj.to_json end diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index c397da0f..3a9586fb 100644 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -3,7 +3,7 @@ class Origami::SalesController < BaseOrigamiController def show @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.all + @complete = Sale.where("sale_status != 'new'") @orders = Order.all.order('date desc') @sale = Sale.find(params[:sale_id]) end diff --git a/app/models/ability.rb b/app/models/ability.rb index 1cf1d902..f9d98bfc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -75,8 +75,8 @@ class Ability can :read, Sale can :update, Sale - can :add_customer, Customer - can :update_sale_by_customer, Customer + can :add_customer, Customer + can :update_sale_by_customer, Customer can :index, :other_charge can :create, :other_charge diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 66a16b2b..8b84b4b9 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -46,11 +46,11 @@
- <%= f.input :nrc_no, :class => "form-control nrc_no" %> + <%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %>
- <%= f.input :company, :class => "form-control col-md-6 company",:required => true%> + <%= f.input :company, :class => "form-control col-md-6 company"%> <% flash.each do |name, msg| %> <% str="[\"#{msg['company']}\"]" diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index a1d359e8..1f06704b 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -121,10 +121,10 @@
- <%= f.input :nrc_no, :class => "form-control nrc_no" %> + <%= f.input :nrc_no, :label => "NRC No",:class => "form-control nrc_no" %>
- <%= f.input :company, :class => "form-control col-md-6 company",:required => true%> + <%= f.input :company, :class => "form-control col-md-6 company"%> <% flash.each do |name, msg| %> <% str="[\"#{msg['company']}\"]" diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 88e2bce6..b0e324a5 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -519,7 +519,7 @@ $(document).ready(function(){ } $.confirm({ - title: 'Infomation!', + title: result.title, content: result.status, columnClass: 'small', type: type, @@ -542,18 +542,14 @@ $(document).ready(function(){ } }); }else{ - $.confirm({ - title: 'Alert !', - content: 'Please Select Account', - type: 'red', + $.alert({ + title: 'Alert!', + content: 'Please Select Account', + type: 'red', typeAnimated: true, - buttons: { - confirm: { - text: 'Ok', - btnClass: 'btn-danger', - } - } - }); + btnClass: 'btn-danger', + }); + } });//end member discount diff --git a/app/views/origami/moveroom/move_dining.html.erb b/app/views/origami/moveroom/move_dining.html.erb index a8620d6e..3cc878a3 100644 --- a/app/views/origami/moveroom/move_dining.html.erb +++ b/app/views/origami/moveroom/move_dining.html.erb @@ -15,13 +15,13 @@ -
+
-
+
<% @tables.each do |table| %> <% if table.status == 'occupied' %>
@@ -42,7 +42,7 @@
-
+
<% @rooms.each do |room| %> <% if room.status == 'occupied' %>
@@ -95,7 +95,7 @@
-
+
diff --git a/app/views/origami/movetable/move_dining.html.erb b/app/views/origami/movetable/move_dining.html.erb index d64b71f0..d8abdd86 100644 --- a/app/views/origami/movetable/move_dining.html.erb +++ b/app/views/origami/movetable/move_dining.html.erb @@ -15,13 +15,13 @@ -
+
-
+
<% @tables.each do |table| %> <% if table.status == 'occupied' %>
@@ -42,7 +42,7 @@
-
+
<% @rooms.each do |room| %> <% if room.status == 'occupied' %>
@@ -95,7 +95,7 @@
-
+
diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index e8c391d1..bc614504 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -175,11 +175,9 @@ - <%if @selected_item.discount_type == 'member_discount'%> - - <%else%> + - <%end%> + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 63b6b0d0..83373b8e 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1,4 +1,6 @@ - +
@@ -104,6 +106,7 @@
+
Amount Due
@@ -258,6 +261,8 @@
+ +
+ \ No newline at end of file diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 988bcf5a..d115b765 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -203,7 +203,7 @@ - <%if @obj.discount_type == 'member_discount'%> + <%if @obj != nil && @status_sale == 'sale' && @obj.discount_type == 'member_discount'%> <%else%> diff --git a/app/views/origami/shifts/new.html.erb b/app/views/origami/shifts/new.html.erb index 8d3ca457..a8ded240 100644 --- a/app/views/origami/shifts/new.html.erb +++ b/app/views/origami/shifts/new.html.erb @@ -110,7 +110,7 @@ $(document).on('focusout', '.float-value', function(event){ $('#open_cashier').on('click',function(){ var cashier_terminal = $('#cashier_terminal').val(); - var amount = $('#total').text(); + var amount = $('#total').text()||0; $.ajax({type: "POST", url: "<%= origami_shifts_path %>", data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal, diff --git a/app/views/settings/membership_settings/_form.html.erb b/app/views/settings/membership_settings/_form.html.erb index 98ae8f0a..77a189c4 100644 --- a/app/views/settings/membership_settings/_form.html.erb +++ b/app/views/settings/membership_settings/_form.html.erb @@ -11,7 +11,6 @@ <%= f.input :rebate %> <%= f.input :bonus %> <%= f.input :point %> - <%= f.input :created_by %>
diff --git a/app/views/settings/membership_settings/index.html.erb b/app/views/settings/membership_settings/index.html.erb index f03683e1..e382f026 100644 --- a/app/views/settings/membership_settings/index.html.erb +++ b/app/views/settings/membership_settings/index.html.erb @@ -22,7 +22,6 @@
- @@ -40,7 +39,6 @@ - diff --git a/app/views/settings/order_queue_stations/show.html.erb b/app/views/settings/order_queue_stations/show.html.erb index fbb19182..97c5dd4c 100644 --- a/app/views/settings/order_queue_stations/show.html.erb +++ b/app/views/settings/order_queue_stations/show.html.erb @@ -32,7 +32,7 @@ - + diff --git a/public/image/loading-ajax.gif b/public/image/loading-ajax.gif new file mode 100755 index 0000000000000000000000000000000000000000..e3d3cb83b4e3064e6f430ca5a50861d20e12531e GIT binary patch literal 1915 zcmciDc}&w+00;02zn(HwkhTyUJ!nfOC=**H6brT>Y~lep3@T8D77BtOObc>|9OWvu z^Z;uCD|ewvfeHg1N6T4Ibchy&;SdQfVa_et{uwKnC1$eBWZ7Qw{(AZ4z0dcX-+Kpq zz4yAZsGvQdHz3f;%8I$Uc}7MCnM}5|wKW(FAt50%GcyAN0|5a60)fD|`tHE~2EY*@ z5D5Fb4I|++EAey$=0a3rB!3r;;Eg8IOrbzqzL#B5i?J-0pb7d6y&% zldF+BNAz8*)`d9dAV(IuH=SIwxi-e4N$i=A4rj?Zll!FHgrRydq;Kj z*Nm!)-af6ae_&A7!@p}Cdpx*an-+UNhF#5lnh|wsPXvo-bq)^Bn&z!o;O^(xlxz;xpWRefLQD+`w%Aly*t6*uOCUn)IPWRim?+$q5A0PpjVhM0@oW zZFUp0WiH1KWmdKw&B-zG<=R_)rMbL2u<@AJ;g5Sj`fFNEf}hX+N#-*dSv4ISUm zxzE`R%7Ub&XXoVd^71WUa0(n&V1&n5F?;iyaQbXgp-CdRQIKvmEc zkyXtX%Vct)C|n}6EGq8oUhQzmveZF;j#kNhfNvyCaB7K@Cm#{j__3MxVcwk1NYpKL zuMvss5=Y-}@$ZR4yUE34DAAxSKc5oKW?M?yDLY})ZUWuV5CmmIYI|CIHOirZ%5Hy=nNG#0+1R8at;NuY z5F+rIc$gGu3-l(arEu(3`+JlD@z5~#n!Q%o|Dcj^SK7_JQ`q6tY1P~^MIToVE{-Z+ z{xEs#$L;G1NB#>TZ6AL=^hxk18P;r{Y;-O?4|#=AgifOil11XxAMqd!je-!t6x0eAf86z20Pe!UsHmZy z*j9?>6t=1McC6a2MpYlH#NAL-q1F=dk;(h5!0d;j`wED-byg*wrp<_q0Z5?Jkfkz* z{|$&^DkL7?ZC?eXTfj1@Y4mtx3J-u6aFE4RIvXXXNIg+}p1?IGIJY=o;ctC8Gb=lX zpQ=)~w6?u1w*}1ZI{G=TBNK9{1S2MvVuwTJSS_vJWzfzDimt~)wGe}5TcP@9t6sgR zT4&J=o7ZUe1^bclQ2J{8+K9fol&<;*INv!pxt3F0Jnj5LMU6K4nW=6auL RpY|=j7}ptrge@SqKLBjxAp-ya literal 0 HcmV?d00001 From 25ef380b4f3fd40b4b104f5e184464bc7febbaf8 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 17 Jul 2017 11:22:24 +0630 Subject: [PATCH 3/5] finished report for all --- app/controllers/base_report_controller.rb | 61 +-- app/controllers/origami/shifts_controller.rb | 2 - .../reports/receipt_no_controller.rb | 246 ++--------- .../reports/saleitem_controller.rb | 414 +++++++++--------- .../reports/shiftsale_controller.rb | 32 +- app/models/sale.rb | 146 ++---- .../_shift_sale_report_filter.html.erb | 177 ++++++++ app/views/reports/dailysale/index.html.erb | 71 +-- app/views/reports/dailysale/index.xls.erb | 38 +- .../_shift_sale_report_filter.html.erb | 102 +---- app/views/reports/receipt_no/index.html.erb | 130 +++--- app/views/reports/receipt_no/index.xls.erb | 118 ++--- .../_shift_sale_report_filter.html.erb | 96 +--- app/views/reports/saleitem/index.html.erb | 24 +- .../_shift_sale_report_filter.html.erb | 34 +- app/views/reports/shiftsale/index.html.erb | 91 +++- 16 files changed, 792 insertions(+), 990 deletions(-) create mode 100644 app/views/reports/_shift_sale_report_filter.html.erb diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 12eeccd2..af9ec4fc 100644 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -34,12 +34,10 @@ class BaseReportController < ActionController::Base to = params[:to] day_ref = Time.now.utc.getlocal - if params[:report_type] == "daily_sale" || params[:report_type] == "sale_item" + if from.present? && to.present? - if from != "" && to != "" - - f_date = DateTime.parse(params[:from]) - t_date = DateTime.parse(params[:to]) + f_date = DateTime.parse(from) + t_date = DateTime.parse(to) f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) from = f_time.beginning_of_day.utc.getlocal @@ -83,59 +81,6 @@ class BaseReportController < ActionController::Base to = (day_ref - 1.year).end_of_year.utc end end - else # end daily sale report - if period_type.to_i == 1 - - if params[:from] != "" && params[:to] !="" - - f_date = DateTime.parse(params[:from]) - t_date = DateTime.parse(params[:to]) - f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - from = f_time.beginning_of_day.utc.getlocal - to = t_time.end_of_day.utc.getlocal - else - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc - 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 - end return from, to diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 92f174ae..24ef0b76 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,8 +4,6 @@ class Origami::ShiftsController < BaseOrigamiController end def show - puts ">>>>>" - puts current_user.id @shift = ShiftSale.current_open_shift(current_user.id) end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index e71df43e..d1427e6e 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,25 +1,31 @@ class Reports::ReceiptNoController < BaseReportController authorize_resource :class => false def index - from, to, report_type = get_date_range_from_params + @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["Other Payment","card"]] - if params[:shift_name].to_i != 0 - @shift = ShiftSale.where('shift_started_at >= ? and shift_closed_at <= ?',from,to).take - # puts @shift.to_json - if @shift.present? - @sale_data = Sale.where('shift_sale_id = ? ',@shift.id) - @sale_taxes = Sale.get_separate_tax(from,to) - end - else - @sale_data = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from.utc,to.utc) - @sale_taxes = Sale.get_separate_tax(from.utc,to.utc) - end - + from, to = get_date_range_from_params - if @shift.present? - @shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") - @shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") - end + @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + @shift = '' + if params[:shift_name].to_i != 0 + shift_sale = ShiftSale.find(params[:shift_name]) + if to.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at) + else + + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end + end + @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to, params[:payment_type]) + + if @shift.present? + @shift.each do |sh| + @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_data = sh + end + end respond_to do |format| format.html @@ -28,7 +34,7 @@ authorize_resource :class => false end def show - from, to, report_type = get_date_range_from_params + from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) @@ -38,7 +44,8 @@ authorize_resource :class => false local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc - str = { :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} date_arr.push(str) end @@ -48,205 +55,4 @@ authorize_resource :class => false format.json { render json: out } end end - - - def get_date_range_from_params - - period_type = params[:period_type] - period = params[:period] - - branch = params[:branch] - report_type = params[:report_type] - - shift_name = params[:shift_name] - unless shift_name.nil? - shift_arr = shift_name.split(' - ') - shift_from = shift_arr[0] - shift_to = shift_arr[1] - end - - day_ref = day_ref = Time.now.utc.getlocal - - if period_type.to_i == 1 - - ### =>search by from and to - unless shift_name.nil? - if shift_name.to_s == '0' - ### => all shift - f_date = DateTime.parse(params[:from]) - t_date = DateTime.parse(params[:to]) - f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - from = f_time.beginning_of_day.utc.getlocal - to = t_time.end_of_day.utc.getlocal - - else - unless shift_from == '-' - f_date = DateTime.parse(shift_from) - from = f_date - else - from = '' - end - - unless shift_to == '-' - t_date = DateTime.parse(shift_to) - to = t_date - else - to = '' - end - end - else - f_date = DateTime.parse(params[:from]) - t_date = DateTime.parse(params[:to]) - f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - from = f_time.beginning_of_day.utc.getlocal - to = t_time.end_of_day.utc.getlocal - end - else - ### => search by Today or yesterday - - unless shift_name.nil? - if shift_name.to_s == '0' - ### => all shift - 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 - - else - unless shift_from == '-' - f_date = DateTime.parse(shift_from) - #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - from = f_date.utc - else - from = '' - end - - unless shift_to == '-' - t_date = DateTime.parse(shift_to) - #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - to = t_date.utc - else - to = '' - end - end - else - if params[:report_type].to_i != 0 - r_type = params[:report_type].to_s - - if r_type == 'shift_item' - - 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 - else - ### => report not shift - 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 - end - - end - - return from, to,report_type - end - - end \ No newline at end of file diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 80bd8b93..c9715fc3 100644 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -2,17 +2,20 @@ class Reports::SaleitemController < BaseReportController authorize_resource :class => false def index - from, to, report_type = get_date_range_from_params + from, to = get_date_range_from_params shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) shift = '' - if to.blank? - shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',from) - else - shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',from, to) - end + if params[:shift_name].to_i != 0 + shift_sale = ShiftSale.find(params[:shift_name]) + if to.blank? + shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at) + else - @sale_data, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED, report_type) + shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end + end + @sale_data, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED) @account_cate_count = Hash.new {|hash, key| hash[key] = 0} @@ -27,7 +30,7 @@ class Reports::SaleitemController < BaseReportController @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} - if !shift.nil? + if shift.present? shift.each do |sh| @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") @shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") @@ -52,7 +55,8 @@ class Reports::SaleitemController < BaseReportController local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc - str = { :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} date_arr.push(str) end @@ -63,225 +67,225 @@ class Reports::SaleitemController < BaseReportController end end - def get_date_range_from_params - period_type = params[:period_type] - period = params[:period] - from = params[:from] - to = params[:to] - branch = params[:branch] - report_type = params[:report_type] + # def get_date_range_from_params + # period_type = params[:period_type] + # period = params[:period] + # from = params[:from] + # to = params[:to] + # branch = params[:branch] + # report_type = params[:report_type] - shift_name = params[:shift_name] - unless shift_name.nil? - shift_arr = shift_name.split(' - ') - shift_from = shift_arr[0] - shift_to = shift_arr[1] - end + # shift_name = params[:shift_name] + # unless shift_name.nil? + # shift_arr = shift_name.split(' - ') + # shift_from = shift_arr[0] + # shift_to = shift_arr[1] + # end - day_ref = Time.now + # day_ref = Time.now - if period_type.to_i == 1 - ### =>search by from and to - unless shift_name.nil? - if shift_name.to_s == '0' - ### => all shift - #f_date = DateTime.parse(from) - #t_date = DateTime.parse(to) - if params[:from] && params[:to] - if params[:from] != "" && params[:to] !="" - f_date = DateTime.strptime(from, "%m/%d/%Y") - t_date = DateTime.strptime(to, "%m/%d/%Y") + # if period_type.to_i == 1 + # ### =>search by from and to + # unless shift_name.nil? + # if shift_name.to_s == '0' + # ### => all shift + # #f_date = DateTime.parse(from) + # #t_date = DateTime.parse(to) + # if params[:from] && params[:to] + # if params[:from] != "" && params[:to] !="" + # f_date = DateTime.strptime(from, "%m/%d/%Y") + # t_date = DateTime.strptime(to, "%m/%d/%Y") - f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - from = f_time.beginning_of_day.utc - to = t_time.end_of_day.utc - end - else - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc - end - else - unless shift_from == '-' - f_date = DateTime.parse(shift_from) - from = f_date - else - from = '' - end + # f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) + # t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) + # from = f_time.beginning_of_day.utc + # to = t_time.end_of_day.utc + # end + # else + # from = day_ref.beginning_of_day.utc + # to = day_ref.end_of_day.utc + # end + # else + # unless shift_from == '-' + # f_date = DateTime.parse(shift_from) + # from = f_date + # else + # from = '' + # end - unless shift_to == '-' - t_date = DateTime.parse(shift_to) - to = t_date - else - to = '' - end - end - else - # f_date = DateTime.parse(from) - # t_date = DateTime.parse(to) - if params[:from] && params[:to] - if params[:from] != "" && params[:to] !="" - f_date = DateTime.strptime(from, "%m/%d/%Y") - t_date = DateTime.strptime(to, "%m/%d/%Y") - f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - from = f_time.beginning_of_day.utc - to = t_time.end_of_day.utc - end - else - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc - end - end - else - ### => search by Today or yesterday - unless shift_name.nil? - if shift_name.to_s == '0' - ### => all shift - case period.to_i - when PERIOD["today"] + # unless shift_to == '-' + # t_date = DateTime.parse(shift_to) + # to = t_date + # else + # to = '' + # end + # end + # else + # # f_date = DateTime.parse(from) + # # t_date = DateTime.parse(to) + # if params[:from] && params[:to] + # if params[:from] != "" && params[:to] !="" + # f_date = DateTime.strptime(from, "%m/%d/%Y") + # t_date = DateTime.strptime(to, "%m/%d/%Y") + # f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) + # t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) + # from = f_time.beginning_of_day.utc + # to = t_time.end_of_day.utc + # end + # else + # from = day_ref.beginning_of_day.utc + # to = day_ref.end_of_day.utc + # end + # end + # else + # ### => search by Today or yesterday + # unless shift_name.nil? + # if shift_name.to_s == '0' + # ### => all shift + # case period.to_i + # when PERIOD["today"] - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc + # 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["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 + # 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 - else - unless shift_from == '-' - f_date = DateTime.parse(shift_from) - # f_date = DateTime.strptime(shift_from, "%m/%d/%Y") - #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - from = f_date - else - from = '' - end + # else + # unless shift_from == '-' + # f_date = DateTime.parse(shift_from) + # # f_date = DateTime.strptime(shift_from, "%m/%d/%Y") + # #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) + # from = f_date + # else + # from = '' + # end - unless shift_to == '-' - t_date = DateTime.parse(shift_to) - # t_date = DateTime.strptime(shift_to, "%m/%d/%Y") + # unless shift_to == '-' + # t_date = DateTime.parse(shift_to) + # # t_date = DateTime.strptime(shift_to, "%m/%d/%Y") - #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - to = t_date - else - to = '' - end - end - else - if params[:report_type].to_i != 0 - r_type = params[:report_type].to_s + # #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) + # to = t_date + # else + # to = '' + # end + # end + # else + # if params[:report_type].to_i != 0 + # r_type = params[:report_type].to_s - if r_type == 'shift_item' + # if r_type == 'shift_item' - case period.to_i - when PERIOD["today"] + # case period.to_i + # when PERIOD["today"] - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc + # 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["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 + # 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 - else - ### => report not shift - case period.to_i - when PERIOD["today"] - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc + # end + # end + # else + # ### => report not shift + # 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["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 - end + # 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 + # end - end + # end - return from, to,report_type - end + # return from, to,report_type + # end end diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 87fae97d..fc3adbf9 100644 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -3,16 +3,40 @@ class Reports::ShiftsaleController < BaseReportController def index - from, to, report_type = get_date_range_from_params - @sale_data = Sale.get_by_shiftsales(from,to) - respond_to do |format| + from, to = get_date_range_from_params + @shift = '' + if params[:shift_name].to_i != 0 + @shift = ShiftSale.find(params[:shift_name]) + end + @sale_data = Sale.get_by_shiftsales(from,to,@shift) + + respond_to do |format| format.html format.xls end end def show - + from, to = get_date_range_from_params + + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + date_arr = Array.new + @sale_data.each do |sale| + local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") + local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") + opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc + closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + date_arr.push(str) + end + + out = {:status => 'ok', :message => date_arr} + + respond_to do |format| + format.json { render json: out } + end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 12896b7d..8fa54a7c 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -503,84 +503,18 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) - case report_type.to_i - when REPORT_TYPE["daily"] - return query - when REPORT_TYPE["monthly"] - - return query.group("MONTH(date)") - when REPORT_TYPE["yearly"] - return query.group("YEAR(date)") - end end -def self.get_by_shiftsales(from,to) - return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) +def self.get_by_shiftsales(from,to,shift) + if !shift.blank? + ShiftSale.where("id =?",shift.id) + else + ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) + end end -# def self.get_by_shiftsales(from,to) -# shift_sales = ShiftSale.select('shift_sales.id, cs.name as cashier_station_name, shift_sales.shift_started_at as opening_date, shift_sales.shift_closeed_at as closing_date') -# .joins(" INNER JOIN cashier_terminals cs ON cs.id = shift_sales.cashier_terminal_id") -# .where("shift_sales.employee_id = ? and (shift_sales.shift_started_at between ? and ? OR shift_sales.shift_closeed_at between ? and ? )", employee, from, to, from, to) -# .order("shift_sales.id DESC") - -# sale_arr = Array.new -# shift_sales.each do |shift| -# all_total= Sale.select("grand_total,sr.payment_method, sr.payment_amount, rounding_adjustment") -# .joins("join employees e on sales.cashier_id = e.id join shift_sales sh on sh.id = sales.shift_sale_id") -# .joins("INNER JOIN (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sr ON sr.sale_id = sales.sale_id") -# .where("sales.shift_sale_id =? and sales.sale_status = 'completed' and sales.total_amount != 0",shift.id) - -# void = Sale.select("SUM(sales.grand_total) AS grand_total") -# .joins("join shift_sales sh on sh.id = sales.shift_sale_id") -# .where('sales.sale_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id) -# .sum(:grand_total) -# cash = all_total.select('sr.payment_method') -# .where('sr.payment_method = "cash"') -# .sum(:amount) - -# credit = all_total.where('sr.payment_method = "creditnote"') -# .sum(:amount) - -# accept_credit = all_total.select('ci.amout') -# .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id") -# .where('sr.payment_method = "creditnote"') -# .sum(:amout) - - - -# foc = all_total.where('sales.payment_method = "foc" and sales.sale_status = "completed"') -# .sum(:grand_total) - -# card = all_total.select('payment_method') -# .where('sr.payment_method = "card"') -# .sum(:amount).to_f - -# rounding_adj = all_total.sum(:rounding_adjustment) - -# discount = all_total.sum(:discount_amount) -# void = void.nil? ? 0 : void -# cash = cash.nil? ? 0 : cash -# credit = credit.nil? ? 0 : credit -# foc = foc.nil? ? 0 : foc -# card = card.nil? ? 0 : card -# accept_credit = accept_credit.nil? ? 0 : accept_credit -# # all_payments = void.to_d + cash.to_d + credit.to_d + foc.to_d + card.to_d + accept_credit.to_d -# all_payments = cash.to_d + credit.to_d + foc.to_d + card.to_d + accept_credit.to_d -# payments = { void_amount: void, cash_amount: cash, credit_amount: credit,accept_credit_amount: accept_credit, foc_amount: foc, card_amount: card, grand_total: all_payments , cashier_station_name: shift.cashier_station_name, opening_date: shift.opening_date, closing_date: shift.closing_date, rounding_adj: rounding_adj } - -# sale_arr.push(payments) -# end - -# return sale_arr -# end - -# def self.get_receipt_no_list(from,to) -# sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to) -# end - def self.get_by_shift_sale(from,to,status) query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,shift_closed_at As closing_date," + " grand_total AS grand_total, cash_sales AS cash," + @@ -604,7 +538,7 @@ def self.get_item_query() end - def self.get_by_shift_items(shift_sale_range, shift, from, to, status, report_type) + def self.get_by_shift_items(shift_sale_range, shift, from, to, status) # date_type_selection = get_sql_function_for_report_type(report_type) @@ -616,11 +550,12 @@ def self.get_item_query() total_foc_amount = 0 total_grand_total = 0 - if shift == '[]' + if shift.blank? ### => get all sales range in shift_sales query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) - sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_ - sales.amount_changed) else 0 end) as card_amount, + change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) + sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") @@ -633,11 +568,11 @@ def self.get_item_query() total_foc_amount += s_c.foc_amount.to_f end total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f - - elsif shift_sale_range == '[]' + else query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) - sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount, + change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) + sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") @@ -649,31 +584,38 @@ def self.get_item_query() total_credit_amount += s_c.credit_amount.to_f total_foc_amount += s_c.foc_amount.to_f end - total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f - - else - query = query.where("receipt_date between ? and ? and sale_status=?",from,to,'completed') - sale_cash = Sale.select("sales.total_discount as total_discount, - SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount, - SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, - SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, - SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") - .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shift_sale_id in (?) and sale_status = 'completed' ", shift.to_a) - - sale_cash.each do |s_c| - total_cash_amount += s_c.cash_amount.to_f - total_card_amount += s_c.card_amount.to_f - total_credit_amount += s_c.credit_amount.to_f - total_foc_amount += s_c.foc_amount.to_f - discount_query = s_c.total_discount.to_f - end - total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f - + total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f + end - return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total - end + return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount +end + +def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type) + ## => left join -> show all sales although no orders + if payment_type.blank? + payment_type = '' + else + if payment_type == 'card' + payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar'" + else + payment_type = " and sale_payments.payment_method = '#{payment_type}'" + end + end + query = Sale.all + if shift.present? + query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sales.total_amount != 0", shift.to_a) + .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") + .group("sales.sale_id") + + else + query = query .where("sale_status=? #{payment_type} and sales.shift_sale_id in (?)","completed",shift_sale_range.to_a) + .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") + .group("sales.sale_id") + end + +end + def self.get_separate_tax(from,to,payment_method=nil) @@ -692,7 +634,7 @@ end cash = 0.0 self.sale_payments.each do |pay| if pay.payment_method == 'cash' - cash = pay.payment_amount + cash = pay.payment_amount-self.amount_changed end end return cash diff --git a/app/views/reports/_shift_sale_report_filter.html.erb b/app/views/reports/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..a5513531 --- /dev/null +++ b/app/views/reports/_shift_sale_report_filter.html.erb @@ -0,0 +1,177 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ +
+
+ <% end %> + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index 996393ac..7e70615f 100644 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -35,7 +35,7 @@
- + @@ -59,7 +59,8 @@ <% foc = 0 %> <% discount = 0 %> <% total = 0 %> - <% grand_total = 0 %> + <% grand_total = 0 %> + <% old_grand_total = 0 %> <% count = 1 %> <% rounding_adj = 0 %> <% @sale_data.each do |sale| %> <% void += sale[:void_amount] %> @@ -74,6 +75,7 @@ <% discount += sale[:total_discount] %> <% total += sale[:old_grand_total].to_f + sale[:rounding_adj].to_f %> <% grand_total += sale[:grand_total].to_f %> + <% old_grand_total += sale[:old_grand_total].to_f %> <% rounding_adj += sale[:rounding_adj].to_f %> @@ -90,25 +92,25 @@ - + <% count = count + 1 %> <% end %> - - - - - + + + + + - + <% total_tax = 0 %> @@ -135,54 +137,3 @@ - - - \ No newline at end of file diff --git a/app/views/reports/dailysale/index.xls.erb b/app/views/reports/dailysale/index.xls.erb index 67e76e3c..424f3b63 100644 --- a/app/views/reports/dailysale/index.xls.erb +++ b/app/views/reports/dailysale/index.xls.erb @@ -1,12 +1,11 @@ -
+
+
<%= sub_total %>
Member Discount:Discount:(<%=@selected_item.total_discount rescue 0%>)
<%= sub_total %>
Member Discount:Discount: Rebate Bonus PointCreated by
<%= settings_membership_setting.rebate %> <%= settings_membership_setting.bonus %> <%= settings_membership_setting.point %><%= settings_membership_setting.created_by %> <%= link_to 'Edit', edit_settings_membership_setting_path(settings_membership_setting) %> <%= link_to 'Destroy', settings_membership_setting_path(settings_membership_setting), method: :delete, data: { confirm: 'Are you sure?' } %>
<%= @settings_order_queue_station.station_name %> <%= @settings_order_queue_station.is_active %> <%= @settings_order_queue_station.auto_print %><%= @settings_order_queue_station.processing_items %><%= JSON.parse(@settings_order_queue_station.processing_items).count %> <%= @settings_order_queue_station.print_copy %> <%= @settings_order_queue_station.printer_name %> <%= @settings_order_queue_station.font_size %>Master Sales Visa Sales Jcb SalesPaypar SalesRedeem Sales Cash Sales Credit Sales FOC Sales
<%= count %>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>) <%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",mpu), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%> (<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>) <%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",old_grand_total), :delimiter => ',') rescue '-'%>
- <% if params[:from]%> - + - <% end %> @@ -15,7 +14,7 @@ - + @@ -39,7 +38,8 @@ <% foc = 0 %> <% discount = 0 %> <% total = 0 %> - <% grand_total = 0 %> + <% grand_total = 0 %> + <% old_grand_total = 0 %> <% count = 1 %> <% rounding_adj = 0 %> <% @sale_data.each do |sale| %> <% void += sale[:void_amount] %> @@ -48,12 +48,13 @@ <% visa += sale[:visa_amount] %> <% jcb += sale[:jcb_amount] %> <% paypar += sale[:paypar_amount] %> - <% cash += sale[:cash_amount] %> + <% cash += sale[:cash_amount]-sale[:total_change_amount] %> <% credit += sale[:credit_amount] %> <% foc += sale[:foc_amount] %> <% discount += sale[:total_discount] %> - <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> + <% total += sale[:old_grand_total].to_f + sale[:rounding_adj].to_f %> <% grand_total += sale[:grand_total].to_f %> + <% old_grand_total += sale[:old_grand_total].to_f %> <% rounding_adj += sale[:rounding_adj].to_f %> @@ -64,31 +65,31 @@ - + - + - + <% count = count + 1 %> <% end %> - - - - - + + + + + - + <% total_tax = 0 %> @@ -113,4 +114,5 @@ <% end %>
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>) Sale (<%= from rescue '-' %> - <%= to rescue '-'%>)
Sr.no DateMaster Sales Visa Sales Jcb SalesPaypar SalesRedeem Sales Cash Sales Credit Sales FOC Sales
<%= count %><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%> (<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",mpu), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%> (<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>) <%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",old_grand_total), :delimiter => ',') rescue '-'%>
-
\ No newline at end of file +
+
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 index 8e1de8e2..c6308a66 100644 --- a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -6,6 +6,7 @@
- + <% if defined? payments %>
- - + + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
+ <% end %>
@@ -41,7 +36,8 @@
- +
@@ -49,70 +45,6 @@
<% end %> - - -
-
- <% if defined? promotions %> - <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> - <% end %> - - <% if defined? menu_types %> - <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> - <% end %> - - <% if defined? payments %> - <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> - <% end %> - - - - <% if defined? cashiers %> - <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> - <% end %> - - <% if defined? singer %> - <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> - <% end %> - - <% if defined? bsm %> - <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> - <% end %> - - <% if defined? guest_role %> - <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> - <% end %> - - <% if defined? list_by_payment_type %> - <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> - <% end %> - - <% if defined? products %> - <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> - <% end %> - - <% if defined? items %> - <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> - <% end %> -
-
- - - <% end %>
@@ -150,12 +82,22 @@ $(function(){ } }); + <% if params[:shift_name].to_i > 0%> + shift_id = '<%= params[:shift_name] %>' + local_date = '<%= @shift_from %> - <%= @shift_to %> ' + var shift = $('#shift_name'); + str = ''; + shift.append(str); +<% end %> - -// $("#from").val("<%=params[:from] rescue '-'%>"); -// $("#to").val("<%=params[:to] rescue '-'%>"); -// $("#sel_period").val(<%=params[:period] rescue '-'%>); -// $("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>); + $("#from").val("<%=params[:from] rescue '-'%>"); + $("#to").val("<%=params[:to] rescue '-'%>"); + $("#sel_period").val(<%=params[:period] rescue '-'%>); + $("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>); + // shift = $(".shift-id").text() + // if (shift.length>0) { + // $('.shift_name > option[value="'+shift+'"]').attr('selected','selected'); + // } <% if params[:period_type] == 1 || params[:period_type] == "1" %> $("#rd_period_type_1").attr("checked","checked"); diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index d4438d43..30689437 100644 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -7,35 +7,36 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_receipt_no_index_path} %> + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_receipt_no_index_path} %>
- +
- <% if !params[:from].blank?%> - - - - <% end %> - <% if @shift_from %> - - <% if @shift.employee %> - <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %> - <% end %> - - - <% end %> + + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> @@ -61,53 +62,54 @@ <% other_amt = 0 %> <% total_nett = 0 %> <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + <%if @sale_data %> + <% @sale_data.each do |result| %> - <% @sale_data.each do |result| %> + <% grand_total = grand_total.to_f + result.grand_total.to_f %> + <% old_grand_total = old_grand_total.to_f + result.old_grand_total.to_f %> + <% total_tax += result.total_tax.to_f %> + <% total_sum += result.total_amount.to_f %> + <% discount_amt += result.total_discount.to_f %> + <% rounding_adj += result.rounding_adjustment.to_f %> + + + + + + + + + + + + + + - <% grand_total = grand_total.to_f + result.grand_total.to_f %> - <% old_grand_total = old_grand_total.to_f + result.old_grand_total.to_f %> - <% total_tax += result.total_tax.to_f %> - <% total_sum += result.total_amount.to_f %> - <% discount_amt += result.total_discount.to_f %> - <% rounding_adj += result.rounding_adjustment.to_f %> - - - - - - - - - - - - - - - - <% end %> - - - - - - - - - - - - - - - - - - - + <% end %> + + + + + + + + + + + + + + + + + + + + <%end%>
From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%>
Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
Recipt No
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.total_amount rescue '-' %><%= result.total_discount rescue '-' %><%= result.total_tax rescue '-' %><%= result.old_grand_total %><%= result.rounding_adjustment.to_f rescue '-' %><%= result.grand_total_after_rounding() rescue '-'%>
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.total_amount rescue '-' %><%= result.total_discount rescue '-' %><%= result.total_tax rescue '-' %><%= result.grand_total %><%= result.rounding_adjustment.to_f rescue '-' %><%= result.grand_total_after_rounding() rescue '-'%>
 <%= total_sum rescue '-'%><%= discount_amt rescue '-'%><%= sprintf "%.2f",total_tax rescue '-'%><%= grand_total.to_f.round(2) rescue '-'%><%= rounding_adj rescue '-'%><%= old_grand_total.to_f.round + rounding_adj %>
 Total AmountDiscount AmountTax AmountGrand TotalRounding Adj.Grand Total +
- Rounding Adj. -
 <%= total_sum rescue '-'%><%= discount_amt rescue '-'%><%= sprintf "%.2f",total_tax rescue '-'%><%= old_grand_total.to_f.round(2) rescue '-'%><%= rounding_adj rescue '-'%><%= old_grand_total.to_f.round + rounding_adj %>
 Total AmountDiscount AmountTax AmountGrand TotalRounding Adj.Grand Total +
+ Rounding Adj. +
@@ -181,9 +183,9 @@ var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date; var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date; - + var shift_id = data.message[index].shift_id ; if(param_shift != ''){ - if(sh_date == param_shift){ + if(shift_id == param_shift){ selected = 'selected = "selected"'; } else{ @@ -192,7 +194,7 @@ }else{ selected = ''; } - str += ''; + str += ''; // console.log(sh_date) }) diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index b55a40c4..2739356d 100644 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -2,19 +2,20 @@
- <% if !params[:from].blank?%> - - - - <% end %> - <% if @shift_from %> - - <% if @shift.employee %> - <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %> - <% end %> - - - <% end %> + + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> @@ -32,6 +33,7 @@ <% grand_total = 0 %> + <% old_grand_total = 0 %> <% total_tax = 0 %> <% guest_count = 0 %> <% total_sum = 0 %> @@ -39,52 +41,54 @@ <% other_amt = 0 %> <% total_nett = 0 %> <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + <%if @sale_data %> + <% @sale_data.each do |result| %> - <% @sale_data.each do |result| %> + <% grand_total = grand_total.to_f + result.grand_total.to_f %> + <% old_grand_total = old_grand_total.to_f + result.old_grand_total.to_f %> + <% total_tax += result.total_tax.to_f %> + <% total_sum += result.total_amount.to_f %> + <% discount_amt += result.total_discount.to_f %> + <% rounding_adj += result.rounding_adjustment.to_f %> + + + + + + + + + + + + + + - <% grand_total = grand_total.to_f + result.grand_total.to_f %> - <% total_tax += result.total_tax.to_f %> - <% total_sum += result.total_amount.to_f %> - <% discount_amt += result.total_discount.to_f %> - <% rounding_adj += result.rounding_adjustment.to_f %> - - - - - - - - - - - - - - - - <% end %> - - - - - - - - - - - - - - - - - - - + <% end %> + + + + + + + + + + + + + + + + + + + + <%end%>
From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%>
Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
Recipt No
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.total_amount rescue '-' %><%= result.total_discount rescue '-' %><%= result.total_tax rescue '-' %><%= result.old_grand_total %><%= result.rounding_adjustment.to_f rescue '-' %><%= result.grand_total_after_rounding() rescue '-'%>
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.total_amount rescue '-' %><%= result.total_discount rescue '-' %><%= sprintf "%.2f",result.total_tax rescue '-' %><%= result.grand_total %><%= result.rounding_adjustment.to_f rescue '-' %><%= result.grand_total_after_rounding() rescue '-'%>
 <%= total_sum rescue '-'%><%= discount_amt rescue '-'%><%= sprintf "%.2f",total_tax rescue '-'%><%= grand_total.to_f.round(2) rescue '-'%><%= rounding_adj rescue '-'%><%= grand_total.to_f.round + rounding_adj %>
 Total AmountDiscount AmountTax AmountGrand TotalRounding Adj.Grand Total +
- Rounding Adj. -
 <%= total_sum rescue '-'%><%= discount_amt rescue '-'%><%= sprintf "%.2f",total_tax rescue '-'%><%= old_grand_total.to_f.round(2) rescue '-'%><%= rounding_adj rescue '-'%><%= old_grand_total.to_f.round + rounding_adj %>
 Total AmountDiscount AmountTax AmountGrand TotalRounding Adj.Grand Total +
+ Rounding Adj. +
diff --git a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb index 5c8c47b1..9ed12d12 100644 --- a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb +++ b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb @@ -41,7 +41,8 @@
- +
@@ -49,74 +50,6 @@
<% end %> - - -
-
- <% if defined? promotions %> - <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> - <% end %> - - <% if defined? menu_types %> - <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> - <% end %> - - <% if defined? payments %> - <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> - <% end %> - - <% if defined? shift_name %> - - <% end %> - - <% if defined? cashiers %> - <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> - <% end %> - - <% if defined? singer %> - <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> - <% end %> - - <% if defined? bsm %> - <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> - <% end %> - - <% if defined? guest_role %> - <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> - <% end %> - - <% if defined? list_by_payment_type %> - <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> - <% end %> - - <% if defined? products %> - <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> - <% end %> - - <% if defined? items %> - <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> - <% end %> -
-
- - - <% end %>
@@ -152,20 +85,19 @@ $(function(){ } }); -//Reset the form to pervious values -$("#branch").val(<%=params[:branch]%>); -$("#waiter").val("<%=params[:waiter]%>"); -$("#cashier").val(<%=params[:cashier]%>); -$("#product").val(<%=params[:product]%>); -$("#singer").val(<%=params[:singer]%>); -$("#item").val('<%=params[:item]%>'); -$("#guest_role").val('<%=params[:guest_role]%>'); + <% if params[:shift_name].to_i > 0%> + shift_id = '<%= params[:shift_name] %>' + local_date = '<%= @shift_from %> - <%= @shift_to %> ' + var shift = $('#shift_name'); + str = ''; + shift.append(str); +<% end %> + $("#from").val("<%=params[:from] rescue '-'%>"); + $("#to").val("<%=params[:to] rescue '-'%>"); + $("#sel_period").val(<%=params[:period] rescue '-'%>); + $("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>); -$("#from").val("<%=params[:from]%>"); -$("#to").val("<%=params[:to]%>"); -$("#sel_period").val(<%=params[:period]%>); -$("#sel_sale_type").val(<%=params[:sale_type]%>); <% if params[:period_type] == 1 || params[:period_type] == "1" %> $("#rd_period_type_1").attr("checked","checked"); @@ -195,4 +127,4 @@ $('#item').change(function(){ } } }); - \ No newline at end of file + diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index 7f51fee5..6a9c5620 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -134,15 +134,11 @@ <%= grand_total%> <% end %> - - - + <%= @grand_total - @change_amount%> +
@@ -256,9 +252,10 @@ var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date; var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date; + var shift_id = data.message[index].shift_id ; if(param_shift != ''){ - if(sh_date == param_shift){ + if(shift_id == param_shift){ selected = 'selected = "selected"'; } else{ @@ -270,7 +267,7 @@ } - str += ''; + str += ''; // console.log(sh_date) }) @@ -278,10 +275,5 @@ }); } - //total price by account - - $('#items_table tr').each(function(i){ - - }); }); \ No newline at end of file diff --git a/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb b/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb index 34173d99..1ccf99ad 100644 --- a/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb +++ b/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb @@ -18,18 +18,7 @@
- - +
@@ -39,6 +28,11 @@
+
+ + +
@@ -82,15 +76,13 @@ $(function(){ }); //Reset the form to pervious values -$("#branch").val(<%=params[:branch]%>); -$("#waiter").val("<%=params[:waiter]%>"); -$("#cashier").val(<%=params[:cashier]%>); -$("#product").val(<%=params[:product]%>); -$("#singer").val(<%=params[:singer]%>); -$("#item").val('<%=params[:item]%>'); -$("#guest_role").val('<%=params[:guest_role]%>'); - - +<% if params[:shift_name].to_i > 0%> + shift_id = '<%= params[:shift_name] %>' + local_date = '<%= @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")%> -<%= @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") %>' + var shift = $('#shift_name'); + str = ''; + shift.append(str); +<% end %> $("#from").val("<%=params[:from]%>"); $("#to").val("<%=params[:to]%>"); $("#sel_period").val(<%=params[:period]%>); diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb index 714a8328..e8f2d1d8 100644 --- a/app/views/reports/shiftsale/index.html.erb +++ b/app/views/reports/shiftsale/index.html.erb @@ -7,7 +7,7 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_shiftsale_index_path} %> + :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_shiftsale_index_path} %>
@@ -110,5 +110,94 @@ + From bd0b8681c988ef54bb8e7981a07128664ed63b10 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 17 Jul 2017 12:11:21 +0630 Subject: [PATCH 4/5] update reports --- .../reports/saleitem_controller.rb | 223 +---------------- app/models/sale.rb | 7 +- app/views/reports/saleitem/index.xls.erb | 232 +++++++++++------- 3 files changed, 144 insertions(+), 318 deletions(-) diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index c9715fc3..b9f71494 100644 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -66,226 +66,5 @@ class Reports::SaleitemController < BaseReportController format.json { render json: out } end end - - # def get_date_range_from_params - # period_type = params[:period_type] - # period = params[:period] - # from = params[:from] - # to = params[:to] - # branch = params[:branch] - # report_type = params[:report_type] - - # shift_name = params[:shift_name] - # unless shift_name.nil? - # shift_arr = shift_name.split(' - ') - # shift_from = shift_arr[0] - # shift_to = shift_arr[1] - # end - - # day_ref = Time.now - - # if period_type.to_i == 1 - # ### =>search by from and to - # unless shift_name.nil? - # if shift_name.to_s == '0' - # ### => all shift - # #f_date = DateTime.parse(from) - # #t_date = DateTime.parse(to) - # if params[:from] && params[:to] - # if params[:from] != "" && params[:to] !="" - # f_date = DateTime.strptime(from, "%m/%d/%Y") - # t_date = DateTime.strptime(to, "%m/%d/%Y") - - # f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - # t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - # from = f_time.beginning_of_day.utc - # to = t_time.end_of_day.utc - # end - # else - # from = day_ref.beginning_of_day.utc - # to = day_ref.end_of_day.utc - # end - # else - # unless shift_from == '-' - # f_date = DateTime.parse(shift_from) - # from = f_date - # else - # from = '' - # end - - # unless shift_to == '-' - # t_date = DateTime.parse(shift_to) - # to = t_date - # else - # to = '' - # end - # end - # else - # # f_date = DateTime.parse(from) - # # t_date = DateTime.parse(to) - # if params[:from] && params[:to] - # if params[:from] != "" && params[:to] !="" - # f_date = DateTime.strptime(from, "%m/%d/%Y") - # t_date = DateTime.strptime(to, "%m/%d/%Y") - # f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - # t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - # from = f_time.beginning_of_day.utc - # to = t_time.end_of_day.utc - # end - # else - # from = day_ref.beginning_of_day.utc - # to = day_ref.end_of_day.utc - # end - # end - # else - # ### => search by Today or yesterday - # unless shift_name.nil? - # if shift_name.to_s == '0' - # ### => all shift - # 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 - - # else - # unless shift_from == '-' - # f_date = DateTime.parse(shift_from) - # # f_date = DateTime.strptime(shift_from, "%m/%d/%Y") - # #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) - # from = f_date - # else - # from = '' - # end - - # unless shift_to == '-' - # t_date = DateTime.parse(shift_to) - # # t_date = DateTime.strptime(shift_to, "%m/%d/%Y") - - # #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) - # to = t_date - # else - # to = '' - # end - # end - # else - # if params[:report_type].to_i != 0 - # r_type = params[:report_type].to_s - - # if r_type == 'shift_item' - - # 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 - # else - # ### => report not shift - # 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 - # end - - - - # end - - # return from, to,report_type - # end - + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 8fa54a7c..4e47f6cd 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -602,14 +602,15 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty payment_type = " and sale_payments.payment_method = '#{payment_type}'" end end + puts payment_type + query = Sale.all if shift.present? - query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sales.total_amount != 0", shift.to_a) + query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a) .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .group("sales.sale_id") - else - query = query .where("sale_status=? #{payment_type} and sales.shift_sale_id in (?)","completed",shift_sale_range.to_a) + query = query .where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a) .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .group("sales.sale_id") end diff --git a/app/views/reports/saleitem/index.xls.erb b/app/views/reports/saleitem/index.xls.erb index 3773619b..dfdd77dc 100644 --- a/app/views/reports/saleitem/index.xls.erb +++ b/app/views/reports/saleitem/index.xls.erb @@ -1,104 +1,150 @@ - - - - - - - -
-<% unless @sale_data.blank? %> +
+
+
+ - - +
+ - <% if !params[:from].blank?%> - - + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + + <% unless @sale_data.blank? %> + <% acc_arr = Array.new %> + <% cate_arr = Array.new %> + + <% sub_total = 0.0 %> + <% count = 0%> + <% total_price = 0.0 %> + <% cate_count = 0 %> + <% acc_count = 0%> + <% grand_total = 0%> + <% total_qty = 0%> + <% total_amount = 0 %> + <% discount = 0%> + + <% @sale_data.each do |sale| %> + <% total_qty += sale.total_item %> + + <% if !acc_arr.include?(sale.account_id) %> + + + + + + + <% acc_arr.push(sale.account_id) %> + + <% end %> + + + <% if !cate_arr.include?(sale.menu_category_id) %> + + <% cate_arr.push(sale.menu_category_id) %> + <% else %> + + <% end %> + + + + + + + + + + <% @menu_cate_count.each do |key,value| %> + <% if sale.menu_category_id == key %> + + <% count = count + 1 %> + <% sub_total += sale.grand_total %> + <% if count == value %> + + + + + + + <% sub_total = 0.0%> + <% count = 0%> + <% end %> + <% end %> + <% end %> + + + + <% end %> + + + + + + + + + <% end %> + + + + + - <% end %> - <% if @shift_from %> - <% if @shift_data.employee %> - <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> - <% end %> - - - <% end %> - - - - - - - - - - - - - <% acc_arr = Array.new %> - <% cate_arr = Array.new %> - - <% sub_total = 0.0 %> - <% count = 0%> - <% total_price = 0.0 %> - <% cate_count = 0 %> - <% acc_count = 0%> - <% grand_total = 0%> - <% total_discount = 0.0 %> - - <% @sale_data.order("total_item desc").each do |sale| %> - - - - <% if !cate_arr.include?(sale.menu_category_id) %> - - <% cate_arr.push(sale.menu_category_id) %> - <% else %> - - <% end %> - - <% if @item_table == 'sale' %> - <% if sale.item_remark == 'FOC' %> - - <% elsif sale.item_remark == 'FOC ITEM' %> - - <% elsif sale.item_remark == 'DISCOUNT' %> - - <% else %> - - <% end %> - <% if sale.item_remark == 'DISCOUNT' %> - - - - <% total_price += sale.total_price %> - <% else %> - - - - <% end %> - <% else %> - - - - - <% end %> + + + - - - - - <% grand_total += sale.grand_total%> - <% end %> + + + + + + + + + + + + + + + - + + - +
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
 Menu CategoryCodeProductTotal ItemUnit PriceRevenue
<%= sale.account_name %> Total Price By <%= sale.account_name %> + <% @totalByAccount.each do |account, total| %> + <% if sale.account_id == account %> + <%= total %> + <% grand_total += total %> + <% end %> + <% end %> +
 <%= sale.menu_category_name %> <%= sale.item_code rescue '-' %><%= sale.product_name rescue '-' %><%= sale.total_item rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total rescue '-' %>
 Sub Total<%= sub_total %>
 Total Item<%= total_qty%>Total Amount<%= grand_total%>
 Cash Received<%= @cash_data - @change_amount %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
 Menu CategoryCodeProductTotal ItemUnit PriceRevenue
 <%= sale.menu_category_name %> <%= sale.code rescue '-' %><%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %><%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %><%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %><%= sale.product_name.to_s rescue '-' %> - - <%= sale.total_price.abs rescue '-' %><%= sale.total_item.abs rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total.abs rescue '-' %><%= sale.product_name.to_s rescue '-' %><%= sale.total_item.abs rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total.abs rescue '-' %> Card Sales<%= @card_data %>
 Credit Sales<%= @credit_data %>
 FOC Sales<%= @foc_data %>
 Discount Amount<%= @discount_data %>
  Grand Total<%= grand_total + total_discount %><%= @grand_total - @change_amount%>
-<% end %>
- - \ No newline at end of file +
+
From 33537cef60c51b768e74e8f229b2360c91ea3ea3 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 17 Jul 2017 16:55:18 +0630 Subject: [PATCH 5/5] 17 update for bitp --- app/controllers/home_controller.rb | 3 ++- app/controllers/oqs/home_controller.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index fb37dbdc..fb42bfee 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -21,7 +21,8 @@ class HomeController < ApplicationController session[:session_token] = @employee.token_session route_by_role(@employee) else - render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!" + flash[:notice] ="Invalid PIN for Employee. Please try again!" + render :show end end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 226b3a83..28645a74 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -112,7 +112,7 @@ class Oqs::HomeController < BaseOqsController left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") - .where("assigned_order_items.delivery_status = true AND odt.price <> 0") + .where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at <= ?", Time.now.end_of_day.utc) .group("assigned_order_items.order_id")