From ccbdd5b2c8fe2e559c96b5927c482338101b44af Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 16 Nov 2017 10:03:01 +0630 Subject: [PATCH 1/6] update shift sale detail --- .../transactions/shift_sales_controller.rb | 61 ++++++ app/models/shift_sale.rb | 16 ++ .../transactions/shift_sales/index.html.erb | 105 ++++++++++ .../shift_sales/index.json.jbuilder | 1 + .../shift_sales/indexback.html.erb | 59 ++++++ .../transactions/shift_sales/show.html.erb | 196 ++++++++++++++++++ .../shift_sales/show.json.jbuilder | 1 + config/locales/en.yml | 1 + config/locales/mm.yml | 1 + config/routes.rb | 1 + 10 files changed, 442 insertions(+) create mode 100644 app/controllers/transactions/shift_sales_controller.rb create mode 100755 app/views/transactions/shift_sales/index.html.erb create mode 100755 app/views/transactions/shift_sales/index.json.jbuilder create mode 100755 app/views/transactions/shift_sales/indexback.html.erb create mode 100755 app/views/transactions/shift_sales/show.html.erb create mode 100755 app/views/transactions/shift_sales/show.json.jbuilder diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb new file mode 100644 index 00000000..1f765d21 --- /dev/null +++ b/app/controllers/transactions/shift_sales_controller.rb @@ -0,0 +1,61 @@ +class Transactions::ShiftSalesController < ApplicationController + load_and_authorize_resource except: [:create] + before_action :set_transactions_shift_sale, only: [:show, :edit, :update, :destroy] + + def index + + filter = params[:filter] + from = params[:from] + to = params[:to] + + if filter.nil? && from.nil? && to.nil? + @shift_sales = ShiftSale.all.order("id desc") + @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) + else + shift_sale = ShiftSale.search(filter,from,to) + if shift_sale.count > 0 + @shift_sales = shift_sale + @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) + else + @shift_sales = 0 + end + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @shift_sales } + end + + end + + # GET /transactions/shift_sales/1 + # GET /transactions/shift_sales/1.json + def show + + @shift = ShiftSale.find(params[:id]) + + #get tax + shift_obj = ShiftSale.where('id =?',@shift.id) + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') + #other payment details for mpu or visa like card + @other_payment = ShiftSale.get_by_shift_other_payment(@shift) + + # Calculate price_by_accounts + @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') + @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') + @total_member_discount = ShiftSale.get_total_member_discount(@shift) + + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @shift } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_transactions_shift_sale + @transactions_shift_sale = ShiftSale.find(params[:id]) + end +end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index e9a6dd44..7546daa5 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -135,4 +135,20 @@ class ShiftSale < ApplicationRecord end + def self.search(filter,from,to) + if filter.blank? + keyword = '' + else + keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%" + end + + if from.present? && to.present? + booking = ShiftSale.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to) + query = booking.where(keyword) + else + where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") + end + + end + end diff --git a/app/views/transactions/shift_sales/index.html.erb b/app/views/transactions/shift_sales/index.html.erb new file mode 100755 index 00000000..2ef296e9 --- /dev/null +++ b/app/views/transactions/shift_sales/index.html.erb @@ -0,0 +1,105 @@ + +
+
+
+
+ + + + + + +
+ <%= form_tag transactions_shift_sales_path, :method => :get do %> +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+
+ <% end %> +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + <% if @shift_sales != 0 %> + <% @shift_sales.each do |shift_sale| %> + + + + + + + + + + + + + + + + <% end %> + <% else %> + + <% end %> + +
Cashier NameCashier Terminal Opening Time Closing Time Opening float Closing Amount Cast In Cast Out Total Receipt Dining Count Takeaway Count Total VoidAction
<%= shift_sale.employee.name%><%=shift_sale.cashier_terminal.name%><%= shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %> + <%= shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') rescue '-' %> + <%=shift_sale.opening_balance %><%=shift_sale.closing_balance %><%=shift_sale.cash_in %><%=shift_sale.cash_out %><%= shift_sale.total_receipt %><%= shift_sale.dining_count %><%= shift_sale.takeaway_count %>(<%= shift_sale.total_void.round(2) %>)<%= link_to t("views.btn.show"), transactions_shift_sale_path(shift_sale),:class => 'btn btn-info btn-sm waves-effect' %>

There is no data for search....

+
+ <% if @shift_sales != 0 %> + <%= paginate @shift_sales %> + <% end %> +
+
+
+ +
+
+ + + + + diff --git a/app/views/transactions/shift_sales/index.json.jbuilder b/app/views/transactions/shift_sales/index.json.jbuilder new file mode 100755 index 00000000..a67adc38 --- /dev/null +++ b/app/views/transactions/shift_sales/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @transactions_sales, partial: 'transactions_sales/transactions_sale', as: :transactions_sale diff --git a/app/views/transactions/shift_sales/indexback.html.erb b/app/views/transactions/shift_sales/indexback.html.erb new file mode 100755 index 00000000..fe8c820a --- /dev/null +++ b/app/views/transactions/shift_sales/indexback.html.erb @@ -0,0 +1,59 @@ +

<%= notice %>

+ +

<%= t("views.right_panel.header.transactions_sales") %>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + <% @transactions_sales.each do |transactions_sale| %> + + + + + + + + + + + + + + + + + + + + + + + <% end %> + +
<%= t :cashier %><%= t :cashier %> <%= t("views.right_panel.detail.name_txt2") %><%= t("views.right_panel.detail.requested_by") %><%= t("views.right_panel.detail.requested_at") %><%= t("views.right_panel.detail.receipt_no") %><%= t("views.right_panel.detail.receipt_date") %><%= t :customer %><%= t("views.right_panel.detail.payment_status") %><%= t("views.right_panel.detail.sale_status") %><%= t("views.right_panel.detail.total_amount") %><%= t("views.right_panel.detail.total_discount") %><%= t("views.right_panel.detail.total_tax") %><%= t("views.right_panel.detail.tax_type") %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj") %><%= t("views.right_panel.detail.amt_received") %><%= t("views.right_panel.detail.amt_changed") %>
<%= transactions_sale.cashier %><%= transactions_sale.cashier_name %><%= transactions_sale.requested_by %><%= transactions_sale.requested_at %><%= transactions_sale.receipt_no %><%= transactions_sale.receipt_date %><%= transactions_sale.customer %><%= transactions_sale.payment_status %><%= transactions_sale.sale_status %><%= transactions_sale.total_amount %><%= transactions_sale.total_discount %><%= transactions_sale.total_tax %><%= transactions_sale.tax_type %><%= transactions_sale.grand_total %><%= transactions_sale.rounding_adjustment %><%= transactions_sale.amount_received %><%= transactions_sale.amount_changed %><%= link_to t("views.btn.show"), transactions_sale %><%= link_to t("views.btn.edit"), edit_transactions_sale_path(transactions_sale) %><%= link_to t("views.btn.delete"), transactions_sale, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Transactions Sale', new_transactions_sale_path %> diff --git a/app/views/transactions/shift_sales/show.html.erb b/app/views/transactions/shift_sales/show.html.erb new file mode 100755 index 00000000..3b2b6c6d --- /dev/null +++ b/app/views/transactions/shift_sales/show.html.erb @@ -0,0 +1,196 @@ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cashier Cashier Terminal Opening Date Opening float Received Amount Cast In Cast Out Total Receipt Dining Count Takeaway Count Total Void
<%= @shift.employee.name%><%=@shift.cashier_terminal.name%><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %> + <%=@shift.opening_balance %><%=@shift.closing_balance %><%=@shift.cash_in %><%=@shift.cash_out %><%= @shift.total_receipt %><%= @shift.dining_count %><%= @shift.takeaway_count %>(<%= @shift.total_void.round(2) %>)
+ + <% @total_amount_by_account.each do |amount| %> + + + + + + <%end%> + + + + + + + <% @total_discount_by_account.each do |amount| %> + + + + + + <%end%> + + <% if !@total_member_discount[0].member_discount.nil? + @member_discount = @total_member_discount[0].member_discount rescue 0.0 + @overall = @shift.total_discounts - @member_discount + %> + + + + + + <%else @overall = @shift.total_discounts %> + + <%end%> + + + + + + + + + + + + <% @sale_taxes.each do |tax| %> + + + + + + <%end%> + + + + + + + + + + + + + + + +
Total <%= amount.account_name %> Amount<%= amount.total_price.round(2) %>
Net Sales<%=@shift.nett_sales %>
Total <%= amount.account_name %> Discount<%= amount.total_price.round(2) %>
Total Member Discount<%= @member_discount %>
Total Overall Discount<%= @overall %>
Total Discount<%= @shift.total_discounts %>
<%= tax.tax_name %> <%= tax.st_amount.round(2) %>
Total Tax <%=@shift.total_taxes %>
Rounding Adj <%= @shift.total_rounding.round(2) %>
Grand Total <%= @shift.grand_total.round(2) %>
+
+ + + + + + + + + + + + <% @total_amount = 0 + + @other_payment.each do |other| %> + + + + + + + + + + <% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.visa_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.master_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.foc_amount rescue 0.0 %> + + <%end%> + + + + + + + + + + + + +
Cash Payment <%=@shift.cash_sales %>
Credit Payment <%=@shift.credit_sales %>
Other Payment Detail
MPU Payment <%=other.mpu_amount.round(2) rescue 0.0 %>
VISA Payment <%=other.visa_amount.round(2) rescue 0.0 %>
JCB Payment <%=other.master_amount.round(2) rescue 0.0 %>
Master Payment <%=other.jcb_amount.round(2) rescue 0.0 %>
Reedem Payment <%=other.paypar_amount.round(2) rescue 0.0 %>
FOC <%=other.foc_amount.round(2) rescue 0.0 %>
Total Other Payment <%=@shift.other_sales %>
Total Payment <%= @total_amount+@shift.cash_sales+@shift.credit_sales %>
+
+
+
+
+
+
diff --git a/app/views/transactions/shift_sales/show.json.jbuilder b/app/views/transactions/shift_sales/show.json.jbuilder new file mode 100755 index 00000000..48c70528 --- /dev/null +++ b/app/views/transactions/shift_sales/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale diff --git a/config/locales/en.yml b/config/locales/en.yml index 69f0904c..242c60cf 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,6 +28,7 @@ en: hourly: "Hourly" top: "Top" orders: "Orders" + shiftsale: "ShiftSale" credit: "Credit" bookings: "Booking" home: "Home" diff --git a/config/locales/mm.yml b/config/locales/mm.yml index d103a5c0..5becd44b 100755 --- a/config/locales/mm.yml +++ b/config/locales/mm.yml @@ -28,6 +28,7 @@ mm: hourly: "နာရီအလိုက်" top: "အရောင်းရဆုံး" orders: "အော်ဒါများ" + shiftsale: "အော်ဒါများ" bookings: "အော်ဒါများ" credit: "အကြွေး" home: "မူလစာမျက်နှာ" diff --git a/config/routes.rb b/config/routes.rb index 64f68262..0adeb4bc 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -336,6 +336,7 @@ scope "(:locale)", locale: /en|mm/ do resources :orders resources :credit_notes resources :bookings + resources :shift_sales get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale" get "/sales/:sale_id/void" => "manual_sales#void", :as => "void" From 6360a914b402933ed4a09aaf4ad086f70f70e881 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 16 Nov 2017 14:23:51 +0630 Subject: [PATCH 2/6] update add order for popup qty --- app/assets/javascripts/addorder.js | 51 +++++++++++++---- app/assets/stylesheets/addorder.scss | 2 +- app/views/layouts/_left_sidebar.html.erb | 9 ++- app/views/origami/addorders/detail.html.erb | 55 ++++++++++++++----- app/views/settings/employees/_form.html.erb | 2 +- .../transactions/shift_sales/index.html.erb | 4 +- 6 files changed, 94 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 2804583a..34c93405 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -339,13 +339,14 @@ $(function(){ $(".sx_item_set_detailModal").css({ 'display': "none" }); }else{ $(".sx_item_set_detailModal").css({ 'display': "block" }); - $.alert({ - title: 'Alert!', - content: 'Please Select Minimum ' + min_qty + " items", - type: 'red', - typeAnimated: true, - btnClass: 'btn-danger', - }); + swal("Alert !", 'Please Select Minimum ' + min_qty + " items", "warning"); + // $.alert({ + // title: 'Alert!', + // content: 'Please Select Minimum ' + min_qty + " items", + // type: 'red', + // typeAnimated: true, + // btnClass: 'btn-danger', + // }); } }); //End add order Click @@ -420,7 +421,7 @@ $(function(){ for(var field in attributes) { value = attributes[field]["values"]; type = attributes[field]["type"] - row = "

"+attributes[field]["type"]+"

"; + row = "
"+attributes[field]["type"]+"
"; $(value).each(function(i){ disabled = "" @@ -794,11 +795,10 @@ $(function(){ // Get Selected Class function change_qty_plus_minus(id,plus,minus) { - var count = 1; + var count = parseInt($('#'+id).val()) var countEl = document.getElementById(id); $('#'+plus).on("click", function(){ - count++; countEl.value = count; @@ -852,6 +852,37 @@ $(function(){ } }) } + + + $('.keypress_qty').keyup(function(e){ + + id = $(this).attr('id'); + value = $(this).val(); + + if (id=="count") { + price = $("#unit_price").text(); + $("#total_price").text(value*price); + }else{ + var item_row = $('.selected-instance'); + price = $("#set_unit_price").text(); + set_total_price = $("#set_total_price").text(); + $("#set_count").val(value); + if (item_row.length > 1) { + total = 0 ; + $(item_row).each(function(i){ + total += value * $(item_row[i]).attr('data-price'); + total_price = total; + }); + }else{ + total_price = value*price; + } + $("#set_total_price").text(total_price); + } + }); + + /* $("input").keypress(function(){ + $("span").text(i += 1); +});*/ // $("#set_change_qty").change(function(){ // qty = $(this).val(); // price = $("#set_total_price").text(); diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index b14895df..47b52a07 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -152,6 +152,6 @@ section.content{ } -#count { +#count ,#set_count{ text-align: center; } \ No newline at end of file diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index 25b196af..1ec77487 100755 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -77,12 +77,12 @@ <%= t :transactions %>
  • diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 8fa1b640..6cfe0bbf 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -33,7 +33,7 @@
    - ORDER DETAILS | Table<%=@table.name%> + ORDER DETAILS | Table-<%=@table.name%> @@ -98,8 +98,16 @@
    @@ -110,7 +118,7 @@ @@ -173,7 +193,7 @@